OTA Updates

Last Updated on : 2024-06-24 10:14:05download

This topic describes firmware updates via OTA, where the update is sent over the GATT connection between the device and either the mobile app or gateway.

Firmware updates depend on the chip platform architecture. Therefore, adaptations at the kernel layer are required for each platform. For chip platforms that have been adapted by Tuya, no more adaptations are needed. The application only needs to populate the OTA callback with the GATT data received in the Bluetooth LE data callback. For more information, see the demo in the SDK.

Concepts

Update process

How firmware updates work:

Tuya Smart AppDeviceRequest OTA updateAccept OTA update requestOTA update informationAllow OTA updateRecommended OTA update offsetActual OTA update offsetSend OTA update dataReceived successfullyOTA update completedSuccessful OTA updateTuya Smart AppDevice

Resumable download

The SDK supports resumable downloads for all chip platforms except TLSR825x. This feature allows the update download to be resumed from where it left off if there is a lost connection.

Unexpected disconnection

If the device is disconnected from the mobile app or gateway during the update process, it will restart immediately.

API description

OTA initialization

During initialization, the device calls the OTA initialization API to initialize variables. This API is already initialized internally in the SDK, without the application handling it.

VOID tal_ble_ota_init(VOID);

OTA data reception

After receiving OTA data through the GATT callback, call this API to send the data to the OTA component for decryption and processing.

VOID tal_ble_ota_data_recv(UINT8_T *buf, UINT16_T len);

How-to

Implement the Bluetooth data reception callback in the application and register it to the SDK using the registration API. In this callback, pass the received TAL_BLE_EVT_WRITE_REQ to the OTA data reception API.

VOID app_ble_data_recv(TAL_BLE_EVT_PARAMS_T *p_event)
{
    switch (p_event->type) {
        case TAL_BLE_EVT_WRITE_REQ:
            tal_ble_ota_data_recv(p_event->ble_event.write_report.report.p_data, p_event->ble_event.write_report.report.len);
        break;

        default:
        break;
    }
}

OPERATE_RET tal_mesh_ble_recv_cb_init(TAL_BLE_EVT_FUNC_CB ble_event);

Configuration description

Create and manage firmware

Create and manage firmware on the Tuya Developer Platform.

Configure OTA updates

Log in to the Tuya Developer Platform. Go to Hardware Development and click OTA Update.

OTA Updates

Alternatively, navigate to Firmware Update and generate a product-specific firmware update.

OTA Updates

Update options:

  • Update notification: Users are prompted whether to install an update when they open a device panel.
  • Forced update: Users receive a firmware update notification and have no option but to update the firmware.
  • Check for updates: Users will not receive a firmware update notification, but need to manually check for new updates.

Support for incremental updates varies by platform. To deploy an incremental update, you must upload the corresponding incremental package.

OTA Updates

Verify firmware updates

Before release, a firmware update needs to be verified to ensure it is properly deployed.

OTA Updates

Enter the virtual ID of the test device. When you open the control panel of this device in the mobile app, you will receive an update notification.

Note: The test device must match the PID to which the update is deployed.

OTA Updates

Release firmware updates

Once the update is verified, you can release it to make it available to all devices associated with the target PID.

OTA Updates

For more information about canary release and full release, see Update Firmware.