我们使用BK7231N:ty_iot_sdk_BK7231NL_2.3.3-beta.347的SDK做的门磁产品,发现一个问题,就是我上报门磁状态的时候会有一定几率上报显示成功了,但界面无更新,所以就感觉很奇怪,现在我每次门磁状态发生改变的时候只上报一次,不能上报多次,上报多次的话开关一次门就会有多个记录。
上报函数如下,
/*
OPERATE_RET tuya_hard_upload_arm(VOID)
{
OPERATE_RET op_ret = OPRT_OK;
UINT_T dp_arr_num = 1;
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 OPRT_NETWORK_ERROR;
}
TY_OBJ_DP_S *dp_arr = (TY_OBJ_DP_S )malloc(dp_arr_num * SIZEOF(TY_OBJ_DP_S));
if (NULL == dp_arr)
{
PR_ERR("tuya_upload_alloc_space fail");
return OPRT_COM_ERROR;
}
Door_State = tuya_gpio_read(TY_GPIOA_7);
dp_arr[0].dpid = DPID_Door_State_ON_OFF; / DP ID /
dp_arr[0].type = PROP_BOOL; / DP type */
dp_arr[0].time_stamp = 0;
dp_arr[0].value.dp_bool = Door_State;
op_ret = dev_report_dp_json_async(NULL, dp_arr, dp_arr_num);
free(dp_arr);
dp_arr = NULL;
if (OPRT_OK != op_ret)
{
PR_ERR("dev_report_dp_json_async all_data is fail,fail_num:%d",op_ret);
return op_ret;
}
PR_DEBUG("upload door dp data sucess");
return OPRT_OK;
}
*/