Gateway Device Development Kit

Last Updated on : 2024-06-25 09:44:07download

Gateway Device Development Kit, built on top of the TuyaOS system, is designed to help you develop a typical gateway. It incorporates capabilities including device pairing, cloud connectivity, device control, sub-device connectivity, and scene linkage.

Features

Gateway Device Development Kit can enable Ethernet, Wi-Fi, 4G, or Bluetooth connectivity for your gateway product. This kit applies to various fields such as smart homes, hotels, real estate, and apartments. It features:

  • Less dependency: Support for TCP/IP protocol is required only, without dependency on third-party libraries.
  • Easy-to-develop: Gateway capabilities are provided as service APIs, allowing you to implement the desired features simply with API calls.
  • Highly flexible: Use the desired chip platform without being limited to platforms adapted by Tuya.
  • Feature-rich: Leverage various features, such as scene linkage over local network or LAN, group control, and failover, to make your product stand out in the market.
  • Safe and reliable: Data encryption at rest and in transit, secure communication channels, and the one-device-one-key authentication mechanism ensure data security.

Resource requirements

  • At least 4 MB of ROM and RAM.
  • The device runs Linux or Android.

Capability map

Device management

Capability
Description
Device initialization Call a set of APIs to initialize TuyaOS software. Device initialization is the prerequisite before building other features.
Device reset A device is restored to the settings that the device had before it was paired. Device reset can be triggered by hardware operation or mobile app operation. In terms of device status after a reset, there are two types of reset: normal reset (device unbound) and factory reset (device unbound with data erased).
Testing and authorization Testing and authorization is the process of writing a license to the non-volatile memory on a device for the purpose of authentication with the Tuya Developer Platform.

Basic services

Capability
Description
Log management TuyaOS allows you to set the logging level and logging destination (such as serial port, file, terminal, and network). You can pull the local logs remotely to assist you in troubleshooting.
Local access Local access allows for access to the device list and device-reported data as well as local control.

Pairing and activation

Capability
Description
Wired pairing After a device is connected to a router, it regularly sends user datagram protocol (UDP) packets over a LAN. In the same LAN, after the mobile app receives a packet, it negotiates a secret key and then sends the activation token to the device. The device authenticates with the cloud for activation using the authorization information and token.
Pairing in AP mode A device acts as an access point (AP). After the mobile phone is connected to this AP, it sends the device the SSID and password of the router and the activation token over a TLS connection. After receiving the SSID and password, the device switches to station mode to connect to the router and then authenticates with the cloud for activation using the authorization information and token.
Bluetooth pairing A device regularly sends Bluetooth advertising packets to any listening device. After discovering a device, the mobile app pairs with it, exchanges keys, establishes a connection, and sends it the SSID and password of the router and the activation token. After receiving the SSID and password, the device switches to station mode to connect to the router and then authenticates with the cloud for activation using the authorization information and token.

Connect to third-party sub-devices

Capability
Description
Add sub-devices Through the gateway, a sub-device is bound with and connected to the cloud.
Remove sub-devices Remove a sub-device from a gateway. It can be triggered by hardware operation or mobile app operation. If a sub-device is removed with hardware operation, it requests to leave the network. After the gateway receives the network leaving notification, it calls the unbinding interface to clear the sub-device data. If a sub-device is removed with mobile app operation, the gateway removes the sub-device after receiving the network leaving notification from the mobile app or the cloud.
Sub-device heartbeat The heartbeat is used to test the connectivity between the gateway and the sub-device. Within a heartbeat interval, if the application does not refresh the sub-device heartbeat time, TuyaOS invokes a callback to notify the application to check if the sub-device is online. The application should refresh the sub-device heartbeat time on receiving any data from the sub-device to indicate the online status.
Operations on sub-device data points A data point (DP) is an abstraction of a feature you apply to a product. A gateway sends DP commands to a sub-device. A sub-device reports DP data to the gateway. To send a DP command, TuyaOS invokes a callback to notify the application for processing. The application converts the DP data to the specified format and then sends the converted data to the sub-device. When receiving DP data from a sub-device, the application converts the data to the DP data and calls the data reporting interface to send the converted data to TuyaOS.
Sub-device update Update the sub-device firmware via OTA. TuyaOS supports firmware download and integrity checks.

Connect to Tuya-enabled sub-devices

Capability
Description
Connect to Zigbee sub-devices Interface your gateway hardware with Tuya’s Zigbee module and call the Zigbee service interface to run the Zigbee software stack. This allows you to quickly build a Zigbee gateway capable of connecting to Zigbee sub-devices in the Tuya ecosystem.
Connect to Bluetooth sub-devices Interface your gateway hardware with Tuya’s Bluetooth module and call the Bluetooth service interface to run the Bluetooth software stack. This allows you to quickly build a Bluetooth gateway capable of connecting to Bluetooth Low Energy (LE) and Bluetooth mesh sub-devices in the Tuya ecosystem.

Linkage and automation

Capability
Description
Local linkage Local linkage is a type of automation, in which the devices involved in the condition and action for automation are connected to the same gateway. Local linkage is not dependent on the cloud. It can be run even if the gateway cannot access the internet.
LAN linkage LAN linkage is a type of automation, in which the devices involved in the condition and action for automation are connected to different gateways that belong to the same home and are in the same LAN. Gateways form a primary-secondary topology dynamically. The primary gateway takes over the automation rules so that the LAN linkage can be run even if the gateway cannot access the internet.

Update service

Capability
Description
Main firmware update Update the gateway firmware via OTA.
Subordinate firmware update Update the firmware on the connected network modules via OTA, such as Zigbee and Bluetooth modules.

Value-added services

Capability
Description
Commissioning without internet access Commission gateway devices without internet access, widely used in smart real estate fields. Engineers can set up smart scenes without internet access in the construction stage and hand over privileges to users after they move in. This way, users can directly try out the pre-configured scenes without going through the setup process.
Security Security capabilities support arming and disarming and alerting for environmental anomalies, helping you quickly add security features to your gateway product.
Problem diagnosis A core dump is a snapshot of the memory when the program crashes. The dump analyzer in tandem with the program compiled with a symbol table can help you find the failed function interface for troubleshooting device exceptions.
Failover Switch to a new gateway if the current gateway fails. All the data on the failed device can be migrated to the new one, which frees users from setting up sub-devices and scenes all over again.

Support and help

If you have any problems with TuyaOS development, you can post your questions in the Tuya Developer Forum.