Skip to content

Commit d573491

Browse files
authored
Azure RTOS 2.1.9 (#298)
* Update Azure RTOS to 2.1.9 * Update Azure RTOS middleware API to PNP * Move to tcpip offload for STM and Renesas boards * Move core to shared
1 parent 59c8307 commit d573491

File tree

287 files changed

+4614
-41561
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+4614
-41561
lines changed

.gitmodules

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
[submodule "core/lib/threadx"]
2-
path = core/lib/threadx
1+
[submodule "shared/lib/threadx"]
2+
path = shared/lib/threadx
33
url = https://github.com/azure-rtos/threadx.git
4-
[submodule "core/lib/netxduo"]
5-
path = core/lib/netxduo
4+
[submodule "shared/lib/netxduo"]
5+
path = shared/lib/netxduo
66
url = https://github.com/azure-rtos/netxduo.git
7-
[submodule "core/lib/jsmn/src"]
8-
path = core/lib/jsmn/src
7+
[submodule "shared/lib/jsmn/src"]
8+
path = shared/lib/jsmn/src
99
url = https://github.com/zserge/jsmn

MXChip/AZ3166/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
55
set(CMAKE_C_STANDARD 99)
66

77
set(GSG_BASE_DIR ${CMAKE_SOURCE_DIR}/../..)
8-
set(CORE_SRC_DIR ${GSG_BASE_DIR}/core/src)
9-
set(CORE_LIB_DIR ${GSG_BASE_DIR}/core/lib)
8+
set(SHARED_SRC_DIR ${GSG_BASE_DIR}/shared/src)
9+
set(SHARED_LIB_DIR ${GSG_BASE_DIR}/shared/lib)
1010

1111
# use the repo version of ninja on Windows as there is no Ninja installer
1212
if(WIN32)
@@ -29,6 +29,6 @@ project(mxchip_azure_iot C ASM)
2929
# Disable common networking component, MXCHIP has it's own
3030
set(DISABLE_COMMON_NETWORK true)
3131

32-
add_subdirectory(${CORE_SRC_DIR} core_src)
32+
add_subdirectory(${SHARED_SRC_DIR} shared_src)
3333
add_subdirectory(lib)
3434
add_subdirectory(app)

MXChip/AZ3166/app/nx_client.c

+62-50
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "nx_azure_iot_provisioning_client.h"
1616

1717
#include "azure_iot_nx_client.h"
18-
#include "nx_azure_iot_pnp_helpers.h"
1918

2019
#include "azure_config.h"
2120
#include "azure_device_x509_cert_config.h"
@@ -57,7 +56,7 @@ static TX_EVENT_FLAGS_GROUP azure_iot_flags;
5756

5857
static int32_t telemetry_interval = 10;
5958

60-
static UINT append_device_info_properties(NX_AZURE_IOT_JSON_WRITER* json_writer, VOID* context)
59+
static UINT append_device_info_properties(NX_AZURE_IOT_JSON_WRITER* json_writer)
6160
{
6261
if (nx_azure_iot_json_writer_append_property_with_string_value(json_writer,
6362
(UCHAR*)DEVICE_INFO_MANUFACTURER_PROPERTY_NAME,
@@ -106,7 +105,7 @@ static UINT append_device_info_properties(NX_AZURE_IOT_JSON_WRITER* json_writer,
106105
return NX_AZURE_IOT_SUCCESS;
107106
}
108107

109-
static UINT append_device_telemetry(NX_AZURE_IOT_JSON_WRITER* json_writer, VOID* context)
108+
static UINT append_device_telemetry(NX_AZURE_IOT_JSON_WRITER* json_writer)
110109
{
111110
lps22hb_t lps22hb_data = lps22hb_data_read();
112111
hts221_data_t hts221_data = hts221_data_read();
@@ -127,7 +126,7 @@ static UINT append_device_telemetry(NX_AZURE_IOT_JSON_WRITER* json_writer, VOID*
127126
return NX_AZURE_IOT_SUCCESS;
128127
}
129128

130-
static UINT append_device_telemetry_magnetometer(NX_AZURE_IOT_JSON_WRITER* json_writer, VOID* context)
129+
static UINT append_device_telemetry_magnetometer(NX_AZURE_IOT_JSON_WRITER* json_writer)
131130
{
132131
lis2mdl_data_t lis2mdl_data = lis2mdl_data_read();
133132

@@ -153,7 +152,7 @@ static UINT append_device_telemetry_magnetometer(NX_AZURE_IOT_JSON_WRITER* json_
153152
return NX_AZURE_IOT_SUCCESS;
154153
}
155154

156-
static UINT append_device_telemetry_accelerometer(NX_AZURE_IOT_JSON_WRITER* json_writer, VOID* context)
155+
static UINT append_device_telemetry_accelerometer(NX_AZURE_IOT_JSON_WRITER* json_writer)
157156
{
158157
lsm6dsl_data_t lsm6dsl_data = lsm6dsl_data_read();
159158

@@ -179,7 +178,7 @@ static UINT append_device_telemetry_accelerometer(NX_AZURE_IOT_JSON_WRITER* json
179178
return NX_AZURE_IOT_SUCCESS;
180179
}
181180

182-
static UINT append_device_telemetry_gyroscope(NX_AZURE_IOT_JSON_WRITER* json_writer, VOID* context)
181+
static UINT append_device_telemetry_gyroscope(NX_AZURE_IOT_JSON_WRITER* json_writer)
183182
{
184183
lsm6dsl_data_t lsm6dsl_data = lsm6dsl_data_read();
185184

@@ -209,77 +208,83 @@ static void set_led_state(bool level)
209208
{
210209
if (level)
211210
{
212-
printf("LED is turned ON\r\n");
211+
printf("\tLED is turned ON\r\n");
213212
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET);
214213
}
215214
else
216215
{
217-
printf("LED is turned OFF\r\n");
216+
printf("\tLED is turned OFF\r\n");
218217
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);
219218
}
220219
}
221220

222-
static void direct_method_cb(AZURE_IOT_NX_CONTEXT* nx_context,
221+
static void command_received_cb(AZURE_IOT_NX_CONTEXT* nx_context_ptr,
223222
const UCHAR* method,
224223
USHORT method_length,
225224
UCHAR* payload,
226225
USHORT payload_length,
227-
VOID* context,
226+
VOID* context_ptr,
228227
USHORT context_length)
229228
{
230229
UINT status;
231-
UINT http_status = 501;
232-
CHAR* http_response = "{}";
233230

234231
if (strncmp((CHAR*)method, SET_LED_STATE_COMMAND, method_length) == 0)
235232
{
236233
bool arg = (strncmp((CHAR*)payload, "true", payload_length) == 0);
237234
set_led_state(arg);
238235

239-
azure_iot_nx_client_publish_bool_property(&azure_iot_nx_client, LED_STATE_PROPERTY, arg);
236+
if ((status = nx_azure_iot_hub_client_command_message_response(
237+
&nx_context_ptr->iothub_client, 200, context_ptr, context_length, NULL, 0, NX_WAIT_FOREVER)))
238+
{
239+
printf("Direct method response failed! (0x%08x)\r\n", status);
240+
return;
241+
}
240242

241-
http_status = 200;
243+
azure_iot_nx_client_publish_bool_property(&azure_iot_nx_client, LED_STATE_PROPERTY, arg);
242244
}
243-
244245
else if (strncmp((CHAR*)method, SET_DISPLAY_TEXT_COMMAND, method_length) == 0)
245246
{
246247
// drop the first and last character to remove the quotes
247248
screen_printn((CHAR*)payload + 1, payload_length - 2, L0);
248-
249-
http_status = 200;
249+
if ((status = nx_azure_iot_hub_client_command_message_response(
250+
&nx_context_ptr->iothub_client, 200, context_ptr, context_length, NULL, 0, NX_WAIT_FOREVER)))
251+
{
252+
printf("Direct method response failed! (0x%08x)\r\n", status);
253+
return;
254+
}
250255
}
251-
252-
if ((status = nx_azure_iot_hub_client_direct_method_message_response(&nx_context->iothub_client,
253-
http_status,
254-
context,
255-
context_length,
256-
(UCHAR*)http_response,
257-
strlen(http_response),
258-
NX_WAIT_FOREVER)))
256+
else
259257
{
260-
printf("Direct method response failed! (0x%08x)\r\n", status);
261-
return;
258+
printf("Direct method is not for this device\r\n");
259+
260+
if ((status = nx_azure_iot_hub_client_command_message_response(
261+
&nx_context_ptr->iothub_client, 501, context_ptr, context_length, NULL, 0, NX_WAIT_FOREVER)))
262+
{
263+
printf("Direct method response failed! (0x%08x)\r\n", status);
264+
return;
265+
}
262266
}
263267
}
264268

265-
static void device_twin_desired_property_cb(UCHAR* component_name,
269+
static void writable_property_received_cb(AZURE_IOT_NX_CONTEXT* nx_context,
270+
const UCHAR* component_name,
266271
UINT component_name_len,
267272
UCHAR* property_name,
268273
UINT property_name_len,
269-
NX_AZURE_IOT_JSON_READER property_value_reader,
270-
UINT version,
271-
VOID* userContextCallback)
274+
NX_AZURE_IOT_JSON_READER* json_reader_ptr,
275+
UINT version)
272276
{
273277
UINT status;
274-
AZURE_IOT_NX_CONTEXT* nx_context = (AZURE_IOT_NX_CONTEXT*)userContextCallback;
275278

276279
if (strncmp((CHAR*)property_name, TELEMETRY_INTERVAL_PROPERTY, property_name_len) == 0)
277280
{
278-
status = nx_azure_iot_json_reader_token_int32_get(&property_value_reader, &telemetry_interval);
281+
status = nx_azure_iot_json_reader_token_int32_get(json_reader_ptr, &telemetry_interval);
279282
if (status == NX_AZURE_IOT_SUCCESS)
280283
{
284+
printf("\tUpdating %s to %ld\r\n", TELEMETRY_INTERVAL_PROPERTY, telemetry_interval);
285+
281286
// Confirm reception back to hub
282-
azure_nx_client_respond_int_writeable_property(
287+
azure_nx_client_respond_int_writable_property(
283288
nx_context, TELEMETRY_INTERVAL_PROPERTY, telemetry_interval, 200, version);
284289

285290
// Set a telemetry event so we pick up the change immediately
@@ -288,17 +293,23 @@ static void device_twin_desired_property_cb(UCHAR* component_name,
288293
}
289294
}
290295

291-
static void device_twin_property_cb(UCHAR* component_name,
296+
static void property_received_cb(AZURE_IOT_NX_CONTEXT* context,
297+
const UCHAR* component_name,
292298
UINT component_name_len,
293299
UCHAR* property_name,
294300
UINT property_name_len,
295-
NX_AZURE_IOT_JSON_READER property_value_reader,
296-
UINT version,
297-
VOID* userContextCallback)
301+
NX_AZURE_IOT_JSON_READER* json_reader_ptr,
302+
UINT version)
298303
{
304+
UINT status;
305+
299306
if (strncmp((CHAR*)property_name, TELEMETRY_INTERVAL_PROPERTY, property_name_len) == 0)
300307
{
301-
nx_azure_iot_json_reader_token_int32_get(&property_value_reader, &telemetry_interval);
308+
status = nx_azure_iot_json_reader_token_int32_get(json_reader_ptr, &telemetry_interval);
309+
if (status == NX_AZURE_IOT_SUCCESS)
310+
{
311+
printf("\tUpdating %s to %ld\r\n", TELEMETRY_INTERVAL_PROPERTY, telemetry_interval);
312+
}
302313
}
303314
}
304315

@@ -350,25 +361,25 @@ UINT azure_iot_nx_client_entry(
350361
}
351362

352363
// Register the callbacks
353-
azure_iot_nx_client_register_direct_method(&azure_iot_nx_client, direct_method_cb);
354-
azure_iot_nx_client_register_device_twin_desired_prop(&azure_iot_nx_client, device_twin_desired_property_cb);
355-
azure_iot_nx_client_register_device_twin_prop(&azure_iot_nx_client, device_twin_property_cb);
364+
azure_iot_nx_client_register_command_callback(&azure_iot_nx_client, command_received_cb);
365+
azure_iot_nx_client_register_writable_property_callback(&azure_iot_nx_client, writable_property_received_cb);
366+
azure_iot_nx_client_register_property_callback(&azure_iot_nx_client, property_received_cb);
356367

357368
if ((status = azure_iot_nx_client_connect(&azure_iot_nx_client)))
358369
{
359370
printf("ERROR: failed to connect nx client (0x%08x)\r\n", status);
360371
return status;
361372
}
362373

363-
// Request the device twin for writeable property update
364-
if ((status = azure_iot_nx_client_device_twin_request_and_wait(&azure_iot_nx_client)))
374+
// Request the device twin for writable property update
375+
if ((status = azure_iot_nx_client_properties_request_and_wait(&azure_iot_nx_client)))
365376
{
366-
printf("ERROR: azure_iot_nx_client_device_twin_request_and_wait failed (0x%08x)\r\n", status);
377+
printf("ERROR: azure_iot_nx_client_properties_request_and_wait failed (0x%08x)\r\n", status);
367378
return status;
368379
}
369380

370381
// Send out property updates
371-
azure_iot_nx_client_publish_int_writeable_property(
382+
azure_iot_nx_client_publish_int_writable_property(
372383
&azure_iot_nx_client, TELEMETRY_INTERVAL_PROPERTY, telemetry_interval);
373384
azure_iot_nx_client_publish_bool_property(&azure_iot_nx_client, LED_STATE_PROPERTY, false);
374385
azure_iot_nx_client_publish_properties(
@@ -385,19 +396,20 @@ UINT azure_iot_nx_client_entry(
385396
switch (telemetry_state)
386397
{
387398
case TELEMETRY_STATE_DEFAULT:
388-
azure_iot_nx_client_publish_telemetry(&azure_iot_nx_client, append_device_telemetry);
399+
azure_iot_nx_client_publish_telemetry(&azure_iot_nx_client, NULL, append_device_telemetry);
389400
break;
390401

391402
case TELEMETRY_STATE_MAGNETOMETER:
392-
azure_iot_nx_client_publish_telemetry(&azure_iot_nx_client, append_device_telemetry_magnetometer);
403+
azure_iot_nx_client_publish_telemetry(&azure_iot_nx_client, NULL, append_device_telemetry_magnetometer);
393404
break;
394405

395406
case TELEMETRY_STATE_ACCELEROMETER:
396-
azure_iot_nx_client_publish_telemetry(&azure_iot_nx_client, append_device_telemetry_accelerometer);
407+
azure_iot_nx_client_publish_telemetry(
408+
&azure_iot_nx_client, NULL, append_device_telemetry_accelerometer);
397409
break;
398410

399411
case TELEMETRY_STATE_GYROSCOPE:
400-
azure_iot_nx_client_publish_telemetry(&azure_iot_nx_client, append_device_telemetry_gyroscope);
412+
azure_iot_nx_client_publish_telemetry(&azure_iot_nx_client, NULL, append_device_telemetry_gyroscope);
401413
break;
402414

403415
default:

MXChip/AZ3166/azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
scriptType: 'ps'
3737
scriptLocation: 'scriptPath'
3838
scriptPath: '$(Build.SourcesDirectory)\Device-Lab\generate_creds.ps1'
39-
arguments: '$(Build.SourcesDirectory)\getting-started\core\model'
39+
arguments: '$(Build.SourcesDirectory)\getting-started\shared\model'
4040
useGlobalConfig: true
4141
displayName: "Start Certification"
4242

MXChip/AZ3166/lib/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ set(NXD_ENABLE_FILE_SERVERS OFF CACHE BOOL "Disable fileX dependency by netxduo"
1313
set(NX_AZURE_DISABLE_IOT_SECURITY_MODULE OFF CACHE BOOL "Security Module")
1414

1515
# Core libraries
16-
add_subdirectory(${CORE_LIB_DIR}/threadx threadx)
17-
add_subdirectory(${CORE_LIB_DIR}/netxduo netxduo)
18-
add_subdirectory(${CORE_LIB_DIR}/jsmn jsmn)
16+
add_subdirectory(${SHARED_LIB_DIR}/threadx threadx)
17+
add_subdirectory(${SHARED_LIB_DIR}/netxduo netxduo)
18+
add_subdirectory(${SHARED_LIB_DIR}/jsmn jsmn)
1919

2020
add_subdirectory(stm32cubef4)
2121
add_subdirectory(mxchip_bsp)

MXChip/AZ3166/lib/wiced_sdk/binary_build/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.13)
55
set(CMAKE_C_STANDARD 99)
66

77
set(GSG_BASE_DIR ${CMAKE_SOURCE_DIR}/../../../../..)
8-
set(CORE_LIB_DIR ${GSG_BASE_DIR}/core/lib)
8+
set(SHARED_LIB_DIR ${GSG_BASE_DIR}/core/lib)
99

1010
# use the repo version of ninja on Windows as there is no Ninja installer
1111
if(WIN32)

Microchip/ATSAME54-XPRO/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
55
set(CMAKE_C_STANDARD 99)
66

77
set(GSG_BASE_DIR ${CMAKE_SOURCE_DIR}/../..)
8-
set(CORE_SRC_DIR ${GSG_BASE_DIR}/core/src)
9-
set(CORE_LIB_DIR ${GSG_BASE_DIR}/core/lib)
8+
set(SHARED_SRC_DIR ${GSG_BASE_DIR}/shared/src)
9+
set(SHARED_LIB_DIR ${GSG_BASE_DIR}/shared/lib)
1010

1111
# use the repo version of ninja on Windows as there is no Ninja installer
1212
if(WIN32)
@@ -23,6 +23,6 @@ include(${GSG_BASE_DIR}/cmake/utilities.cmake)
2323
# Define the Project
2424
project(atsame54_azure_iot C ASM)
2525

26-
add_subdirectory(${CORE_SRC_DIR} core_src)
26+
add_subdirectory(${SHARED_SRC_DIR} shared_src)
2727
add_subdirectory(lib)
2828
add_subdirectory(app)

0 commit comments

Comments
 (0)