我刚开始玩mxchip。我想让我的设备在收到命令时触发警报。在我看来,我找到的所有示例都是设备收集信息并发送到iot集线器。mxchip可以从iothub或azure函数接收数据吗?也许还有一些关于入门的指导?
发布于 2019-04-10 21:01:33
是的,假设您使用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;
}
发布于 2019-04-05 20:24:09
是。可以从IOT集线器向设备(云到设备)发送消息。以下是这些链接中提到的一些示例
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-csharp-csharp-c2d
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messaging
https://stackoverflow.com/questions/55529280
复制相似问题