Skip to content

Commit c5a1034

Browse files
authored
rework config ready for Central change (#166)
1 parent becdf23 commit c5a1034

32 files changed

+174
-234
lines changed

MXChip/AZ3166/app/azure_config.h

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,35 @@ typedef enum
2929
// Azure IoT Dynamic Provisioning Service
3030
// Define this to use the DPS service, otherwise direct IoT Hub
3131
// ----------------------------------------------------------------------------
32-
// #define ENABLE_DPS
32+
//#define ENABLE_DPS
3333

3434
// ----------------------------------------------------------------------------
3535
// Azure IoT DPS Self-Signed X509Certificate
36-
// Define this to connect to DPS or Iot Hub using a self-signed X509
37-
/// certificate
36+
// Define this to connect to DPS or Iot Hub using a X509 certificate
3837
// ----------------------------------------------------------------------------
3938
// #define ENABLE_X509
4039

4140
// ----------------------------------------------------------------------------
42-
// Azure IoT Device ID
43-
// Make sure this is the same as the Device ID on the corresponding IoT Hub
44-
// NOTE: To be used only when ENABLE_DPS is NOT defined
41+
// Azure IoT Hub connection config
42+
// IOT_HUB_HOSTNAME: The Azure IoT Hub hostname
43+
// IOT_HUB_DEVICE_ID: The Azure IoT Hub device id
4544
// ----------------------------------------------------------------------------
46-
#define IOT_DEVICE_ID ""
45+
#define IOT_HUB_HOSTNAME ""
46+
#define IOT_HUB_DEVICE_ID ""
4747

4848
// ----------------------------------------------------------------------------
49-
// Azure IoT SAS Key
50-
// The SAS key generated by configuring an IoT Hub device or DPS individual
51-
// enrollment
52-
// NOTE: To be used only when ENABLE_X509 is not defined
53-
// ----------------------------------------------------------------------------
54-
#define IOT_PRIMARY_KEY ""
55-
56-
// ----------------------------------------------------------------------------
57-
// Azure IoT Hub Hostname
58-
// The Hostname found on your IoT Hub Overview page
59-
// NOTE: To be used only when ENABLE_DPS is not defined
49+
// Azure IoT DPS connection config
50+
// IOT_DPS_ID_SCOPE: The DPS ID Scope
51+
// IOT_DPS_REGISTRATION_ID: The DPS device Registration Id
6052
// ----------------------------------------------------------------------------
61-
#define IOT_HUB_HOSTNAME ""
53+
#define IOT_DPS_ID_SCOPE ""
54+
#define IOT_DPS_REGISTRATION_ID ""
6255

6356
// ----------------------------------------------------------------------------
64-
// Azure IoT DPS config
65-
// DPS connection information
66-
// IOT_DPS_ENDPOINT is always "global.azure-devices-provisioning.net"
67-
// IOT_DPS_ID_SCOPE can be found on your DPS Overview page
68-
// IOT_DPS_REGISTRATION ID is the title of your individual enrollment
69-
// containing your SAS key or X509 certificate
57+
// Azure IoT device SAS key
58+
// The SAS key generated by configuring an IoT Hub device or DPS individual
59+
// enrollment
7060
// ----------------------------------------------------------------------------
71-
#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net"
72-
#define IOT_DPS_ID_SCOPE ""
73-
#define IOT_DPS_REGISTRATION_ID ""
61+
#define IOT_DEVICE_SAS_KEY ""
7462

7563
#endif // _AZURE_CONFIG_H
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. */
3+
14
#ifndef _AZURE_DEVICE_X509_CERT_CONFIG_H
25
#define _AZURE_DEVICE_X509_CERT_CONFIG_H
36

@@ -6,13 +9,13 @@
69
// Replace {0x00} with your formatted output from OpenSSL and xxd here
710
// ----------------------------------------------------------------------------
811
const unsigned char iot_x509_device_cert[] = {0x00};
9-
unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert);
12+
unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert);
1013

