This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS/LAUNCHXL-CC3235SF:使用 Azure IOT Direct 方法时直接方法失败- Azure IoT SDK

Guru**** 2546020 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/919758/ccs-launchxl-cc3235sf-direct-method-failing-when-using-azure-iot-direct-methods---azure-iot-sdk

器件型号:LAUNCHXL-CC3235SF

工具/软件:Code Composer Studio

我目前在 TI CC-3235微控制器上使用 azure-IoT-SDK-c。 我尝试使用 Azure Direct 方法在微控制器上调用方法(blinkLED1)。 Azure IoT Hub 给我一个错误提示"未注册"、如下所示:  

{"message":"Device {\"Message\":\"{\\\"errorCode\\\":404103,\\\"trackingId\\\":\\\"c1763a63a5b54381aa555198de1e884c-TimeStamp:07/01/2020 12:03:39\\\",\\\"message\\\":\\\"Timed out waiting for device to connect.\\\",\\\"info\\\":{\\\"timeout\\\":\\\"00:03:45\\\"},\\\"timestampUtc\\\":\\\"2020-07-01T12:03:39.1927271Z\\\"}\",\"ExceptionMessage\":\"\"} not registered"}

下面的代码是对来自 TI/Microsoft 的示例代码的修改。 微控制器 C 代码如下:

{
(空) userContextCallback;
(无效)有效载荷;
display_printf (display、0、0、"\r\n 调用的设备方法");
Display_printf (display、0、0、"设备方法名称:%s"、method_name);
display_printf (display、0、0、"设备方法有效载荷:%.*s"、(int)大小、(const char*)有效载荷);

INT STATUS = 200;
char* Response_string ="{\"RESPONSE\":\"这是器件的响应\"};
Display_printf (display、0、0、"\r\n 响应状态:%d"、STATUS);
display_printf (display、0、0、"响应有效载荷:%s\r\n、RESPONSE_string);
if (strcmp ("blinkLED1"、method_name)=0){
const char deviceMethodResponse[]="{\"RESPONSE\":\"LED Blink1 Received\""}";
display_printf (display、0、0、"\r\n 调用的设备方法");
*RESP_SIZE = sizeof (deviceMethodResponse)-1;
*响应=malloc (* RESP_SIZE);
(void) memcpy (*响应、deviceMethodResponse、* RESP_SIZE);
状态= 200;
}
*RESP_SIZE = strlen (RESPONSE_string);
如果((*响应= malloc (* RESP_SIZE)= NULL)
{
状态=-1;
}
其他
{
(void) memcpy (*响应、RESPONSE_string、* RESP_SIZE);
}
G_continueRunning = false;
返回状态;
} 

TI 示例参考:https://dev.ti.com/tirex/explore/node?node=ANXoNQGeQjExMVJXpE5vjg__9QUeYYT__LATEST

Azure IoT SDK C 参考: https://github.com/Azure/azure-iot-sdk-c/tree/master/iothub_client/samples/iothub_client_device_twin_and_methods_sample

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Pranav MP:

    您是否能够运行默认示例? 您是否已按照插件 快速入门指南中的步骤 设置物联网集线器、配置器件并完成示例预编译步骤?  是否设置了连接字符串?

    此致、

    Sarah