【已解决】低功耗设备获取app下发dp问题

Wi-Fi 设备、Wi-Fi 低功耗设备、Wi-Fi BLE 双模设备、Ethernet设备、Ethernet+Wi-Fi设备等
Post Reply
cheng_JS
Posts: 117

我做一个温湿度传感器,使用的sdk:ty_iot_sdk_BK7231NL_2.3.3-beta.347;需要获取APP下发的温标DP,当我调用tuya_iot_dp_low_power_query函数获取数据时,可以在串口输出数据中发现我需要的数据(LOG里面的红色字体部分),但函数是封装好的,我不知道怎么怎么引用,而我又不知道如何正确引用函数的返回参数,打印出来的返回值却很奇怪;想问红色部分的数据如何引用:

程序:
unsigned char dps_Get[1] = {9};
TY_RECV_OBJ_DP_S **obj_Get = NULL;
TY_RECV_RAW_DP_S **raw_Get = NULL;

obj_Get = (TY_RECV_OBJ_DP_S **)malloc(sizeof(TY_RECV_OBJ_DP_S));
raw_Get = (TY_RECV_RAW_DP_S )malloc(sizeof(TY_RECV_RAW_DP_S));
tuya_iot_dp_low_power_query(dps_Get, 1,obj_Get, raw_Get);
PR_NOTICE("++++++++------I want to got dpid: %d",*dps_Get);
PR_NOTICE("++++++++------I got dpid: %d",(
obj_Get).dps->dpid);
PR_NOTICE("++++++++------I got data: %d",(obj_Get).dps->value.dp_enum);
PR_NOTICE("++++++++------I got dpcnt: %d",(
obj_Get).dps_cnt);
free(obj_Get);
log:
[06-27 19:40:44 TUYA D][lr:0x9c1a7] TUYA_TLS Success Connect a3.tuyacn.com:443 CustomNet:TRUE Suit:TLS-PSK-WITH-AES-128-CBC-SHA256
[06-27 19:40:44 TUYA D][lr:0xc14fb] Decode Rev:{"result":["{\"9\":\"f\"}"],"t":1687866044,"success":true}
[06-27 19:40:44 TUYA D][lr:0x9c31b] TUYA_TLS Disconnect ENTER
[06-27 19:40:44 TUYA D][lr:0x9c37f] TUYA_TLS Disconnect Success
[06-27 19:40:44 TUYA N][lr:0xb9e3f] result:["{\"9\":\"f\"}"
[06-27 19:40:44 TUYA E][lr:0xb9e59] lp pack_dp err:-2
[06-27 19:40:44 TUYA N][lr:0x57c45] ++++++++------I want to got dpid: 9
[06-27 19:40:44 TUYA N][lr:0x57c51] ++++++++------I got dpid: 20
[06-27 19:40:44 TUYA N][lr:0x57c5d] ++++++++------I got data: -442503148
[06-27 19:40:44 TUYA N][lr:0x57c69] ++++++++------I got dpcnt: -442503148

愚者千虑必有一得
Posts: 510

Re: 低功耗设备获取app下发dp问题

之前回复过你。

cheng_JS 2023年 Jun 21日 09:37

有没有大佬帮忙看看,

Code: Select all

unsigned char dps_Get[1] = {9};
OUT TY_RECV_OBJ_DP_S *obj_Get = NULL;
OUT TY_RECV_RAW_DP_S *dp_data_Get = NULL;

tuya_iot_dp_low_power_query(dps_Get, 1, &obj_Get, &dp_data_Get);

注意,如果要获取全部缓存dp,cnt 传入0,处理完了之后,obj_Get、dp_data_Get要释放掉。

yingtao_33
Posts: 245

Re: 低功耗设备获取app下发dp问题

请参看这个帖子回复里的例程:viewtopic.php?p=1927#p1927

cheng_JS
Posts: 117

Re: 低功耗设备获取app下发dp问题

已经解决了,谢谢

Post Reply