【分享】825x 3.9.0 mesh sdk 如何接收涂鸦beacon遥控器数据
参考代码
#include "tfm_light_beacon_remote.h" // 头文件
extern VOID_T tuya_mesh_scan_beacon_adv_cb_init(tuya_mesh_scan_beacon_adv_cb cb);
extern VOID_T tfm_ligt_beacon_remote_info_cb_init(tfm_light_beacon_remote_info_cb cb);//遥控器回调 广播数据
VOID_T tuya_mesh_scan_beacon_adv_callback(UINT8_T *data, UINT16_T data_len, UINT8_T *mac)
{
app_common_debug("app_beacon_data_recv:\r\n");
for(UINT8_T i=0;i<data_len;i++){
app_common_debug("%02x ", (data&0xFF));
if(((i+1)%data_len) == 0) {
app_common_debug("\r\n");
}
}
//tuya_mesh_scan_beacon_app_adv_cb(data);
}
//遥控器回调 遥控器信息
VOID_T tfm_light_beacon_remote_info_callback(UINT8_T *info, UINT16_T info_len, UINT8_T index)
{
app_common_debug("app_beacon_info_recv: %x\r\n",index);
for(UINT8_T i=0;i<info_len;i++){
app_common_debug("%02x ", (info&0xFF));
if(((i+1)%info_len) == 0) {
app_common_debug("\r\n");
}
}
//tuya_mesh_scan_beacon_app_adv_cb(data);
}在last init里面初始化,
......
tuya_mesh_scan_beacon_adv_cb_init(tuya_mesh_scan_beacon_adv_callback);
tfm_ligt_beacon_remote_info_cb_init(tfm_light_beacon_remote_info_callback);
ty_light_beacon_remote_init(30);
......在ble回调里面接收广播数据
UINT8_T sg_prompting_flag = 0; //开始配网的时候置1UINT8_T app_get_if_prompting(VOID) // 这个就是判断在提醒的时候不传广播数据,不允许配网提醒的时候控制设备
{
return sg_prompting_flag;
}Code: Select all
...... case TAL_BLE_EVT_ADV_REPORT: tal_rssi_test_ble_adv_recv(p_event->ble_event.adv_report.p_data, p_event->ble_event.adv_report.data_len, p_event->ble_event.adv_report.peer_addr.addr, p_event->ble_event.adv_report.rssi); if(!app_get_if_prompting()) { tfm_light_parser_beacon_remote_data_proc(p_event->ble_event.adv_report.p_data,p_event->ble_event.adv_report.data_len,p_event->ble_event.adv_report.peer_addr.addr, p_event->ble_event.adv_report.rssi ); } break; ......
- 存储遥控器信息
tfm_ligt_beacon_remote_info_cb_init(tfm_light_beacon_remote_info_callback);-----把这个注册下去,配对的时候遥控器信息会报上来。自己存储到flash,下次上电的时候使用此接口 tfm_light_beacon_remote_info_set设置下去。就不会出现掉电没得现象