Skip to content

Commit e1835c9

Browse files
authored
Merge pull request #18 from maxiwoj/wakaama
Wakaama
2 parents ef019fc + 3eec0d9 commit e1835c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+15810
-23
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
build/*
22
r
3+
.gcc-flags.json
4+
cscope*
5+
.cscope*

.mxproject

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

Inc/FreeRTOSConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
#define configTICK_RATE_HZ ((TickType_t)1000)
102102
#define configMAX_PRIORITIES ( 7 )
103103
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
104-
#define configTOTAL_HEAP_SIZE ((size_t)15360)
104+
#define configTOTAL_HEAP_SIZE ((size_t)102400)
105105
#define configMAX_TASK_NAME_LEN ( 16 )
106106
#define configUSE_16_BIT_TICKS 0
107107
#define configUSE_MUTEXES 1
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*******************************************************************************
2+
*
3+
* Copyright (c) 2013, 2014 Intel Corporation and others.
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* and Eclipse Distribution License v1.0 which accompany this distribution.
7+
*
8+
* The Eclipse Public License is available at
9+
* http://www.eclipse.org/legal/epl-v10.html
10+
* The Eclipse Distribution License is available at
11+
* http://www.eclipse.org/org/documents/edl-v10.php.
12+
*
13+
* Contributors:
14+
* David Navarro, Intel Corporation - initial API and implementation
15+
*
16+
*******************************************************************************/
17+
18+
#ifndef __CONNECTION_H_
19+
#define __CONNECTION_H_
20+
21+
#include <stdio.h>
22+
#include "netdb.h"
23+
#include "lwip/opt.h"
24+
#include "lwip/arch.h"
25+
#include "lwip/api.h"
26+
#include "lwip/inet.h"
27+
#include "lwip/sockets.h"
28+
#include <liblwm2m.h>
29+
30+
#define LWM2M_STANDARD_PORT_STR "5683"
31+
#define LWM2M_STANDARD_PORT 5683
32+
#define LWM2M_DTLS_PORT_STR "5684"
33+
#define LWM2M_DTLS_PORT 5684
34+
#define LWM2M_BSSERVER_PORT_STR "5685"
35+
#define LWM2M_BSSERVER_PORT 5685
36+
37+
typedef struct _connection_t
38+
{
39+
struct _connection_t * next;
40+
int sock;
41+
struct sockaddr_in addr;
42+
size_t addrLen;
43+
} connection_t;
44+
45+
connection_t * connection_find(connection_t * connList, struct sockaddr_storage * addr, size_t addrLen);
46+
connection_t * connection_new_incoming(connection_t * connList, int sock, struct sockaddr * addr, size_t addrLen);
47+
connection_t * connection_create(connection_t * connList, int sock, char * host, char * port, int addressFamily);
48+
49+
void connection_free(connection_t * connList);
50+
51+
int connection_send(connection_t *connP, uint8_t * buffer, size_t length);
52+
53+
int createUDPSocket(int port, int addressFamily);
54+
55+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef __OBJECTS_H
2+
#define __OBJECTS_H
3+
4+
lwm2m_object_t * get_security_object();
5+
lwm2m_object_t * get_server_object(int serverId,
6+
const char* binding,
7+
int lifetime,
8+
bool storing);
9+
lwm2m_object_t * get_object_device();
10+
lwm2m_object_t * get_test_object();
11+
12+
void free_security_object();
13+
void clean_server_object();
14+
void free_object_device();
15+
void free_test_object();
16+
17+
#define OBJ_COUNT 4
18+
19+
#endif
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef __WAKAAMA_H
2+
#define __WAKAAMA_H
3+
4+
#include "connection.h"
5+
#include "objects.h"
6+
#include "communication_config.h"
7+
8+
typedef struct
9+
{
10+
lwm2m_object_t * securityObjP;
11+
int sock;
12+
connection_t * connList;
13+
int addressFamily;
14+
} client_data_t;
15+
16+
//WAKAAMA
17+
static lwm2m_context_t *lwm2mContext = NULL;
18+
static lwm2m_object_t *objArray[OBJ_COUNT];
19+
static client_data_t data;
20+
static int q_reset = 0;
21+
22+
static void print_state(lwm2m_context_t * lwm2mH);
23+
void taskWakaama(void *socket);
24+
void * lwm2m_connect_server(uint16_t secObjInstID,
25+
void * userData);
26+
void lwm2m_close_connection(void * sessionH,
27+
void * userData);
28+
#endif

