Authorize Bluetooth LE Series Modules

Last Updated on : 2024-06-20 06:16:50download

To connect your modules to the cloud for access to cloud services, you need to authorize them with licenses. Tuya provides three options for license delivery. This topic describes how to get the license and write them to chips.

Get the license

  1. Create a product of custom solution on the Tuya Developer Platform. For more information, see Create Products.

  2. In the third step of Hardware Development, click Get 2 Free Licenses.

    One Tuya Developer Platform account is eligible for a maximum of two free licenses.

    Authorize Bluetooth LE Series Modules
  3. Choose a Delivery Mode. Tuya provides three options, namely Credential, Credential (Authorization Only), and License List.

    Authorize Bluetooth LE Series Modules

License list

The license is delivered in a spreadsheet, including UUID, authkey, and MAC address. The server generates a license list. You can write licenses to your chips without an internet connection.

Scenarios

You are debugging Bluetooth modules and have control over production information.

Step 1: Purchase licenses

Select License List as the delivery mode.

Authorize Bluetooth LE Series Modules

You can use the license for debugging purposes. Define it as consistent and write it to your SDK.

Authorize Bluetooth LE Series Modules

Step 2: Configure the SDK

Modify the code in the SDK to obtain a temporary authorization.

  1. Define macros in the header file with the information in the license list.

    Authorize Bluetooth LE Series Modules

  2. Enable the license in the demo.c file.

    Authorize Bluetooth LE Series Modules

    Change the value of two parameters, as shown in the following code.

    .use_ext_license_key = 1, // 1: info in tuya_ble_sdk_demo.h. 0: auth info
    .device_id_len       = 16, //DEVICE_ID_LEN,
    

    In the earlier versions of the SDK, the member use_ext_license_key is not included. You can change the value of device_id_len. See the annotation in the following code.

    device_param.device_id_len = 16;    // If you use the license stored by the SDK, initialize the value 0; otherwise to 16.
    

Credential

A credential is a string. It includes information about firmware and authorization, which is required when you use the software Cloud Module Burning Authorization Platform to authorize your chips. This software depends on an internet connection to pull credential information from the cloud. You can view the available credentials in the user interface. For more information, see Flashing and Authorization for Wi-Fi SDK.

Scenarios

For projects involving multiple parties, you delegate Tuya to flash firmware to chips for functionality verification.

Step 1: Configure firmware

  • Modify tuya_ble_sdk_demo.c. The configuration in tuya_ble_sdk_demo.c defaults to using the authorization information stored in the flash memory of the chip. Authorization information is imported by the host.

    use_ext_license_key = 0
    device_id_len =0
    

    Authorize Bluetooth LE Series Modules

  • Modify tuya_ble_sdk_demo.h. The following table describes some parameters.

    Authorize Bluetooth LE Series Modules

    Parameter Description
    TY_DEVICE_PID Product ID (PID). Create a product on the Tuya Developer Platform, and this product will be assigned a unique PID.
    TY_DEVICE_FIR_NAME Firmware identifier. The unique identifier of your firmware, which is a required field when you upload your firmware to the Tuya Developer Platform. The recommended naming convention is company acronym + chip or product name.
    TY_DEVICE_FVER_NUM The firmware version number in hexadecimal format. To be aligned with TY_DEVICE_FVER_STR, the version number is stored in the lower address, and the first two bytes are significant.
    TY_DEVICE_FVER_STR The firmware version number in string format. This parameter is required when you upload your firmware to the Tuya Developer Platform. The supported format is X.X.

After the configuration above is completed, you can compile the firmware.

Step 2: Create firmware

  1. Go to Hardware Development and click Add Custom Firmware.

    Authorize Bluetooth LE Series Modules
  2. Complete all the required information.

    Authorize Bluetooth LE Series Modules

    The following table describes some fields.

    Parameter Description
    Firmware identifier Enter the value you define for TY_DEVICE_FIR_NAME.
    The firmware type. Select Bluetooth Firmware.
    Flash Size Follow the chip specification.
    Firmware Flashing by Tuya If you choose Tuya Standard Module SDK, you can enable this option.
  3. After the configuration is completed, click Upload Firmware.

Step 3: Upload firmware

Authorize Bluetooth LE Series Modules

Note that the Firmware Version must match the one you specified in the SDK. The file types of Production Firmware, User Area Firmware, and Firmware Updates vary depending on the chip platforms. If you need help with the firmware types, file a service ticket. After you upload the firmware, you must enable the firmware to make it available.

Step 4: Purchase licenses

  1. Select Credential as the delivery mode.

    Authorize Bluetooth LE Series Modules
  2. Download the file.

    • Click Purchase > Order in the left navigation pane. Select the Debugging & Sample Order tab and download the credential.
    • If your order is for production use, select the Production Order tab and download the credential. The downloaded TXT file includes the license, the number of licenses, and the date.

Step 5: Write licenses

Download the Cloud Module Burning Authorization Platform software and write licenses to the chip. For more information, see Flash and Authorize.

The procedure is as follows:

  1. Power off the module.
  2. Open the software, input the license, and click Run.
  3. Power on the module after the license is written.

Credential (authorization only)

The credential (authorization only) is a string that does not include the firmware information and is only used for authorization.

You must use Tuya’s host to write licenses to your chips. The host must be connected to the internet to pull the authorization information from the cloud and display the number of available licenses.

Scenarios

You use Tuya’s host only for the purpose of writing licenses to chips.

Step 1: Purchase licenses

  1. Select Credential (Authorization Only) as the delivery mode.

    Authorize Bluetooth LE Series Modules
  2. Click Purchase > Order in the left navigation pane. Select the Debugging & Sample Order or Production Order tab according to your order type and download the credential. The downloaded TXT file includes the license, the number of licenses, and the date.

Step 2: Write licenses

For authorization only, Tuya provides two methods for writing licenses to chips.

  • Use the dedicated authorization tool and the credentials (authorization only).
  • Use the dedicated authorization tool and the production work orders.
  • Before you proceed with this step, you must have implemented the production test feature in the SDK.
  • You have got a PMS account.

Debugging stage

  1. Log in to Smart PMS. Choose Production Support > Software Download. Click Production Toolkit to download.

    Authorize Bluetooth LE Series Modules

  2. After you have installed the software on your computer, log in to it with your PMS account. Click KingBird.

    Authorize Bluetooth LE Series Modules
  3. Enter your credential.

    1. The software communicates with the chip or module through the serial port. In the Basic Information Setting section, set Communication Method to Serial Port and the Baud to 9600. Leave the rest of the fields with the default values.
    2. In the right section, select the correct COM and then click Start in the Basic Information Setting.
    • You do not need to enter any text in the Wait for SN input box.
    • The software supports 32 channels at the same time.
  4. Click Independent Authorization.

  5. When you are prompted with Start authorizing 10%, reset the chip or module.

    If the process fails, set the baud rate to 9600 and try again, or try resetting the chip or module.

  6. Wait for independent authorization to finish.

Production stage

  1. Convert your credential (authorization only) into the work order number.

    If you get an error saying no permission, file a service ticket.

  2. Input the work order number for authorization.

  3. Input the work order and SN.

    SN = work order number + 5-digit serial code in hex format. The serial code starts with zero, and the maximum value indicates the total number of licenses. For example, if the work order number is FGSHFBE, the SN can be FGSHFBE00001.