Contiki-NG
lwm2m-rd-client.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2018, SICS Swedish ICT AB.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28  * OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 /**
32  * \addtogroup lwm2m
33  * @{
34  */
35 
36 /**
37  * \file
38  * Header file for the Contiki OMA LWM2M Registration and Bootstrap
39  * Client.
40  * \author
41  * Joakim Eriksson <joakime@sics.se>
42  * Niclas Finne <nfi@sics.se>
43  * Carlos Gonzalo Peces <carlosgp143@gmail.com>
44  */
45 
46 #ifndef LWM2M_RD_CLIENT_H_
47 #define LWM2M_RD_CLIENT_H_
48 
49 #define LWM2M_RD_CLIENT_BOOTSTRAPPED 1
50 #define LWM2M_RD_CLIENT_REGISTERED 2
51 #define LWM2M_RD_CLIENT_DEREGISTERED 3
52 #define LWM2M_RD_CLIENT_DEREGISTER_FAILED 4
53 #define LWM2M_RD_CLIENT_DISCONNECTED 5
54 
55 #include "lwm2m-object.h"
56 #include "lwm2m-queue-mode-conf.h"
57 
58 struct lwm2m_session_info;
59 typedef void (*session_callback_t)(struct lwm2m_session_info *session, int status);
60 
61 int lwm2m_rd_client_is_registered(void);
62 void lwm2m_rd_client_use_bootstrap_server(int use);
63 void lwm2m_rd_client_use_registration_server(int use);
64 void lwm2m_rd_client_register_with_server(const coap_endpoint_t *server);
65 void lwm2m_rd_client_register_with_bootstrap_server(const coap_endpoint_t *server);
66 uint16_t lwm2m_rd_client_get_lifetime(void);
67 void lwm2m_rd_client_set_lifetime(uint16_t lifetime);
68 /* Indicate that something in the object list have changed */
69 void lwm2m_rd_client_set_update_rd(void);
70 /* Control if the object list should be automatically updated at updates of lifetime */
71 void lwm2m_rd_client_set_automatic_update(int update);
72 /* trigger an immediate update */
73 void lwm2m_rd_client_update_triggered(void);
74 
75 int lwm2m_rd_client_deregister(void);
76 void lwm2m_rd_client_init(const char *ep);
77 
78 void lwm2m_rd_client_set_session_callback(session_callback_t cb);
79 
80 #if LWM2M_QUEUE_MODE_ENABLED
81 uint8_t lwm2m_rd_client_is_client_awake(void);
82 void lwm2m_rd_client_restart_client_awake_timer(void);
83 void lwm2m_rd_client_fsm_execute_queue_mode_awake();
84 void lwm2m_rd_client_fsm_execute_queue_mode_update();
85 #endif
86 
87 #ifndef LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN
88 #define LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN 15
89 #endif /* LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN */
90 
91 /*---------------------------------------------------------------------------*/
92 /*- Server session-*Currently single session only*---------------------------*/
93 /*---------------------------------------------------------------------------*/
94 struct lwm2m_session_info {
95  const char *ep;
96  const char *binding;
97  char assigned_ep[LWM2M_RD_CLIENT_ASSIGNED_ENDPOINT_MAX_LEN];
98  uint16_t lifetime;
99  coap_endpoint_t bs_server_ep;
100  coap_endpoint_t server_ep;
101  uint8_t use_bootstrap;
102  uint8_t has_bs_server_info;
103  uint8_t use_registration;
104  uint8_t has_registration_server_info;
105  uint8_t registered;
106  uint8_t bootstrapped; /* bootstrap done */
107  session_callback_t callback;
108 };
109 
110 #endif /* LWM2M_RD_CLIENT_H_ */
111 /** @} */
Header file for the LWM2M object API
Queue Mode Configuration Parameters