Bluetooth Porting Guide

Last Updated on : 2024-02-07 06:56:40download

This topic describes how to port a Bluetooth chip platform to TuyaOS, using nRF52832 as an example.

Process

The process of porting your Bluetooth chip to TuyaOS is shown as follows:

Developer (You)TuyaFile a requestPrepare SDK andtest casesProvide SDK and test casesPort the SDK andself-testProvide the test resultsPerform productdevelopmentArchive test resultsDeveloper (You)Tuya

Step 1: File a request

If your chip platform is not supported by the TuyaOS development framework, you can file a request for porting to TuyaOS. After your request is approved, you will receive the TuyaOS SDK-based development framework applicable to your desired chip platform. Then, adapt, debug, and verify the TuyaOS kernel APIs on your own. After porting is completed, you can proceed with product development.

Preparation

Have the following ready prior to porting.

Fill out request

Fill out the porting request using the provided template and send it to your Tuya representative.

Porting request template

Title: Apply for Porting to TuyaOS – Bluetooth

  • Applicant: <Your Tuya IoT Development Platform account>

  • Organization: <Your organization name>

  • Contact: <Your phone number>

  • Reason: <Specify why you want to port to TuyaOS>

  • Development type: <Networked product/gateway/central control product/IPC/Zigbee/Bluetooth/NB-IoT>

  • Remarks: <Specify your special requirements if any>

Chip details:

  • Name: <Chip name, such as nRF52832>

  • Vendor: <Chip vendor, such as Nordic>

  • Model: <Chip model, such as nRF52832>

  • Architecture: <Chip architecture, such as Arm Cortex-M4>

  • Chip type: <Wireless SoC or MCU>

  • Communication type: <This field applies when you select wireless SoC. Options include Ethernet/Wi-Fi/Wi-Fi & Bluetooth LE/Bluetooth/Zigbee/Cellular/NB-IoT>

  • Bit width: <16-bit/32-bit/64-bit>

  • Operating system: <Linux/RTOS/Non-OS>

  • Endianness: <Little-endian/big-endian>

Development environment:

  • Development tool: such as Keil
  • Development tool version: such as v5.28.0.0. You can attach a screenshot.
  • Computer system: such as Windows 10 and later.
  • Instructions for setting up the development environment: step-by-step instructions that should be tested on a different computer.
  • Step-by-step instructions for building and generating library files, as well as an example program.
  • Zip file: zip your files and name the compressed file as TuyaOS_SDK_company name_chip model, for example, TuyaOS_SDK_xxxx_nRF52832.

Please find attached the TuyaOS_SDK_xxxx_nRF52832 for development environment information and instructions.

Recipient: contact your Tuya representative (account manager or project manager) for the recipient’s email address.

After your request is approved, open Tuya Wind IDE and select the TuyaOS SDK mode and then the development framework, type development kit, and chip platform to download the development framework. For more information, see Environment Setup.

Note: The security-related C library will be compiled into a library file according to your development environment. The development environment information you provide helps us generate the correct library files for your project.

Step 2: Tuya prepares and provides SDK and test cases

Tuya prepares and provides the SDK for porting.

Review your request
Input chip model and
information into system
Generate the security library
Package the SDK
Publish the SDK with an allowlist
  1. Review your request.

  2. Tuya staff inputs your chip model and information into the system.

    Tuya staff generates the library files based on the information you provide in Step 1. Currently, only three core component libraries are included in the Bluetooth LE development kit. .\software\TuyaOS\libs stores the chip platforms imported by Tuya, whereas the chip platform adapted by you is located in .\software\TuyaOS\vendor\nrf52832_ble\sdk\lib.

  3. Generate the security library.

  4. Package files to generate an SDK. Package the library files, source files, and other materials to create an SDK.

  5. The SDK is published on the Tuya Wind IDE and has limited access through an allowlist. For information about how to get the SDK, see Environment Setup.

Step 3: Porting the SDK

Try TuyaOS

Before porting, you can try the chip platforms imported by Tuya to familiarize yourself with how the TuyaOS framework works. This can help you debug and troubleshoot your project later.

Steps to try TuyaOS:

Read the TuyaOS Quick Start and follow the instructions to download the development kit and explore the TuyaOS features.

Three key milestones in the process of porting to TuyaOS:

  1. Put the files in the designated location.

  2. Add the source and header files and the building succeeds.

  3. Implement and test the APIs successfully.

.\software\TuyaOS\vendor stores all the files for porting. Do not modify files and code in other locations.

Port the SDK

Steps to port the SDK:

  1. Open the SDK obtained in Step 2.

  2. Put the chip vendor SDK in .\software\TuyaOS\vendor\xxxx_ble\sdk.

  3. Add all source and library files in the folders shown below to the example project provided by the chip vendor.

    .\software\TuyaOS\apps\tuyaos_demo_ble_peripheral //tuyaos_demo_ble_peripheral The file name may be different
    .\software\TuyaOS\components\……\src //"\software\TuyaOS\components" All subfolders under the folder.
    .\software\TuyaOS\libs // If empty, do not add.
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\bluetooth
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\drivers
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\include
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\system
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\utilities
    .\software\TuyaOS\vendor\nrf52832_ble\sdk\lib
    
  4. Add the header file directory shown below to the example project provided by the chip vendor.

    .\software\TuyaOS\apps\tuyaos_demo_ble_peripheral
    .\software\TuyaOS\apps\tuyaos_demo_ble_peripheral\include
    .\software\TuyaOS\components\……\include //"\software\TuyaOS\components" All subfolders under the folder.
    .\software\TuyaOS\include //"\software\TuyaOS\include" All subfolders containing header files under the folder.
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\include
    .\software\TuyaOS\vendor\nrf52832_ble\sdk\lib //".\software\TuyaOS\vendor\nrf52832_ble\sdk\lib" All subfolders containing header files under the folder.
    
  5. Alter the code until it is built successfully.

  6. With the header files in .\software\TuyaOS\include\vendor\adapter and the API reference in \software\TuyaOS\vendor\ats2835x_bt_le\tuyaos_doc, implement the TKL APIs stored in the source files as shown below.

    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\bluetooth
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\drivers
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\include
    .\software\TuyaOS\vendor\nrf52832_ble\tuyaos\system
    

    It is not necessary to implement all the APIs. Refer to the chip platforms imported by Tuya and implement the APIs accordingly.

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

Step 4: Compete self-test and provide results

Self-test your implementation using the provided test cases and refer to the chip platforms imported by Tuya. After all implemented features match the imported chip platforms and all test cases are passed, send the test results to your Tuya representative.

If you encounter any issues during testing:

Step 5: Perform product development

After completing the porting and self-test, you can develop a product on your own or provide the SDK to third-party developers for product development.

To help other developers use the chip platform you have imported, it is recommended to document the platform feature descriptions. See Bluetooth LE–nRF52832 for the documentation structure.

Step 6: Tuya archives test results

Tuya archives the test results and your documentation of platform feature descriptions.