Azure IoT HUB. cloud-to-device messages (MQTT, custom topic)
I have an Azure IoT Hub. Here I created a custom device. This device is connected successfully with the Azure IoT Hub. I can also receive the data from this device (device-to -cloud).
But I also want to send a message to this device.
This device uses the "MQTT protocol". I cannot change the subscribe topic and the publish topic in this device, so I have to be able to set this "customtopics" in Azure (Function App).
For this, I have created a function App (IoT Hub (Event Hub)), but I do not know how to implement the "publish and/or subscribe topic" here. All examples are about "messages/events".
run.csx
public static async void Run(EventData myIoTHubMessage, TraceWriter log)
{
log.Info($"{myIoTHubMessage.SystemProperties["iothub-connection-device-id"]}");
var deviceId = myIoTHubMessage.SystemProperties["iothub-connection-device-id"].ToString();
var msg = JsonConvert.SerializeObject("{\"Values\": {\"Slave 8.Channel 1.Output\": false,");
var c2dmsg = new Microsoft.Azure.Devices.Message(Encoding.ASCII.GetBytes(msg));
await client.SendAsync(deviceId, c2dmsg);
}
devices/{device_id}/messages/devicebound/#
to subscribe and usemessages/events
to publish message successfully? If you can get both of them working, while do you want to specify your own topics instead of the only two out of box? – Rita Han