Skip to content

Commit 4723e19

Browse files
Merge pull request #7 from rahul-daga-imgtec/move_to_static
move to static apis
2 parents c15089b + 00f22a4 commit 4723e19

File tree

2 files changed

+33
-55
lines changed

2 files changed

+33
-55
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ CONTIKI=../../constrained-os/contiki
66
CONTIKI_WITH_IPV6 = 1
77
CONTIKI_WITH_RPL = 0
88

9-
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" -DVERSION='$(VERSION)'
9+
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" -DVERSION='\"$(VERSION)\"'
1010
CFLAGS += -Wall -Wno-pointer-sign -DLWM2M_CLIENT
11-
CFLAGS += -I$(LWM2M_DIR)/core/src/common
12-
CFLAGS += -I$(LWM2M_DIR)/core/src/client
13-
CFLAGS += -I$(LWM2M_DIR)/core/src
11+
CFLAGS += -I$(LWM2M_DIR)/api/include
1412

1513
ifneq (,$(filter $(TARGET),seedeye mikro-e))
1614
CFLAGS += -fno-short-double

lwm2m-client-button-sensor.c

Lines changed: 31 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,14 @@
4646
#include "lib/sensors.h"
4747
#include "button-sensor.h"
4848

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+
5752

5853
#include "lwm2m-client-flow-object.h"
5954
#include "lwm2m-client-flow-access-object.h"
6055
#include "lwm2m-client-ipso-digital-input.h"
61-
56+
#include "lwm2m-client-device-object.h"
6257
/***************************************************************************************************
6358
* Definitions
6459
**************************************************************************************************/
@@ -108,40 +103,24 @@ Options options =
108103
**************************************************************************************************/
109104

110105

111-
void ConstructObjectTree(Lwm2mContextType * context)
106+
void ConstructObjectTree(AwaStaticClient *client)
112107
{
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);
129112
}
130113

131-
Lwm2mContextType * Lwm2mClient_Start()
114+
void AwaStaticClient_Start(AwaStaticClient *client)
132115
{
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);
145124
}
146125

147126
PROCESS(lwm2m_client, "LwM2M Client");
@@ -158,20 +137,20 @@ PROCESS_THREAD(lwm2m_client, ev, data)
158137

159138
PROCESS_PAUSE();
160139

161-
Lwm2m_Info("Starting LWM2M Client for lwm2m-client-button-sensor\n");
140+
printf("Starting LWM2M Client for lwm2m-client-button-sensor\n");
162141

163142
#ifdef RF_CHANNEL
164-
Lwm2m_Info("RF channel: %u\n", RF_CHANNEL);
143+
printf("RF channel: %u\n", RF_CHANNEL);
165144
#endif
166145
#ifdef IEEE802154_PANID
167-
Lwm2m_Info("PAN ID: 0x%04X\n", IEEE802154_PANID);
146+
printf("PAN ID: 0x%04X\n", IEEE802154_PANID);
168147
#endif
169148

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);
173152
#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);
175154
#endif
176155

177156
uip_ipaddr_t ipaddr;
@@ -180,23 +159,24 @@ PROCESS_THREAD(lwm2m_client, ev, data)
180159
BOOTSTRAP_IPv6_ADDR8);
181160
uip_ds6_defrt_add(&ipaddr, 0);
182161

183-
static Lwm2mContextType * context;
162+
static AwaStaticClient *client;
163+
client = AwaStaticClient_New();
164+
AwaStaticClient_Start(client);
184165

185-
context = Lwm2mClient_Start();
186166

187167
/* Define application-specific events here. */
188168
while(1)
189169
{
190170
static struct etimer et;
191171
static int WaitTime;
192-
WaitTime = Lwm2mCore_Process(context);
172+
WaitTime = AwaStaticClient_Process(client);
193173
etimer_set(&et, (WaitTime * CLOCK_SECOND) / 1000);
194174
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et) || (ev == sensors_event));
195175

196176
if (data == &button_sensor)
197177
{
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);
200180
}
201181
}
202182

0 commit comments

Comments
 (0)