Inc/lwipopts.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979
/* Parameters set in STM32CubeMX LwIP Configuration GUI -*/
8080
/*----- Value in opt.h for LWIP_DHCP: 0 -----*/
8181
#define LWIP_DHCP 1
82+
/*----- Default Value for LWIP_DNS: 0 ---*/
83+
#define LWIP_DNS 1
8284
/*----- Value in opt.h for MEM_ALIGNMENT: 1 -----*/
8385
#define MEM_ALIGNMENT 4
84-
/*----- Value in opt.h for MEMP_NUM_SYS_TIMEOUT: (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) -*/
85-
#define MEMP_NUM_SYS_TIMEOUT 5
8686
/*----- Value in opt.h for LWIP_ETHERNET: LWIP_ARP || PPPOE_SUPPORT -*/
8787
#define LWIP_ETHERNET 1
8888
/*----- Value in opt.h for LWIP_DNS_SECURE: (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) -*/

JtagProgrammer.ioc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ ETH.IPParameters=MediaInterface,PhyAddress
33
ETH.MediaInterface=ETH_MEDIA_INTERFACE_RMII
44
ETH.PhyAddress=0
55
FREERTOS.FootprintOK=true
6-
FREERTOS.IPParameters=Tasks01,configMINIMAL_STACK_SIZE,FootprintOK
6+
FREERTOS.IPParameters=Tasks01,configMINIMAL_STACK_SIZE,FootprintOK,configTOTAL_HEAP_SIZE
77
FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL
88
FREERTOS.configMINIMAL_STACK_SIZE=128
9+
FREERTOS.configTOTAL_HEAP_SIZE=102400
910
File.Version=6
1011
KeepUserPlacement=false
12+
LWIP.IPParameters=LWIP_DNS
13+
LWIP.LWIP_DNS=1
1114
LWIP.Version=v2.0.3_Cube
1215
Mcu.Family=STM32F4
1316
Mcu.IP0=ETH

Makefile

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##########################################################################################################################
2-
# File automatically-generated by tool: [projectgenerator] version: [2.30.0] date: [Sat Sep 29 11:39:00 CEST 2018]
2+
# File automatically-generated by tool: [projectgenerator] version: [2.30.0] date: [Mon Oct 15 23:30:01 CEST 2018]
33
##########################################################################################################################
44

55
# ------------------------------------------------
@@ -13,7 +13,7 @@
1313
######################################
1414
# target
1515
######################################
16-
TARGET = JtagProgrammer
16+
TARGET = RemoteProgrammer
1717

1818

1919
######################################
@@ -160,12 +160,55 @@ Src/ethernetif.c \
160160
Src/stm32f4xx_it.c \
161161
Src/stm32f4xx_hal_msp.c \
162162
Src/communication/dbgu.c \
163-
Src/communication/term_io.c
163+
Src/communication/term_io.c \
164+
Src/communication/wakaama_client/wakaama.c
164165

165166
# ASM sources
166167
ASM_SOURCES = \
167168
startup_stm32f429xx.s
168169

