diff --git a/.cproject b/.cproject
index 7a8dff5..3466b14 100644
--- a/.cproject
+++ b/.cproject
@@ -52,6 +52,9 @@
+
@@ -63,7 +66,7 @@
-
+
@@ -130,7 +133,7 @@
-
+
diff --git a/MQTTSNGateway/gateway.conf b/MQTTSNGateway/gateway.conf
index 6d020c6..aa031ea 100644
--- a/MQTTSNGateway/gateway.conf
+++ b/MQTTSNGateway/gateway.conf
@@ -40,3 +40,6 @@ Baudrate=38400
SerialDevice=/dev/ttyUSB0
ApiMode=2
+# LOG
+ShearedMemory=NO;
+
diff --git a/MQTTSNGateway/src/MQTTGWConnectionHandler.cpp b/MQTTSNGateway/src/MQTTGWConnectionHandler.cpp
index 88263da..d670ef9 100644
--- a/MQTTSNGateway/src/MQTTGWConnectionHandler.cpp
+++ b/MQTTSNGateway/src/MQTTGWConnectionHandler.cpp
@@ -95,12 +95,4 @@ void MQTTGWConnectionHandler::handlePingresp(Client* client, MQTTGWPacket* packe
_gateway->getClientSendQue()->post(ev1);
}
-void MQTTGWConnectionHandler::handleDisconnect(Client* client, MQTTGWPacket* packet)
-{
- MQTTSNPacket* snPacket = new MQTTSNPacket();
- snPacket->setDISCONNECT(0);
- client->disconnected();
- Event* ev1 = new Event();
- ev1->setClientSendEvent(client, snPacket);
-}
diff --git a/MQTTSNGateway/src/MQTTGWConnectionHandler.h b/MQTTSNGateway/src/MQTTGWConnectionHandler.h
index 8d8af3c..aae892e 100644
--- a/MQTTSNGateway/src/MQTTGWConnectionHandler.h
+++ b/MQTTSNGateway/src/MQTTGWConnectionHandler.h
@@ -30,13 +30,9 @@ public:
~MQTTGWConnectionHandler();
void handleConnack(Client* client, MQTTGWPacket* packet);
void handlePingresp(Client* client, MQTTGWPacket* packet);
- void handleDisconnect(Client* client, MQTTGWPacket* packet);
-
private:
Gateway* _gateway;
};
}
-
-
#endif /* MQTTGWCONNECTIONHANDLER_H_ */
diff --git a/MQTTSNGateway/src/MQTTSNGWBrokerRecvTask.cpp b/MQTTSNGateway/src/MQTTSNGWBrokerRecvTask.cpp
index 11a2d3e..0e233ed 100644
--- a/MQTTSNGateway/src/MQTTSNGWBrokerRecvTask.cpp
+++ b/MQTTSNGateway/src/MQTTSNGWBrokerRecvTask.cpp
@@ -176,7 +176,6 @@ int BrokerRecvTask::log(Client* client, MQTTGWPacket* packet)
switch (packet->getType())
{
case CONNACK:
- case DISCONNECT:
WRITELOG(FORMAT_Y_Y_W, currentDateTime(), packet->getName(), LEFTARROW, client->getClientId(), packet->print(pbuf));
break;
case PUBLISH:
diff --git a/MQTTSNGateway/src/MQTTSNGWBrokerSendTask.cpp b/MQTTSNGateway/src/MQTTSNGWBrokerSendTask.cpp
index 0c44ee7..ea589e4 100644
--- a/MQTTSNGateway/src/MQTTSNGWBrokerSendTask.cpp
+++ b/MQTTSNGateway/src/MQTTSNGWBrokerSendTask.cpp
@@ -34,41 +34,13 @@ BrokerSendTask::BrokerSendTask(Gateway* gateway)
{
_gateway = gateway;
_gateway->attach((Thread*)this);
- _host = 0;
- _port = 0;
- _portSecure = 0;
- _certDirectory = 0;
- _rootCAfile = 0;
-
+ _gwparams = 0;
_light = 0;
}
BrokerSendTask::~BrokerSendTask()
{
- if (_host)
- {
- free(_host);
- }
- if (_port)
- {
- free(_port);
- }
- if (_portSecure)
- {
- free(_portSecure);
- }
- if (_certDirectory)
- {
- free(_certDirectory);
- }
- if (_rootCApath)
- {
- free(_rootCApath);
- }
- if (_rootCAfile)
- {
- free(_rootCAfile);
- }
+
}
/**
@@ -76,34 +48,7 @@ BrokerSendTask::~BrokerSendTask()
*/
void BrokerSendTask::initialize(int argc, char** argv)
{
- char param[MQTTSNGW_PARAM_MAX];
-
- if (_gateway->getParam("BrokerName", param) == 0)
- {
- _host = strdup(param);
- }
- if (_gateway->getParam("BrokerPortNo", param) == 0)
- {
- _port = strdup(param);
- }
- if (_gateway->getParam("BrokerSecurePortNo", param) == 0)
- {
- _portSecure = strdup(param);
- }
-
- if (_gateway->getParam("CertsDirectory", param) == 0)
- {
- _certDirectory = strdup(param);
- }
- if (_gateway->getParam("RootCApath", param) == 0)
- {
- _rootCApath = strdup(param);
- }
- if (_gateway->getParam("RootCAfile", param) == 0)
- {
- _rootCAfile = strdup(param);
- }
-
+ _gwparams = _gateway->getGWParams();
_light = _gateway->getLightIndicator();
}
@@ -122,16 +67,16 @@ void BrokerSendTask::run()
ev = _gateway->getBrokerSendQue()->wait();
client = ev->getClient();
packet = ev->getMQTTGWPacket();
-
+ /*
if ( client->getNetwork()->isValid() && !client->getNetwork()->isSecure() && packet->getType() == CONNECT )
{
client->getNetwork()->close();
}
-
+ */
if ( !client->getNetwork()->isValid() )
{
/* connect to the broker and send a packet */
- char* portNo = _port;
+ char* portNo = _gwparams->port;
const char* cert = 0;
const char* keyFile = 0;
string certFile;
@@ -139,33 +84,33 @@ void BrokerSendTask::run()
if (client->isSecureNetwork())
{
- portNo = _portSecure;
- if ( _certDirectory )
+ portNo = _gwparams->portSecure;
+ if ( _gwparams->certDirectory )
{
- certFile = _certDirectory;
+ certFile = _gwparams->certDirectory;
certFile += client->getClientId();
certFile += ".crt";
cert = certFile.c_str();
- privateKeyFile = _certDirectory;
+ privateKeyFile = _gwparams->certDirectory;
privateKeyFile += client->getClientId();
privateKeyFile += ".key";
keyFile = privateKeyFile.c_str();
}
- rc = client->getNetwork()->connect(_host, portNo, _rootCApath, _rootCAfile, cert, keyFile);
+ rc = client->getNetwork()->connect(_gwparams->brokerName, _gwparams->portSecure, _gwparams->rootCApath, _gwparams->rootCAfile, cert, keyFile);
}
else
{
- rc = client->getNetwork()->connect(_host, portNo);
+ rc = client->getNetwork()->connect(_gwparams->brokerName, portNo);
}
if ( !rc )
{
- /* disconnect the broker and change the client's status */
+ /* disconnect the broker and the client */
WRITELOG("%s BrokerSendTask can't connect to the broker. errno=%d %s%s\n",
ERRMSG_HEADER, rc == -1 ? errno : 0, client->getClientId(), ERRMSG_FOOTER);
- client->disconnected();
- client->getNetwork()->disconnect();
delete ev;
+ disconnect(client);
+ client->getNetwork()->disconnect();
continue;
}
}
@@ -231,3 +176,13 @@ void BrokerSendTask::log(Client* client, MQTTGWPacket* packet)
break;
}
}
+
+void BrokerSendTask::disconnect(Client* client)
+{
+ MQTTSNPacket* snMsg = new MQTTSNPacket();
+ snMsg->setDISCONNECT(0);
+ Event* ev1 = new Event();
+ ev1->setClientSendEvent(client, snMsg);
+ _gateway->getClientSendQue()->post(ev1);
+ client->disconnected();
+}
diff --git a/MQTTSNGateway/src/MQTTSNGWBrokerSendTask.h b/MQTTSNGateway/src/MQTTSNGWBrokerSendTask.h
index 7ce73ea..a589a5d 100644
--- a/MQTTSNGateway/src/MQTTSNGWBrokerSendTask.h
+++ b/MQTTSNGateway/src/MQTTSNGWBrokerSendTask.h
@@ -35,14 +35,9 @@ public:
void run();
private:
void log(Client*, MQTTGWPacket*);
-
+ void disconnect(Client*);
Gateway* _gateway;
- char* _host;
- char* _port;
- char* _portSecure;
- char* _rootCApath;
- char* _rootCAfile;
- char* _certDirectory;
+ GatewayParams* _gwparams;
LightIndicator* _light;
};
diff --git a/MQTTSNGateway/src/MQTTSNGWClient.cpp b/MQTTSNGateway/src/MQTTSNGWClient.cpp
index 430498b..4a8aecf 100644
--- a/MQTTSNGateway/src/MQTTSNGWClient.cpp
+++ b/MQTTSNGateway/src/MQTTSNGWClient.cpp
@@ -375,13 +375,9 @@ void Client::setClientSleepPacket(MQTTSNPacket* packet)
_clientSleepPacketQue.post(packet);
}
-void Client::checkTimeover(void)
+bool Client::checkTimeover(void)
{
- if (_status == Cstat_Active && _keepAliveTimer.isTimeup())
- {
- _status = Cstat_Lost;
- _network->disconnect();
- }
+ return (_status == Cstat_Active && _keepAliveTimer.isTimeup());
}
void Client::setKeepAlive(MQTTSNPacket* packet)
diff --git a/MQTTSNGateway/src/MQTTSNGWClient.h b/MQTTSNGateway/src/MQTTSNGWClient.h
index 0ba2b03..d210fc3 100644
--- a/MQTTSNGateway/src/MQTTSNGWClient.h
+++ b/MQTTSNGateway/src/MQTTSNGWClient.h
@@ -248,7 +248,7 @@ public:
void setWaitedPubTopicId(uint16_t msgId, uint16_t topicId, MQTTSN_topicTypes type);
void setWaitedSubTopicId(uint16_t msgId, uint16_t topicId, MQTTSN_topicTypes type);
- void checkTimeover(void);
+ bool checkTimeover(void);
void updateStatus(MQTTSNPacket*);
void updateStatus(ClientStatus);
void connectSended(void);
diff --git a/MQTTSNGateway/src/MQTTSNGWDefines.h b/MQTTSNGateway/src/MQTTSNGWDefines.h
index 839708e..cbaacda 100644
--- a/MQTTSNGateway/src/MQTTSNGWDefines.h
+++ b/MQTTSNGateway/src/MQTTSNGWDefines.h
@@ -20,11 +20,11 @@
namespace MQTTSNGW
{
/*=================================
- * Log controls
+ * Config Parametrs
==================================*/
-//#define DEBUG // print out log for debug
-//#define RINGBUFFER // print out Packets log into shared memory
-//#define DEBUG_NWSTACK // print out SensorNetwork log
+#define CONFIG_DIRECTORY "./"
+#define CONFIG_FILE "gateway.conf"
+#define CLIENT_LIST "clients.conf"
/*=================================
* MQTT-SN Parametrs
@@ -43,11 +43,13 @@ typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
/*=================================
- * Macros
+ * Log controls
==================================*/
+//#define DEBUG // print out log for debug
+//#define DEBUG_NWSTACK // print out SensorNetwork log
+
#ifdef DEBUG
#define DEBUGLOG(...) printf(__VA_ARGS__)
-#undef RINGBUFFER
#else
#define DEBUGLOG(...)
#endif
diff --git a/MQTTSNGateway/src/MQTTSNGWPacketHandleTask.cpp b/MQTTSNGateway/src/MQTTSNGWPacketHandleTask.cpp
index 77dc86b..bf8a85d 100644
--- a/MQTTSNGateway/src/MQTTSNGWPacketHandleTask.cpp
+++ b/MQTTSNGateway/src/MQTTSNGWPacketHandleTask.cpp
@@ -109,7 +109,11 @@ void PacketHandleTask::run()
client = clist->getClient();
while (client > 0)
{
- client->checkTimeover();
+ if ( client->checkTimeover() )
+ {
+ _mqttsnConnection->handleDisconnect(client, 0);
+ client->disconnected();
+ }
client = client->getNextClient();
}
/*------ Check Keep Alive Timer & send Advertise ------*/
@@ -200,9 +204,6 @@ void PacketHandleTask::run()
case CONNACK:
_mqttConnection->handleConnack(client, brPacket);
break;
- case DISCONNECT:
- _mqttConnection->handleDisconnect(client, brPacket);
- break;
case PINGRESP:
_mqttConnection->handlePingresp(client, brPacket);
break;
diff --git a/MQTTSNGateway/src/MQTTSNGWProcess.cpp b/MQTTSNGateway/src/MQTTSNGWProcess.cpp
index ce5085e..bd6d2ad 100644
--- a/MQTTSNGateway/src/MQTTSNGWProcess.cpp
+++ b/MQTTSNGateway/src/MQTTSNGWProcess.cpp
@@ -53,8 +53,9 @@ Process::Process()
{
_argc = 0;
_argv = 0;
- _configDir = MQTTSNGW_CONFIG_DIRECTORY;
- _configFile = MQTTSNGW_CONFIG_FILE;
+ _configDir = CONFIG_DIRECTORY;
+ _configFile = CONFIG_FILE;
+ _log = 0;
}
Process::~Process()
@@ -76,6 +77,7 @@ void Process::run()
void Process::initialize(int argc, char** argv)
{
+ char param[MQTTSNGW_PARAM_MAX];
_argc = argc;
_argv = argv;
signal(SIGINT, signalHandler);
@@ -102,6 +104,18 @@ void Process::initialize(int argc, char** argv)
}
_rbsem = new Semaphore(MQTTSNGW_RB_SEMAPHOR_NAME, 0);
_rb = new RingBuffer(_configDir.c_str());
+
+ if (getParam("ShearedMemory", param) == 0)
+ {
+ if (!strcasecmp(param, "YES"))
+ {
+ _log = 1;
+ }
+ else
+ {
+ _log = 0;
+ }
+ }
}
int Process::getArgc()
@@ -178,8 +192,15 @@ void Process::putLog(const char* format, ...)
va_end(arg);
if (strlen(_rbdata))
{
- _rb->put(_rbdata);
- _rbsem->post();
+ if ( _log > 0 )
+ {
+ _rb->put(_rbdata);
+ _rbsem->post();
+ }
+ else
+ {
+ printf("%s", _rbdata);
+ }
}
_mt.unlock();
}
diff --git a/MQTTSNGateway/src/MQTTSNGWProcess.h b/MQTTSNGateway/src/MQTTSNGWProcess.h
index c1b9110..3606678 100644
--- a/MQTTSNGateway/src/MQTTSNGWProcess.h
+++ b/MQTTSNGateway/src/MQTTSNGWProcess.h
@@ -31,11 +31,6 @@ namespace MQTTSNGW
/*=================================
* Parameters
==================================*/
-#define MQTTSNGW_CONFIG_DIRECTORY "./"
-
-#define MQTTSNGW_CONFIG_FILE "gateway.conf"
-#define MQTTSNGW_CLIENT_LIST "clients.conf"
-
#define MQTTSNGW_MAX_TASK 10 // number of Tasks
#define PROCESS_LOG_BUFFER_SIZE 16384 // Ring buffer size for Logs
#define MQTTSNGW_PARAM_MAX 128 // Max length of config records.
@@ -43,12 +38,7 @@ namespace MQTTSNGW
/*=================================
* Macros
==================================*/
-#ifdef RINGBUFFER
#define WRITELOG theProcess->putLog
-#else
-#define WRITELOG printf
-#endif
-
/*=================================
Class Process
@@ -77,6 +67,7 @@ private:
RingBuffer* _rb;
Semaphore* _rbsem;
Mutex _mt;
+ int _log;
char _rbdata[PROCESS_LOG_BUFFER_SIZE + 1];
};
diff --git a/MQTTSNGateway/src/MQTTSNGateway.cpp b/MQTTSNGateway/src/MQTTSNGateway.cpp
index fa90643..1352b6a 100644
--- a/MQTTSNGateway/src/MQTTSNGateway.cpp
+++ b/MQTTSNGateway/src/MQTTSNGateway.cpp
@@ -31,6 +31,17 @@ Gateway::Gateway()
theProcess = this;
_params.loginId = 0;
_params.password = 0;
+ _params.keepAlive = 0;
+ _params.gatewayId = 0;
+ _params.mqttVersion = 0;
+ _params.maxInflightMsgs = 0;
+ _params.gatewayName = 0;
+ _params.brokerName = 0;
+ _params.port = 0;
+ _params.portSecure = 0;
+ _params.rootCApath = 0;
+ _params.rootCAfile = 0;
+ _params.certDirectory = 0;
_packetEventQue.setMaxSize(MAX_INFLIGHTMESSAGES * MAX_CLIENTS);
}
@@ -44,15 +55,71 @@ Gateway::~Gateway()
{
free(_params.password);
}
+ if ( _params.gatewayName )
+ {
+ free(_params.gatewayName);
+ }
+ if ( _params.brokerName )
+ {
+ free(_params.brokerName);
+ }
+ if ( _params.port )
+ {
+ free(_params.port);
+ }
+ if ( _params.portSecure )
+ {
+ free(_params.portSecure);
+ }
+ if ( _params.rootCApath )
+ {
+ free(_params.rootCApath);
+ }
+
+ if ( _params.clientListName )
+ {
+ free(_params.clientListName);
+ }
+ if ( _params.configName )
+ {
+ free(_params.configName);
+ }
}
void Gateway::initialize(int argc, char** argv)
{
char param[MQTTSNGW_PARAM_MAX];
+ string fileName;
MultiTaskProcess::initialize(argc, argv);
resetRingBuffer();
- _params.gatewayId = 0;
+
+ if (getParam("BrokerName", param) == 0)
+ {
+ _params.brokerName = strdup(param);
+ }
+ if (getParam("BrokerPortNo", param) == 0)
+ {
+ _params.port = strdup(param);
+ }
+ if (getParam("BrokerSecurePortNo", param) == 0)
+ {
+ _params.portSecure = strdup(param);
+ }
+
+ if (getParam("CertsDirectory", param) == 0)
+ {
+ _params.certDirectory = strdup(param);
+ }
+ if (getParam("RootCApath", param) == 0)
+ {
+ _params.rootCApath = strdup(param);
+ }
+ if (getParam("RootCAfile", param) == 0)
+ {
+ _params.rootCAfile = strdup(param);
+ }
+
if (getParam("GatewayID", param) == 0)
{
_params.gatewayId = atoi(param);
@@ -65,7 +132,7 @@ void Gateway::initialize(int argc, char** argv)
if (getParam("GatewayName", param) == 0)
{
- _params.gatewayName = (uint8_t*) strdup(param);
+ _params.gatewayName = strdup(param);
}
_params.mqttVersion = DEFAULT_MQTT_VERSION;
@@ -94,17 +161,16 @@ void Gateway::initialize(int argc, char** argv)
if (getParam("LoginID", param) == 0)
{
- _params.loginId = (uint8_t*) strdup(param);
+ _params.loginId = strdup(param);
}
if (getParam("Password", param) == 0)
{
- _params.password = (uint8_t*) strdup(param);
+ _params.password = strdup(param);
}
if (getParam("ClientAuthentication", param) == 0)
{
- string fileName;
if (!strcasecmp(param, "YES"))
{
if (getParam("ClientsList", param) == 0)
@@ -113,15 +179,18 @@ void Gateway::initialize(int argc, char** argv)
}
else
{
- fileName = *getConfigDirName() + string(MQTTSNGW_CLIENT_LIST);
+ fileName = *getConfigDirName() + string(CLIENT_LIST);
}
if (!_clientList.authorize(fileName.c_str()))
{
throw Exception("Gateway::initialize: No client list defined by configuration.");
}
+ _params.clientListName = strdup(fileName.c_str());
}
}
+ fileName = *getConfigDirName() + *getConfigFileName();
+ _params.configName = strdup(fileName.c_str());
}
void Gateway::run(void)
@@ -134,15 +203,19 @@ void Gateway::run(void)
WRITELOG(" *\n%s\n", PAHO_COPYRIGHT3);
WRITELOG("%s\n", GATEWAY_VERSION);
WRITELOG("%s\n", PAHO_COPYRIGHT4);
- WRITELOG("\n%s %s has been started.\n listening on, %s\n", currentDateTime(), _params.gatewayName, _sensorNetwork.getDescription());
-
+ WRITELOG("\n%s %s has been started.\n\n", currentDateTime(), _params.gatewayName);
+ WRITELOG(" ConfigFile: %s\n", _params.configName);
if ( getClientList()->isAuthorized() )
{
- WRITELOG("\nClient authentication is required by the configuration settings.\n\n");
+ WRITELOG(" ClientList: %s\n", _params.clientListName);
}
+ WRITELOG(" SensorN/W: %s\n", _sensorNetwork.getDescription());
+ WRITELOG(" Broker: %s : %s, %s\n", _params.brokerName, _params.port, _params.portSecure);
+ WRITELOG(" RootCApath: %s\n", _params.rootCApath);
+ WRITELOG(" RootCAfile: %s\n", _params.rootCAfile);
+ WRITELOG(" ClientCerts: %s\n", _params.certDirectory);
- /* execute threads & wait StopProcessEvent MQTTSNGWPacketHandleTask posts by CTL-C */
-
+ /* Execute threads and wait StopProcessEvent from MQTTSNGWPacketHandleTask */
MultiTaskProcess::run();
WRITELOG("%s MQTT-SN Gateway stoped\n", currentDateTime());
_lightIndicator.allLightOff();
diff --git a/MQTTSNGateway/src/MQTTSNGateway.h b/MQTTSNGateway/src/MQTTSNGateway.h
index f3e2b4d..ab370e3 100644
--- a/MQTTSNGateway/src/MQTTSNGateway.h
+++ b/MQTTSNGateway/src/MQTTSNGateway.h
@@ -31,7 +31,7 @@ namespace MQTTSNGW
/*=================================
* Starting prompt
==================================*/
-#define GATEWAY_VERSION " * Version: 0.6.0"
+#define GATEWAY_VERSION " * Version: 0.8.0"
#define PAHO_COPYRIGHT0 " * MQTT-SN Transparent Gateway"
#define PAHO_COPYRIGHT1 " * Part of Project Paho in Eclipse"
@@ -145,13 +145,21 @@ private:
*/
typedef struct
{
- uint8_t* loginId;
- uint8_t* password;
+ char* configName;
+ char* clientListName;
+ char* loginId;
+ char* password;
uint16_t keepAlive;
uint8_t gatewayId;
uint8_t mqttVersion;
uint16_t maxInflightMsgs;
- uint8_t* gatewayName;
+ char* gatewayName;
+ char* brokerName;
+ char* port;
+ char* portSecure;
+ char* rootCApath;
+ char* rootCAfile;
+ char* certDirectory;
}GatewayParams;
/*=====================================
diff --git a/MQTTSNGateway/src/linux/Network.cpp b/MQTTSNGateway/src/linux/Network.cpp
index 6d43da7..e7b9790 100644
--- a/MQTTSNGateway/src/linux/Network.cpp
+++ b/MQTTSNGateway/src/linux/Network.cpp
@@ -248,6 +248,7 @@ Network::~Network()
{
if (_ssl)
{
+ SSL_shutdown(_ssl);
SSL_free(_ssl);
_numOfInstance--;
}
@@ -351,7 +352,7 @@ bool Network::connect(const char* host, const char* port, const char* caPath, co
SSL_free(_ssl);
}
- SSL_set_options(_ssl, SSL_OP_NO_TICKET);
+ //SSL_set_options(_ssl, SSL_OP_NO_TICKET);
if ( cert )
{
@@ -535,6 +536,7 @@ int Network::recv(uint8_t* buf, uint16_t len)
case SSL_ERROR_ZERO_RETURN:
SSL_shutdown(_ssl);
_ssl = 0;
+ _numOfInstance--;
TCPStack::close();
_busy = false;
_mutex.unlock();
diff --git a/MQTTSNGateway/src/linux/Threading.cpp b/MQTTSNGateway/src/linux/Threading.cpp
index b6eeb5c..b4f462c 100644
--- a/MQTTSNGateway/src/linux/Threading.cpp
+++ b/MQTTSNGateway/src/linux/Threading.cpp
@@ -236,7 +236,7 @@ void Semaphore::timedwait(uint16_t millsec)
=========================================*/
RingBuffer::RingBuffer()
{
- RingBuffer(MQTTSNGW_CONFIG_DIRECTORY);
+ RingBuffer(MQTTSNGW_KEY_DIRECTORY);
}
RingBuffer::RingBuffer(const char* keyDirectory)
diff --git a/MQTTSNGateway/src/linux/Threading.h b/MQTTSNGateway/src/linux/Threading.h
index 185ce69..2ff3a9f 100644
--- a/MQTTSNGateway/src/linux/Threading.h
+++ b/MQTTSNGateway/src/linux/Threading.h
@@ -23,7 +23,7 @@
namespace MQTTSNGW
{
-
+#define MQTTSNGW_KEY_DIRECTORY "./"
#define MQTTSNGW_RINGBUFFER_KEY "ringbuffer.key"
#define MQTTSNGW_RB_MUTEX_KEY "rbmutex.key"
#define MQTTSNGW_RB_SEMAPHOR_NAME "/rbsemaphor"
diff --git a/MQTTSNGateway/src/linux/Timer.cpp b/MQTTSNGateway/src/linux/Timer.cpp
index e0af9ed..487b50b 100644
--- a/MQTTSNGateway/src/linux/Timer.cpp
+++ b/MQTTSNGateway/src/linux/Timer.cpp
@@ -180,24 +180,30 @@ void LightIndicator::init()
pinMode(LIGHT_INDICATOR_BLUE);
}
-void LightIndicator::lit(int gpioNo, const char* onoff)
+int LightIndicator::lit(int gpioNo, const char* onoff)
{
+ int rc = 0;
if( _gpio[gpioNo] )
{
- write(_gpio[gpioNo], onoff, 1);
+ rc = write(_gpio[gpioNo], onoff, 1);
}
+ return rc;
}
void LightIndicator::pinMode(int gpioNo)
{
- int fd = open("/sys/class/gpio/export", O_WRONLY);
+ int rc = 0;
+ int fd = rc; // eliminate unused warnning of compiler
+
+ fd = open("/sys/class/gpio/export", O_WRONLY);
if ( fd < 0 )
{
return;
}
char no[4];
+
sprintf(no,"%d", gpioNo);
- write(fd, no, strlen(no));
+ rc = write(fd, no, strlen(no));
close(fd);
char fileName[64];
@@ -208,9 +214,8 @@ void LightIndicator::pinMode(int gpioNo)
{
return;
}
- write(fd,"out", 3);
+ rc = write(fd,"out", 3);
close(fd);
-
sprintf( fileName, "/sys/class/gpio/gpio%d/value", gpioNo);
fd = open(fileName, O_WRONLY);
if ( fd > 0 )
diff --git a/MQTTSNGateway/src/linux/Timer.h b/MQTTSNGateway/src/linux/Timer.h
index 21862e9..43885b1 100644
--- a/MQTTSNGateway/src/linux/Timer.h
+++ b/MQTTSNGateway/src/linux/Timer.h
@@ -61,7 +61,7 @@ public:
private:
void init();
- void lit(int gpioNo, const char* onoff);
+ int lit(int gpioNo, const char* onoff);
void pinMode(int gpioNo);
bool _greenStatus;
int _gpio[MAX_GPIO + 1];
diff --git a/MQTTSNGateway/src/linux/udp/SensorNetwork.cpp b/MQTTSNGateway/src/linux/udp/SensorNetwork.cpp
index 9c54d4e..93b2a1e 100644
--- a/MQTTSNGateway/src/linux/udp/SensorNetwork.cpp
+++ b/MQTTSNGateway/src/linux/udp/SensorNetwork.cpp
@@ -141,7 +141,7 @@ int SensorNetwork::initialize(void)
if (theProcess->getParam("GatewayPortNo", param) == 0)
{
unicastPortNo = atoi(param);
- _description += " and Gateway Port ";
+ _description += " Gateway Port ";
_description += param;
}
diff --git a/MQTTSNGateway/src/tests/TestTask.cpp b/MQTTSNGateway/src/tests/TestTask.cpp
index cf1667e..6a95ae3 100644
--- a/MQTTSNGateway/src/tests/TestTask.cpp
+++ b/MQTTSNGateway/src/tests/TestTask.cpp
@@ -39,11 +39,11 @@ void TestTask::run(void)
{
while(true)
{
- printf("Task is running. Enter CTRL+C \n");
if (theProcess->checkSignal() == SIGINT)
{
throw Exception("Terminated by CTL-C");
}
+ printf("Task is running. Enter CTRL+C\n");
sleep(1);
}
}