1114
// ----------------------------------------------------------------------------
1215
// Azure IoT X509 Device Private Key
1316
// Replace {0x00} with your formatted output from OpenSSL and xxd here
1417
// ----------------------------------------------------------------------------
15-
unsigned char iot_x509_private_key[] = {0x00};
18+
unsigned char iot_x509_private_key[] = {0x00};
1619
const unsigned int iot_x509_private_key_len = sizeof(iot_x509_private_key);
1720

1821
#endif

MXChip/AZ3166/app/legacy/mqtt.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p
133133
pool_ptr,
134134
dns_ptr,
135135
time_get,
136-
IOT_DPS_ENDPOINT,
137136
IOT_DPS_ID_SCOPE,
138137
IOT_DPS_REGISTRATION_ID,
139-
IOT_PRIMARY_KEY,
138+
IOT_DEVICE_SAS_KEY,
140139
IOT_MODEL_ID);
141140
#else
142141
// 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
146145
dns_ptr,
147146
time_get,
148147
IOT_HUB_HOSTNAME,
149-
IOT_DEVICE_ID,
150-
IOT_PRIMARY_KEY,
148+
IOT_HUB_DEVICE_ID,
149+
IOT_DEVICE_SAS_KEY,
151150
IOT_MODEL_ID);
152151
#endif
153152

