summaryrefslogtreecommitdiff
path: root/addons/azure_iot/docs/azure_rtos_iot.md
blob: 7dd54d2da0b913ed1f5384d9148eec778f98e322 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Azure IoT

**nx_azure_iot_create**
***
<div style="text-align: right"> Create the Azure IoT subsystem</div>

**Prototype**
```c
UINT nx_azure_iot_create(NX_AZURE_IOT *nx_azure_iot_ptr, const UCHAR *name_ptr,
                         NX_IP *ip_ptr, NX_PACKET_POOL *pool_ptr, NX_DNS *dns_ptr,
                         VOID *stack_memory_ptr, UINT stack_memory_size,
                         UINT priority, UINT (*unix_time_callback)(ULONG *unix_time));
```
**Description**

<p>This routine creates the Azure IoT subsystem.  An internal thread is created to manage activities related to Azure IoT services. Only one `NX_AZURE_IOT` instance is needed to manage instances for Azure IoT hub, IoT Central, and Device Provisioning Services (DPS). </p>

**Parameters**
| Name | Description |
| - |:-|
| nx_azure_iot_ptr [in]    | A pointer to a NX_AZURE_IOT |
| name_ptr [in]      | A pointer to a NULL-terminated string indicating the name of the Azure IoT instance. |
| ip_ptr [in] | A pointer to a `NX_IP`, which is the IP stack used to connect to Azure IoT Services.     |
| pool_ptr [in] | A pointer to a `NX_PACKET_POOL`, which is the packet pool used by Azure IoT Services.     |
| dns_ptr [in] | A pointer to a `NX_DNS`.     |
| stack_memory_ptr [in] | A pointer to memory to be used as a stack space for the internal thread.     |
| stack_memory_size [in] | Size of stack memory area.  |
| priority [in] | Priority of the internal thread.    |
| unix_time_callback [in] | Callback to fetch unix time from platform.  |


**Return Values**
* NX_AZURE_IOT_SUCCESS Successfully created the Azure IoT instance.
* NX_AZURE_IOT_INVALID_PARAMETER Fail to create the Azure IoT instance due to invalid parameter.
* NX_OPTION_ERROR Fail to create the Azure IoT instance due to invalid priority.
* NX_PTR_ERROR Fail to create the Azure IoT instance due to invalid parameter.
* NX_SIZE_ERROR Fail to create the Azure IoT instance due to insufficient size of stack memory.

**Allowed From**

Initialization, Threads

**Example**

**See Also**

<div style="page-break-after: always;"></div>

**nx_azure_iot_delete**
***
<div style="text-align: right"> Shutdown and cleanup the Azure IoT subsystem</div>

**Prototype**
```c
UINT  nx_azure_iot_delete(NX_AZURE_IOT *nx_azure_iot_ptr);
```
**Description**

<p>This routine stops all Azure services managed by this instance, and cleans up internal resources. </p>

**Parameters**

| Name | Description |
| - |:-|
| nx_azure_iot_ptr  [in]    | A pointer to a `NX_AZURE_IOT` |


**Return Values**
* NX_AZURE_IOT_SUCCESS Successful stopped Azure IoT services and cleaned up internal resources.
* NX_AZURE_IOT_INVALID_PARAMETER Fail to delete the Azure IoT instance due to invalid parameter.
* NX_AZURE_IOT_DELETE_ERROR Fail to delete the Azure IoT instance due to resource is still in use.

**Allowed From**

Threads

**Example**

**See Also**

<div style="page-break-after: always;"></div>

**nx_azure_iot_log_init**
***
<div style="text-align: right"> Initialize logging</div>

**Prototype**
```c
VOID nx_azure_iot_log_init(VOID(*log_callback)(az_log_classification classification, UCHAR *msg, UINT msg_len));
```
**Description**

<p>This routine initialized the logging with customer specific callback to output the logs for different classifications </p>

* AZ_LOG_IOT_AZURERTOS
* AZ_LOG_MQTT_RECEIVED_TOPIC
* AZ_LOG_MQTT_RECEIVED_PAYLOAD
* AZ_LOG_IOT_RETRY
* AZ_LOG_IOT_SAS_TOKEN

**Parameters**

| Name | Description |
| - |:-|
| log_callback  [in]    | A pointer to a callback |

**Allowed From**

Threads

**Example**

**See Also**

<div style="page-break-after: always;"></div>