From 4eb394e3918dd769d5781fa7cc6ca568869e991e Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Tue, 7 Jun 2016 14:30:11 +0100 Subject: [PATCH] Move Nanostack connect semaphore into object Connect semaphore was being constructed and consuming RAM even if Nanostack isn't in use. Avoid this by moving it into the class, where it should be anyway. --- net/nanostack-interface/NanostackInterface.cpp | 3 +-- net/nanostack-interface/NanostackInterface.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/net/nanostack-interface/NanostackInterface.cpp b/net/nanostack-interface/NanostackInterface.cpp index 4b40acc4dc..7aaf1fdc6d 100644 --- a/net/nanostack-interface/NanostackInterface.cpp +++ b/net/nanostack-interface/NanostackInterface.cpp @@ -107,8 +107,7 @@ private: socket_mode_t mode; }; -static Semaphore connect_semaphore(0); -static NanostackSocket * socket_tbl[NS_INTERFACE_SOCKETS_MAX] = {0}; +static NanostackSocket * socket_tbl[NS_INTERFACE_SOCKETS_MAX]; static int map_mesh_error(mesh_error_t err) { diff --git a/net/nanostack-interface/NanostackInterface.h b/net/nanostack-interface/NanostackInterface.h index 7d747cf63d..051e1024b7 100644 --- a/net/nanostack-interface/NanostackInterface.h +++ b/net/nanostack-interface/NanostackInterface.h @@ -13,6 +13,7 @@ class NanostackInterface : public MeshInterface, public NetworkStack { public: + NanostackInterface() : connect_semaphore(0) { } int disconnect(); /** Get the internally stored IP address @@ -226,6 +227,7 @@ protected: uint8_t eui64[8]; char ip_addr_str[40]; char mac_addr_str[24]; + Semaphore connect_semaphore; }; class LoWPANNDInterface : public NanostackInterface {