MXChip/AZ3166/app/nx_client.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ static UINT append_device_telemetry_accelerometer(NX_AZURE_IOT_JSON_WRITER* json
167167
lsm6dsl_data.acceleration_mg[1],
168168
2) ||
169169
nx_azure_iot_json_writer_append_property_with_double_value(json_writer,
170-
(UCHAR*)TELEMETRY_ACCELEROMETERY,
171-
sizeof(TELEMETRY_ACCELEROMETERY) - 1,
170+
(UCHAR*)TELEMETRY_ACCELEROMETERZ,
171+
sizeof(TELEMETRY_ACCELEROMETERZ) - 1,
172172
lsm6dsl_data.acceleration_mg[2],
173173
2))
174174
{
@@ -186,21 +186,13 @@ static UINT append_device_telemetry_gyroscope(NX_AZURE_IOT_JSON_WRITER* json_wri
186186
(UCHAR*)TELEMETRY_GYROSCOPEX,
187187
sizeof(TELEMETRY_GYROSCOPEX) - 1,
188188
lsm6dsl_data.angular_rate_mdps[0],
189-
2))
190-
{
191-
return NX_NOT_SUCCESSFUL;
192-
}
193-
194-
if (nx_azure_iot_json_writer_append_property_with_double_value(json_writer,
189+
2) ||
190+
nx_azure_iot_json_writer_append_property_with_double_value(json_writer,
195191
(UCHAR*)TELEMETRY_GYROSCOPEY,
196192
sizeof(TELEMETRY_GYROSCOPEY) - 1,
197193
lsm6dsl_data.angular_rate_mdps[1],
198-
2))
199-
{
200-
return NX_NOT_SUCCESSFUL;
201-
}
202-
203-
if (nx_azure_iot_json_writer_append_property_with_double_value(json_writer,
194+
2) ||
195+
nx_azure_iot_json_writer_append_property_with_double_value(json_writer,
204196
(UCHAR*)TELEMETRY_GYROSCOPEZ,
205197
sizeof(TELEMETRY_GYROSCOPEZ) - 1,
206198
lsm6dsl_data.angular_rate_mdps[2],
@@ -345,7 +337,7 @@ UINT azure_iot_nx_client_entry(
345337
(UCHAR*)iot_x509_private_key,
346338
iot_x509_private_key_len);
347339
#else
348-
status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_PRIMARY_KEY);
340+
status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_DEVICE_SAS_KEY);
349341
#endif
350342
if (status != NX_SUCCESS)
351343
{
@@ -354,9 +346,9 @@ UINT azure_iot_nx_client_entry(
354346
}
355347

356348
#ifdef ENABLE_DPS
357-
azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID);
349+
azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID);
358350
#else
359-
azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_DEVICE_ID);
351+
azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_HUB_DEVICE_ID);
360352
#endif
361353
if (status != NX_SUCCESS)
362354
{

MXChip/AZ3166/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ To connect the MXCHIP DevKit to Azure, you'll modify a configuration file for Wi
148148
|Constant name|Value|
149149
|-------------|-----|
150150
|`IOT_HUB_HOSTNAME` |{*Your Iot hub hostName value*}|
151-
|`IOT_DEVICE_ID` |{*Your deviceID value*}|
152-
|`IOT_PRIMARY_KEY` |{*Your primaryKey value*}|
151+
|`IOT_HUB_DEVICE_ID` |{*Your deviceID value*}|
152+
|`IOT_DEVICE_SAS_KEY` |{*Your primaryKey value*}|
153153
154154
1. Save and close the file.
155155

Microchip/ATSAME54-XPRO/app/azure_config.h

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// 0 - BME280 sensor is not present
99
// 1 - BME280 sensor is present
1010
// ----------------------------------------------------------------------------
11-
#define __SENSOR_BME280__ 0
11+
#define __SENSOR_BME280__ 1
1212

1313
// ----------------------------------------------------------------------------
1414
// Azure IoT Hub Connection Transport
@@ -20,47 +20,35 @@
2020
// Azure IoT Dynamic Provisioning Service
2121
// Define this to use the DPS service, otherwise direct IoT Hub
2222
// ----------------------------------------------------------------------------
23-
// #define ENABLE_DPS
23+
//#define ENABLE_DPS
2424

2525
// ----------------------------------------------------------------------------
2626
// Azure IoT DPS Self-Signed X509Certificate
27-
// Define this to connect to DPS or Iot Hub using a self-signed X509
28-
/// certificate
27+
// Define this to connect to DPS or Iot Hub using a X509 certificate
2928
// ----------------------------------------------------------------------------
3029
// #define ENABLE_X509
3130

3231
// ----------------------------------------------------------------------------
33-
// Azure IoT Device ID
34-
// Make sure this is the same as the Device ID on the corresponding IoT Hub
35-
// NOTE: To be used only when ENABLE_DPS is NOT defined
32+
// Azure IoT Hub connection config
33+
// IOT_HUB_HOSTNAME: The Azure IoT Hub hostname
34+
// IOT_HUB_DEVICE_ID: The Azure IoT Hub device id
3635
// ----------------------------------------------------------------------------
37-
#define IOT_DEVICE_ID ""
36+
#define IOT_HUB_HOSTNAME ""
37+
#define IOT_HUB_DEVICE_ID ""
3838

3939
// ----------------------------------------------------------------------------
40-
// Azure IoT SAS Key
41-
// The SAS key generated by configuring an IoT Hub device or DPS individual
42-
// enrollment
43-
// NOTE: To be used only when ENABLE_X509 is not defined
44-
// ----------------------------------------------------------------------------
45-
#define IOT_PRIMARY_KEY ""
46-
47-
// ----------------------------------------------------------------------------
48-
// Azure IoT Hub Hostname
49-
// The Hostname found on your IoT Hub Overview page
50-
// NOTE: To be used only when ENABLE_DPS is not defined
40+
// Azure IoT DPS connection config
41+
// IOT_DPS_ID_SCOPE: The DPS ID Scope
42+
// IOT_DPS_REGISTRATION_ID: The DPS device Registration Id
5143
// ----------------------------------------------------------------------------
52-
#define IOT_HUB_HOSTNAME ""
44+
#define IOT_DPS_ID_SCOPE ""
45+
#define IOT_DPS_REGISTRATION_ID ""
5346

5447
// ----------------------------------------------------------------------------
55-
// Azure IoT DPS config
56-
// DPS connection information
57-
// IOT_DPS_ENDPOINT is always "global.azure-devices-provisioning.net"
58-
// IOT_DPS_ID_SCOPE can be found on your DPS Overview page
59-
// IOT_DPS_REGISTRATION ID is the title of your individual enrollment
60-
// containing your SAS key or X509 certificate
48+
// Azure IoT device SAS key
49+
// The SAS key generated by configuring an IoT Hub device or DPS individual
50+
// enrollment
6151
// ----------------------------------------------------------------------------
62-
#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net"
63-
#define IOT_DPS_ID_SCOPE ""
64-
#define IOT_DPS_REGISTRATION_ID ""
52+
#define IOT_DEVICE_SAS_KEY ""
6553

6654
#endif // _AZURE_CONFIG_H
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. */
3+
14
#ifndef _AZURE_DEVICE_X509_CERT_CONFIG_H
25
#define _AZURE_DEVICE_X509_CERT_CONFIG_H
36

@@ -6,13 +9,13 @@
69
// Replace {0x00} with your formatted output from OpenSSL and xxd here
710
// ----------------------------------------------------------------------------
811
const unsigned char iot_x509_device_cert[] = {0x00};
9-
unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert);
12+
unsigned int iot_x509_device_cert_len = sizeof(iot_x509_device_cert);
1013

