Mxchip 物联网开发工具包从物联网中心接收数据



我刚开始玩mxchip。我希望我的设备在收到某些命令时触发警报。在我看来,我发现的所有示例都是设备收集信息并发送到物联网中心。MXCHIP可以从iothub或Azure Function接收数据吗?也许还有一些入门指导?

是的,假设您使用 MXChip 示例中的 SDK,您有这些处理程序可用:

DevKitMQTTClient_SetMessageCallback(MessageCallback);
DevKitMQTTClient_SetDeviceMethodCallback(DeviceMethodCallback);

例子:

static void MessageCallback(const char *payLoad, int size)
{
   Screen.print(1, payLoad, true);
}
static int DeviceMethodCallback(const char *methodName, const unsigned char *payload, 
   int size, unsigned char **response, int *response_size)
{
   LogInfo("Try to invoke method %s", methodName);
   // Do your logic...
   int result = 200;
   return result;
}

是的。可以从物联网中心将消息发送到设备(云到设备(。以下是这些链接中提到的一些示例

https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-csharp-csharp-c2d

https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messaging

最新更新