Device Initialization

Last Updated on : 2024-05-17 02:35:44download

This topic describes the initialization process for beacon mesh devices.

Overview

Concepts

Concept Description
Authkey The license list you request or purchase from the Developer Platform contains the UUID, Authkey, and MAC address. Beacon mesh devices use the MAC address and Authkey.

Features

Initialize the beacon mesh node with the required information.

Data structure

You only need to manage the required parameters in beacon_dev_s described below.

API description

Function u8 ty_beacon2_node_init(beacon_dev_s *p_beacon_dev) -
Purpose Initialize the beacon mesh protocol stack. -
Request parameter beacon_dev_s *p_beacon_dev -
-> .mac The 6-byte MAC address.
-> .authkey The Authkey in the license list.
-> .pid The product ID.
-> .version The version. For example, 0x13 represents version 1.3.
-> .kind The product category. The classification is identical to that of Bluetooth mesh devices.

Example

This function is called during program initialization.

static beacon_dev_s beacon_dev = {
    .mac = {0xdc,0x23,0xFF,0xFF,0xFF,0xFF},//Set it to the MAC address from the license list you requested from the Developer Platform.
    .authkey = "IAmFFFFFFFFFFFFF",//Set it to the first 16 bytes of the Authkey from the license list you requested from the Developer Platform.
    .pid = "wzojep0f",//Set it to the PID of your product.
    .version = 0x10,//Firmware version. For example, 0x14 means version 1.4.
    .flag = 0x00, //Default to 0x00
    .kind = 0x1015,
    .state = STATE_NOT_PAIRED
};

...

VOID_T tal_framework_init_last(VOID_T){
    app_led_init();

    ty_beacon2_node_init(&beacon_dev);

    ...
}

Product category

Lighting products

Lights Capability value
W 0x1011
CW 0x1012
RGB 0x1013
RGBW 0x1014
RGBCW 0x1015

Electrical products

Socket/Switch Capability value
1-gang 0x1021
2-gang 0x1022
3-gang 0x1023
4-gang 0x1024
5-gang 0x1025
6-gang 0x1026

Sensors (low power)

Sensor Capability value
Contact sensor 0x2041
PIR 0x2042
Luminance sensor 0x2043
Temperature and humidity sensor 0x2044
Water leak detector 0x2045
Microwave sensor 0x2046
Others 0x2047

Remotes

Number of buttons for groups Capability value
1 0x1051
2 0x1052
3 0x1053
4 0x1054

Wireless switches (low power)

Number of buttons Capability value
1 0x2061
2 0x2062
3 0x2063
4 0x2064
5 0x2065
6 0x2066

Sensors (mains-powered)

Sensor Capability value
Contact sensor 0x2061
PIR 0x2062
Luminance sensor 0x2063
Temperature and humidity sensor 0x2064

Wireless switches (mains-powered)

Number of buttons Capability value
1 0x2081
2 0x2082
3 0x2083
4 0x2084
5 0x2086
6 0x2086

Support and help

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