1114
// ----------------------------------------------------------------------------
1215
// Azure IoT X509 Device Private Key
1316
// Replace {0x00} with your formatted output from OpenSSL and xxd here
1417
// ----------------------------------------------------------------------------
15-
unsigned char iot_x509_private_key[] = {0x00};
18+
unsigned char iot_x509_private_key[] = {0x00};
1619
const unsigned int iot_x509_private_key_len = sizeof(iot_x509_private_key);
1720

1821
#endif

Microchip/ATSAME54-XPRO/app/legacy/mqtt.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p
129129
pool_ptr,
130130
dns_ptr,
131131
time_get,
132-
IOT_DPS_ENDPOINT,
133132
IOT_DPS_ID_SCOPE,
134133
IOT_DPS_REGISTRATION_ID,
135-
IOT_PRIMARY_KEY,
134+
IOT_DEVICE_SAS_KEY,
136135
IOT_MODEL_ID);
137136
#else
138137
// 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
142141
dns_ptr,
143142
time_get,
144143
IOT_HUB_HOSTNAME,
145-
IOT_DEVICE_ID,
146-
IOT_PRIMARY_KEY,
144+
IOT_HUB_DEVICE_ID,
145+
IOT_DEVICE_SAS_KEY,
147146
IOT_MODEL_ID);
148147
#endif
149148

