-
Dear Simen Gangstad and others, I have tried to connect our AVR-IoT-Cellular Mini to our Azure IoT Hub with the mqtt_polling example, but with no success. I have made the following steps. I have then tried to connect the AVR-IoT with both the root and sub CA in the Azure IoT Hub like in I have also tried the IoT provisioning tool from Microchip: $ ./iotprovision-bin.exe -c azure Does this mean, there is not a provisioning for Azure possible yet? Or have I just missed something? If so, can you please provide an example how to provision the AVR-IoT-Cellular mini for the Azure IoT Hub? Thank you and best regards |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hello @CsFreiber, We have a working Azure example with certificates that we’ve been testing internally, I just have to double check some details with a colleague on Monday. I’ll keep you updated. |
Beta Was this translation helpful? Give feedback.
-
Hello again, Sorry for the delay. Could you try to extract the ECC608 device certificate using the This way to provision with the ECC is not something we have explicitly available with the I'm attaching a sketch which you can use to test this setup. You need to fill out your Azure IoT Hub hostname and the common name field of the device certificate (it should be something alike Please feel free to ask more questions if something doesn't work as expected. #include <Arduino.h>
#include <led_ctrl.h>
#include <log.h>
#include <lte.h>
#include <mqtt_client.h>
#define MQTT_PUB_TOPIC_FMT "devices/%s/messages/events/"
#define MQTT_SUB_TOPIC_FMT "%s/messages/devicebound/#"
#define DEVICE_ID "<common name field from device certificate>"
#define IOT_HUB_HOST_NAME "<azure iot hub host name>"
#define MQTT_USER_NAME \
IOT_HUB_HOST_NAME "/" DEVICE_ID "/?api-version=2018-06-30"
char mqtt_sub_topic[128];
char mqtt_pub_topic[128];
void setup() {
Log.begin(115200);
LedCtrl.begin();
LedCtrl.startupCycle();
Log.info("Starting initialization of MQTT Polling for Azure\r\n");
// Set up topics
sprintf(mqtt_sub_topic, MQTT_SUB_TOPIC_FMT, DEVICE_ID);
sprintf(mqtt_pub_topic, MQTT_PUB_TOPIC_FMT, DEVICE_ID);
if (!Lte.begin()) {
Log.error("Failed to connect to operator");
// Halt here if we fail
while (1) {}
}
// Attempt to connect to the broker. The device ID is here the common name
// field of the device certificate.
if (MqttClient.begin(DEVICE_ID,
IOT_HUB_HOST_NAME,
8883,
true,
60,
true,
MQTT_USER_NAME)) {
Log.infof("Connecting to broker");
while (!MqttClient.isConnected()) {
Log.rawf(".");
delay(500);
}
Log.rawf(" OK!\r\n");
// Subscribe to the topic
MqttClient.subscribe(mqtt_sub_topic);
} else {
Log.rawf("\r\n");
Log.error("Failed to connect to broker");
// Halt here
while (1) {}
}
}
void loop() {
bool published_successfully =
MqttClient.publish(mqtt_pub_topic, "{\"light\": 9, \"temp\": 9}");
Log.infof("Publishing: %s\r\n", mqtt_pub_topic);
if (published_successfully) {
Log.info("Published message");
} else {
Log.error("Failed to publish\r\n");
}
delay(2000);
String message = MqttClient.readMessage(mqtt_sub_topic);
// Read message will return an empty string if there were no new
// messages, so anything other than that means that there were a
// new message
if (message != "") {
Log.infof("Got new message: %s\r\n", message.c_str());
}
delay(2000);
} Best, |
Beta Was this translation helpful? Give feedback.
-
Hello @CsFreiber, I realise I misunderstood my colleague a bit. I've been out of the country and have not had a device to test with me. Individual enrollment is not necessary. You simply need to create a device in IoT Hub and use the sha256 sum of the device certificate. With the following steps I'm able to connect to Azure IoT Hub.
Please let me know if this works for you. Happy to help if there are any other issues. Best, |
Beta Was this translation helpful? Give feedback.
Hello @CsFreiber,
I realise I misunderstood my colleague a bit. I've been out of the country and have not had a device to test with me. Individual enrollment is not necessary. You simply need to create a device in IoT Hub and use the sha256 sum of the device certificate. With the following steps I'm able to connect to Azure IoT Hub.
X.509 Self-Signed
.openssl x509 -in device.pem -outform der | sha256sum
.Flash the provision sketch and follow the same process as before w…