Code: Select all
OPERATE_RET __app_product_test_mf_cb(USHORT_T cmd, UCHAR_T *data, UINT_T len, OUT UCHAR_T **ret_data, OUT USHORT_T *ret_len)
{
TAL_PR_ERR("__app_product_test_mf_cb ,cmd: %d,len=%d", cmd, len);
TAL_PR_HEXDUMP_DEBUG("data:", data, len);
UINT32_T time_start = 0, timer_end = 0;
ty_cJSON *cmd_json = NULL;
ty_cJSON *cmd_type = NULL;
ty_cJSON *sensor_channel = NULL;
char send_data[50] = {0};
unsigned short length = 0;
unsigned char flag;
switch (cmd)
{
case 0x01:
switch (*data)
{
case 0:
tuya_hard_set_led(LED_ON_OFF, 0);
break;
case 1:
tuya_hard_set_led(LED_ON_OFF, 1);
break;
case 2:
tuya_hard_set_led(LED_FLASH, 500);
break;
}
*ret_len = strlen("{\"ret\":true}");
strcpy(ret_data, "{\"ret\":true}");
TAL_PR_ERR("ret_data=%s,ret_len=%d", ret_data, *ret_len);
break;
case 0x03:
time_start = tal_system_get_millisecond();
user_state.KEY_MF_FLAG=true;
*ret_len = strlen("{\"keyID\":0}");
strcpy(ret_data, "{\"keyID\":0}");
TAL_PR_DEBUG("ret_data=%s,ret_len=%d", ret_data, *ret_len);
user_state.KEY_MF_FLAG = false;
break;
case 0x35:
cmd_json = ty_cJSON_Parse(data);
if (NULL == cmd_json)
{
ty_cJSON_Delete(cmd_json);
return;
}
cmd_type = ty_cJSON_GetObjectItem(cmd_json, "testItem");
if (NULL == cmd_type)
{
ty_cJSON_Delete(cmd_type);
return;
}
sensor_channel = ty_cJSON_GetObjectItem(cmd_json, "type");
if (NULL == sensor_channel)
{
ty_cJSON_Delete(sensor_channel);
return;
}
TAL_PR_ERR("type=%s,channel=%s", cmd_type->valuestring, sensor_channel->valuestring);
if (strcmp(cmd_type->valuestring, "pid") == 0)
{
sprintf(ret_data,"{\"ret\":true,\"testItem\":\"pid\", \"type\":\"string\", \"value\":\"%s\"}",PID);
*ret_len=strlen(ret_data);
TAL_PR_ERR("ret_data=%s,ret_len=%d", ret_data,*ret_len);
}
break;
}
return OPRT_OK;
}
用成品产测的函数 做局域网产测 在进cmd回调侯 回复消息失败 我看了下产测那里的日志 是re_data没有成功上报上去 不知道是什么原因 用的是BK7231 3.9.0开成品产测的sdk 然后T3的这块成品局域网产测可以进 但是每次ret_data的时候会直接进user_hard_fault