Last Updated on : 2024-05-17 03:12:05download
This topic describes how to implement control of beacon mesh devices, such as lights, sockets, and switches, using a physical remote.
Concepts | Description |
---|---|
Remote | A device, usually low power, sends control commands to a device. |
Controlled device | A device, usually mains powered, receives control commands, for example, lights, fans, and switches. |
Bind | Bind a remote with a controlled device. |
Unbind | Unbind a remote from a controlled device. |
Time window for binding | During this time window, a controlled device can receive codes from a remote to bind with it. A time window is specified with a timeout and trigger event. Example:
|
Reset remote | Reset the remote to factory settings, removing all binding relationships. |
Reset controlled device | A remote sends a reset command to a controlled device for a factory reset. |
Remote control | A remote sends a control command to a device. |
Group | A remote supports up to six groups and one overall control. Users can group devices for bulk control. |
Beacon remotes can control paired or unpaired Bluetooth beacon mesh devices after binding. There is no need to add the remote to the Tuya-based mobile app. Due to its weak security, this feature typically applies to lights, fans, and radio-controlled cars.
This feature is provided as a library libtal_beacon2.lib
. Initialize it after ty_beacon2_node_init
. During initialization, specify the time window, which determines how long the device remains open for binding with a remote.
The remote controls the beacon mesh device through DP commands. Therefore, whether the controller is a remote or an app, the control command will be sent to app_dps_download
. When the beacon mesh device is bound with or unbound from a remote, the callback ty_beacon2_event_cb
will be invoked.
No external data structure.
Function | void ty_beacon_remoter_init(u8 pair_window_s) | - |
---|---|---|
Purpose | Initialize the remote feature. | - |
Request parameter | pair_window_s | The time window for binding, in seconds. |
Example:
Check the demo tuyaos_demo_beaconmesh_peripheral
.
VOID_T tal_framework_init_last(VOID_T){
#if (DEVELOP_DEBUG == 0)
get_pid(beacon_dev.pid);
get_anthkey(beacon_dev.authkey);
tkl_beacon_get_mac(beacon_dev.mac);
#endif
app_led_init();
ty_beacon2_node_init(&beacon_dev);
ty_beacon_remoter_init(30);
if(beacon_dev.state == STATE_NOT_PAIRED){
ty_beacon2_node_pair_start(180000000);
app_led_blink(720);
}else{
u8 payload[16];
memset(payload,0,16);
payload[0] = 0x01;
frame_send(0x08, 0x8000, 0x02, payload, beacon_dev.beaconkey, 0);//Report heartbeat upon power on, with no forwarding.
}
}
ty_beacon2_event_cb
returns the binding result.app_dps_download
.If you have any problems with TuyaOS development, you can post your questions in the Tuya Developer Forum.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback