Reputation: 1566
I just started playing with the mxchip. I want my device to trigger an alarm when receiving some command. It seems to me all examples I found are device collecting info and send to iot hub. Can mxchip receive data from iothub or azure function? And maybe some guidance on getting started?
Upvotes: 0
Views: 110
Reputation: 16138
Yes, assuming you use the SDK from the examples for the MXChip you have those handlers available:
DevKitMQTTClient_SetMessageCallback(MessageCallback);
DevKitMQTTClient_SetDeviceMethodCallback(DeviceMethodCallback);
Examples:
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;
}
Upvotes: 2
Reputation: 1096
Yes. Its possible to send messages to device ( Cloud-to-device) from IOT Hub. Here is some example mentioned in these links
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
Upvotes: 1