lwm2m_client.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef LWM2M_CLIENT_H
21 #define LWM2M_CLIENT_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <ctype.h>
28 #include <errno.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <sys/types.h>
33 #include <unistd.h>
34 #include <sys/time.h>
35 
36 #include "periph/pm.h"
37 #include "net/sock/udp.h"
38 
39 #if IS_USED(MODULE_WAKAAMA_CLIENT_DTLS)
40 #include "net/sock/dtls.h"
41 #endif
42 
43 #include "lwm2m_client_config.h"
44 #include "liblwm2m.h"
45 
49 typedef enum {
53 
57 typedef struct lwm2m_client_connection {
60 #if IS_USED(MODULE_WAKAAMA_CLIENT_DTLS) || DOXYGEN
62 #endif
64  time_t last_send;
66 
70 typedef struct {
73 #if IS_USED(MODULE_WAKAAMA_CLIENT_DTLS)
74  sock_udp_t dtls_udp_sock;
75  sock_dtls_t dtls_sock;
76  sock_udp_ep_t dtls_local_ep;
77 #endif
79  lwm2m_context_t *lwm2m_ctx;
82 
86 #define LWM2M_CLIENT_RCV_BUFFER_SIZE (200)
87 
92 #define LWM2M_CLIENT_REBOOT_TIME (5)
93 
100 #define LWM2M_CLIENT_MIN_REFRESH_TIME (1)
101 
111 lwm2m_context_t *lwm2m_client_run(lwm2m_client_data_t *client_data,
112  lwm2m_object_t *obj_list[],
113  uint16_t obj_numof);
114 
124 
132 static inline lwm2m_context_t *lwm2m_client_get_ctx(
133  lwm2m_client_data_t *client_data)
134 {
135  return client_data->lwm2m_ctx;
136 }
137 
138 #if IS_USED(MODULE_WAKAAMA_CLIENT_DTLS) || defined(DOXYGEN)
144 
153 
160 #endif /* MODULE_WAKAAMA_CLIENT_DTLS || DOXYGEN */
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* LWM2M_CLIENT_H */
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:139
void lwm2m_client_refresh_dtls_credentials(void)
Refreshes the client available credentials using the currently registered security objects.
void lwm2m_client_init(lwm2m_client_data_t *client_data)
Initializes a LwM2M client.
void lwm2m_client_remove_credential(credman_tag_t tag)
Removes a credential tag from the available to use with the LwM2M DTLS sock.
void lwm2m_client_add_credential(credman_tag_t tag)
Adds a credential tag to be used with the LwM2M DTLS sock.
lwm2m_context_t * lwm2m_client_run(lwm2m_client_data_t *client_data, lwm2m_object_t *obj_list[], uint16_t obj_numof)
Starts a LwM2M client.
struct lwm2m_client_connection lwm2m_client_connection_t
Connection to server descriptor.
static lwm2m_context_t * lwm2m_client_get_ctx(lwm2m_client_data_t *client_data)
Returns the LwM2M context of a LwM2M client.
Definition: lwm2m_client.h:132
lwm2m_client_connection_type_t
Type of connection to the LwM2M server.
Definition: lwm2m_client.h:49
@ LWM2M_CLIENT_CONN_DTLS
DTLS over UDP.
Definition: lwm2m_client.h:51
@ LWM2M_CLIENT_CONN_UDP
UDP.
Definition: lwm2m_client.h:50
uint16_t credman_tag_t
Tag of the credential.
Definition: credman.h:96
LwM2M client configurations.
Power management interface.
DTLS sock definitions.
UDP sock definitions.
stdio wrapper to extend the C libs stdio
Common IP-based transport layer end point.
Definition: sock.h:215
Connection to server descriptor.
Definition: lwm2m_client.h:57
time_t last_send
last sent packet to the server
Definition: lwm2m_client.h:64
sock_dtls_session_t session
DTLS session (needs wakaama_client_dtls module)
Definition: lwm2m_client.h:61
lwm2m_client_connection_type_t type
type of connection
Definition: lwm2m_client.h:63
sock_udp_ep_t remote
remote endpoint
Definition: lwm2m_client.h:59
struct lwm2m_client_connection * next
pointer to the next connection
Definition: lwm2m_client.h:58
LwM2M client descriptor.
Definition: lwm2m_client.h:70
lwm2m_client_connection_t * conn_list
LwM2M connections list.
Definition: lwm2m_client.h:80
kernel_pid_t pid
PID of the client thread.
Definition: lwm2m_client.h:71
sock_udp_t sock
UDP server sock.
Definition: lwm2m_client.h:72
sock_udp_ep_t local_ep
Local endpoint.
Definition: lwm2m_client.h:78
lwm2m_context_t * lwm2m_ctx
LwM2M context.
Definition: lwm2m_client.h:79
Information about remote client connected to the server.
Information about DTLS sock.
UDP sock type.
Definition: sock_types.h:128