1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11 #include <stdio.h>
12 #include <setjmp.h>
13 #include <cmocka.h> /* macros: https://api.cmocka.org/group__cmocka__asserts.html */
14
15 #include "nx_api.h"
16 #include "nx_azure_iot_hub_client.h"
17 #include "nx_azure_iot_hub_client_properties.h"
18 #include "nx_azure_iot_cert.h"
19 #include "nx_azure_iot_ciphersuites.h"
20
21
22 #define DEMO_DHCP_DISABLE
23 #define DEMO_IPV4_ADDRESS IP_ADDRESS(192, 168, 100, 33)
24 #define DEMO_IPV4_MASK 0xFFFFFF00UL
25 #define DEMO_GATEWAY_ADDRESS IP_ADDRESS(192, 168, 100, 1)
26 #define DEMO_DNS_SERVER_ADDRESS IP_ADDRESS(192, 168, 100, 1)
27 #define NETWORK_DRIVER _nx_ram_network_driver
28
29 /* Include main.c in the test case since we need to disable DHCP in this test. */
30 #include "main.c"
31
32
33 #define STRING_UNSIGNED_ARGS(s) (UCHAR *)s, strlen(s)
34
35 #ifndef DEMO_CLOUD_STACK_SIZE
36 #define DEMO_CLOUD_STACK_SIZE 2048
37 #endif /* DEMO_CLOUD_STACK_SIZE */
38
39 #ifndef DEMO_CLOUD_THREAD_PRIORITY
40 #define DEMO_CLOUD_THREAD_PRIORITY (4)
41 #endif /* DEMO_CLOUD_THREAD_PRIORITY */
42
43 static UINT api_no_model_id_test();
44 static VOID api_model_id_test();
45
46 static NX_AZURE_IOT iot;
47 static NX_AZURE_IOT_HUB_CLIENT iot_client;
48 static NX_SECURE_X509_CERT root_ca_cert;
49 static UCHAR metadata_buffer[NX_AZURE_IOT_TLS_METADATA_BUFFER_SIZE];
50 static ULONG demo_cloud_thread_stack[DEMO_CLOUD_STACK_SIZE / sizeof(ULONG)];
51
52 NX_SECURE_X509_CERT device_certificate;
53 NX_PACKET *packet_ptr;
54 UCHAR *property_name = "propertyA";
55 USHORT property_name_length = sizeof("propertyA") - 1;
56 UCHAR *property_value;
57 USHORT property_value_lenght;
58 UCHAR *name;
59 USHORT name_length;
60 UCHAR *context_ptr;
61 USHORT context_length;
62 UCHAR *component_name;
63 USHORT component_name_length;
64 UCHAR message_buffer[1024];
65 UINT message_length = 1024;
66 UINT request_id;
67 UINT response_status;
68 ULONG version;
69 NX_AZURE_IOT_JSON_WRITER json_writer;
70 NX_AZURE_IOT_JSON_READER json_reader;
71 UCHAR json_buffer[2014];
72
demo_entry(NX_IP * ip_ptr,NX_PACKET_POOL * pool_ptr,NX_DNS * dns_ptr,UINT (* unix_time_callback)(ULONG * unix_time))73 VOID demo_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_ptr, UINT (*unix_time_callback)(ULONG *unix_time))
74 {
75
76 /* Initialize root certificate. */
77 assert_int_equal(nx_secure_x509_certificate_initialize(&root_ca_cert, (UCHAR *)_nx_azure_iot_root_cert, (USHORT)_nx_azure_iot_root_cert_size,
78 NX_NULL, 0, NULL, 0, NX_SECURE_X509_KEY_TYPE_NONE),
79 NX_AZURE_IOT_SUCCESS);
80
81 assert_int_equal(nx_azure_iot_create(&iot, (UCHAR *)"Azure IoT", ip_ptr, pool_ptr, dns_ptr, (UCHAR *)demo_cloud_thread_stack,
82 sizeof(demo_cloud_thread_stack), DEMO_CLOUD_THREAD_PRIORITY, unix_time_callback),
83 NX_AZURE_IOT_SUCCESS);
84
85 /* Perform actual tests. */
86 api_no_model_id_test();
87 api_model_id_test();
88 }
89
connection_status_callback(NX_AZURE_IOT_HUB_CLIENT * hub_client_ptr,UINT status)90 static VOID connection_status_callback(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr, UINT status)
91 {
92 NX_PARAMETER_NOT_USED(hub_client_ptr);
93 NX_PARAMETER_NOT_USED(status);
94 }
95
message_receive_callback_properties(NX_AZURE_IOT_HUB_CLIENT * hub_client_ptr,VOID * context)96 static VOID message_receive_callback_properties(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr, VOID *context)
97 {
98 NX_PARAMETER_NOT_USED(hub_client_ptr);
99 NX_PARAMETER_NOT_USED(context);
100 }
101
reported_properties_response_callback(NX_AZURE_IOT_HUB_CLIENT * hub_client_ptr,UINT request_id,UINT response_status,ULONG version,VOID * args)102 static VOID reported_properties_response_callback(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr, UINT request_id,
103 UINT response_status, ULONG version, VOID *args)
104 {
105 NX_PARAMETER_NOT_USED(hub_client_ptr);
106 NX_PARAMETER_NOT_USED(request_id);
107 NX_PARAMETER_NOT_USED(response_status);
108 NX_PARAMETER_NOT_USED(version);
109 NX_PARAMETER_NOT_USED(args);
110 }
111
api_no_model_id_test()112 static UINT api_no_model_id_test()
113 {
114
115 /* Using IoT Hub APIs if nx_azure_iot_hub_client_model_id_set is not called after initialization. */
116 assert_int_equal(nx_azure_iot_hub_client_initialize(&iot_client, &iot,
117 STRING_UNSIGNED_ARGS("host_name"),
118 STRING_UNSIGNED_ARGS("device_id"),
119 STRING_UNSIGNED_ARGS(""),
120 _nx_azure_iot_tls_supported_crypto,
121 _nx_azure_iot_tls_supported_crypto_size,
122 _nx_azure_iot_tls_ciphersuite_map,
123 _nx_azure_iot_tls_ciphersuite_map_size,
124 metadata_buffer, sizeof(metadata_buffer),
125 &root_ca_cert),
126 NX_AZURE_IOT_SUCCESS);
127
128 /* Connect APIs. */
129 assert_int_not_equal(nx_azure_iot_hub_client_device_cert_set(&iot_client, &device_certificate),
130 NX_AZURE_IOT_NOT_SUPPORTED);
131
132 assert_int_not_equal(nx_azure_iot_hub_client_symmetric_key_set(&iot_client, "symmetric_key", sizeof("symmetric_key") - 1),
133 NX_AZURE_IOT_NOT_SUPPORTED);
134
135 assert_int_not_equal(nx_azure_iot_hub_client_component_add(&iot_client, "componentA", sizeof("componentA") - 1),
136 NX_AZURE_IOT_NOT_SUPPORTED);
137
138 assert_int_not_equal(nx_azure_iot_hub_client_connection_status_callback_set(&iot_client, connection_status_callback),
139 NX_AZURE_IOT_NOT_SUPPORTED);
140
141 assert_int_not_equal(nx_azure_iot_hub_client_receive_callback_set(&iot_client, NX_AZURE_IOT_HUB_PROPERTIES,
142 message_receive_callback_properties, NX_NULL),
143 NX_AZURE_IOT_NOT_SUPPORTED);
144
145 assert_int_not_equal(nx_azure_iot_hub_client_connect(&iot_client, NX_TRUE, NX_NO_WAIT),
146 NX_AZURE_IOT_NOT_SUPPORTED);
147
148 assert_int_not_equal(nx_azure_iot_hub_client_disconnect(&iot_client),
149 NX_AZURE_IOT_NOT_SUPPORTED);
150
151 /* C2D APIs. */
152 assert_int_not_equal(nx_azure_iot_hub_client_cloud_message_enable(&iot_client),
153 NX_AZURE_IOT_NOT_SUPPORTED);
154
155 assert_int_not_equal(nx_azure_iot_hub_client_cloud_message_disable(&iot_client),
156 NX_AZURE_IOT_NOT_SUPPORTED);
157
158 assert_int_not_equal(nx_azure_iot_hub_client_cloud_message_receive(&iot_client, &packet_ptr, NX_NO_WAIT),
159 NX_AZURE_IOT_NOT_SUPPORTED);
160
161 assert_int_not_equal(nx_azure_iot_hub_client_cloud_message_property_get(&iot_client, packet_ptr,
162 property_name, property_name_length,
163 (const UCHAR **)&property_value, &property_value_lenght),
164 NX_AZURE_IOT_NOT_SUPPORTED);
165
166 /* Telemetry APIs. */
167 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_message_create(&iot_client, &packet_ptr, NX_NO_WAIT),
168 NX_AZURE_IOT_NOT_SUPPORTED);
169
170 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_component_set(packet_ptr,
171 "componentA", sizeof("componentA") - 1,
172 NX_NO_WAIT),
173 NX_AZURE_IOT_NOT_SUPPORTED);
174
175 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_property_add(packet_ptr,
176 "propertyA", sizeof("propertyA") - 1,
177 "valueA", sizeof("valueA") - 1,
178 NX_NO_WAIT),
179 NX_AZURE_IOT_NOT_SUPPORTED);
180
181 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_send(&iot_client, packet_ptr,
182 "data", sizeof("data") - 1,
183 NX_NO_WAIT),
184 NX_AZURE_IOT_NOT_SUPPORTED);
185
186 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_message_delete(packet_ptr),
187 NX_AZURE_IOT_NOT_SUPPORTED);
188
189 /* Direct Method APIs. */
190 assert_int_not_equal(nx_azure_iot_hub_client_direct_method_enable(&iot_client),
191 NX_AZURE_IOT_NOT_SUPPORTED);
192
193 assert_int_not_equal(nx_azure_iot_hub_client_direct_method_disable(&iot_client),
194 NX_AZURE_IOT_NOT_SUPPORTED);
195
196 assert_int_not_equal(nx_azure_iot_hub_client_direct_method_message_receive(&iot_client,
197 (const UCHAR **)&name, (USHORT *)&name_length,
198 (void **)&context_ptr, &context_length,
199 &packet_ptr, NX_NO_WAIT),
200 NX_AZURE_IOT_NOT_SUPPORTED);
201
202 assert_int_not_equal(nx_azure_iot_hub_client_direct_method_message_response(&iot_client, 200,
203 "12222", sizeof("12222") - 1,
204 "payload", sizeof("payload") - 1,
205 NX_NO_WAIT),
206 NX_AZURE_IOT_NOT_SUPPORTED);
207
208 /* Command APIs. */
209 assert_int_not_equal(nx_azure_iot_hub_client_command_enable(&iot_client),
210 NX_AZURE_IOT_NOT_SUPPORTED);
211
212 assert_int_not_equal(nx_azure_iot_hub_client_command_disable(&iot_client),
213 NX_AZURE_IOT_NOT_SUPPORTED);
214
215 assert_int_not_equal(nx_azure_iot_hub_client_command_message_receive(&iot_client,
216 (const UCHAR **)&component_name, &component_name_length,
217 (const UCHAR **)&name, &name_length,
218 (void **)&context_ptr, &context_length,
219 &packet_ptr, NX_NO_WAIT),
220 NX_AZURE_IOT_NOT_SUPPORTED);
221
222 assert_int_not_equal(nx_azure_iot_hub_client_command_message_response(&iot_client, 200,
223 "12222", sizeof("12222") - 1,
224 "payload", sizeof("payload") - 1,
225 NX_NO_WAIT),
226 NX_AZURE_IOT_NOT_SUPPORTED);
227
228 /* Device twin APIs. */
229 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_enable(&iot_client),
230 NX_AZURE_IOT_NOT_SUPPORTED);
231
232 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_disable(&iot_client),
233 NX_AZURE_IOT_NOT_SUPPORTED);
234
235 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_response_callback_set(&iot_client,
236 reported_properties_response_callback,
237 NX_NULL),
238 NX_AZURE_IOT_NOT_SUPPORTED);
239
240 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_reported_properties_send(&iot_client,
241 message_buffer, message_length,
242 &request_id, &response_status,
243 &version, NX_NO_WAIT),
244 NX_AZURE_IOT_NOT_SUPPORTED);
245
246 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_properties_request(&iot_client, NX_NO_WAIT),
247 NX_AZURE_IOT_NOT_SUPPORTED);
248
249 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_properties_receive(&iot_client, &packet_ptr, NX_NO_WAIT),
250 NX_AZURE_IOT_NOT_SUPPORTED);
251
252 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_desired_properties_receive(&iot_client, &packet_ptr, NX_NO_WAIT),
253 NX_AZURE_IOT_NOT_SUPPORTED);
254
255 /* Properties APIs. */
256 assert_int_not_equal(nx_azure_iot_hub_client_properties_enable(&iot_client),
257 NX_AZURE_IOT_NOT_SUPPORTED);
258
259 assert_int_not_equal(nx_azure_iot_hub_client_properties_disable(&iot_client),
260 NX_AZURE_IOT_NOT_SUPPORTED);
261
262 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_response_callback_set(&iot_client,
263 reported_properties_response_callback,
264 NX_NULL),
265 NX_AZURE_IOT_NOT_SUPPORTED);
266
267 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_create(&iot_client,
268 &packet_ptr,
269 NX_NO_WAIT),
270 NX_AZURE_IOT_NOT_SUPPORTED);
271
272 assert_int_equal(nx_azure_iot_json_writer_with_buffer_init(&json_writer, json_buffer, sizeof(json_buffer)),
273 NX_AZURE_IOT_SUCCESS);
274 assert_int_equal(nx_azure_iot_json_writer_append_begin_object(&json_writer),
275 NX_AZURE_IOT_SUCCESS);
276
277 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_component_begin(&iot_client,
278 &json_writer,
279 "componentA",
280 sizeof("componentA") - 1),
281 NX_AZURE_IOT_NOT_SUPPORTED);
282
283 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_component_end(&iot_client, &json_writer),
284 NX_AZURE_IOT_NOT_SUPPORTED);
285
286 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_status_begin(&iot_client, &json_writer,
287 "property_name", sizeof("property_name") - 1,
288 200, 20,
289 NX_NULL, 0),
290 NX_AZURE_IOT_NOT_SUPPORTED);
291
292 assert_int_equal(nx_azure_iot_json_writer_append_int32(&json_writer, 20),
293 NX_AZURE_IOT_SUCCESS);
294
295
296 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_status_end(&iot_client, &json_writer),
297 NX_AZURE_IOT_NOT_SUPPORTED);
298
299 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_send(&iot_client,
300 packet_ptr,
301 &request_id, &response_status,
302 &version, NX_NO_WAIT),
303 NX_AZURE_IOT_NOT_SUPPORTED);
304
305 assert_int_not_equal(nx_azure_iot_hub_client_properties_request(&iot_client, NX_NO_WAIT),
306 NX_AZURE_IOT_NOT_SUPPORTED);
307
308 assert_int_not_equal(nx_azure_iot_hub_client_properties_receive(&iot_client,
309 &packet_ptr,
310 NX_NO_WAIT),
311 NX_AZURE_IOT_NOT_SUPPORTED);
312
313 assert_int_not_equal(nx_azure_iot_hub_client_writable_properties_receive(&iot_client,
314 &packet_ptr,
315 NX_NO_WAIT),
316 NX_AZURE_IOT_NOT_SUPPORTED);
317
318 assert_int_not_equal(nx_azure_iot_hub_client_properties_component_property_next_get(&iot_client,
319 &json_reader,
320 NX_AZURE_IOT_HUB_WRITABLE_PROPERTIES,
321 NX_AZURE_IOT_HUB_CLIENT_PROPERTY_WRITABLE,
322 (const UCHAR **)&component_name,
323 &component_name_length),
324 NX_AZURE_IOT_NOT_SUPPORTED);
325
326 /* Deinitialize. */
327 assert_int_not_equal(nx_azure_iot_hub_client_deinitialize(&iot_client),
328 NX_AZURE_IOT_NOT_SUPPORTED);
329 }
330
api_model_id_test()331 static VOID api_model_id_test()
332 {
333
334 /* Using PnP APIs if nx_azure_iot_hub_client_model_id_set is called after initialization. */
335 assert_int_equal(nx_azure_iot_hub_client_initialize(&iot_client, &iot,
336 STRING_UNSIGNED_ARGS("host_name"),
337 STRING_UNSIGNED_ARGS("device_id"),
338 STRING_UNSIGNED_ARGS(""),
339 _nx_azure_iot_tls_supported_crypto,
340 _nx_azure_iot_tls_supported_crypto_size,
341 _nx_azure_iot_tls_ciphersuite_map,
342 _nx_azure_iot_tls_ciphersuite_map_size,
343 metadata_buffer, sizeof(metadata_buffer),
344 &root_ca_cert),
345 NX_AZURE_IOT_SUCCESS);
346
347 assert_int_equal(nx_azure_iot_hub_client_model_id_set(&iot_client,
348 "pnp_model_id_unit_test",
349 sizeof("pnp_model_id_unit_test") - 1),
350 NX_AZURE_IOT_SUCCESS);
351
352 /* Connect APIs. */
353 assert_int_not_equal(nx_azure_iot_hub_client_device_cert_set(&iot_client, &device_certificate),
354 NX_AZURE_IOT_NOT_SUPPORTED);
355
356 assert_int_not_equal(nx_azure_iot_hub_client_symmetric_key_set(&iot_client, "symmetric_key", sizeof("symmetric_key") - 1),
357 NX_AZURE_IOT_NOT_SUPPORTED);
358
359 assert_int_not_equal(nx_azure_iot_hub_client_component_add(&iot_client, "componentA", sizeof("componentA") - 1),
360 NX_AZURE_IOT_NOT_SUPPORTED);
361
362 assert_int_not_equal(nx_azure_iot_hub_client_connection_status_callback_set(&iot_client, connection_status_callback),
363 NX_AZURE_IOT_NOT_SUPPORTED);
364
365 assert_int_not_equal(nx_azure_iot_hub_client_receive_callback_set(&iot_client, NX_AZURE_IOT_HUB_PROPERTIES,
366 message_receive_callback_properties, NX_NULL),
367 NX_AZURE_IOT_NOT_SUPPORTED);
368
369 assert_int_not_equal(nx_azure_iot_hub_client_connect(&iot_client, NX_TRUE, NX_NO_WAIT),
370 NX_AZURE_IOT_NOT_SUPPORTED);
371
372 assert_int_not_equal(nx_azure_iot_hub_client_disconnect(&iot_client),
373 NX_AZURE_IOT_NOT_SUPPORTED);
374
375 /* C2D APIs. */
376 assert_int_not_equal(nx_azure_iot_hub_client_cloud_message_enable(&iot_client),
377 NX_AZURE_IOT_NOT_SUPPORTED);
378
379 assert_int_not_equal(nx_azure_iot_hub_client_cloud_message_disable(&iot_client),
380 NX_AZURE_IOT_NOT_SUPPORTED);
381
382 assert_int_not_equal(nx_azure_iot_hub_client_cloud_message_receive(&iot_client, &packet_ptr, NX_NO_WAIT),
383 NX_AZURE_IOT_NOT_SUPPORTED);
384
385 assert_int_not_equal(nx_azure_iot_hub_client_cloud_message_property_get(&iot_client, packet_ptr,
386 property_name, property_name_length,
387 (const UCHAR **)&property_value, &property_value_lenght),
388 NX_AZURE_IOT_NOT_SUPPORTED);
389
390 /* Telemetry APIs. */
391 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_message_create(&iot_client, &packet_ptr, NX_NO_WAIT),
392 NX_AZURE_IOT_NOT_SUPPORTED);
393
394 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_component_set(packet_ptr,
395 "componentA", sizeof("componentA") - 1,
396 NX_NO_WAIT),
397 NX_AZURE_IOT_NOT_SUPPORTED);
398
399 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_property_add(packet_ptr,
400 "propertyA", sizeof("propertyA") - 1,
401 "valueA", sizeof("valueA") - 1,
402 NX_NO_WAIT),
403 NX_AZURE_IOT_NOT_SUPPORTED);
404
405 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_send(&iot_client, packet_ptr,
406 "data", sizeof("data") - 1,
407 NX_NO_WAIT),
408 NX_AZURE_IOT_NOT_SUPPORTED);
409
410 assert_int_not_equal(nx_azure_iot_hub_client_telemetry_message_delete(packet_ptr),
411 NX_AZURE_IOT_NOT_SUPPORTED);
412
413 /* Direct Method APIs. */
414 assert_int_not_equal(nx_azure_iot_hub_client_direct_method_enable(&iot_client),
415 NX_AZURE_IOT_NOT_SUPPORTED);
416
417 assert_int_not_equal(nx_azure_iot_hub_client_direct_method_disable(&iot_client),
418 NX_AZURE_IOT_NOT_SUPPORTED);
419
420 assert_int_not_equal(nx_azure_iot_hub_client_direct_method_message_receive(&iot_client,
421 (const UCHAR **)&name, (USHORT *)&name_length,
422 (void **)&context_ptr, &context_length,
423 &packet_ptr, NX_NO_WAIT),
424 NX_AZURE_IOT_NOT_SUPPORTED);
425
426 assert_int_not_equal(nx_azure_iot_hub_client_direct_method_message_response(&iot_client, 200,
427 "12222", sizeof("12222") - 1,
428 "payload", sizeof("payload") - 1,
429 NX_NO_WAIT),
430 NX_AZURE_IOT_NOT_SUPPORTED);
431
432 /* Command APIs. */
433 assert_int_not_equal(nx_azure_iot_hub_client_command_enable(&iot_client),
434 NX_AZURE_IOT_NOT_SUPPORTED);
435
436 assert_int_not_equal(nx_azure_iot_hub_client_command_disable(&iot_client),
437 NX_AZURE_IOT_NOT_SUPPORTED);
438
439 assert_int_not_equal(nx_azure_iot_hub_client_command_message_receive(&iot_client,
440 (const UCHAR **)&component_name, &component_name_length,
441 (const UCHAR **)&name, &name_length,
442 (void **)&context_ptr, &context_length,
443 &packet_ptr, NX_NO_WAIT),
444 NX_AZURE_IOT_NOT_SUPPORTED);
445
446 assert_int_not_equal(nx_azure_iot_hub_client_command_message_response(&iot_client, 200,
447 "12222", sizeof("12222") - 1,
448 "payload", sizeof("payload") - 1,
449 NX_NO_WAIT),
450 NX_AZURE_IOT_NOT_SUPPORTED);
451
452 /* Device twin APIs. */
453 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_enable(&iot_client),
454 NX_AZURE_IOT_NOT_SUPPORTED);
455
456 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_disable(&iot_client),
457 NX_AZURE_IOT_NOT_SUPPORTED);
458
459 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_response_callback_set(&iot_client,
460 reported_properties_response_callback,
461 NX_NULL),
462 NX_AZURE_IOT_NOT_SUPPORTED);
463
464 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_reported_properties_send(&iot_client,
465 message_buffer, message_length,
466 &request_id, &response_status,
467 &version, NX_NO_WAIT),
468 NX_AZURE_IOT_NOT_SUPPORTED);
469
470 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_properties_request(&iot_client, NX_NO_WAIT),
471 NX_AZURE_IOT_NOT_SUPPORTED);
472
473 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_properties_receive(&iot_client, &packet_ptr, NX_NO_WAIT),
474 NX_AZURE_IOT_NOT_SUPPORTED);
475
476 assert_int_not_equal(nx_azure_iot_hub_client_device_twin_desired_properties_receive(&iot_client, &packet_ptr, NX_NO_WAIT),
477 NX_AZURE_IOT_NOT_SUPPORTED);
478
479 /* Properties APIs. */
480 assert_int_not_equal(nx_azure_iot_hub_client_properties_enable(&iot_client),
481 NX_AZURE_IOT_NOT_SUPPORTED);
482
483 assert_int_not_equal(nx_azure_iot_hub_client_properties_disable(&iot_client),
484 NX_AZURE_IOT_NOT_SUPPORTED);
485
486 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_response_callback_set(&iot_client,
487 reported_properties_response_callback,
488 NX_NULL),
489 NX_AZURE_IOT_NOT_SUPPORTED);
490
491 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_create(&iot_client,
492 &packet_ptr,
493 NX_NO_WAIT),
494 NX_AZURE_IOT_NOT_SUPPORTED);
495
496 assert_int_equal(nx_azure_iot_json_writer_with_buffer_init(&json_writer, json_buffer, sizeof(json_buffer)),
497 NX_AZURE_IOT_SUCCESS);
498 assert_int_equal(nx_azure_iot_json_writer_append_begin_object(&json_writer),
499 NX_AZURE_IOT_SUCCESS);
500
501 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_component_begin(&iot_client,
502 &json_writer,
503 "componentA",
504 sizeof("componentA") - 1),
505 NX_AZURE_IOT_NOT_SUPPORTED);
506
507 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_component_end(&iot_client, &json_writer),
508 NX_AZURE_IOT_NOT_SUPPORTED);
509
510 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_status_begin(&iot_client, &json_writer,
511 "property_name", sizeof("property_name") - 1,
512 200, 20,
513 NX_NULL, 0),
514 NX_AZURE_IOT_NOT_SUPPORTED);
515
516 assert_int_equal(nx_azure_iot_json_writer_append_int32(&json_writer, 20),
517 NX_AZURE_IOT_SUCCESS);
518
519
520 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_status_end(&iot_client, &json_writer),
521 NX_AZURE_IOT_NOT_SUPPORTED);
522
523 assert_int_not_equal(nx_azure_iot_hub_client_reported_properties_send(&iot_client,
524 packet_ptr,
525 &request_id, &response_status,
526 &version, NX_NO_WAIT),
527 NX_AZURE_IOT_NOT_SUPPORTED);
528
529 assert_int_not_equal(nx_azure_iot_hub_client_properties_request(&iot_client, NX_NO_WAIT),
530 NX_AZURE_IOT_NOT_SUPPORTED);
531
532 assert_int_not_equal(nx_azure_iot_hub_client_properties_receive(&iot_client,
533 &packet_ptr,
534 NX_NO_WAIT),
535 NX_AZURE_IOT_NOT_SUPPORTED);
536
537 assert_int_not_equal(nx_azure_iot_hub_client_writable_properties_receive(&iot_client,
538 &packet_ptr,
539 NX_NO_WAIT),
540 NX_AZURE_IOT_NOT_SUPPORTED);
541
542 assert_int_not_equal(nx_azure_iot_hub_client_properties_component_property_next_get(&iot_client,
543 &json_reader,
544 NX_AZURE_IOT_HUB_WRITABLE_PROPERTIES,
545 NX_AZURE_IOT_HUB_CLIENT_PROPERTY_WRITABLE,
546 (const UCHAR **)&component_name,
547 &component_name_length),
548 NX_AZURE_IOT_NOT_SUPPORTED);
549
550 /* Deinitialize. */
551 assert_int_not_equal(nx_azure_iot_hub_client_deinitialize(&iot_client),
552 NX_AZURE_IOT_NOT_SUPPORTED);
553 }
554
__wrap_nx_azure_iot_publish_packet_get(NX_AZURE_IOT * nx_azure_iot_ptr,NXD_MQTT_CLIENT * client_ptr,NX_PACKET ** packet_pptr,UINT wait_option)555 UINT __wrap_nx_azure_iot_publish_packet_get(NX_AZURE_IOT *nx_azure_iot_ptr, NXD_MQTT_CLIENT *client_ptr,
556 NX_PACKET **packet_pptr, UINT wait_option)
557 {
558 return(NX_AZURE_IOT_FAILURE);
559 }
560
__wrap_az_iot_hub_client_properties_builder_begin_component(az_iot_hub_client const * client,az_json_writer * ref_json_writer,az_span component_name)561 UINT __wrap_az_iot_hub_client_properties_builder_begin_component(az_iot_hub_client const* client,
562 az_json_writer* ref_json_writer,
563 az_span component_name)
564 {
565 return(NX_AZURE_IOT_FAILURE);
566 }
567
__wrap_az_iot_hub_client_properties_builder_end_component(az_iot_hub_client const * client,az_json_writer * ref_json_writer)568 UINT __wrap_az_iot_hub_client_properties_builder_end_component(az_iot_hub_client const* client,
569 az_json_writer* ref_json_writer)
570 {
571 return(NX_AZURE_IOT_FAILURE);
572 }
573
__wrap_az_iot_hub_client_properties_builder_begin_response_status(az_iot_hub_client const * client,az_json_writer * ref_json_writer,az_span property_name,int32_t ack_code,int32_t ack_version,az_span ack_description)574 UINT __wrap_az_iot_hub_client_properties_builder_begin_response_status(az_iot_hub_client const* client,
575 az_json_writer* ref_json_writer,
576 az_span property_name,
577 int32_t ack_code,
578 int32_t ack_version,
579 az_span ack_description)
580 {
581 return(NX_AZURE_IOT_FAILURE);
582 }
583
__wrap_az_iot_hub_client_properties_builder_end_response_status(az_iot_hub_client const * client,az_json_writer * ref_json_writer)584 UINT __wrap_az_iot_hub_client_properties_builder_end_response_status(az_iot_hub_client const* client,
585 az_json_writer* ref_json_writer)
586 {
587 return(NX_AZURE_IOT_FAILURE);
588 }
589