forked from apache/nuttx-apps
-
Notifications
You must be signed in to change notification settings - Fork 4
/
lte_lwm2m.h
321 lines (239 loc) · 9.39 KB
/
lte_lwm2m.h
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/****************************************************************************
* apps/include/lte/lte_lwm2m.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __APPS_INCLUDE_LTE_LTE_LWM2M_H
#define __APPS_INCLUDE_LTE_LTE_LWM2M_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/wireless/lte/lte.h>
#define LWM2MSTUB_RESOURCE_HANDLENOCARE (0)
#define LWM2MSTUB_RESOURCE_HANDLEHOST (1)
#define LWM2MSTUB_RESOURCE_HANDLEMODEMH (2)
#define LWM2MSTUB_MAX_WRITE_SIZE (1500)
#define LWM2MSTUB_MAX_TOKEN_SIZE (8 * 2 + 1)
#define LWM2MSTUB_MAX_SERVER_NAME (256)
#define LWM2MSTUB_MAX_DEVID (256)
#define LWM2MSTUB_MAX_SEQKEY (256)
#define LWM2MSTUB_CONDVALID_MINPERIOD (1<<0)
#define LWM2MSTUB_CONDVALID_MAXPERIOD (1<<1)
#define LWM2MSTUB_CONDVALID_GRATERTHAN (1<<2)
#define LWM2MSTUB_CONDVALID_LESSTHAN (1<<3)
#define LWM2MSTUB_CONDVALID_STEP (1<<4)
#define LWM2MSTUB_FWUP_PEND_DL (0)
#define LWM2MSTUB_FWUP_PEND_UPD (1)
#define LWM2MSTUB_FWUP_COMP_DL (2)
#define LWM2MSTUB_FWUP_FAIL_DL (3)
#define LWM2MSTUB_FWUP_CANCELED (4)
#define LWM2MSTUB_CMD_REGISTER (0)
#define LWM2MSTUB_CMD_DEREGISTER (1)
#define LWM2MSTUB_CMD_UPDATERESIGER (2)
#define LWM2MSTUB_STATE_NOTREGISTERD (0)
#define LWM2MSTUB_STATE_REGISTPENDING (1)
#define LWM2MSTUB_STATE_REGISTERD (2)
#define LWM2MSTUB_STATE_REGISTERFAILED (3)
#define LWM2MSTUB_STATE_UPDATEPENDING (4)
#define LWM2MSTUB_STATE_DEREGISTPENDING (5)
#define LWM2MSTUB_STATE_BSHOLDOFF (6)
#define LWM2MSTUB_STATE_BSREQUESTED (7)
#define LWM2MSTUB_STATE_BSONGOING (8)
#define LWM2MSTUB_STATE_BSDONE (9)
#define LWM2MSTUB_STATE_BSFAILED (10)
#define LWM2MSTUB_RESOP_READ (0)
#define LWM2MSTUB_RESOP_WRITE (1)
#define LWM2MSTUB_RESOP_RW (2)
#define LWM2MSTUB_RESOP_EXEC (3)
#define LWM2MSTUB_RESINST_SINGLE (0)
#define LWM2MSTUB_RESINST_MULTI (1)
#define LWM2MSTUB_RESDATA_NONE (0)
#define LWM2MSTUB_RESDATA_STRING (1)
#define LWM2MSTUB_RESDATA_INT (2)
#define LWM2MSTUB_RESDATA_UNSIGNED (3)
#define LWM2MSTUB_RESDATA_FLOAT (4)
#define LWM2MSTUB_RESDATA_BOOL (5)
#define LWM2MSTUB_RESDATA_OPAQUE (6)
#define LWM2MSTUB_RESDATA_TIME (7)
#define LWM2MSTUB_RESDATA_OBJLINK (8)
#define LWM2MSTUB_SECUREMODE_PSK (0)
#define LWM2MSTUB_SECUREMODE_RPK (1)
#define LWM2MSTUB_SECUREMODE_CERT (2)
#define LWM2MSTUB_SECUREMODE_NOSEC (3)
#define LWM2MSTUB_SECUREMODE_CERTEST (4)
#define LWM2MSTUB_CONNECT_REGISTER (0)
#define LWM2MSTUB_CONNECT_DEREGISTER (1)
#define LWM2MSTUB_CONNECT_REREGISTER (2)
#define LWM2MSTUB_CONNECT_BOOTSTRAP (3)
#define LWM2MSTUB_RESP_CHANGED (0)
#define LWM2MSTUB_RESP_CONTENT (1)
#define LWM2MSTUB_RESP_BADREQ (2)
#define LWM2MSTUB_RESP_UNAUTH (3)
#define LWM2MSTUB_RESP_NOURI (4)
#define LWM2MSTUB_RESP_NOTALLOW (5)
#define LWM2MSTUB_RESP_NOTACCEPT (6)
#define LWM2MSTUB_RESP_UNSUPPORT (7)
#define LWM2MSTUB_RESP_INTERNALERROR (8)
/* Client received "Write" operation */
#define LWM2MSTUB_OP_WRITE (0)
/* Client received "Execute" operation */
#define LWM2MSTUB_OP_EXEC (1)
/* Client received "Write Attributes" operation */
#define LWM2MSTUB_OP_WATTR (4)
/* Client received "Discover" operation */
#define LWM2MSTUB_OP_DISCOVER (5)
/* Client received "Read" operation */
#define LWM2MSTUB_OP_READ (6)
/* Client received "Observe" operation */
#define LWM2MSTUB_OP_OBSERVE (7)
/* Client received "Cancel observation" operation */
#define LWM2MSTUB_OP_CANCELOBS (8)
/* Client is offline now. */
#define LWM2MSTUB_OP_OFFLINE (9)
/* Client is online now. */
#define LWM2MSTUB_OP_ONLINE (10)
/* Client sent observation notification to a server. */
#define LWM2MSTUB_OP_SENDNOTICE (11)
/* Client received wakeup SMS. */
#define LWM2MSTUB_OP_RCVWUP (12)
/* Client received notification acknowledge. */
#define LWM2MSTUB_OP_RCVOBSACK (13)
/* Client ON: LMM2M client exits Client OFF state
* and tries to re-connect server due to explicitly
* AT Command registration request.
*/
#define LWM2MSTUB_OP_CLIENTON (14)
/* Client OFF: LWM2M client has exhausted server connection retries. */
#define LWM2MSTUB_OP_CLIENTOFF (15)
/* Confirmable NOTIFY failed. */
#define LWM2MSTUB_OP_FAILNOTIFY (16)
/* Bootstrap finished and completed successfully. */
#define LWM2MSTUB_OP_BSFINISH (20)
/* Registration finished and completed successfully.
* all server observation requests are cleaned,
* the host should clean host objects observation rules too.
*/
#define LWM2MSTUB_OP_REGSUCCESS (21)
/* Register update finished and completed successfully. */
#define LWM2MSTUB_OP_REGUPDATED (22)
/* De-register finished and completed successfully. */
#define LWM2MSTUB_OP_DEREGSUCCESS (23)
/* Notification was not saved and not sent to server */
#define LWM2MSTUB_OP_NOSENDNOTICE (24)
struct lwm2mstub_resource_s
{
int res_id;
int operation;
int inst_type;
int data_type;
int handl;
};
struct lwm2mstub_instance_s
{
int object_id;
int object_inst;
int res_id;
int res_inst;
};
struct lwm2mstub_ovcondition_s
{
uint8_t valid_mask;
unsigned int min_period;
unsigned int max_period;
double gt_cond;
double lt_cond;
double step_val;
};
struct lwm2mstub_serverinfo_s
{
int object_inst;
int state;
bool bootstrap;
bool nonip;
int security_mode;
uint32_t lifetime;
char server_uri[LWM2MSTUB_MAX_SERVER_NAME];
char device_id[LWM2MSTUB_MAX_DEVID];
char security_key[LWM2MSTUB_MAX_SEQKEY];
};
typedef void (*lwm2mstub_write_cb_t)(int seq_no, int srv_id,
struct lwm2mstub_instance_s *inst, char *value, int len);
typedef void (*lwm2mstub_read_cb_t)(int seq_no, int srv_id,
struct lwm2mstub_instance_s *inst);
typedef void (*lwm2mstub_exec_cb_t)(int seq_no, int srv_id,
struct lwm2mstub_instance_s *inst);
typedef void (*lwm2mstub_ovstart_cb_t)(int seq_no, int srv_id,
struct lwm2mstub_instance_s *inst, char *token,
struct lwm2mstub_ovcondition_s *cond);
typedef void (*lwm2mstub_ovstop_cb_t)(int seq_no, int srv_id,
struct lwm2mstub_instance_s *inst, char *token);
typedef void (*lwm2mstub_operation_cb_t)(int event);
typedef void (*lwm2mstub_fwupstate_cb_t)(int event);
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* On powe on state */
int lte_setm2m_endpointname(FAR char *name);
int lte_getm2m_endpointname(FAR char *name, int len);
int lte_getm2m_servernum(void);
int lte_setm2m_serverinfo(FAR struct lwm2mstub_serverinfo_s *info, int id);
int lte_getm2m_serverinfo(FAR struct lwm2mstub_serverinfo_s *info, int id);
int lte_getm2m_enabled_objectnum(void);
int lte_getm2m_enabled_objects(uint16_t *objids, int objnum);
int lte_enablem2m_objects(uint16_t *objids, int objnum);
int lte_getm2m_objresourcenum(uint16_t objid);
int lte_getm2m_objresourceinfo(uint16_t objids, int res_num,
struct lwm2mstub_resource_s *reses);
int lte_setm2m_objectdefinition(uint16_t objids, int res_num,
struct lwm2mstub_resource_s *reses);
int lte_apply_m2msetting(void);
/* After attached */
int lte_m2m_connection(int cmd);
int lte_set_report_m2mwrite(lwm2mstub_write_cb_t cb);
int lte_set_report_m2mread(lwm2mstub_read_cb_t cb);
int lte_set_report_m2mexec(lwm2mstub_exec_cb_t cb);
int lte_set_report_m2movstart(lwm2mstub_ovstart_cb_t cb);
int lte_set_report_m2movstop(lwm2mstub_ovstop_cb_t cb);
int lte_set_report_m2moperation(lwm2mstub_operation_cb_t cb);
int lte_set_report_m2mfwupdate(lwm2mstub_fwupstate_cb_t cb);
int lte_m2m_readresponse(int seq_no,
FAR struct lwm2mstub_instance_s *inst,
int resp, char *readvalue, int len);
int lte_m2m_writeresponse(int seq_no,
FAR struct lwm2mstub_instance_s *inst,
int resp);
int lte_m2m_executeresp(int seq_no,
FAR struct lwm2mstub_instance_s *inst,
int resp);
int lte_m2m_observeresp(int seq_no, int resp);
int lte_m2m_observeupdate(char *token,
FAR struct lwm2mstub_instance_s *inst,
char *value, int len);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_LTE_LTE_LWM2M_H */