46
46
#include "lib/sensors.h"
47
47
#include "button-sensor.h"
48
48
49
- #include "lwm2m_core.h"
50
- #include "lwm2m_object_store.h"
51
- #include "coap_abstraction.h"
52
- #include "client/lwm2m_bootstrap.h"
53
- #include "client/lwm2m_registration.h"
54
- #include "client/lwm2m_device_object.h"
55
- #include "client/lwm2m_security_object.h"
56
- #include "client/lwm2m_server_object.h"
49
+
50
+ #include "awa/static.h"
51
+
57
52
58
53
#include "lwm2m-client-flow-object.h"
59
54
#include "lwm2m-client-flow-access-object.h"
60
55
#include "lwm2m-client-ipso-digital-input.h"
61
-
56
+ #include "lwm2m-client-device-object.h"
62
57
/***************************************************************************************************
63
58
* Definitions
64
59
**************************************************************************************************/
@@ -108,40 +103,24 @@ Options options =
108
103
**************************************************************************************************/
109
104
110
105
111
- void ConstructObjectTree (Lwm2mContextType * context )
106
+ void ConstructObjectTree (AwaStaticClient * client )
112
107
{
113
- Lwm2m_Debug ("Construct object tree\n" );
114
-
115
- Lwm2m_RegisterSecurityObject (context );
116
- if (options .BootStrap != NULL )
117
- {
118
- Lwm2m_PopulateSecurityObject (context , options .BootStrap );
119
- }
120
- Lwm2m_RegisterServerObject (context );
121
- Lwm2m_RegisterDeviceObject (context );
122
-
123
- Lwm2m_RegisterFlowObject (context );
124
- Lwm2m_RegisterFlowAccessObject (context );
125
-
126
- DigitalInput_RegisterDigitalInputObject (context );
127
- DigitalInput_AddDigitialInput (context , 0 );
128
- DigitalInput_AddDigitialInput (context , 1 );
108
+ DefineDeviceObject (client );
109
+ DefineFlowObject (client );
110
+ DefineFlowAccessObject (client );
111
+ DefineDigitalInputObject (client );
129
112
}
130
113
131
- Lwm2mContextType * Lwm2mClient_Start ( )
114
+ void AwaStaticClient_Start ( AwaStaticClient * client )
132
115
{
133
- Lwm2m_SetOutput (stdout );
134
- Lwm2m_SetLogLevel ((options .Verbose ) ? DebugLevel_Debug : DebugLevel_Info );
135
- Lwm2m_PrintBanner ();
136
- Lwm2m_Info ("LWM2M client - CoAP port %d\n" , options .CoapPort );
137
- Lwm2m_Info ("LWM2M client - IPC port %d\n" , options .IpcPort );
138
-
139
- CoapInfo * coap = coap_Init ("0.0.0.0" , options .CoapPort ,
140
- (options .Verbose ) ? DebugLevel_Debug : DebugLevel_Info );
141
- Lwm2mContextType * context = Lwm2mCore_Init (coap , options .EndPointName );
142
- ConstructObjectTree (context );
143
-
144
- return context ;
116
+ AwaStaticClient_SetLogLevel ((options .Verbose ) ? AwaLogLevel_Debug : AwaLogLevel_Warning );
117
+ printf ("LWM2M client - CoAP port %d\n" , options .CoapPort );
118
+ printf ("LWM2M client - IPC port %d\n" , options .IpcPort );
119
+ AwaStaticClient_SetEndPointName (client , options .EndPointName );
120
+ AwaStaticClient_SetCoAPListenAddressPort (client , "0.0.0.0" , options .CoapPort );
121
+ AwaStaticClient_SetBootstrapServerURI (client , options .BootStrap );
122
+ AwaStaticClient_Init (client );
123
+ ConstructObjectTree (client );
145
124
}
146
125
147
126
PROCESS (lwm2m_client , "LwM2M Client" );
@@ -158,20 +137,20 @@ PROCESS_THREAD(lwm2m_client, ev, data)
158
137
159
138
PROCESS_PAUSE ();
160
139
161
- Lwm2m_Info ("Starting LWM2M Client for lwm2m-client-button-sensor\n" );
140
+ printf ("Starting LWM2M Client for lwm2m-client-button-sensor\n" );
162
141
163
142
#ifdef RF_CHANNEL
164
- Lwm2m_Info ("RF channel: %u\n" , RF_CHANNEL );
143
+ printf ("RF channel: %u\n" , RF_CHANNEL );
165
144
#endif
166
145
#ifdef IEEE802154_PANID
167
- Lwm2m_Info ("PAN ID: 0x%04X\n" , IEEE802154_PANID );
146
+ printf ("PAN ID: 0x%04X\n" , IEEE802154_PANID );
168
147
#endif
169
148
170
- Lwm2m_Info ("uIP buffer: %u\n" , UIP_BUFSIZE );
171
- Lwm2m_Info ("LL header: %u\n" , UIP_LLH_LEN );
172
- Lwm2m_Info ("IP+UDP header: %u\n" , UIP_IPUDPH_LEN );
149
+ printf ("uIP buffer: %u\n" , UIP_BUFSIZE );
150
+ printf ("LL header: %u\n" , UIP_LLH_LEN );
151
+ printf ("IP+UDP header: %u\n" , UIP_IPUDPH_LEN );
173
152
#ifdef REST_MAX_CHUNK_SIZE
174
- Lwm2m_Info ("REST max chunk: %u\n" , REST_MAX_CHUNK_SIZE );
153
+ printf ("REST max chunk: %u\n" , REST_MAX_CHUNK_SIZE );
175
154
#endif
176
155
177
156
uip_ipaddr_t ipaddr ;
@@ -180,23 +159,24 @@ PROCESS_THREAD(lwm2m_client, ev, data)
180
159
BOOTSTRAP_IPv6_ADDR8 );
181
160
uip_ds6_defrt_add (& ipaddr , 0 );
182
161
183
- static Lwm2mContextType * context ;
162
+ static AwaStaticClient * client ;
163
+ client = AwaStaticClient_New ();
164
+ AwaStaticClient_Start (client );
184
165
185
- context = Lwm2mClient_Start ();
186
166
187
167
/* Define application-specific events here. */
188
168
while (1 )
189
169
{
190
170
static struct etimer et ;
191
171
static int WaitTime ;
192
- WaitTime = Lwm2mCore_Process ( context );
172
+ WaitTime = AwaStaticClient_Process ( client );
193
173
etimer_set (& et , (WaitTime * CLOCK_SECOND ) / 1000 );
194
174
PROCESS_WAIT_EVENT_UNTIL (etimer_expired (& et ) || (ev == sensors_event ));
195
175
196
176
if (data == & button_sensor )
197
177
{
198
- Lwm2m_Info ("Button press event received\n" );
199
- DigitalInput_IncrementCounter (context , 0 );
178
+ printf ("Button press event received\n" );
179
+ DigitalInput_IncrementCounter (client , 0 );
200
180
}
201
181
}
202
182
0 commit comments