mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-13 15:36:51 +01:00
BugFix: Que template
Update: Add ProcessFramework test and change Makefile for it. Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -33,14 +33,15 @@ BrokerSecurePortNo=8883
|
||||
ClientAuthentication=NO
|
||||
#ClientsList=/path/to/your_clients.conf
|
||||
|
||||
RootCAfile=/path/to/your_Root_CA.crt
|
||||
RootCApath=/path/to/your_certs_directory/
|
||||
#RootCAfile=/path/to/your_Root_CA.crt
|
||||
#RootCApath=/path/to/your_certs_directory/
|
||||
#CertsDirectory=/path/to/your_client_certs_directory/
|
||||
|
||||
GatewayID=1
|
||||
GatewayName=PahoGateway-01
|
||||
KeepAlive=900
|
||||
#LoginID=
|
||||
#Password=
|
||||
#LoginID=your_ID
|
||||
#Password=your_Password
|
||||
|
||||
# UDP
|
||||
GatewayPortNo=10000
|
||||
@@ -50,6 +51,7 @@ MulticastPortNo=1883
|
||||
# XBee
|
||||
Baudrate=38400
|
||||
SerialDevice=/dev/ttyUSB0
|
||||
ApiMode=2
|
||||
```
|
||||
|
||||
**BrokerName** to specify a domain name of the Broker, and **BrokerPortNo** is a port No of the Broker. **BrokerSecurePortNo** is for TLS connection.
|
||||
|
||||
@@ -20,7 +20,7 @@ BrokerSecurePortNo=8883
|
||||
ClientAuthentication=NO
|
||||
#ClientsList=/path/to/your_clients.conf
|
||||
|
||||
RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
||||
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
||||
#RootCApath=/etc/ssl/certs/
|
||||
#CertsDirectory=/usr/share/GW/IoTcerts/
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ void BrokerRecvTask::run(void)
|
||||
/* post a BrokerRecvEvent */
|
||||
ev = new Event();
|
||||
ev->setBrokerRecvEvent(client, packet);
|
||||
if ( _gateway->getPacketEventQue()->post(ev) == 1 )
|
||||
if ( _gateway->getPacketEventQue()->post(ev) == 0 )
|
||||
{
|
||||
delete ev;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
namespace MQTTSNGW
|
||||
{
|
||||
|
||||
#define ERRNO_APL_03 13 // Task Initialize Error
|
||||
/*=====================================
|
||||
Class BrokerRecvTask
|
||||
=====================================*/
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
namespace MQTTSNGW
|
||||
{
|
||||
#define ERRNO_APL_04 14 // Task Initialize Error
|
||||
/*=====================================
|
||||
Class BrokerSendTask
|
||||
=====================================*/
|
||||
|
||||
@@ -77,7 +77,7 @@ void ClientRecvTask::run()
|
||||
log(0, packet);
|
||||
ev = new Event();
|
||||
ev->setBrodcastEvent(packet);
|
||||
if ( _gateway->getPacketEventQue()->post(ev) == 1 )
|
||||
if ( _gateway->getPacketEventQue()->post(ev) == 0 )
|
||||
{
|
||||
delete ev;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void ClientRecvTask::run()
|
||||
log(client, packet);
|
||||
ev = new Event();
|
||||
ev->setClientRecvEvent(client,packet);
|
||||
if ( _gateway->getPacketEventQue()->post(ev) == 1 )
|
||||
if ( _gateway->getPacketEventQue()->post(ev) == 0 )
|
||||
{
|
||||
delete ev;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void ClientRecvTask::run()
|
||||
client->setClientAddress(_sensorNetwork->getSenderAddress());
|
||||
ev = new Event();
|
||||
ev->setClientRecvEvent(client, packet);
|
||||
if ( _gateway->getPacketEventQue()->post(ev) == 1 )
|
||||
if ( _gateway->getPacketEventQue()->post(ev) == 0 )
|
||||
{
|
||||
delete ev;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <signal.h>
|
||||
#include "MQTTSNGWDefines.h"
|
||||
#include "Threading.h"
|
||||
|
||||
@@ -164,6 +165,7 @@ public:
|
||||
_head = 0;
|
||||
_tail = 0;
|
||||
_cnt = 0;
|
||||
_maxSize = 0;
|
||||
}
|
||||
|
||||
~Que()
|
||||
@@ -212,6 +214,8 @@ public:
|
||||
}
|
||||
|
||||
int post(T* t)
|
||||
{
|
||||
if ( t && ( _maxSize == 0 || size() < _maxSize ))
|
||||
{
|
||||
QueElement<T>* elm = new QueElement<T>(t);
|
||||
if ( _head )
|
||||
@@ -220,6 +224,7 @@ public:
|
||||
{
|
||||
elm->_prev = _tail;
|
||||
_tail = elm;
|
||||
_head->_next = elm;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -236,14 +241,22 @@ public:
|
||||
_cnt++;
|
||||
return _cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int size(void)
|
||||
{
|
||||
return _cnt;
|
||||
}
|
||||
|
||||
void setMaxSize(int maxSize)
|
||||
{
|
||||
_maxSize = maxSize;
|
||||
}
|
||||
|
||||
private:
|
||||
int _cnt;
|
||||
int _maxSize;
|
||||
QueElement<T>* _head;
|
||||
QueElement<T>* _tail;
|
||||
};
|
||||
|
||||
@@ -188,7 +188,7 @@ GatewayParams* Gateway::getGWParams(void)
|
||||
=====================================*/
|
||||
EventQue::EventQue()
|
||||
{
|
||||
_maxSize = 0;
|
||||
|
||||
}
|
||||
|
||||
EventQue::~EventQue()
|
||||
@@ -198,7 +198,7 @@ EventQue::~EventQue()
|
||||
|
||||
void EventQue::setMaxSize(uint16_t maxSize)
|
||||
{
|
||||
_maxSize = maxSize;
|
||||
_que.setMaxSize((int)maxSize);
|
||||
}
|
||||
|
||||
Event* EventQue::wait(void)
|
||||
@@ -245,15 +245,12 @@ Event* EventQue::timedwait(uint16_t millsec)
|
||||
|
||||
int EventQue::post(Event* ev)
|
||||
{
|
||||
if ( ev && ( _maxSize == 0 || size() < _maxSize ) )
|
||||
{
|
||||
int rc = 0;
|
||||
_mutex.lock();
|
||||
_que.post(ev);
|
||||
rc = _que.post(ev);
|
||||
_sem.post();
|
||||
_mutex.unlock();
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int EventQue::size()
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace MQTTSNGW
|
||||
/*=================================
|
||||
* Starting prompt
|
||||
==================================*/
|
||||
#define GATEWAY_VERSION " * Version: 0.5.0"
|
||||
#define GATEWAY_VERSION " * Version: 0.6.0"
|
||||
|
||||
#define PAHO_COPYRIGHT0 " * MQTT-SN Transparent Gateway"
|
||||
#define PAHO_COPYRIGHT1 " * Part of Project Paho in Eclipse"
|
||||
@@ -138,7 +138,6 @@ private:
|
||||
Que<Event> _que;
|
||||
Mutex _mutex;
|
||||
Semaphore _sem;
|
||||
uint16_t _maxSize;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include "MQTTSNGWDefines.h"
|
||||
|
||||
namespace MQTTSNGW
|
||||
{
|
||||
|
||||
@@ -152,6 +152,7 @@ SensorNetAddress* SensorNetwork::getSenderAddress(void)
|
||||
XBee::XBee(){
|
||||
_serialPort = new SerialPort();
|
||||
_respCd = 0;
|
||||
_respId = 0;
|
||||
_dataLen = 0;
|
||||
_frameId = 0;
|
||||
_apiMode = 2;
|
||||
|
||||
@@ -25,18 +25,17 @@ using namespace MQTTSNGW;
|
||||
/*
|
||||
* Gateway Process
|
||||
*/
|
||||
Gateway* gateway = new Gateway();
|
||||
PacketHandleTask* t0 = new PacketHandleTask(gateway);
|
||||
ClientRecvTask* t1 = new ClientRecvTask(gateway);
|
||||
ClientSendTask* t2 = new ClientSendTask(gateway);
|
||||
BrokerRecvTask* t3 = new BrokerRecvTask(gateway);
|
||||
BrokerSendTask* t4 = new BrokerSendTask(gateway);
|
||||
Gateway* gw = new Gateway();
|
||||
PacketHandleTask task1(gw);
|
||||
ClientRecvTask task2(gw);
|
||||
ClientSendTask task3(gw);
|
||||
BrokerRecvTask task4(gw);
|
||||
BrokerSendTask task5(gw);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
gateway->initialize(argc, argv);
|
||||
gateway->run();
|
||||
delete gateway;
|
||||
gw->initialize(argc, argv);
|
||||
gw->run();
|
||||
delete gw;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
151
MQTTSNGateway/src/tests/TestProcessFramework.cpp
Normal file
151
MQTTSNGateway/src/tests/TestProcessFramework.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016, Tomoaki Yamaguchi
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Tomoaki Yamaguchi - initial API and implementation
|
||||
**************************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <cassert>
|
||||
#include "TestProcessFramework.h"
|
||||
#include "MQTTSNGWProcess.h"
|
||||
#include "Timer.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace MQTTSNGW;
|
||||
|
||||
#define ARGV "./testPFW"
|
||||
#define CONFDIR "./"
|
||||
#define CONF "gateway.conf"
|
||||
|
||||
const char* currentDateTime(void);
|
||||
|
||||
TestProcessFramework::TestProcessFramework()
|
||||
{
|
||||
theMultiTaskProcess = this;
|
||||
theProcess = this;
|
||||
}
|
||||
|
||||
TestProcessFramework::~TestProcessFramework()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TestProcessFramework::initialize(int argc, char** argv)
|
||||
{
|
||||
MultiTaskProcess::initialize(argc, argv);
|
||||
assert(0 == strcmp(CONFDIR, getConfigDirName()->c_str()));
|
||||
assert(0 == strcmp(CONF, getConfigFileName()->c_str()));
|
||||
resetRingBuffer();
|
||||
}
|
||||
|
||||
void TestProcessFramework::run(void)
|
||||
{
|
||||
char value[256];
|
||||
int* v = 0;
|
||||
int i = 0;
|
||||
Timer tm;
|
||||
TestQue que;
|
||||
|
||||
assert(1 == getArgc() || 3 == getArgc() );
|
||||
assert(0 == strcmp(ARGV, *getArgv()));
|
||||
getParam("BrokerName", value);
|
||||
assert(0 == strcmp("iot.eclipse.org", value));
|
||||
|
||||
for ( i = 0; i < 1000; i++)
|
||||
{
|
||||
putLog("Test RingBuffer %d ", 1234567890);
|
||||
}
|
||||
putLog("\n\nRingBuffer Test complieted. Enter CTRL+C\n");
|
||||
|
||||
for ( i = 0; i < 10; i++ )
|
||||
{
|
||||
v = new int(i);
|
||||
que.post(v);
|
||||
}
|
||||
assert( 10 == que.size());
|
||||
|
||||
for ( i = 0; i < 10; i++ )
|
||||
{
|
||||
assert(i == *que.front());
|
||||
int* p = que.front();
|
||||
if ( p )
|
||||
{
|
||||
assert(i == *p);
|
||||
que.pop();
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
assert(0 == que.front());
|
||||
assert(0 == que.size());
|
||||
|
||||
que.setMaxSize(5);
|
||||
for ( i = 0; i < 10; i++ )
|
||||
{
|
||||
v = new int(i);
|
||||
que.post(v);
|
||||
assert( 5 >= que.size());
|
||||
}
|
||||
for ( i = 0; i < 10; i++ )
|
||||
{
|
||||
int* p = que.front();
|
||||
if ( p )
|
||||
{
|
||||
que.pop();
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%s Timer start\n", currentDateTime());
|
||||
tm.start(1000);
|
||||
while (!tm.isTimeup());
|
||||
printf("%s Timer 1sec\n", currentDateTime());
|
||||
|
||||
tm.start();
|
||||
while (!tm.isTimeup(1000));
|
||||
printf("%s Timer 1sec\n", currentDateTime());
|
||||
|
||||
MultiTaskProcess::run();
|
||||
printf("ProcessFramework test complited.\n");
|
||||
}
|
||||
|
||||
TestQue::TestQue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TestQue::~TestQue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int* TestQue::front(void)
|
||||
{
|
||||
return _que.front();
|
||||
}
|
||||
void TestQue::pop(void)
|
||||
{
|
||||
_que.pop();
|
||||
}
|
||||
int TestQue::size(void)
|
||||
{
|
||||
return _que.size();
|
||||
}
|
||||
void TestQue::setMaxSize(int maxsize)
|
||||
{
|
||||
_que.setMaxSize(maxsize);
|
||||
}
|
||||
|
||||
void TestQue::post(int* val)
|
||||
{
|
||||
_que.post(val);
|
||||
}
|
||||
50
MQTTSNGateway/src/tests/TestProcessFramework.h
Normal file
50
MQTTSNGateway/src/tests/TestProcessFramework.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016, Tomoaki Yamaguchi
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Tomoaki Yamaguchi - initial API and implementation
|
||||
**************************************************************************************/
|
||||
#ifndef TESTPROCESSFRAMEWORK_H_
|
||||
#define TESTPROCESSFRAMEWORK_H_
|
||||
|
||||
#include "MQTTSNGWProcess.h"
|
||||
|
||||
|
||||
namespace MQTTSNGW
|
||||
{
|
||||
class TestProcessFramework: public MultiTaskProcess{
|
||||
public:
|
||||
TestProcessFramework();
|
||||
~TestProcessFramework();
|
||||
virtual void initialize(int argc, char** argv);
|
||||
void run(void);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
class TestQue
|
||||
{
|
||||
public:
|
||||
TestQue();
|
||||
~TestQue();
|
||||
void post(int*);
|
||||
int* front(void);
|
||||
void pop(void);
|
||||
int size(void);
|
||||
void setMaxSize(int maxsize);
|
||||
private:
|
||||
Que<int> _que;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* TESTPROCESSFRAMEWORK_H_ */
|
||||
49
MQTTSNGateway/src/tests/TestTask.cpp
Normal file
49
MQTTSNGateway/src/tests/TestTask.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016, Tomoaki Yamaguchi
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Tomoaki Yamaguchi - initial API and implementation
|
||||
**************************************************************************************/
|
||||
#include <unistd.h>
|
||||
#include "TestTask.h"
|
||||
#include "Threading.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace MQTTSNGW;
|
||||
|
||||
TestTask::TestTask(TestProcessFramework* proc)
|
||||
{
|
||||
proc->attach((Thread*)this);
|
||||
}
|
||||
|
||||
TestTask::~TestTask()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TestTask::initialize(int argc, char** argv)
|
||||
{
|
||||
printf("Task initialize complite.\n");
|
||||
}
|
||||
|
||||
void TestTask::run(void)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
printf("Task is running. Enter CTRL+C \n");
|
||||
if (theProcess->checkSignal() == SIGINT)
|
||||
{
|
||||
throw Exception("Terminated by CTL-C");
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
42
MQTTSNGateway/src/tests/TestTask.h
Normal file
42
MQTTSNGateway/src/tests/TestTask.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016, Tomoaki Yamaguchi
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Tomoaki Yamaguchi - initial API and implementation
|
||||
**************************************************************************************/
|
||||
#ifndef TESTTASK_H_
|
||||
#define TESTTASK_H_
|
||||
|
||||
#include "Threading.h"
|
||||
#include "TestProcessFramework.h"
|
||||
|
||||
namespace MQTTSNGW
|
||||
{
|
||||
|
||||
class TestTask: public Thread
|
||||
{
|
||||
MAGIC_WORD_FOR_THREAD;
|
||||
;
|
||||
public:
|
||||
TestTask(TestProcessFramework* proc);
|
||||
~TestTask();
|
||||
void initialize(int argc, char** argv);
|
||||
void run(void);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* TESTTASK_H_ */
|
||||
31
MQTTSNGateway/src/tests/mainTestProcessFramework.cpp
Normal file
31
MQTTSNGateway/src/tests/mainTestProcessFramework.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/**************************************************************************************
|
||||
* Copyright (c) 2016, Tomoaki Yamaguchi
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Tomoaki Yamaguchi - initial API and implementation
|
||||
**************************************************************************************/
|
||||
#include "TestProcessFramework.h"
|
||||
#include "TestTask.h"
|
||||
|
||||
using namespace MQTTSNGW;
|
||||
|
||||
TestProcessFramework* proc = new TestProcessFramework();
|
||||
TestTask* task = new TestTask(proc);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
proc->initialize(argc, argv);
|
||||
proc->run();
|
||||
delete proc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
41
Makefile
41
Makefile
@@ -4,6 +4,9 @@ APPL := mainGateway
|
||||
LPROGNAME := MQTT-SNLogmonitor
|
||||
LAPPL := mainLogmonitor
|
||||
|
||||
TESTPROGNAME := testPFW
|
||||
TESTAPPL := mainTestProcessFramework
|
||||
|
||||
CONFIG := MQTTSNGateway/gateway.conf
|
||||
CLIENTS := MQTTSNGateway/clients.conf
|
||||
|
||||
@@ -12,6 +15,7 @@ SUBDIR := MQTTSNPacket/src
|
||||
|
||||
OS := linux
|
||||
SENSORNET := udp
|
||||
TEST := tests
|
||||
|
||||
CPPSRCS := \
|
||||
$(SRCDIR)/MQTTGWConnectionHandler.cpp \
|
||||
@@ -34,7 +38,10 @@ $(SRCDIR)/MQTTSNGWSubscribeHandler.cpp \
|
||||
$(SRCDIR)/$(OS)/$(SENSORNET)/SensorNetwork.cpp \
|
||||
$(SRCDIR)/$(OS)/Timer.cpp \
|
||||
$(SRCDIR)/$(OS)/Network.cpp \
|
||||
$(SRCDIR)/$(OS)/Threading.cpp
|
||||
$(SRCDIR)/$(OS)/Threading.cpp \
|
||||
$(SRCDIR)/$(TEST)/TestProcessFramework.cpp \
|
||||
$(SRCDIR)/$(TEST)/TestTask.cpp
|
||||
|
||||
|
||||
CSRCS := $(SUBDIR)/MQTTSNConnectClient.c \
|
||||
$(SUBDIR)/MQTTSNConnectServer.c \
|
||||
@@ -51,13 +58,14 @@ $(SUBDIR)/MQTTSNUnsubscribeServer.c
|
||||
CXX := g++
|
||||
CPPFLAGS +=
|
||||
|
||||
INCLUDES += -IMQTTSNGateway/src \
|
||||
-IMQTTSNGateway/src/$(OS) \
|
||||
-IMQTTSNGateway/src/$(OS)/$(SENSORNET) \
|
||||
-IMQTTSNPacket/src
|
||||
INCLUDES += -I$(SRCDIR) \
|
||||
-I$(SRCDIR)/$(OS) \
|
||||
-I$(SRCDIR)/$(OS)/$(SENSORNET) \
|
||||
-I$(SUBDIR) \
|
||||
-I$(SRCDIR)/$(TEST)
|
||||
|
||||
DEFS :=
|
||||
LIBS +=
|
||||
LIBS += -L/usr/local/lib
|
||||
LDFLAGS :=
|
||||
CXXFLAGS := -Wall -O3 -std=c++11
|
||||
LDADD := -lpthread -lssl -lcrypto
|
||||
@@ -65,17 +73,22 @@ OUTDIR := Build
|
||||
|
||||
PROG := $(OUTDIR)/$(PROGNAME)
|
||||
LPROG := $(OUTDIR)/$(LPROGNAME)
|
||||
TPROG := $(OUTDIR)/$(TESTPROGNAME)
|
||||
|
||||
OBJS := $(CPPSRCS:%.cpp=$(OUTDIR)/%.o)
|
||||
OBJS += $(CSRCS:%.c=$(OUTDIR)/%.o)
|
||||
DEPS := $(CPPSRCS:%.cpp=$(OUTDIR)/%.d)
|
||||
DEPS += $(CSRCS:%.c=$(OUTDIR)/%.d)
|
||||
|
||||
.PHONY: install clean
|
||||
.PHONY: install clean exectest
|
||||
|
||||
all: $(PROG) $(LPROG)
|
||||
all: $(PROG) $(LPROG) $(TPROG)
|
||||
|
||||
monitor: $(LPROG)
|
||||
|
||||
test: $(TPROG) $(LPROG) exectest
|
||||
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
$(PROG): $(OBJS) $(OUTDIR)/$(SRCDIR)/$(APPL).o
|
||||
@@ -84,6 +97,10 @@ $(PROG): $(OBJS) $(OUTDIR)/$(SRCDIR)/$(APPL).o
|
||||
$(LPROG): $(OBJS) $(OUTDIR)/$(SRCDIR)/$(LAPPL).o
|
||||
$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS) $(LDADD)
|
||||
|
||||
$(TPROG): $(OBJS) $(OUTDIR)/$(SRCDIR)/$(TEST)/$(TESTAPPL).o
|
||||
$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS) $(LDADD)
|
||||
|
||||
|
||||
$(OUTDIR)/$(SRCDIR)/%.o:$(SRCDIR)/%.cpp
|
||||
@if [ ! -e `dirname $@` ]; then mkdir -p `dirname $@`; fi
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) $(DEFS) -o $@ -c -MMD -MP -MF $(@:%.o=%.d) $<
|
||||
@@ -92,6 +109,10 @@ $(OUTDIR)/$(SRCDIR)/$(APPL).o:$(SRCDIR)/$(APPL).cpp
|
||||
@if [ ! -e `dirname $@` ]; then mkdir -p `dirname $@`; fi
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) $(DEFS) -o $@ -c -MMD -MP -MF $(@:%.o=%.d) $<
|
||||
|
||||
$(OUTDIR)/$(SRCDIR)/$(TEST)/$(TESTAPPL).o:$(SRCDIR)/$(TEST)/$(TESTAPPL).cpp
|
||||
@if [ ! -e `dirname $@` ]; then mkdir -p `dirname $@`; fi
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) $(DEFS) -o $@ -c -MMD -MP -MF $(@:%.o=%.d) $<
|
||||
|
||||
$(OUTDIR)/$(SRCDIR)/$(LAPPL).o:$(SRCDIR)/$(LAPPL).cpp
|
||||
@if [ ! -e `dirname $@` ]; then mkdir -p `dirname $@`; fi
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) $(DEFS) -o $@ -c -MMD -MP -MF $(@:%.o=%.d) $<
|
||||
@@ -109,4 +130,8 @@ install:
|
||||
cp -pf $(CONFIG) ../
|
||||
cp -pf $(CLIENTS) ../
|
||||
|
||||
exectest:
|
||||
cp -pf $(CONFIG) $(OUTDIR)
|
||||
cd $(OUTDIR); ./$(TESTPROGNAME) -f ./gateway.conf
|
||||
|
||||
|
||||
Reference in New Issue
Block a user