Microchip/ATSAME54-XPRO/app/nx_client.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ UINT azure_iot_nx_client_entry(
209209
(UCHAR*)iot_x509_private_key,
210210
iot_x509_private_key_len);
211211
#else
212-
status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_PRIMARY_KEY);
212+
status = azure_iot_nx_client_sas_set(&azure_iot_nx_client, IOT_DEVICE_SAS_KEY);
213213
#endif
214214
if (status != NX_SUCCESS)
215215
{
@@ -218,9 +218,9 @@ UINT azure_iot_nx_client_entry(
218218
}
219219

220220
#ifdef ENABLE_DPS
221-
azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ENDPOINT, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID);
221+
azure_iot_nx_client_dps_create(&azure_iot_nx_client, IOT_DPS_ID_SCOPE, IOT_DPS_REGISTRATION_ID);
222222
#else
223-
azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_DEVICE_ID);
223+
azure_iot_nx_client_hub_create(&azure_iot_nx_client, IOT_HUB_HOSTNAME, IOT_HUB_DEVICE_ID);
224224
#endif
225225
if (status != NX_SUCCESS)
226226
{

Microchip/ATSAME54-XPRO/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ To connect the Microchip E54 to Azure, you'll modify a configuration file for Az
148148
|Constant name|Value|
149149
|-------------|-----|
150150
|`IOT_HUB_HOSTNAME` |{*Your Iot hub hostName value*}|
151-
|`IOT_DEVICE_ID` |{*Your deviceID value*}|
152-
|`IOT_PRIMARY_KEY` |{*Your primaryKey value*}|
151+
|`IOT_HUB_DEVICE_ID` |{*Your deviceID value*}|
152+
|`IOT_DEVICE_SAS_KEY` |{*Your primaryKey value*}|
153153
154154
1. Save and close the file.
155155

NXP/MIMXRT1050-EVKB/app/azure_config.h

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,35 @@
1414
// Azure IoT Dynamic Provisioning Service
1515
// Define this to use the DPS service, otherwise direct IoT Hub
1616
// ----------------------------------------------------------------------------
17-
// #define ENABLE_DPS
17+
//#define ENABLE_DPS
1818

1919
// ----------------------------------------------------------------------------
2020
// Azure IoT DPS Self-Signed X509Certificate
21-
// Define this to connect to DPS or Iot Hub using a self-signed X509
22-
/// certificate
21+
// Define this to connect to DPS or Iot Hub using a X509 certificate
2322
// ----------------------------------------------------------------------------
2423
// #define ENABLE_X509
2524

2625
// ----------------------------------------------------------------------------
27-
// Azure IoT Device ID
28-
// Make sure this is the same as the Device ID on the corresponding IoT Hub
29-
// NOTE: To be used only when ENABLE_DPS is NOT defined
26+
// Azure IoT Hub connection config
27+
// IOT_HUB_HOSTNAME: The Azure IoT Hub hostname
28+
// IOT_HUB_DEVICE_ID: The Azure IoT Hub device id
3029
// ----------------------------------------------------------------------------
31-
#define IOT_DEVICE_ID ""
30+
#define IOT_HUB_HOSTNAME ""
31+
#define IOT_HUB_DEVICE_ID ""
3232

3333
// ----------------------------------------------------------------------------
34-
// Azure IoT SAS Key
35-
// The SAS key generated by configuring an IoT Hub device or DPS individual
36-
// enrollment
37-
// NOTE: To be used only when ENABLE_X509 is not defined
38-
// ----------------------------------------------------------------------------
39-
#define IOT_PRIMARY_KEY ""
40-
41-
// ----------------------------------------------------------------------------
42-
// Azure IoT Hub Hostname
43-
// The Hostname found on your IoT Hub Overview page
44-
// NOTE: To be used only when ENABLE_DPS is not defined
34+
// Azure IoT DPS connection config
35+
// IOT_DPS_ID_SCOPE: The DPS ID Scope
36+
// IOT_DPS_REGISTRATION_ID: The DPS device Registration Id
4537
// ----------------------------------------------------------------------------
46-
#define IOT_HUB_HOSTNAME ""
38+
#define IOT_DPS_ID_SCOPE ""
39+
#define IOT_DPS_REGISTRATION_ID ""
4740

4841
// ----------------------------------------------------------------------------
49-
// Azure IoT DPS config
50-
// DPS connection information
51-
// IOT_DPS_ENDPOINT is always "global.azure-devices-provisioning.net"
52-
// IOT_DPS_ID_SCOPE can be found on your DPS Overview page
53-
// IOT_DPS_REGISTRATION ID is the title of your individual enrollment
54-
// containing your SAS key or X509 certificate
42+
// Azure IoT device SAS key
43+
// The SAS key generated by configuring an IoT Hub device or DPS individual
44+
// enrollment
5545
// ----------------------------------------------------------------------------
56-
#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net"
57-
#define IOT_DPS_ID_SCOPE ""
58-
#define IOT_DPS_REGISTRATION_ID ""
46+
#define IOT_DEVICE_SAS_KEY ""
5947

6048
#endif // _AZURE_CONFIG_H

0 commit comments

Comments
 (0)