diff --git a/MXChip/AZ3166/app/azure_config.h b/MXChip/AZ3166/app/azure_config.h index d446ea20..6818c27d 100644 --- a/MXChip/AZ3166/app/azure_config.h +++ b/MXChip/AZ3166/app/azure_config.h @@ -29,47 +29,35 @@ typedef enum // Azure IoT Dynamic Provisioning Service // Define this to use the DPS service, otherwise direct IoT Hub // ---------------------------------------------------------------------------- -// #define ENABLE_DPS +//#define ENABLE_DPS // ---------------------------------------------------------------------------- // Azure IoT DPS Self-Signed X509Certificate -// Define this to connect to DPS or Iot Hub using a self-signed X509 -/// certificate +// Define this to connect to DPS or Iot Hub using a X509 certificate // ---------------------------------------------------------------------------- // #define ENABLE_X509 // ---------------------------------------------------------------------------- -// Azure IoT Device ID -// Make sure this is the same as the Device ID on the corresponding IoT Hub -// NOTE: To be used only when ENABLE_DPS is NOT defined +// Azure IoT Hub connection config +// IOT_HUB_HOSTNAME: The Azure IoT Hub hostname +// IOT_HUB_DEVICE_ID: The Azure IoT Hub device id // ---------------------------------------------------------------------------- -#define IOT_DEVICE_ID "" +#define IOT_HUB_HOSTNAME "" +#define IOT_HUB_DEVICE_ID "" // ---------------------------------------------------------------------------- -// Azure IoT SAS Key -// The SAS key generated by configuring an IoT Hub device or DPS individual -// enrollment -// NOTE: To be used only when ENABLE_X509 is not defined -// ---------------------------------------------------------------------------- -#define IOT_PRIMARY_KEY "" - -// ---------------------------------------------------------------------------- -// Azure IoT Hub Hostname -// The Hostname found on your IoT Hub Overview page -// NOTE: To be used only when ENABLE_DPS is not defined +// Azure IoT DPS connection config +// IOT_DPS_ID_SCOPE: The DPS ID Scope +// IOT_DPS_REGISTRATION_ID: The DPS device Registration Id // ---------------------------------------------------------------------------- -#define IOT_HUB_HOSTNAME "" +#define IOT_DPS_ID_SCOPE "" +#define IOT_DPS_REGISTRATION_ID "" // ---------------------------------------------------------------------------- -// Azure IoT DPS config -// DPS connection information -// IOT_DPS_ENDPOINT is always "global.azure-devices-provisioning.net" -// IOT_DPS_ID_SCOPE can be found on your DPS Overview page -// IOT_DPS_REGISTRATION ID is the title of your individual enrollment -// containing your SAS key or X509 certificate +// Azure IoT device SAS key +// The SAS key generated by configuring an IoT Hub device or DPS individual +// enrollment // ---------------------------------------------------------------------------- -#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" -#define IOT_DPS_ID_SCOPE "" -#define IOT_DPS_REGISTRATION_ID "" +#define IOT_DEVICE_SAS_KEY "" #endif // _AZURE_CONFIG_H diff --git a/MXChip/AZ3166/app/azure_device_x509_cert_config.h b/MXChip/AZ3166/app/azure_device_x509_cert_config.h index 3b75e094..214b0092 100644 --- a/MXChip/AZ3166/app/azure_device_x509_cert_config.h +++ b/MXChip/AZ3166/app/azure_device_x509_cert_config.h @@ -1,3 +1,6 @@ +/* Copyright (c) Microsoft Corporation. + Licensed under the MIT License. */ + #ifndef _AZURE_DEVICE_X509_CERT_CONFIG_H #define _AZURE_DEVICE_X509_CERT_CONFIG_H @@ -6,13 +9,13 @@ // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- const unsigned char iot_x509_device_cert[] = {0x00}; -unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); +unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); // ---------------------------------------------------------------------------- // Azure IoT X509 Device Private Key // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- -unsigned char iot_x509_private_key[] = {0x00}; +unsigned char iot_x509_private_key[] = {0x00}; const unsigned int iot_x509_private_key_len = sizeof(iot_x509_private_key); #endif \ No newline at end of file diff --git a/MXChip/AZ3166/app/legacy/mqtt.c b/MXChip/AZ3166/app/legacy/mqtt.c index 2c88e2fc..b57c51b1 100644 --- a/MXChip/AZ3166/app/legacy/mqtt.c +++ b/MXChip/AZ3166/app/legacy/mqtt.c @@ -133,10 +133,9 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p pool_ptr, dns_ptr, time_get, - IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID, - IOT_PRIMARY_KEY, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #else // Create Azure MQTT for Hub @@ -146,8 +145,8 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p dns_ptr, time_get, IOT_HUB_HOSTNAME, - IOT_DEVICE_ID, - IOT_PRIMARY_KEY, + IOT_HUB_DEVICE_ID, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #endif diff --git a/MXChip/AZ3166/app/nx_client.c b/MXChip/AZ3166/app/nx_client.c index ef831276..9e1d3f39 100644 --- a/MXChip/AZ3166/app/nx_client.c +++ b/MXChip/AZ3166/app/nx_client.c @@ -167,8 +167,8 @@ static UINT append_device_telemetry_accelerometer(NX_AZURE_IOT_JSON_WRITER* json lsm6dsl_data.acceleration_mg[1], 2) || nx_azure_iot_json_writer_append_property_with_double_value(json_writer, - (UCHAR*)TELEMETRY_ACCELEROMETERY, - sizeof(TELEMETRY_ACCELEROMETERY) - 1, + (UCHAR*)TELEMETRY_ACCELEROMETERZ, + sizeof(TELEMETRY_ACCELEROMETERZ) - 1, lsm6dsl_data.acceleration_mg[2], 2)) { @@ -186,21 +186,13 @@ static UINT append_device_telemetry_gyroscope(NX_AZURE_IOT_JSON_WRITER* json_wri (UCHAR*)TELEMETRY_GYROSCOPEX, sizeof(TELEMETRY_GYROSCOPEX) - 1, lsm6dsl_data.angular_rate_mdps[0], - 2)) - { - return NX_NOT_SUCCESSFUL; - } - - if (nx_azure_iot_json_writer_append_property_with_double_value(json_writer, + 2) || + nx_azure_iot_json_writer_append_property_with_double_value(json_writer, (UCHAR*)TELEMETRY_GYROSCOPEY, sizeof(TELEMETRY_GYROSCOPEY) - 1, lsm6dsl_data.angular_rate_mdps[1], - 2)) - { - return NX_NOT_SUCCESSFUL; - } - - if (nx_azure_iot_json_writer_append_property_with_double_value(json_writer, + 2) || + nx_azure_iot_json_writer_append_property_with_double_value(json_writer, (UCHAR*)TELEMETRY_GYROSCOPEZ, sizeof(TELEMETRY_GYROSCOPEZ) - 1, lsm6dsl_data.angular_rate_mdps[2], @@ -345,7 +337,7 @@ UINT azure_iot_nx_client_entry( (UCHAR*)iot_x509_private_key, iot_x509_private_key_len); #else - status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_PRIMARY_KEY); + status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_DEVICE_SAS_KEY); #endif if (status != NX_SUCCESS) { @@ -354,9 +346,9 @@ UINT azure_iot_nx_client_entry( } #ifdef ENABLE_DPS - azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); + azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); #else - azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_DEVICE_ID); + azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_HUB_DEVICE_ID); #endif if (status != NX_SUCCESS) { diff --git a/MXChip/AZ3166/readme.md b/MXChip/AZ3166/readme.md index a46eb399..54e4368d 100644 --- a/MXChip/AZ3166/readme.md +++ b/MXChip/AZ3166/readme.md @@ -148,8 +148,8 @@ To connect the MXCHIP DevKit to Azure, you'll modify a configuration file for Wi |Constant name|Value| |-------------|-----| |`IOT_HUB_HOSTNAME` |{*Your Iot hub hostName value*}| - |`IOT_DEVICE_ID` |{*Your deviceID value*}| - |`IOT_PRIMARY_KEY` |{*Your primaryKey value*}| + |`IOT_HUB_DEVICE_ID` |{*Your deviceID value*}| + |`IOT_DEVICE_SAS_KEY` |{*Your primaryKey value*}| 1. Save and close the file. diff --git a/Microchip/ATSAME54-XPRO/app/azure_config.h b/Microchip/ATSAME54-XPRO/app/azure_config.h index 1c41de09..82fd68c0 100644 --- a/Microchip/ATSAME54-XPRO/app/azure_config.h +++ b/Microchip/ATSAME54-XPRO/app/azure_config.h @@ -8,7 +8,7 @@ // 0 - BME280 sensor is not present // 1 - BME280 sensor is present // ---------------------------------------------------------------------------- -#define __SENSOR_BME280__ 0 +#define __SENSOR_BME280__ 1 // ---------------------------------------------------------------------------- // Azure IoT Hub Connection Transport @@ -20,47 +20,35 @@ // Azure IoT Dynamic Provisioning Service // Define this to use the DPS service, otherwise direct IoT Hub // ---------------------------------------------------------------------------- -// #define ENABLE_DPS +//#define ENABLE_DPS // ---------------------------------------------------------------------------- // Azure IoT DPS Self-Signed X509Certificate -// Define this to connect to DPS or Iot Hub using a self-signed X509 -/// certificate +// Define this to connect to DPS or Iot Hub using a X509 certificate // ---------------------------------------------------------------------------- // #define ENABLE_X509 // ---------------------------------------------------------------------------- -// Azure IoT Device ID -// Make sure this is the same as the Device ID on the corresponding IoT Hub -// NOTE: To be used only when ENABLE_DPS is NOT defined +// Azure IoT Hub connection config +// IOT_HUB_HOSTNAME: The Azure IoT Hub hostname +// IOT_HUB_DEVICE_ID: The Azure IoT Hub device id // ---------------------------------------------------------------------------- -#define IOT_DEVICE_ID "" +#define IOT_HUB_HOSTNAME "" +#define IOT_HUB_DEVICE_ID "" // ---------------------------------------------------------------------------- -// Azure IoT SAS Key -// The SAS key generated by configuring an IoT Hub device or DPS individual -// enrollment -// NOTE: To be used only when ENABLE_X509 is not defined -// ---------------------------------------------------------------------------- -#define IOT_PRIMARY_KEY "" - -// ---------------------------------------------------------------------------- -// Azure IoT Hub Hostname -// The Hostname found on your IoT Hub Overview page -// NOTE: To be used only when ENABLE_DPS is not defined +// Azure IoT DPS connection config +// IOT_DPS_ID_SCOPE: The DPS ID Scope +// IOT_DPS_REGISTRATION_ID: The DPS device Registration Id // ---------------------------------------------------------------------------- -#define IOT_HUB_HOSTNAME "" +#define IOT_DPS_ID_SCOPE "" +#define IOT_DPS_REGISTRATION_ID "" // ---------------------------------------------------------------------------- -// Azure IoT DPS config -// DPS connection information -// IOT_DPS_ENDPOINT is always "global.azure-devices-provisioning.net" -// IOT_DPS_ID_SCOPE can be found on your DPS Overview page -// IOT_DPS_REGISTRATION ID is the title of your individual enrollment -// containing your SAS key or X509 certificate +// Azure IoT device SAS key +// The SAS key generated by configuring an IoT Hub device or DPS individual +// enrollment // ---------------------------------------------------------------------------- -#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" -#define IOT_DPS_ID_SCOPE "" -#define IOT_DPS_REGISTRATION_ID "" +#define IOT_DEVICE_SAS_KEY "" #endif // _AZURE_CONFIG_H diff --git a/Microchip/ATSAME54-XPRO/app/azure_device_x509_cert_config.h b/Microchip/ATSAME54-XPRO/app/azure_device_x509_cert_config.h index 3b75e094..214b0092 100644 --- a/Microchip/ATSAME54-XPRO/app/azure_device_x509_cert_config.h +++ b/Microchip/ATSAME54-XPRO/app/azure_device_x509_cert_config.h @@ -1,3 +1,6 @@ +/* Copyright (c) Microsoft Corporation. + Licensed under the MIT License. */ + #ifndef _AZURE_DEVICE_X509_CERT_CONFIG_H #define _AZURE_DEVICE_X509_CERT_CONFIG_H @@ -6,13 +9,13 @@ // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- const unsigned char iot_x509_device_cert[] = {0x00}; -unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); +unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); // ---------------------------------------------------------------------------- // Azure IoT X509 Device Private Key // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- -unsigned char iot_x509_private_key[] = {0x00}; +unsigned char iot_x509_private_key[] = {0x00}; const unsigned int iot_x509_private_key_len = sizeof(iot_x509_private_key); #endif \ No newline at end of file diff --git a/Microchip/ATSAME54-XPRO/app/legacy/mqtt.c b/Microchip/ATSAME54-XPRO/app/legacy/mqtt.c index 11974b05..9b8833d8 100644 --- a/Microchip/ATSAME54-XPRO/app/legacy/mqtt.c +++ b/Microchip/ATSAME54-XPRO/app/legacy/mqtt.c @@ -129,10 +129,9 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p pool_ptr, dns_ptr, time_get, - IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID, - IOT_PRIMARY_KEY, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #else // Create Azure MQTT for Hub @@ -142,8 +141,8 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p dns_ptr, time_get, IOT_HUB_HOSTNAME, - IOT_DEVICE_ID, - IOT_PRIMARY_KEY, + IOT_HUB_DEVICE_ID, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #endif diff --git a/Microchip/ATSAME54-XPRO/app/nx_client.c b/Microchip/ATSAME54-XPRO/app/nx_client.c index ea1e836c..554d01ef 100644 --- a/Microchip/ATSAME54-XPRO/app/nx_client.c +++ b/Microchip/ATSAME54-XPRO/app/nx_client.c @@ -209,7 +209,7 @@ UINT azure_iot_nx_client_entry( (UCHAR*)iot_x509_private_key, iot_x509_private_key_len); #else - status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_PRIMARY_KEY); + status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_DEVICE_SAS_KEY); #endif if (status != NX_SUCCESS) { @@ -218,9 +218,9 @@ UINT azure_iot_nx_client_entry( } #ifdef ENABLE_DPS - azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); + azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); #else - azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_DEVICE_ID); + azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_HUB_DEVICE_ID); #endif if (status != NX_SUCCESS) { diff --git a/Microchip/ATSAME54-XPRO/readme.md b/Microchip/ATSAME54-XPRO/readme.md index 455f67b6..8765a192 100644 --- a/Microchip/ATSAME54-XPRO/readme.md +++ b/Microchip/ATSAME54-XPRO/readme.md @@ -148,8 +148,8 @@ To connect the Microchip E54 to Azure, you'll modify a configuration file for Az |Constant name|Value| |-------------|-----| |`IOT_HUB_HOSTNAME` |{*Your Iot hub hostName value*}| - |`IOT_DEVICE_ID` |{*Your deviceID value*}| - |`IOT_PRIMARY_KEY` |{*Your primaryKey value*}| + |`IOT_HUB_DEVICE_ID` |{*Your deviceID value*}| + |`IOT_DEVICE_SAS_KEY` |{*Your primaryKey value*}| 1. Save and close the file. diff --git a/NXP/MIMXRT1050-EVKB/app/azure_config.h b/NXP/MIMXRT1050-EVKB/app/azure_config.h index 98936ace..45fba7c8 100644 --- a/NXP/MIMXRT1050-EVKB/app/azure_config.h +++ b/NXP/MIMXRT1050-EVKB/app/azure_config.h @@ -14,47 +14,35 @@ // Azure IoT Dynamic Provisioning Service // Define this to use the DPS service, otherwise direct IoT Hub // ---------------------------------------------------------------------------- -// #define ENABLE_DPS +//#define ENABLE_DPS // ---------------------------------------------------------------------------- // Azure IoT DPS Self-Signed X509Certificate -// Define this to connect to DPS or Iot Hub using a self-signed X509 -/// certificate +// Define this to connect to DPS or Iot Hub using a X509 certificate // ---------------------------------------------------------------------------- // #define ENABLE_X509 // ---------------------------------------------------------------------------- -// Azure IoT Device ID -// Make sure this is the same as the Device ID on the corresponding IoT Hub -// NOTE: To be used only when ENABLE_DPS is NOT defined +// Azure IoT Hub connection config +// IOT_HUB_HOSTNAME: The Azure IoT Hub hostname +// IOT_HUB_DEVICE_ID: The Azure IoT Hub device id // ---------------------------------------------------------------------------- -#define IOT_DEVICE_ID "" +#define IOT_HUB_HOSTNAME "" +#define IOT_HUB_DEVICE_ID "" // ---------------------------------------------------------------------------- -// Azure IoT SAS Key -// The SAS key generated by configuring an IoT Hub device or DPS individual -// enrollment -// NOTE: To be used only when ENABLE_X509 is not defined -// ---------------------------------------------------------------------------- -#define IOT_PRIMARY_KEY "" - -// ---------------------------------------------------------------------------- -// Azure IoT Hub Hostname -// The Hostname found on your IoT Hub Overview page -// NOTE: To be used only when ENABLE_DPS is not defined +// Azure IoT DPS connection config +// IOT_DPS_ID_SCOPE: The DPS ID Scope +// IOT_DPS_REGISTRATION_ID: The DPS device Registration Id // ---------------------------------------------------------------------------- -#define IOT_HUB_HOSTNAME "" +#define IOT_DPS_ID_SCOPE "" +#define IOT_DPS_REGISTRATION_ID "" // ---------------------------------------------------------------------------- -// Azure IoT DPS config -// DPS connection information -// IOT_DPS_ENDPOINT is always "global.azure-devices-provisioning.net" -// IOT_DPS_ID_SCOPE can be found on your DPS Overview page -// IOT_DPS_REGISTRATION ID is the title of your individual enrollment -// containing your SAS key or X509 certificate +// Azure IoT device SAS key +// The SAS key generated by configuring an IoT Hub device or DPS individual +// enrollment // ---------------------------------------------------------------------------- -#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" -#define IOT_DPS_ID_SCOPE "" -#define IOT_DPS_REGISTRATION_ID "" +#define IOT_DEVICE_SAS_KEY "" #endif // _AZURE_CONFIG_H diff --git a/NXP/MIMXRT1050-EVKB/app/azure_device_x509_cert_config.h b/NXP/MIMXRT1050-EVKB/app/azure_device_x509_cert_config.h index 3b75e094..214b0092 100644 --- a/NXP/MIMXRT1050-EVKB/app/azure_device_x509_cert_config.h +++ b/NXP/MIMXRT1050-EVKB/app/azure_device_x509_cert_config.h @@ -1,3 +1,6 @@ +/* Copyright (c) Microsoft Corporation. + Licensed under the MIT License. */ + #ifndef _AZURE_DEVICE_X509_CERT_CONFIG_H #define _AZURE_DEVICE_X509_CERT_CONFIG_H @@ -6,13 +9,13 @@ // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- const unsigned char iot_x509_device_cert[] = {0x00}; -unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); +unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); // ---------------------------------------------------------------------------- // Azure IoT X509 Device Private Key // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- -unsigned char iot_x509_private_key[] = {0x00}; +unsigned char iot_x509_private_key[] = {0x00}; const unsigned int iot_x509_private_key_len = sizeof(iot_x509_private_key); #endif \ No newline at end of file diff --git a/NXP/MIMXRT1050-EVKB/app/legacy/mqtt.c b/NXP/MIMXRT1050-EVKB/app/legacy/mqtt.c index 85e4f7dc..f9c38c40 100644 --- a/NXP/MIMXRT1050-EVKB/app/legacy/mqtt.c +++ b/NXP/MIMXRT1050-EVKB/app/legacy/mqtt.c @@ -126,10 +126,9 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p pool_ptr, dns_ptr, time_get, - IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID, - IOT_PRIMARY_KEY, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #else // Create Azure MQTT for Hub @@ -139,8 +138,8 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p dns_ptr, time_get, IOT_HUB_HOSTNAME, - IOT_DEVICE_ID, - IOT_PRIMARY_KEY, + IOT_HUB_DEVICE_ID, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #endif diff --git a/NXP/MIMXRT1050-EVKB/app/nx_client.c b/NXP/MIMXRT1050-EVKB/app/nx_client.c index 0f2a762f..212c6bfe 100644 --- a/NXP/MIMXRT1050-EVKB/app/nx_client.c +++ b/NXP/MIMXRT1050-EVKB/app/nx_client.c @@ -205,7 +205,7 @@ UINT azure_iot_nx_client_entry( (UCHAR*)iot_x509_private_key, iot_x509_private_key_len); #else - status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_PRIMARY_KEY); + status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_DEVICE_SAS_KEY); #endif if (status != NX_SUCCESS) { @@ -214,9 +214,9 @@ UINT azure_iot_nx_client_entry( } #ifdef ENABLE_DPS - azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); + azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); #else - azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_DEVICE_ID); + azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_HUB_DEVICE_ID); #endif if (status != NX_SUCCESS) { diff --git a/NXP/MIMXRT1050-EVKB/readme.md b/NXP/MIMXRT1050-EVKB/readme.md index 03015edb..e5ed5a80 100644 --- a/NXP/MIMXRT1050-EVKB/readme.md +++ b/NXP/MIMXRT1050-EVKB/readme.md @@ -142,8 +142,8 @@ To connect the NXP EVK to Azure, you'll modify a configuration file for the Azur |Constant name|Value| |-------------|-----| |`IOT_HUB_HOSTNAME` |{*Your Iot hub hostName value*}| - |`IOT_DEVICE_ID` |{*Your deviceID value*}| - |`IOT_PRIMARY_KEY` |{*Your primaryKey value*}| + |`IOT_HUB_DEVICE_ID` |{*Your deviceID value*}| + |`IOT_DEVICE_SAS_KEY` |{*Your primaryKey value*}| 1. Save and close the file. diff --git a/NXP/MIMXRT1060-EVK/app/azure_config.h b/NXP/MIMXRT1060-EVK/app/azure_config.h index 98936ace..45fba7c8 100644 --- a/NXP/MIMXRT1060-EVK/app/azure_config.h +++ b/NXP/MIMXRT1060-EVK/app/azure_config.h @@ -14,47 +14,35 @@ // Azure IoT Dynamic Provisioning Service // Define this to use the DPS service, otherwise direct IoT Hub // ---------------------------------------------------------------------------- -// #define ENABLE_DPS +//#define ENABLE_DPS // ---------------------------------------------------------------------------- // Azure IoT DPS Self-Signed X509Certificate -// Define this to connect to DPS or Iot Hub using a self-signed X509 -/// certificate +// Define this to connect to DPS or Iot Hub using a X509 certificate // ---------------------------------------------------------------------------- // #define ENABLE_X509 // ---------------------------------------------------------------------------- -// Azure IoT Device ID -// Make sure this is the same as the Device ID on the corresponding IoT Hub -// NOTE: To be used only when ENABLE_DPS is NOT defined +// Azure IoT Hub connection config +// IOT_HUB_HOSTNAME: The Azure IoT Hub hostname +// IOT_HUB_DEVICE_ID: The Azure IoT Hub device id // ---------------------------------------------------------------------------- -#define IOT_DEVICE_ID "" +#define IOT_HUB_HOSTNAME "" +#define IOT_HUB_DEVICE_ID "" // ---------------------------------------------------------------------------- -// Azure IoT SAS Key -// The SAS key generated by configuring an IoT Hub device or DPS individual -// enrollment -// NOTE: To be used only when ENABLE_X509 is not defined -// ---------------------------------------------------------------------------- -#define IOT_PRIMARY_KEY "" - -// ---------------------------------------------------------------------------- -// Azure IoT Hub Hostname -// The Hostname found on your IoT Hub Overview page -// NOTE: To be used only when ENABLE_DPS is not defined +// Azure IoT DPS connection config +// IOT_DPS_ID_SCOPE: The DPS ID Scope +// IOT_DPS_REGISTRATION_ID: The DPS device Registration Id // ---------------------------------------------------------------------------- -#define IOT_HUB_HOSTNAME "" +#define IOT_DPS_ID_SCOPE "" +#define IOT_DPS_REGISTRATION_ID "" // ---------------------------------------------------------------------------- -// Azure IoT DPS config -// DPS connection information -// IOT_DPS_ENDPOINT is always "global.azure-devices-provisioning.net" -// IOT_DPS_ID_SCOPE can be found on your DPS Overview page -// IOT_DPS_REGISTRATION ID is the title of your individual enrollment -// containing your SAS key or X509 certificate +// Azure IoT device SAS key +// The SAS key generated by configuring an IoT Hub device or DPS individual +// enrollment // ---------------------------------------------------------------------------- -#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" -#define IOT_DPS_ID_SCOPE "" -#define IOT_DPS_REGISTRATION_ID "" +#define IOT_DEVICE_SAS_KEY "" #endif // _AZURE_CONFIG_H diff --git a/NXP/MIMXRT1060-EVK/app/azure_device_x509_cert_config.h b/NXP/MIMXRT1060-EVK/app/azure_device_x509_cert_config.h index 3b75e094..214b0092 100644 --- a/NXP/MIMXRT1060-EVK/app/azure_device_x509_cert_config.h +++ b/NXP/MIMXRT1060-EVK/app/azure_device_x509_cert_config.h @@ -1,3 +1,6 @@ +/* Copyright (c) Microsoft Corporation. + Licensed under the MIT License. */ + #ifndef _AZURE_DEVICE_X509_CERT_CONFIG_H #define _AZURE_DEVICE_X509_CERT_CONFIG_H @@ -6,13 +9,13 @@ // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- const unsigned char iot_x509_device_cert[] = {0x00}; -unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); +unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); // ---------------------------------------------------------------------------- // Azure IoT X509 Device Private Key // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- -unsigned char iot_x509_private_key[] = {0x00}; +unsigned char iot_x509_private_key[] = {0x00}; const unsigned int iot_x509_private_key_len = sizeof(iot_x509_private_key); #endif \ No newline at end of file diff --git a/NXP/MIMXRT1060-EVK/app/legacy/mqtt.c b/NXP/MIMXRT1060-EVK/app/legacy/mqtt.c index 85e4f7dc..f9c38c40 100644 --- a/NXP/MIMXRT1060-EVK/app/legacy/mqtt.c +++ b/NXP/MIMXRT1060-EVK/app/legacy/mqtt.c @@ -126,10 +126,9 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p pool_ptr, dns_ptr, time_get, - IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID, - IOT_PRIMARY_KEY, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #else // Create Azure MQTT for Hub @@ -139,8 +138,8 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p dns_ptr, time_get, IOT_HUB_HOSTNAME, - IOT_DEVICE_ID, - IOT_PRIMARY_KEY, + IOT_HUB_DEVICE_ID, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #endif diff --git a/NXP/MIMXRT1060-EVK/app/nx_client.c b/NXP/MIMXRT1060-EVK/app/nx_client.c index 48b338be..8702b6c0 100644 --- a/NXP/MIMXRT1060-EVK/app/nx_client.c +++ b/NXP/MIMXRT1060-EVK/app/nx_client.c @@ -205,7 +205,7 @@ UINT azure_iot_nx_client_entry( (UCHAR*)iot_x509_private_key, iot_x509_private_key_len); #else - status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_PRIMARY_KEY); + status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_DEVICE_SAS_KEY); #endif if (status != NX_SUCCESS) { @@ -214,9 +214,9 @@ UINT azure_iot_nx_client_entry( } #ifdef ENABLE_DPS - azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); + azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); #else - azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_DEVICE_ID); + azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_HUB_DEVICE_ID); #endif if (status != NX_SUCCESS) { diff --git a/NXP/MIMXRT1060-EVK/readme.md b/NXP/MIMXRT1060-EVK/readme.md index 134e40cb..80373044 100644 --- a/NXP/MIMXRT1060-EVK/readme.md +++ b/NXP/MIMXRT1060-EVK/readme.md @@ -142,8 +142,8 @@ To connect the MXCHIP DevKit to Azure, you'll modify a configuration file for Wi |Constant name|Value| |-------------|-----| |`IOT_HUB_HOSTNAME` |{*Your Iot hub hostName value*}| - |`IOT_DEVICE_ID` |{*Your deviceID value*}| - |`IOT_PRIMARY_KEY` |{*Your primaryKey value*}| + |`IOT_HUB_DEVICE_ID` |{*Your deviceID value*}| + |`IOT_DEVICE_SAS_KEY` |{*Your primaryKey value*}| 1. Save and close the file. diff --git a/STMicroelectronics/STM32L4_L4+/app/azure_config.h b/STMicroelectronics/STM32L4_L4+/app/azure_config.h index e97b392b..6818c27d 100644 --- a/STMicroelectronics/STM32L4_L4+/app/azure_config.h +++ b/STMicroelectronics/STM32L4_L4+/app/azure_config.h @@ -29,47 +29,35 @@ typedef enum // Azure IoT Dynamic Provisioning Service // Define this to use the DPS service, otherwise direct IoT Hub // ---------------------------------------------------------------------------- -// #define ENABLE_DPS +//#define ENABLE_DPS // ---------------------------------------------------------------------------- // Azure IoT DPS Self-Signed X509Certificate -// Define this to connect to DPS or Iot Hub using a self-signed X509 -/// certificate +// Define this to connect to DPS or Iot Hub using a X509 certificate // ---------------------------------------------------------------------------- // #define ENABLE_X509 // ---------------------------------------------------------------------------- -// Azure IoT Device ID -// Make sure this is the same as the Device ID on the corresponding IoT Hub -// NOTE: To be used only when ENABLE_DPS is NOT defined +// Azure IoT Hub connection config +// IOT_HUB_HOSTNAME: The Azure IoT Hub hostname +// IOT_HUB_DEVICE_ID: The Azure IoT Hub device id // ---------------------------------------------------------------------------- -#define IOT_DEVICE_ID "" +#define IOT_HUB_HOSTNAME "" +#define IOT_HUB_DEVICE_ID "" // ---------------------------------------------------------------------------- -// Azure IoT SAS Key -// The SAS key generated by configuring an IoT Hub device or DPS individual -// enrollment -// NOTE: To be used only when ENABLE_X509 is NOT defined -// ---------------------------------------------------------------------------- -#define IOT_PRIMARY_KEY "" - -// ---------------------------------------------------------------------------- -// Azure IoT Hub Hostname -// The Hostname found on your IoT Hub Overview page -// NOTE: To be used only when ENABLE_DPS is NOT defined +// Azure IoT DPS connection config +// IOT_DPS_ID_SCOPE: The DPS ID Scope +// IOT_DPS_REGISTRATION_ID: The DPS device Registration Id // ---------------------------------------------------------------------------- -#define IOT_HUB_HOSTNAME "" +#define IOT_DPS_ID_SCOPE "" +#define IOT_DPS_REGISTRATION_ID "" // ---------------------------------------------------------------------------- -// Azure IoT DPS config -// DPS connection information -// IOT_DPS_ENDPOINT is always "global.azure-devices-provisioning.net" -// IOT_DPS_ID_SCOPE can be found on your DPS Overview page -// IOT_DPS_REGISTRATION ID is the title of your individual enrollment -// containing your SAS key or X509 certificate +// Azure IoT device SAS key +// The SAS key generated by configuring an IoT Hub device or DPS individual +// enrollment // ---------------------------------------------------------------------------- -#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" -#define IOT_DPS_ID_SCOPE "" -#define IOT_DPS_REGISTRATION_ID "" +#define IOT_DEVICE_SAS_KEY "" #endif // _AZURE_CONFIG_H diff --git a/STMicroelectronics/STM32L4_L4+/app/azure_device_x509_cert_config.h b/STMicroelectronics/STM32L4_L4+/app/azure_device_x509_cert_config.h index 3b75e094..214b0092 100644 --- a/STMicroelectronics/STM32L4_L4+/app/azure_device_x509_cert_config.h +++ b/STMicroelectronics/STM32L4_L4+/app/azure_device_x509_cert_config.h @@ -1,3 +1,6 @@ +/* Copyright (c) Microsoft Corporation. + Licensed under the MIT License. */ + #ifndef _AZURE_DEVICE_X509_CERT_CONFIG_H #define _AZURE_DEVICE_X509_CERT_CONFIG_H @@ -6,13 +9,13 @@ // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- const unsigned char iot_x509_device_cert[] = {0x00}; -unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); +unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert); // ---------------------------------------------------------------------------- // Azure IoT X509 Device Private Key // Replace {0x00} with your formatted output from OpenSSL and xxd here // ---------------------------------------------------------------------------- -unsigned char iot_x509_private_key[] = {0x00}; +unsigned char iot_x509_private_key[] = {0x00}; const unsigned int iot_x509_private_key_len = sizeof(iot_x509_private_key); #endif \ No newline at end of file diff --git a/STMicroelectronics/STM32L4_L4+/app/legacy/mqtt.c b/STMicroelectronics/STM32L4_L4+/app/legacy/mqtt.c index 0702359f..3510f750 100644 --- a/STMicroelectronics/STM32L4_L4+/app/legacy/mqtt.c +++ b/STMicroelectronics/STM32L4_L4+/app/legacy/mqtt.c @@ -127,10 +127,9 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p pool_ptr, dns_ptr, time_get, - IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID, - IOT_PRIMARY_KEY, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #else // Create Azure MQTT for Hub @@ -140,8 +139,8 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p dns_ptr, time_get, IOT_HUB_HOSTNAME, - IOT_DEVICE_ID, - IOT_PRIMARY_KEY, + IOT_HUB_DEVICE_ID, + IOT_DEVICE_SAS_KEY, IOT_MODEL_ID); #endif diff --git a/STMicroelectronics/STM32L4_L4+/app/nx_client.c b/STMicroelectronics/STM32L4_L4+/app/nx_client.c index 301ca05b..af6a0e85 100644 --- a/STMicroelectronics/STM32L4_L4+/app/nx_client.c +++ b/STMicroelectronics/STM32L4_L4+/app/nx_client.c @@ -207,7 +207,7 @@ UINT azure_iot_nx_client_entry( (UCHAR*)iot_x509_private_key, iot_x509_private_key_len); #else - status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_PRIMARY_KEY); + status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_DEVICE_SAS_KEY); #endif if (status != NX_SUCCESS) { @@ -216,9 +216,9 @@ UINT azure_iot_nx_client_entry( } #ifdef ENABLE_DPS - azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); + azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID); #else - azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_DEVICE_ID); + azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_HUB_DEVICE_ID); #endif if (status != NX_SUCCESS) { diff --git a/STMicroelectronics/STM32L4_L4+/readme.md b/STMicroelectronics/STM32L4_L4+/readme.md index 79aaed2d..99bea610 100644 --- a/STMicroelectronics/STM32L4_L4+/readme.md +++ b/STMicroelectronics/STM32L4_L4+/readme.md @@ -150,8 +150,8 @@ To connect the STM DevKit to Azure, you'll modify a configuration file for Wi-Fi |Constant name|Value| |-------------|-----| |`IOT_HUB_HOSTNAME` |{*Your Iot hub hostName value*}| - |`IOT_DEVICE_ID` |{*Your deviceID value*}| - |`IOT_PRIMARY_KEY` |{*Your primaryKey value*}| + |`IOT_HUB_DEVICE_ID` |{*Your deviceID value*}| + |`IOT_DEVICE_SAS_KEY` |{*Your primaryKey value*}| 1. Save and close the file. diff --git a/core/src/azure_iot_mqtt/azure_iot_dps_mqtt.c b/core/src/azure_iot_mqtt/azure_iot_dps_mqtt.c index d98fab1a..5bb489c8 100644 --- a/core/src/azure_iot_mqtt/azure_iot_dps_mqtt.c +++ b/core/src/azure_iot_mqtt/azure_iot_dps_mqtt.c @@ -12,6 +12,8 @@ #include "json_utils.h" +#define AZURE_IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" + #define USERNAME "%s/registrations/%s/api-version=2019-03-31" #define DPS_REGISTER_BASE "$dps/registrations/res" #define DPS_REGISTER_SUBSCRIBE "$dps/registrations/res/#" @@ -234,7 +236,7 @@ UINT azure_iot_dps_register(AZURE_IOT_MQTT* azure_iot_mqtt, UINT wait) NXD_ADDRESS server_ip; CHAR mqtt_publish_payload[100]; - printf("\tEndpoint: %s\r\n", azure_iot_mqtt->mqtt_dps_endpoint); + printf("\tEndpoint: %s\r\n", AZURE_IOT_DPS_ENDPOINT); printf("\tId scope: %s\r\n", azure_iot_mqtt->mqtt_dps_id_scope); printf("\tRegistration id: %s\r\n", azure_iot_mqtt->mqtt_dps_registration_id); @@ -271,21 +273,21 @@ UINT azure_iot_dps_register(AZURE_IOT_MQTT* azure_iot_mqtt, UINT wait) // Resolve the MQTT server IP address status = nxd_dns_host_by_name_get(azure_iot_mqtt->nx_dns, - (UCHAR*)azure_iot_mqtt->mqtt_dps_endpoint, + (UCHAR*)AZURE_IOT_DPS_ENDPOINT, &server_ip, NX_IP_PERIODIC_RATE, NX_IP_VERSION_V4); if (status != NX_SUCCESS) { printf("Error: Unable to resolve DNS for DPS MQTT Server %s (0x%04x)\r\n", - azure_iot_mqtt->mqtt_dps_endpoint, + AZURE_IOT_DPS_ENDPOINT, status); nx_secure_tls_session_delete(&azure_iot_mqtt->nxd_mqtt_client.nxd_mqtt_tls_session); return status; } // Stash the hostname so we can verify the cert at connect - azure_iot_x509_hostname = azure_iot_mqtt->mqtt_dps_endpoint; + azure_iot_x509_hostname = AZURE_IOT_DPS_ENDPOINT; status = nxd_mqtt_client_secure_connect(&azure_iot_mqtt->nxd_mqtt_client, &server_ip, diff --git a/core/src/azure_iot_mqtt/azure_iot_mqtt.c b/core/src/azure_iot_mqtt/azure_iot_mqtt.c index cf0c4ee6..2a931b18 100644 --- a/core/src/azure_iot_mqtt/azure_iot_mqtt.c +++ b/core/src/azure_iot_mqtt/azure_iot_mqtt.c @@ -191,9 +191,9 @@ static UINT mqtt_publish_float(AZURE_IOT_MQTT* azure_iot_mqtt, CHAR* topic, CHAR { CHAR mqtt_message[100]; - int decvalue = value; + int decvalue = value; int fracvalue = abs(100 * (value - (long)value)); - + snprintf(mqtt_message, sizeof(mqtt_message), "{\"%s\":%d.%2d}", label, decvalue, fracvalue); printf("Sending message %s\r\n", mqtt_message); @@ -601,7 +601,6 @@ UINT azure_iot_mqtt_create_with_dps(AZURE_IOT_MQTT* azure_iot_mqtt, NX_PACKET_POOL* nx_pool, NX_DNS* nx_dns, func_ptr_unix_time_get unix_time_get, - CHAR* iot_dps_endpoint, CHAR* iot_dps_id_scope, CHAR* iot_registration_id, CHAR* iot_sas_key, @@ -617,7 +616,7 @@ UINT azure_iot_mqtt_create_with_dps(AZURE_IOT_MQTT* azure_iot_mqtt, return NX_PTR_ERROR; } - if (iot_dps_endpoint[0] == 0 || iot_dps_id_scope[0] == 0 || iot_registration_id[0] == 0 || iot_sas_key[0] == 0) + if (iot_dps_id_scope[0] == 0 || iot_registration_id[0] == 0 || iot_sas_key[0] == 0) { printf("ERROR: IoT DPS connection configuration is empty\r\n"); return NX_PTR_ERROR; @@ -628,7 +627,6 @@ UINT azure_iot_mqtt_create_with_dps(AZURE_IOT_MQTT* azure_iot_mqtt, // Stash the connection information azure_iot_mqtt->nx_dns = nx_dns; azure_iot_mqtt->unix_time_get = unix_time_get; - azure_iot_mqtt->mqtt_dps_endpoint = iot_dps_endpoint; azure_iot_mqtt->mqtt_dps_id_scope = iot_dps_id_scope; azure_iot_mqtt->mqtt_dps_registration_id = iot_registration_id; azure_iot_mqtt->mqtt_sas_key = iot_sas_key; diff --git a/core/src/azure_iot_mqtt/azure_iot_mqtt.h b/core/src/azure_iot_mqtt/azure_iot_mqtt.h index fc792b9a..deae5e6e 100644 --- a/core/src/azure_iot_mqtt/azure_iot_mqtt.h +++ b/core/src/azure_iot_mqtt/azure_iot_mqtt.h @@ -51,7 +51,6 @@ struct AZURE_IOT_MQTT_STRUCT CHAR mqtt_hub_hostname[AZURE_IOT_MQTT_HOSTNAME_SIZE]; // DPS config - CHAR* mqtt_dps_endpoint; CHAR* mqtt_dps_id_scope; CHAR* mqtt_dps_registration_id; @@ -124,7 +123,6 @@ UINT azure_iot_mqtt_create_with_dps(AZURE_IOT_MQTT* azure_iot_mqtt, NX_PACKET_POOL* nx_pool, NX_DNS* nx_dns, func_ptr_unix_time_get unix_time_get, - CHAR* iot_dps_endpoint, CHAR* iot_dps_id_scope, CHAR* iot_device_id, CHAR* iot_sas_key, diff --git a/core/src/azure_iot_nx/azure_iot_nx_client.c b/core/src/azure_iot_nx/azure_iot_nx_client.c index e88b8889..1d1141b2 100644 --- a/core/src/azure_iot_nx/azure_iot_nx_client.c +++ b/core/src/azure_iot_nx/azure_iot_nx_client.c @@ -18,6 +18,8 @@ #define DEVICE_TWIN_GET_EVENT 0x02 #define DEVICE_TWIN_DESIRED_PROPERTY_EVENT 0x04 +#define AZURE_IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" + #define MODULE_ID "" #define DPS_PAYLOAD "{\"modelId\":\"%s\"}" @@ -493,7 +495,7 @@ UINT azure_iot_nx_client_hub_create(AZURE_IOT_NX_CONTEXT* context, CHAR* iot_hub return NX_PTR_ERROR; } - // Return error if empty endpoint information or empty credentials + // Return error if empty hostname or device id if (iot_hub_hostname[0] == 0 || iot_device_id[0] == 0) { printf("ERROR: azure_iot_nx_client_hub_create iot_hub_hostname is null\r\n"); @@ -508,7 +510,7 @@ UINT azure_iot_nx_client_hub_create(AZURE_IOT_NX_CONTEXT* context, CHAR* iot_hub } UINT azure_iot_nx_client_dps_create( - AZURE_IOT_NX_CONTEXT* context, CHAR* dps_endpoint, CHAR* dps_id_scope, CHAR* dps_registration_id) + AZURE_IOT_NX_CONTEXT* context, CHAR* dps_id_scope, CHAR* dps_registration_id) { UINT status; CHAR payload[DPS_PAYLOAD_SIZE]; @@ -516,7 +518,7 @@ UINT azure_iot_nx_client_dps_create( UINT iot_device_id_len = AZURE_IOT_DEVICE_ID_SIZE; printf("Initializing Azure IoT DPS client\r\n"); - printf("\tDPS endpoint: %s\r\n", dps_endpoint); + printf("\tDPS endpoint: %s\r\n", AZURE_IOT_DPS_ENDPOINT); printf("\tDPS ID scope: %s\r\n", dps_id_scope); printf("\tRegistration ID: %s\r\n", dps_registration_id); @@ -526,8 +528,8 @@ UINT azure_iot_nx_client_dps_create( return NX_PTR_ERROR; } - // Return error if empty endpoint information or empty credentials - if (dps_endpoint[0] == 0 || dps_id_scope[0] == 0 || dps_registration_id[0] == 0) + // Return error if empty credentials + if (dps_id_scope[0] == 0 || dps_registration_id[0] == 0) { printf("ERROR: azure_iot_nx_client_dps_create incorrect parameters\r\n"); return NX_PTR_ERROR; @@ -542,8 +544,8 @@ UINT azure_iot_nx_client_dps_create( // Initialize IoT provisioning client if ((status = nx_azure_iot_provisioning_client_initialize(&context->dps_client, &context->nx_azure_iot, - (UCHAR*)dps_endpoint, - strlen(dps_endpoint), + (UCHAR*)AZURE_IOT_DPS_ENDPOINT, + strlen(AZURE_IOT_DPS_ENDPOINT), (UCHAR*)dps_id_scope, strlen(dps_id_scope), (UCHAR*)dps_registration_id, diff --git a/core/src/azure_iot_nx/azure_iot_nx_client.h b/core/src/azure_iot_nx/azure_iot_nx_client.h index b0cf5966..b3281a1e 100644 --- a/core/src/azure_iot_nx/azure_iot_nx_client.h +++ b/core/src/azure_iot_nx/azure_iot_nx_client.h @@ -88,8 +88,7 @@ UINT azure_iot_nx_client_create(AZURE_IOT_NX_CONTEXT* context, CHAR* iot_model_id); UINT azure_iot_nx_client_hub_create(AZURE_IOT_NX_CONTEXT* context, CHAR* iot_hub_hostname, CHAR* iot_device_id); -UINT azure_iot_nx_client_dps_create( - AZURE_IOT_NX_CONTEXT* context, CHAR* dps_endpoint, CHAR* dps_id_scope, CHAR* dps_registration_id); +UINT azure_iot_nx_client_dps_create(AZURE_IOT_NX_CONTEXT* context, CHAR* dps_id_scope, CHAR* dps_registration_id); UINT azure_iot_nx_client_delete(AZURE_IOT_NX_CONTEXT* context); UINT azure_iot_nx_client_connect(AZURE_IOT_NX_CONTEXT* context); diff --git a/docs/using-azure-rtos.md b/docs/using-azure-rtos.md index 4ae397ec..2b67da45 100644 --- a/docs/using-azure-rtos.md +++ b/docs/using-azure-rtos.md @@ -106,7 +106,7 @@ The *startup* folder contains three components: ### Azure_config.h -The *azure_config.h* file contains configuration required to connect the device to IoT Hub. Primarily it contains the IoT Hub connection information, which you can store in the constants `IOT_HUB_HOSTNAME`, `IOT_DEVICE_ID`, `IOT_PRIMARY_KEY`. The file also contains Wi-Fi configuration details if the device requires a Wi-Fi connection. +The *azure_config.h* file contains configuration required to connect the device to IoT Hub. Primarily it contains the IoT Hub connection information, which you can store in the constants `IOT_HUB_HOSTNAME`, `IOT_HUB_DEVICE_ID`, `IOT_DEVICE_SAS_KEY`. The file also contains Wi-Fi configuration details if the device requires a Wi-Fi connection. > Note: In a production environment, we recommend that you not store connection details in code files. ### mqtt.c diff --git a/docs/using-self-signed-x509-certificates.md b/docs/using-self-signed-x509-certificates.md index d141b6dd..80c010f4 100644 --- a/docs/using-self-signed-x509-certificates.md +++ b/docs/using-self-signed-x509-certificates.md @@ -95,10 +95,9 @@ If you haven't already, please set up your [DPS and IoT Hub instances](https://d #define WIFI_SSID "" #define WIFI_PASSWORD "" -#define IOT_HUB_HOSTNAME ".azure-devices.net" -#define IOT_DEVICE_ID "test-x509-device" +#define IOT_HUB_HOSTNAME ".azure-devices.net" +#define IOT_HUB_DEVICE_ID "test-x509-device" -#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net" #define IOT_DPS_ID_SCOPE "" #define IOT_DPS_REGISTRATION_ID "" # the title of your individual enrollment ```