Code: Select all
VOID_T update_switch_dp(VOID_T)//开关状态上传
{
tal_system_sleep(1000);//电机转动需要时间
OPERATE_RET op_ret = OPRT_OK;
INT_T dp_cnt = 1; /* update DP number */
INT_T DP_cnt;
/* no connect router, return */
GW_WIFI_NW_STAT_E wifi_state = STAT_LOW_POWER;
get_wf_gw_nw_status(&wifi_state);
if (wifi_state <= STAT_AP_STA_DISC || wifi_state == STAT_STA_DISC) {
return;
}
TY_OBJ_DP_S *dp_arr = (TY_OBJ_DP_S *)tal_malloc(dp_cnt * SIZEOF(TY_OBJ_DP_S));
if (NULL == dp_arr) {
TAL_PR_ERR("malloc failed");
return;
}
DP_cnt = 0;
dp_arr[DP_cnt].dpid = switch_1; /* 开关 ID */
dp_arr[DP_cnt].type = PROP_BOOL; /* 开关 type */
dp_arr[DP_cnt].time_stamp = 0;
dp_arr[DP_cnt].value.dp_bool = Switch_State();
//Switch_State(); /* 开关 data */
/* report DP */
op_ret = dev_report_dp_json_async(NULL, dp_arr, dp_cnt);
/* free requested memory space */
tal_free(dp_arr);
dp_arr = NULL;
if (OPRT_OK != op_ret) {
TAL_PR_ERR("dev_report_dp_json_async relay_config data error,err_num", op_ret);
}
return;
}
在dp_process.c里定义了一个这样的函数,下发DP的会调用这个,手动更改也会上传这个,下发和手动在两个.C里面,单独调用的时候不会出现错误,当下发调用后,再手动调用,模组就死机了
[01-01 08:00:10 TUYA D][lr:0x8feeb] rept chan:1
[01-01 08:00:10 TUYA D][lr:0x8e317] dp<1> check. need_update:0 pv_stat:3 trig_t:0 dp_rept_type:0 force_send:0
[01-01 08:00:10 TUYA D][lr:0x8e333] dp_cntl bool:1, dp_data bool:0
[01-01 08:00:10 TUYA D][lr:0x8e451] is_need_update:1, is_dp_passive:0
[01-01 08:00:10 TUYA D][lr:0x8ed0b] dp rept_type:0, data:{"1":false}
[01-01 08:00:10 TUYA D][lr:0x9a941] Send MQTT Msg.P:4 N:10529 Q:1 Data:{"dps":{"1":false}}
of--switch_task