170+
#######################################
171+
# Wakaama
172+
######################################
173+
174+
WAKAAMA_SOURCES = \
175+
Middlewares/Third_Party/wakaama/liblwm2m.c \
176+
Middlewares/Third_Party/wakaama/wakaama_utils.c \
177+
Middlewares/Third_Party/wakaama/uri.c \
178+
Middlewares/Third_Party/wakaama/objects.c \
179+
Middlewares/Third_Party/wakaama/tlv.c \
180+
Middlewares/Third_Party/wakaama/data.c \
181+
Middlewares/Third_Party/wakaama/wakaama_list.c \
182+
Middlewares/Third_Party/wakaama/packet.c \
183+
Middlewares/Third_Party/wakaama/transaction.c \
184+
Middlewares/Third_Party/wakaama/registration.c \
185+
Middlewares/Third_Party/wakaama/bootstrap.c \
186+
Middlewares/Third_Party/wakaama/management.c \
187+
Middlewares/Third_Party/wakaama/observe.c \
188+
Middlewares/Third_Party/wakaama/json.c \
189+
Middlewares/Third_Party/wakaama/discover.c \
190+
Middlewares/Third_Party/wakaama/block1.c \
191+
Middlewares/Third_Party/wakaama/er-coap-13/er-coap-13.c
192+
193+
WAKAAMA_CUSTOM = \
194+
Src/communication/wakaama_client/platform/platform.c \
195+
Src/communication/wakaama_client/connection.c \
196+
Src/communication/wakaama_client/objects/object_device.c \
197+
Src/communication/wakaama_client/objects/object_security.c \
198+
Src/communication/wakaama_client/objects/object_server.c \
199+
Src/communication/wakaama_client/objects/test_object.c
200+
201+
202+
WAKAAMA_INC = \
203+
-IMiddlewares/Third_Party/wakaama \
204+
-IMiddlewares/Third_Party/wakaama/er-coap-13 \
205+
206+
207+
WAKAAMA_SYMBOL = -DLWM2M_LITTLE_ENDIAN
208+
WAKAAMA_SYMBOL += -DLWM2M_CLIENT_MODE
209+
#WAKAAMA_SYMBOL += -DLWM2M_MEMORY_TRACE
210+
#WAKAAMA_SYMBOL += -DCOAPLOG # download logs
211+
#WAKAAMA_SYMBOL += -DLWM2M_WITH_LOGS # LOGS
169212

170213
#######################################
171214
# binaries
@@ -186,7 +229,7 @@ SZ = $(PREFIX)size
186229
endif
187230
HEX = $(CP) -O ihex
188231
BIN = $(CP) -O binary -S
189-
232+
190233
#######################################
191234
# CFLAGS
192235
#######################################
@@ -204,7 +247,7 @@ MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
204247

205248
# macros for gcc
206249
# AS defines
207-
AS_DEFS =
250+
AS_DEFS =
208251

209252
# C defines
210253
C_DEFS = \
@@ -240,13 +283,19 @@ C_INCLUDES = \
240283
-IMiddlewares/Third_Party/LwIP/src/include/posix/sys \
241284
-IMiddlewares/Third_Party/LwIP/system/arch \
242285
-IDrivers/CMSIS/Include \
243-
-IInc/communication
286+
-IInc/communication \
287+
-IInc/communication/wakaama_client \
288+
-IInc/communication/wakaama_client/objects \
289+
-Iconfig
244290

291+
C_INCLUDES += $(WAKAAMA_INC)
292+
293+
C_SOURCES += $(WAKAAMA_SOURCES) $(WAKAAMA_CUSTOM)
245294

246295
# compile gcc flags
247296
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
248297

249-
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
298+
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) $(WAKAAMA_SYMBOL) -Wall -fdata-sections -ffunction-sections
250299

251300
ifeq ($(DEBUG), 1)
252301
CFLAGS += -g -gdwarf-2
@@ -264,8 +313,8 @@ CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
264313
LDSCRIPT = STM32F429ZITx_FLASH.ld
265314

266315
# libraries
267-
LIBS = -lc -lm -lnosys
268-
LIBDIR =
316+
LIBS = -lc -lm -lnosys
317+
LIBDIR =
269318
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
270319

271320
# default action: build all
@@ -282,7 +331,7 @@ vpath %.c $(sort $(dir $(C_SOURCES)))
282331
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
283332
vpath %.s $(sort $(dir $(ASM_SOURCES)))
284333

285-
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
334+
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
286335
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
287336

288337
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
@@ -294,19 +343,19 @@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
294343

295344
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
296345
$(HEX) $< $@
297-
346+
298347
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
299-
$(BIN) $< $@
300-
348+
$(BIN) $< $@
349+
301350
$(BUILD_DIR):
302-
mkdir $@
351+
mkdir $@
303352

304353
#######################################
305354
# clean up
306355
#######################################
307356
clean:
308357
-rm -fR $(BUILD_DIR)
309-
358+
310359
#######################################
311360
# dependencies
312361
#######################################

0 commit comments

Comments
 (0)