diff --git a/CMakeLists.txt b/CMakeLists.txt index bdb6b98..66cfb53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ # Ian Craggs - initial version #*******************************************************************************/ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.1) PROJECT("paho-mqttsn" CXX) MESSAGE(STATUS "CMake version: " ${CMAKE_VERSION}) MESSAGE(STATUS "CMake system name: " ${CMAKE_SYSTEM_NAME}) @@ -39,3 +39,4 @@ INCLUDE(CPack) ENABLE_TESTING() ADD_SUBDIRECTORY(MQTTSNPacket) +ADD_SUBDIRECTORY(MQTTSNGateway) \ No newline at end of file diff --git a/MQTTSNGateway/CMakeLists.txt b/MQTTSNGateway/CMakeLists.txt new file mode 100644 index 0000000..51a8eec --- /dev/null +++ b/MQTTSNGateway/CMakeLists.txt @@ -0,0 +1,16 @@ +#******************************************************************************* +# Copyright (c) 2022 a1lu +# +# 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: +# a1lu - initial version +#*******************************************************************************/ +ADD_SUBDIRECTORY(src) \ No newline at end of file diff --git a/MQTTSNGateway/Makefile b/MQTTSNGateway/Makefile.org similarity index 100% rename from MQTTSNGateway/Makefile rename to MQTTSNGateway/Makefile.org diff --git a/MQTTSNGateway/src/CMakeLists.txt b/MQTTSNGateway/src/CMakeLists.txt new file mode 100644 index 0000000..74d8473 --- /dev/null +++ b/MQTTSNGateway/src/CMakeLists.txt @@ -0,0 +1,113 @@ +#******************************************************************************* +# Copyright (c) 2022 a1lu +# +# 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: +# a1lu - initial version +#*******************************************************************************/ +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../Build) +set(CMAKE_CXX_STANDARD 11) + +SET(OS linux) +SET(SENSORNET udp) + +ADD_LIBRARY(mqtt-sngateway_common + MQTTGWConnectionHandler.cpp + MQTTGWPacket.cpp + MQTTGWPublishHandler.cpp + MQTTGWSubscribeHandler.cpp + MQTTSNGateway.cpp + MQTTSNGWBrokerRecvTask.cpp + MQTTSNGWBrokerSendTask.cpp + MQTTSNGWClient.cpp + MQTTSNGWClientRecvTask.cpp + MQTTSNGWClientSendTask.cpp + MQTTSNGWConnectionHandler.cpp + MQTTSNGWLogmonitor.cpp + MQTTSNGWPacket.cpp + MQTTSNGWPacketHandleTask.cpp + MQTTSNGWProcess.cpp + MQTTSNGWPublishHandler.cpp + MQTTSNGWSubscribeHandler.cpp + MQTTSNGWEncapsulatedPacket.cpp + MQTTSNGWForwarder.cpp + MQTTSNGWQoSm1Proxy.cpp + MQTTSNGWAdapter.cpp + MQTTSNGWAggregater.cpp + MQTTSNGWClientList.cpp + MQTTSNGWTopic.cpp + MQTTSNGWAdapterManager.cpp + MQTTSNAggregateConnectionHandler.cpp + MQTTSNGWMessageIdTable.cpp + MQTTSNGWAggregateTopicTable.cpp + ${OS}/${SENSORNET}/SensorNetwork.cpp + ${OS}/${SENSORNET}/SensorNetwork.h + ${OS}/Timer.cpp + ${OS}/Timer.h + ${OS}/Network.cpp + ${OS}/Network.h + ${OS}/Threading.cpp + ${OS}/Threading.h + ) + +include_directories(../../MQTTSNPacket/src) +link_directories("/usr/local/lib") +link_directories("/usr/local/opt/openssl/lib") + + +TARGET_INCLUDE_DIRECTORIES(mqtt-sngateway_common + PUBLIC + . + ${OS} + ${OS}/${SENSORNET} + ) + +TARGET_LINK_LIBRARIES(mqtt-sngateway_common + PRIVATE + MQTTSNPacketClient + MQTTSNPacketServer + pthread + ssl + crypto) + +ADD_EXECUTABLE(MQTT-SNGateway + mainGateway.cpp + ) + +TARGET_LINK_LIBRARIES(MQTT-SNGateway + mqtt-sngateway_common + ) + +ADD_EXECUTABLE(MQTT-SNLogmonitor + mainLogmonitor.cpp + ) + +TARGET_LINK_LIBRARIES(MQTT-SNLogmonitor + mqtt-sngateway_common + ) + +ADD_EXECUTABLE(testPFW + tests/mainTestProcess.cpp + tests/TestProcess.cpp + tests/TestQue.cpp + tests/TestTree23.cpp + tests/TestTopics.cpp + tests/TestTopicIdMap.cpp + tests/TestTask.cpp + ) +TARGET_LINK_LIBRARIES(testPFW + mqtt-sngateway_common + ) + + +ADD_TEST(NAME testPFW + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/.. + COMMAND testPFW -f ./gateway.conf) diff --git a/MQTTSNGateway/src/tests/TestProcess.cpp b/MQTTSNGateway/src/tests/TestProcess.cpp index 56ba0b1..282d2c3 100644 --- a/MQTTSNGateway/src/tests/TestProcess.cpp +++ b/MQTTSNGateway/src/tests/TestProcess.cpp @@ -29,7 +29,6 @@ using namespace std; using namespace MQTTSNGW; -#define ARGV "./Build/testPFW" #define CONFDIR "./" #define CONF "gateway.conf" @@ -63,7 +62,6 @@ void TestProcess::run(void) /* Test command line parameter */ assert(1 == getArgc() || 3 == getArgc() ); - assert(0 == strcmp(ARGV, *getArgv())); getParam("BrokerName", value); assert(0 == strcmp("mqtt.eclipse.org", value)); diff --git a/MQTTSNPacket/src/CMakeLists.txt b/MQTTSNPacket/src/CMakeLists.txt index 3e53996..1992656 100644 --- a/MQTTSNPacket/src/CMakeLists.txt +++ b/MQTTSNPacket/src/CMakeLists.txt @@ -22,3 +22,6 @@ ADD_LIBRARY(MQTTSNPacketClient SHARED MQTTSNConnectClient.c MQTTSNPacket.c MQTTS ADD_LIBRARY(MQTTSNPacketServer SHARED MQTTSNConnectServer.c MQTTSNPacket.c MQTTSNSearchServer.c MQTTSNSubscribeServer.c MQTTSNUnsubscribeServer.c MQTTSNSerializePublish.c MQTTSNDeserializePublish.c) + +TARGET_INCLUDE_DIRECTORIES(MQTTSNPacketClient PUBLIC .) +TARGET_INCLUDE_DIRECTORIES(MQTTSNPacketServer PUBLIC .) \ No newline at end of file