mirror of https://github.com/eclipse/paho.mqtt.c
Merge branch 'develop' - all 1.1.0 changes
This commit is contained in:
commit
83cc318c96
57
.cproject
57
.cproject
|
|
@ -5,12 +5,12 @@
|
|||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.2116872643" moduleId="org.eclipse.cdt.core.settings" name="debug-native">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
|
|
@ -38,6 +38,17 @@
|
|||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<fileInfo id="cdt.managedbuild.toolchain.gnu.base.2116872643.660980254" name="mqttclient_module.c" rcbsApplicability="disable" resourcePath="test/python/mqttclient_module.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.base.919295913.892752676">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.919295913.892752676" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base.919295913">
|
||||
<option id="gnu.c.compiler.option.include.paths.1043418401" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/include/python2.6"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1471037566" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
|
|
@ -46,12 +57,12 @@
|
|||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.2116872643.128299804" moduleId="org.eclipse.cdt.core.settings" name="debug-x86-linux">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
|
|
@ -79,6 +90,14 @@
|
|||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<fileInfo id="cdt.managedbuild.toolchain.gnu.base.2116872643.128299804.44392871" name="mqttclient_module.c" rcbsApplicability="disable" resourcePath="test/python/mqttclient_module.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.base.1542253543.1236301446">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1542253543.1236301446" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base.1542253543">
|
||||
<option id="gnu.c.compiler.option.include.paths.387085861" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/include/python2.6/"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.912266645" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
|
|
@ -87,12 +106,12 @@
|
|||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.2116872643.1588218084" moduleId="org.eclipse.cdt.core.settings" name="debug-arm-linux-gnueabihf">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
|
|
@ -120,6 +139,14 @@
|
|||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<fileInfo id="cdt.managedbuild.toolchain.gnu.base.2116872643.1588218084.1410045178" name="mqttclient_module.c" rcbsApplicability="disable" resourcePath="test/python/mqttclient_module.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.base.1805700752.404015131">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1805700752.404015131" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base.1805700752">
|
||||
<option id="gnu.c.compiler.option.include.paths.253579949" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/include/python2.6/"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.987997893" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
|
|
@ -128,9 +155,6 @@
|
|||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="org.eclipse.paho.mqtt.c.null.1335713239" name="org.eclipse.paho.mqtt.c"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Default">
|
||||
|
|
@ -144,4 +168,25 @@
|
|||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.2116872643.128299804;cdt.managedbuild.toolchain.gnu.base.2116872643.128299804.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1478312340;cdt.managedbuild.tool.gnu.cpp.compiler.input.1918693642">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.2116872643.128299804;cdt.managedbuild.toolchain.gnu.base.2116872643.128299804.;cdt.managedbuild.tool.gnu.c.compiler.base.1542253543;cdt.managedbuild.tool.gnu.c.compiler.input.273102950">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.2116872643.1588218084;cdt.managedbuild.toolchain.gnu.base.2116872643.1588218084.;cdt.managedbuild.tool.gnu.c.compiler.base.1805700752;cdt.managedbuild.tool.gnu.c.compiler.input.892553453">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.2116872643;cdt.managedbuild.toolchain.gnu.base.2116872643.2105697674;cdt.managedbuild.tool.gnu.cpp.compiler.base.2093522624;cdt.managedbuild.tool.gnu.cpp.compiler.input.58852055">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.2116872643.1588218084;cdt.managedbuild.toolchain.gnu.base.2116872643.1588218084.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1005171182;cdt.managedbuild.tool.gnu.cpp.compiler.input.1367844459">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.2116872643;cdt.managedbuild.toolchain.gnu.base.2116872643.2105697674;cdt.managedbuild.tool.gnu.c.compiler.base.919295913;cdt.managedbuild.tool.gnu.c.compiler.input.873628110">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/dep/
|
||||
/build/output/
|
||||
/build/
|
||||
*.swp
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
[gerrit]
|
||||
host=git.eclipse.org
|
||||
port=29418
|
||||
project=paho/org.eclipse.paho.mqtt.c
|
||||
defaultbranch=develop
|
||||
6
.project
6
.project
|
|
@ -5,6 +5,11 @@
|
|||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
|
|
@ -23,5 +28,6 @@
|
|||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
</pydev_project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
language: c
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
script:
|
||||
- make
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2015 logi.cals GmbH
|
||||
#
|
||||
# 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:
|
||||
# Rainer Poisel - initial version
|
||||
#*******************************************************************************/
|
||||
|
||||
# Note: on OS X you should install XCode and the associated command-line tools
|
||||
|
||||
PROJECT("paho" C)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
|
||||
|
||||
## build settings
|
||||
SET(PAHO_VERSION_MAJOR 1)
|
||||
SET(PAHO_VERSION_MINOR 0)
|
||||
SET(PAHO_VERSION_PATCH 3)
|
||||
SET(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH})
|
||||
|
||||
EXECUTE_PROCESS(COMMAND date -u OUTPUT_VARIABLE BUILD_TIMESTAMP)
|
||||
STRING(STRIP ${BUILD_TIMESTAMP} BUILD_TIMESTAMP)
|
||||
|
||||
## build options
|
||||
SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ")
|
||||
SET(PAHO_BUILD_DOCUMENTATION FALSE CACHE BOOL "Create and install the HTML based API documentation (requires Doxygen)")
|
||||
SET(PAHO_BUILD_SAMPLES FALSE CACHE BOOL "Build sample programs")
|
||||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
IF(PAHO_BUILD_SAMPLES)
|
||||
ADD_SUBDIRECTORY(src/samples)
|
||||
ENDIF()
|
||||
|
||||
IF(PAHO_BUILD_DOCUMENTATION)
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
ENDIF()
|
||||
|
||||
### packaging settings
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
SET(CPACK_GENERATOR "ZIP")
|
||||
ELSE()
|
||||
SET(CPACK_GENERATOR "TGZ")
|
||||
ENDIF()
|
||||
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR})
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR ${PAHO_VERSION_MINOR})
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH ${PAHO_VERSION_PATCH})
|
||||
INCLUDE(CPack)
|
||||
69
Makefile
69
Makefile
|
|
@ -1,5 +1,5 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2009, 2015 IBM Corp.
|
||||
# Copyright (c) 2009, 2016 IBM Corp.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -24,7 +24,7 @@ SHELL = /bin/sh
|
|||
.PHONY: clean, mkdir, install, uninstall, html
|
||||
|
||||
ifndef release.version
|
||||
release.version = 1.0.3
|
||||
release.version = 1.1.0
|
||||
endif
|
||||
|
||||
# determine current platform
|
||||
|
|
@ -50,6 +50,18 @@ ifndef blddir
|
|||
blddir = build/output
|
||||
endif
|
||||
|
||||
ifndef blddir_work
|
||||
blddir_work = build
|
||||
endif
|
||||
|
||||
ifndef docdir
|
||||
docdir = $(blddir)/doc
|
||||
endif
|
||||
|
||||
ifndef docdir_work
|
||||
docdir_work = $(blddir)/../doc
|
||||
endif
|
||||
|
||||
ifndef prefix
|
||||
prefix = /usr/local
|
||||
endif
|
||||
|
|
@ -72,19 +84,19 @@ HEADERS = $(srcdir)/*.h
|
|||
HEADERS_C = $(filter-out $(srcdir)/MQTTAsync.h, $(HEADERS))
|
||||
HEADERS_A = $(HEADERS)
|
||||
|
||||
SAMPLE_FILES_C = stdinpub stdoutsub pubsync pubasync subasync
|
||||
SAMPLE_FILES_C = paho_cs_pub paho_cs_sub MQTTClient_publish MQTTClient_publish_async MQTTClient_subscribe
|
||||
SYNC_SAMPLES = ${addprefix ${blddir}/samples/,${SAMPLE_FILES_C}}
|
||||
|
||||
SAMPLE_FILES_A = stdoutsuba MQTTAsync_subscribe MQTTAsync_publish
|
||||
SAMPLE_FILES_A = paho_c_pub paho_c_sub MQTTAsync_subscribe MQTTAsync_publish
|
||||
ASYNC_SAMPLES = ${addprefix ${blddir}/samples/,${SAMPLE_FILES_A}}
|
||||
|
||||
TEST_FILES_C = test1 sync_client_test test_mqtt4sync
|
||||
TEST_FILES_C = test1 test2 sync_client_test test_mqtt4sync
|
||||
SYNC_TESTS = ${addprefix ${blddir}/test/,${TEST_FILES_C}}
|
||||
|
||||
TEST_FILES_CS = test3
|
||||
SYNC_SSL_TESTS = ${addprefix ${blddir}/test/,${TEST_FILES_CS}}
|
||||
|
||||
TEST_FILES_A = test4 test_mqtt4async
|
||||
TEST_FILES_A = test4 test9 test_mqtt4async
|
||||
ASYNC_TESTS = ${addprefix ${blddir}/test/,${TEST_FILES_A}}
|
||||
|
||||
TEST_FILES_AS = test5
|
||||
|
|
@ -115,7 +127,7 @@ MQTTLIB_A_TARGET = ${blddir}/lib${MQTTLIB_A}.so.${VERSION}
|
|||
MQTTLIB_AS_TARGET = ${blddir}/lib${MQTTLIB_AS}.so.${VERSION}
|
||||
MQTTVERSION_TARGET = ${blddir}/MQTTVersion
|
||||
|
||||
CCFLAGS_SO = -g -fPIC $(CFLAGS) -Os -Wall -fvisibility=hidden
|
||||
CCFLAGS_SO = -g -fPIC $(CFLAGS) -Os -Wall -fvisibility=hidden -I$(blddir_work)
|
||||
FLAGS_EXE = $(LDFLAGS) -I ${srcdir} -lpthread -L ${blddir}
|
||||
FLAGS_EXES = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -lpthread -lssl -lcrypto ${END_GROUP} -L ${blddir}
|
||||
|
||||
|
|
@ -125,9 +137,11 @@ LDFLAGS_CS = $(LDFLAGS) -shared $(START_GROUP) -lpthread $(EXTRA_LIB) -lssl -lcr
|
|||
LDFLAGS_A = $(LDFLAGS) -shared -Wl,-init,$(MQTTASYNC_INIT) -lpthread
|
||||
LDFLAGS_AS = $(LDFLAGS) -shared $(START_GROUP) -lpthread $(EXTRA_LIB) -lssl -lcrypto $(END_GROUP) -Wl,-init,$(MQTTASYNC_INIT)
|
||||
|
||||
ifeq ($(OSTYPE),Linux)
|
||||
SED_COMMAND = sed \
|
||||
-e "s/@CLIENT_VERSION@/${release.version}/g" \
|
||||
-e "s/@BUILD_TIMESTAMP@/${build.level}/g"
|
||||
|
||||
SED_COMMAND = sed -i "s/\#\#MQTTCLIENT_VERSION_TAG\#\#/${release.version}/g; s/\#\#MQTTCLIENT_BUILD_TAG\#\#/${build.level}/g"
|
||||
ifeq ($(OSTYPE),Linux)
|
||||
|
||||
MQTTCLIENT_INIT = MQTTClient_init
|
||||
MQTTASYNC_INIT = MQTTAsync_init
|
||||
|
|
@ -143,8 +157,6 @@ LDFLAGS_AS += -Wl,-soname,lib${MQTTLIB_AS}.so.${MAJOR_VERSION} -Wl,-no-whole-arc
|
|||
|
||||
else ifeq ($(OSTYPE),Darwin)
|
||||
|
||||
SED_COMMAND = sed -i "" -e "s/\#\#MQTTCLIENT_VERSION_TAG\#\#/${release.version}/g" -e "s/\#\#MQTTCLIENT_BUILD_TAG\#\#/${build.level}/g"
|
||||
|
||||
MQTTCLIENT_INIT = _MQTTClient_init
|
||||
MQTTASYNC_INIT = _MQTTAsync_init
|
||||
START_GROUP =
|
||||
|
|
@ -173,7 +185,7 @@ mkdir:
|
|||
echo OSTYPE is $(OSTYPE)
|
||||
|
||||
${SYNC_TESTS}: ${blddir}/test/%: ${srcdir}/../test/%.c $(MQTTLIB_C_TARGET)
|
||||
${CC} -g -o $@ $< -l${MQTTLIB_C} ${FLAGS_EXE}
|
||||
${CC} -DNOSTACKTRACE $(srcdir)/Thread.c -g -o $@ $< -l${MQTTLIB_C} ${FLAGS_EXE}
|
||||
|
||||
${SYNC_SSL_TESTS}: ${blddir}/test/%: ${srcdir}/../test/%.c $(MQTTLIB_CS_TARGET)
|
||||
${CC} -g -o $@ $< -l${MQTTLIB_CS} ${FLAGS_EXES}
|
||||
|
|
@ -190,26 +202,25 @@ ${SYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/samples/%.c $(MQTTLIB_C_TARGET)
|
|||
${ASYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/samples/%.c $(MQTTLIB_A_TARGET)
|
||||
${CC} -o $@ $< -l${MQTTLIB_A} ${FLAGS_EXE}
|
||||
|
||||
${MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C}
|
||||
$(SED_COMMAND) $(srcdir)/MQTTClient.c
|
||||
$(blddir_work)/VersionInfo.h: $(srcdir)/VersionInfo.h.in
|
||||
$(SED_COMMAND) $< > $@
|
||||
|
||||
${MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C} $(blddir_work)/VersionInfo.h
|
||||
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_C} ${LDFLAGS_C}
|
||||
-ln -s lib$(MQTTLIB_C).so.${VERSION} ${blddir}/lib$(MQTTLIB_C).so.${MAJOR_VERSION}
|
||||
-ln -s lib$(MQTTLIB_C).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_C).so
|
||||
|
||||
${MQTTLIB_CS_TARGET}: ${SOURCE_FILES_CS} ${HEADERS_C}
|
||||
$(SED_COMMAND) $(srcdir)/MQTTClient.c
|
||||
${MQTTLIB_CS_TARGET}: ${SOURCE_FILES_CS} ${HEADERS_C} $(blddir_work)/VersionInfo.h
|
||||
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_CS} -DOPENSSL ${LDFLAGS_CS}
|
||||
-ln -s lib$(MQTTLIB_CS).so.${VERSION} ${blddir}/lib$(MQTTLIB_CS).so.${MAJOR_VERSION}
|
||||
-ln -s lib$(MQTTLIB_CS).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_CS).so
|
||||
|
||||
${MQTTLIB_A_TARGET}: ${SOURCE_FILES_A} ${HEADERS_A}
|
||||
$(SED_COMMAND) $(srcdir)/MQTTAsync.c
|
||||
${MQTTLIB_A_TARGET}: ${SOURCE_FILES_A} ${HEADERS_A} $(blddir_work)/VersionInfo.h
|
||||
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_A} ${LDFLAGS_A}
|
||||
-ln -s lib$(MQTTLIB_A).so.${VERSION} ${blddir}/lib$(MQTTLIB_A).so.${MAJOR_VERSION}
|
||||
-ln -s lib$(MQTTLIB_A).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_A).so
|
||||
|
||||
${MQTTLIB_AS_TARGET}: ${SOURCE_FILES_AS} ${HEADERS_A}
|
||||
$(SED_COMMAND) $(srcdir)/MQTTAsync.c
|
||||
${MQTTLIB_AS_TARGET}: ${SOURCE_FILES_AS} ${HEADERS_A} $(blddir_work)/VersionInfo.h
|
||||
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_AS} -DOPENSSL ${LDFLAGS_AS}
|
||||
-ln -s lib$(MQTTLIB_AS).so.${VERSION} ${blddir}/lib$(MQTTLIB_AS).so.${MAJOR_VERSION}
|
||||
-ln -s lib$(MQTTLIB_AS).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_AS).so
|
||||
|
|
@ -252,8 +263,18 @@ uninstall:
|
|||
rm $(DESTDIR)${includedir}/MQTTClient.h
|
||||
rm $(DESTDIR)${includedir}/MQTTClientPersistence.h
|
||||
|
||||
REGEX_DOXYGEN := \
|
||||
's;@PROJECT_SOURCE_DIR@/src/\?;;' \
|
||||
's;@PROJECT_SOURCE_DIR@;..;' \
|
||||
's;@CMAKE_CURRENT_BINARY_DIR@;../build/output;'
|
||||
SED_DOXYGEN := $(foreach sed_exp,$(REGEX_DOXYGEN),-e $(sed_exp))
|
||||
define process_doxygen
|
||||
cd ${srcdir}; sed $(SED_DOXYGEN) ../doc/${1}.in > ../$(docdir_work)/${1}
|
||||
cd ${srcdir}; $(DOXYGEN_COMMAND) ../$(docdir_work)/${1}
|
||||
endef
|
||||
html:
|
||||
-mkdir -p ${blddir}/doc
|
||||
cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3ClientAPI
|
||||
cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3AsyncAPI
|
||||
cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3ClientInternal
|
||||
-mkdir -p $(docdir_work)
|
||||
-mkdir -p ${docdir}
|
||||
$(call process_doxygen,DoxyfileV3ClientAPI)
|
||||
$(call process_doxygen,DoxyfileV3AsyncAPI)
|
||||
$(call process_doxygen,DoxyfileV3ClientInternal)
|
||||
|
|
|
|||
122
README.md
122
README.md
|
|
@ -7,34 +7,114 @@ This code builds libraries which enable applications to connect to an [MQTT](htt
|
|||
|
||||
Both synchronous and asynchronous modes of operation are supported.
|
||||
|
||||
## Build requirements / compilation
|
||||
## Build requirements / compilation using CMake
|
||||
|
||||
The build process requires GNU Make and gcc, and also requires OpenSSL libraries and includes to be available. There are make rules for a number of Linux "flavors" including ARM and s390, OS X, AIX and Solaris.
|
||||
There build process currently supports a number of Linux "flavors" including ARM and s390, OS X, AIX and Solaris as well as the Windows operating system. The build process requires the following tools:
|
||||
* CMake (http://cmake.org)
|
||||
* Ninja (https://martine.github.io/ninja/; preferred) or
|
||||
GNU Make (https://www.gnu.org/software/make/), and
|
||||
* gcc (https://gcc.gnu.org/).
|
||||
|
||||
The documentation requires doxygen and optionally graphviz.
|
||||
|
||||
Before compiling, set some environment variables (or pass these values to the make command directly) in order to configure library locations and other options.
|
||||
|
||||
Specify the location of OpenSSL using `SSL_DIR`
|
||||
|
||||
e.g. using [homebrew](http://mxcl.github.com/homebrew/) on OS X:
|
||||
|
||||
`export SSL_DIR=/usr/local/Cellar/openssl/1.0.1e`
|
||||
|
||||
Specify where the source files are in relation to where the make command is being executed.
|
||||
|
||||
``export MQTTCLIENT_DIR=../src``
|
||||
|
||||
To build the samples, enable the option (`BUILD_SAMPLES`), and specify the location of the code:
|
||||
On Debian based systems this would mean that the following packages have to be installed:
|
||||
|
||||
```
|
||||
export BUILD_SAMPLES=YES
|
||||
export SAMPLES_DIR=../src/samples
|
||||
apt-get install build-essential gcc make cmake cmake-gui cmake-curses-gui
|
||||
```
|
||||
Ninja can be downloaded from its github project page in the "releases" section. Optionally it is possible to build binaries with SSL support. This requires the OpenSSL libraries and includes to be available. E. g. on Debian:
|
||||
|
||||
```
|
||||
apt-get install libssl-dev
|
||||
```
|
||||
|
||||
One more useful environment variable is ``TARGET_PLATFORM``. This provides for cross-compilation. Currently the only recognised value is "Arm" - for instance to cross-compile a Linux ARM version of the libraries:
|
||||
The documentation requires doxygen and optionally graphviz:
|
||||
|
||||
``export TARGET_PLATFORM=Arm``
|
||||
```
|
||||
apt-get install doxygen graphviz
|
||||
```
|
||||
|
||||
Before compiling, determine the value of some variables in order to configure features, library locations, and other options:
|
||||
|
||||
Variable | Default Value | Description
|
||||
------------ | ------------- | -------------
|
||||
PAHO_WITH_SSL | FALSE | Flag that defines whether to build ssl-enabled binaries too.
|
||||
OPENSSL_INC_SEARCH_PATH | "" (system default) | Directory containing OpenSSL includes
|
||||
OPENSSL_LIB_SEARCH_PATH | "" (system default) | Directory containing OpenSSL libraries
|
||||
PAHO_BUILD_DOCUMENTATION | FALSE | Create and install the HTML based API documentation (requires Doxygen)
|
||||
PAHO_BUILD_SAMPLES | FALSE | Build sample programs
|
||||
|
||||
Using these variables CMake can be used to generate your Ninja or Make files. Using CMake, building out-of-source is the default. Therefore it is recommended to invoke all build commands inside your chosen build directory but outside of the source tree.
|
||||
|
||||
An example build session targeting the build platform could look like this:
|
||||
|
||||
```
|
||||
mkdir /tmp/build.paho
|
||||
cd /tmp/build.paho
|
||||
cmake -GNinja -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE ~/git/org.eclipse.paho.mqtt.c
|
||||
```
|
||||
|
||||
Invoking cmake and specifying build options can also be performed using cmake-gui or ccmake (see https://cmake.org/runningcmake/). For example:
|
||||
|
||||
```
|
||||
ccmake -GNinja ~/git/org.eclipse.paho.mqtt.c
|
||||
```
|
||||
|
||||
To compile/link the binaries and to generate packages, simply invoke `ninja package` or `make -j <number-of-cores-to-use> package` after CMake. To simply compile/link invoke `ninja` or `make -j <number-of-cores-to-use>`.
|
||||
|
||||
### Debug builds
|
||||
|
||||
Debug builds can be performed by defining the value of the ```CMAKE_BUILD_TYPE``` option to ```Debug```. For example:
|
||||
|
||||
```
|
||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug git/org.eclipse.paho.mqtt.c
|
||||
```
|
||||
|
||||
### Cross compilation
|
||||
|
||||
Cross compilation using CMake is performed by using so called "toolchain files" (see: http://www.vtk.org/Wiki/CMake_Cross_Compiling).
|
||||
|
||||
The path to the toolchain file can be specified by using CMake's `-DCMAKE_TOOLCHAIN_FILE` option. In case no toolchain file is specified, the build is performed for the native build platform.
|
||||
|
||||
For your convenience toolchain files for the following platforms can be found in the `cmake` directory of Eclipse Paho:
|
||||
* Linux x86
|
||||
* Linux ARM11 (a.k.a. the Raspberry Pi)
|
||||
* Windows x86_64
|
||||
* Windows x86
|
||||
|
||||
The provided toolchain files assume that required compilers/linkers are to be found in the environment, i. e. the PATH-Variable of your user or system. If you prefer, you can also specify the absolute location of your compilers in the toolchain files.
|
||||
|
||||
Example invocation for the Raspberry Pi:
|
||||
|
||||
```
|
||||
cmake -GNinja -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_BUILD_DOCUMENTATION=TRUE -DOPENSSL_LIB_SEARCH_PATH=/tmp/libssl-dev/usr/lib/arm-linux-gnueabihf -DOPENSSL_INC_SEARCH_PATH="/tmp/libssl-dev/usr/include/openssl;/tmp/libssl-dev/usr/include/arm-linux-gnueabihf" -DCMAKE_TOOLCHAIN_FILE=~/git/org.eclipse.paho.mqtt.c/cmake/toolchain.linux-arm11.cmake ~/git/org.eclipse.paho.mqtt.c
|
||||
```
|
||||
|
||||
Compilers for the Raspberry Pi can be obtained from e. g. Linaro (see: http://releases.linaro.org/15.06/components/toolchain/binaries/4.8/arm-linux-gnueabihf/). This example assumes that OpenSSL-libraries and includes have been installed in the ```/tmp/libssl-dev``` directory.
|
||||
|
||||
Example invocation for Windows 64 bit:
|
||||
|
||||
```
|
||||
cmake -GNinja -DPAHO_BUILD_SAMPLES=TRUE -DCMAKE_TOOLCHAIN_FILE=~/git/org.eclipse.paho.mqtt.c/cmake/toolchain.win64.cmake ~/git/org.eclipse.paho.mqtt.c
|
||||
|
||||
```
|
||||
|
||||
In this case the libraries and executable are not linked against OpenSSL Libraries. Cross compilers for the Windows platform can be installed on Debian like systems like this:
|
||||
|
||||
```
|
||||
apt-get install gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
|
||||
```
|
||||
|
||||
|
||||
## Build instructions for GNU Make (deprecated)
|
||||
|
||||
The provided GNU Makefile is intended to perform all build steps in the ```build``` directory within the source-tree of Eclipse Paho. Generated binares, libraries, and the documentation can be found in the ```build/output``` directory after completion.
|
||||
|
||||
Options that are passed to the compiler/linker can be specified by typical Unix build variables:
|
||||
|
||||
Variable | Description
|
||||
------------ | -------------
|
||||
CC | Path to the C compiler
|
||||
CFLAGS | Flags passed to compiler calls
|
||||
LDFLAGS | Flags passed to linker calls
|
||||
|
||||
## Libraries
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,18 @@
|
|||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}</ProjectGuid>
|
||||
|
|
@ -23,6 +31,12 @@
|
|||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
|
|
@ -30,23 +44,42 @@
|
|||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
|
|
@ -62,6 +95,21 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
|
@ -81,6 +129,25 @@
|
|||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -34,56 +34,118 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test4", "test4\test4.vcxpro
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test5", "test5\test5.vcxproj", "{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test9", "test9\test9.vcxproj", "{D133C05E-87A6-48C6-A703-188A83B82400}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test2", "test2\test2.vcxproj", "{A4E14611-05DC-40A1-815B-DA30CA167C9B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{172F8995-C780-44A1-996C-C7949B4DB35A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{172F8995-C780-44A1-996C-C7949B4DB35A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{172F8995-C780-44A1-996C-C7949B4DB35A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{172F8995-C780-44A1-996C-C7949B4DB35A}.Debug|x64.Build.0 = Debug|x64
|
||||
{172F8995-C780-44A1-996C-C7949B4DB35A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{172F8995-C780-44A1-996C-C7949B4DB35A}.Release|Win32.Build.0 = Release|Win32
|
||||
{172F8995-C780-44A1-996C-C7949B4DB35A}.Release|x64.ActiveCfg = Release|x64
|
||||
{172F8995-C780-44A1-996C-C7949B4DB35A}.Release|x64.Build.0 = Release|x64
|
||||
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Debug|x64.Build.0 = Debug|x64
|
||||
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Release|Win32.Build.0 = Release|Win32
|
||||
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Release|x64.ActiveCfg = Release|x64
|
||||
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Release|x64.Build.0 = Release|x64
|
||||
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Debug|x64.Build.0 = Debug|x64
|
||||
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Release|Win32.Build.0 = Release|Win32
|
||||
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Release|x64.ActiveCfg = Release|x64
|
||||
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Release|x64.Build.0 = Release|x64
|
||||
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Debug|x64.Build.0 = Debug|x64
|
||||
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Release|Win32.Build.0 = Release|Win32
|
||||
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Release|x64.ActiveCfg = Release|x64
|
||||
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Release|x64.Build.0 = Release|x64
|
||||
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Debug|x64.Build.0 = Debug|x64
|
||||
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Release|Win32.Build.0 = Release|Win32
|
||||
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Release|x64.ActiveCfg = Release|x64
|
||||
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Release|x64.Build.0 = Release|x64
|
||||
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Debug|x64.Build.0 = Debug|x64
|
||||
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Release|Win32.Build.0 = Release|Win32
|
||||
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Release|x64.ActiveCfg = Release|x64
|
||||
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Release|x64.Build.0 = Release|x64
|
||||
{17F07F98-AA5F-4373-9877-992A341D650A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{17F07F98-AA5F-4373-9877-992A341D650A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{17F07F98-AA5F-4373-9877-992A341D650A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{17F07F98-AA5F-4373-9877-992A341D650A}.Debug|x64.Build.0 = Debug|x64
|
||||
{17F07F98-AA5F-4373-9877-992A341D650A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{17F07F98-AA5F-4373-9877-992A341D650A}.Release|Win32.Build.0 = Release|Win32
|
||||
{17F07F98-AA5F-4373-9877-992A341D650A}.Release|x64.ActiveCfg = Release|x64
|
||||
{17F07F98-AA5F-4373-9877-992A341D650A}.Release|x64.Build.0 = Release|x64
|
||||
{4E643090-289D-487D-BCA8-685EA2210480}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4E643090-289D-487D-BCA8-685EA2210480}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4E643090-289D-487D-BCA8-685EA2210480}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4E643090-289D-487D-BCA8-685EA2210480}.Debug|x64.Build.0 = Debug|x64
|
||||
{4E643090-289D-487D-BCA8-685EA2210480}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4E643090-289D-487D-BCA8-685EA2210480}.Release|Win32.Build.0 = Release|Win32
|
||||
{4E643090-289D-487D-BCA8-685EA2210480}.Release|x64.ActiveCfg = Release|x64
|
||||
{4E643090-289D-487D-BCA8-685EA2210480}.Release|x64.Build.0 = Release|x64
|
||||
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Debug|x64.Build.0 = Debug|x64
|
||||
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Release|Win32.Build.0 = Release|Win32
|
||||
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Release|x64.ActiveCfg = Release|x64
|
||||
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Release|x64.Build.0 = Release|x64
|
||||
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Debug|x64.Build.0 = Debug|x64
|
||||
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Release|Win32.Build.0 = Release|Win32
|
||||
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Release|x64.ActiveCfg = Release|x64
|
||||
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Release|x64.Build.0 = Release|x64
|
||||
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Debug|x64.Build.0 = Debug|x64
|
||||
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Release|Win32.Build.0 = Release|Win32
|
||||
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Release|x64.ActiveCfg = Release|x64
|
||||
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Release|x64.Build.0 = Release|x64
|
||||
{D133C05E-87A6-48C6-A703-188A83B82400}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D133C05E-87A6-48C6-A703-188A83B82400}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D133C05E-87A6-48C6-A703-188A83B82400}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{D133C05E-87A6-48C6-A703-188A83B82400}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D133C05E-87A6-48C6-A703-188A83B82400}.Release|Win32.Build.0 = Release|Win32
|
||||
{D133C05E-87A6-48C6-A703-188A83B82400}.Release|x64.ActiveCfg = Release|Win32
|
||||
{A4E14611-05DC-40A1-815B-DA30CA167C9B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{A4E14611-05DC-40A1-815B-DA30CA167C9B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{A4E14611-05DC-40A1-815B-DA30CA167C9B}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{A4E14611-05DC-40A1-815B-DA30CA167C9B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{A4E14611-05DC-40A1-815B-DA30CA167C9B}.Release|Win32.Build.0 = Release|Win32
|
||||
{A4E14611-05DC-40A1-815B-DA30CA167C9B}.Release|x64.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -5,10 +5,18 @@
|
|||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}</ProjectGuid>
|
||||
|
|
@ -22,6 +30,12 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
|
|
@ -29,23 +43,42 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
|
|
@ -61,6 +94,21 @@
|
|||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3A_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
|
@ -80,6 +128,25 @@
|
|||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3A_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\Clients.c" />
|
||||
<ClCompile Include="..\..\src\Heap.c" />
|
||||
|
|
|
|||
|
|
@ -5,10 +5,18 @@
|
|||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{DEF21D1B-CB65-4A78-805F-CF421249EB83}</ProjectGuid>
|
||||
|
|
@ -22,6 +30,12 @@
|
|||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
|
|
@ -29,23 +43,42 @@
|
|||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
|
|
@ -62,6 +95,22 @@
|
|||
<AdditionalLibraryDirectories>$(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(OpenSSLDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSLDir)\out32dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
|
@ -82,6 +131,26 @@
|
|||
<AdditionalLibraryDirectories>$(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(OpenSSLDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSLDir)\out32dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\Clients.h" />
|
||||
<ClInclude Include="..\..\src\Heap.h" />
|
||||
|
|
@ -131,4 +200,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
@ -5,10 +5,18 @@
|
|||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{172F8995-C780-44A1-996C-C7949B4DB35A}</ProjectGuid>
|
||||
|
|
@ -22,6 +30,12 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
|
|
@ -29,23 +43,42 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
|
|
@ -60,6 +93,20 @@
|
|||
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3C_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
|
@ -78,6 +125,24 @@
|
|||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3C_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\Clients.c" />
|
||||
<ClCompile Include="..\..\src\Heap.c" />
|
||||
|
|
|
|||
|
|
@ -1,134 +1,203 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{17F07F98-AA5F-4373-9877-992A341D650A}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pahomqtt3as</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(OpenSSLDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(OpenSSLDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\Clients.h" />
|
||||
<ClInclude Include="..\..\src\Heap.h" />
|
||||
<ClInclude Include="..\..\src\LinkedList.h" />
|
||||
<ClInclude Include="..\..\src\Log.h" />
|
||||
<ClInclude Include="..\..\src\Messages.h" />
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
<ClInclude Include="..\..\src\MQTTPacket.h" />
|
||||
<ClInclude Include="..\..\src\MQTTPacketOut.h" />
|
||||
<ClInclude Include="..\..\src\MQTTPersistence.h" />
|
||||
<ClInclude Include="..\..\src\MQTTPersistenceDefault.h" />
|
||||
<ClInclude Include="..\..\src\MQTTProtocol.h" />
|
||||
<ClInclude Include="..\..\src\MQTTProtocolClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTProtocolOut.h" />
|
||||
<ClInclude Include="..\..\src\Socket.h" />
|
||||
<ClInclude Include="..\..\src\SocketBuffer.h" />
|
||||
<ClInclude Include="..\..\src\SSLSocket.h" />
|
||||
<ClInclude Include="..\..\src\StackTrace.h" />
|
||||
<ClInclude Include="..\..\src\Thread.h" />
|
||||
<ClInclude Include="..\..\src\Tree.h" />
|
||||
<ClInclude Include="..\..\src\utf-8.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\Clients.c" />
|
||||
<ClCompile Include="..\..\src\Heap.c" />
|
||||
<ClCompile Include="..\..\src\LinkedList.c" />
|
||||
<ClCompile Include="..\..\src\Log.c" />
|
||||
<ClCompile Include="..\..\src\Messages.c" />
|
||||
<ClCompile Include="..\..\src\MQTTClient.c" />
|
||||
<ClCompile Include="..\..\src\MQTTPacket.c" />
|
||||
<ClCompile Include="..\..\src\MQTTPacketOut.c" />
|
||||
<ClCompile Include="..\..\src\MQTTPersistence.c" />
|
||||
<ClCompile Include="..\..\src\MQTTPersistenceDefault.c" />
|
||||
<ClCompile Include="..\..\src\MQTTProtocolClient.c" />
|
||||
<ClCompile Include="..\..\src\MQTTProtocolOut.c" />
|
||||
<ClCompile Include="..\..\src\MQTTVersion.c" />
|
||||
<ClCompile Include="..\..\src\Socket.c" />
|
||||
<ClCompile Include="..\..\src\SocketBuffer.c" />
|
||||
<ClCompile Include="..\..\src\SSLSocket.c" />
|
||||
<ClCompile Include="..\..\src\StackTrace.c" />
|
||||
<ClCompile Include="..\..\src\Thread.c" />
|
||||
<ClCompile Include="..\..\src\Tree.c" />
|
||||
<ClCompile Include="..\..\src\utf-8.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{17F07F98-AA5F-4373-9877-992A341D650A}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pahomqtt3as</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(OpenSSLDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(OpenSSLDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSLDir)\out32dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(OpenSSLDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>$(OpenSSLDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSLDir)\out32dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\Clients.h" />
|
||||
<ClInclude Include="..\..\src\Heap.h" />
|
||||
<ClInclude Include="..\..\src\LinkedList.h" />
|
||||
<ClInclude Include="..\..\src\Log.h" />
|
||||
<ClInclude Include="..\..\src\Messages.h" />
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
<ClInclude Include="..\..\src\MQTTPacket.h" />
|
||||
<ClInclude Include="..\..\src\MQTTPacketOut.h" />
|
||||
<ClInclude Include="..\..\src\MQTTPersistence.h" />
|
||||
<ClInclude Include="..\..\src\MQTTPersistenceDefault.h" />
|
||||
<ClInclude Include="..\..\src\MQTTProtocol.h" />
|
||||
<ClInclude Include="..\..\src\MQTTProtocolClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTProtocolOut.h" />
|
||||
<ClInclude Include="..\..\src\Socket.h" />
|
||||
<ClInclude Include="..\..\src\SocketBuffer.h" />
|
||||
<ClInclude Include="..\..\src\SSLSocket.h" />
|
||||
<ClInclude Include="..\..\src\StackTrace.h" />
|
||||
<ClInclude Include="..\..\src\Thread.h" />
|
||||
<ClInclude Include="..\..\src\Tree.h" />
|
||||
<ClInclude Include="..\..\src\utf-8.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\Clients.c" />
|
||||
<ClCompile Include="..\..\src\Heap.c" />
|
||||
<ClCompile Include="..\..\src\LinkedList.c" />
|
||||
<ClCompile Include="..\..\src\Log.c" />
|
||||
<ClCompile Include="..\..\src\Messages.c" />
|
||||
<ClCompile Include="..\..\src\MQTTClient.c" />
|
||||
<ClCompile Include="..\..\src\MQTTPacket.c" />
|
||||
<ClCompile Include="..\..\src\MQTTPacketOut.c" />
|
||||
<ClCompile Include="..\..\src\MQTTPersistence.c" />
|
||||
<ClCompile Include="..\..\src\MQTTPersistenceDefault.c" />
|
||||
<ClCompile Include="..\..\src\MQTTProtocolClient.c" />
|
||||
<ClCompile Include="..\..\src\MQTTProtocolOut.c" />
|
||||
<ClCompile Include="..\..\src\MQTTVersion.c" />
|
||||
<ClCompile Include="..\..\src\Socket.c" />
|
||||
<ClCompile Include="..\..\src\SocketBuffer.c" />
|
||||
<ClCompile Include="..\..\src\SSLSocket.c" />
|
||||
<ClCompile Include="..\..\src\StackTrace.c" />
|
||||
<ClCompile Include="..\..\src\Thread.c" />
|
||||
<ClCompile Include="..\..\src\Tree.c" />
|
||||
<ClCompile Include="..\..\src\utf-8.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -5,15 +5,24 @@
|
|||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{DFDF6238-DA97-4474-84C2-D313E8B985AE}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>stdoutsub</RootNamespace>
|
||||
<RootNamespace>paho-cs-sub</RootNamespace>
|
||||
<ProjectName>paho-cs-sub</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
|
@ -22,6 +31,12 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
|
|
@ -29,23 +44,42 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\samples\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
|
|
@ -63,6 +97,23 @@
|
|||
<AdditionalDependencies>paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
|
@ -84,13 +135,39 @@
|
|||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\samples\stdoutsub.c" />
|
||||
<ClCompile Include="..\..\src\samples\paho_cs_sub.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\paho-mqtt3cs\paho-mqtt3cs.vcxproj">
|
||||
<Project>{17f07f98-aa5f-4373-9877-992a341d650a}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\samples\stdoutsub.c">
|
||||
<ClCompile Include="..\..\src\samples\paho_cs_sub.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -5,15 +5,24 @@
|
|||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{AF322561-C692-43D3-8502-CC1E6CD2869A}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>stdoutsuba</RootNamespace>
|
||||
<RootNamespace>paho-cs-pub</RootNamespace>
|
||||
<ProjectName>paho-cs-pub</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
|
@ -22,6 +31,12 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
|
|
@ -29,23 +44,42 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\samples\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
|
|
@ -59,10 +93,27 @@
|
|||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\Debug</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
|
@ -80,12 +131,33 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\samples\stdoutsuba.c" />
|
||||
<ClCompile Include="..\..\src\samples\paho_cs_pub.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\samples\stdoutsuba.c">
|
||||
<ClCompile Include="..\..\src\samples\paho_cs_pub.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,95 +1,172 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{4E643090-289D-487D-BCA8-685EA2210480}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test1</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test1.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{4E643090-289D-487D-BCA8-685EA2210480}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test1</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\Debug\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test1.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{A4E14611-05DC-40A1-815B-DA30CA167C9B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test2</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\Log.c" />
|
||||
<ClCompile Include="..\..\src\Messages.c" />
|
||||
<ClCompile Include="..\..\src\StackTrace.c" />
|
||||
<ClCompile Include="..\..\src\Thread.c" />
|
||||
<ClCompile Include="..\..\test\test2.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test2.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Thread.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\StackTrace.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Log.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Messages.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,95 +1,177 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test1</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test3.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test1</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTClient.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test3.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\paho-mqtt3cs\paho-mqtt3cs.vcxproj">
|
||||
<Project>{17f07f98-aa5f-4373-9877-992a341d650a}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -1,95 +1,172 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{29D6A4E9-5A39-4CD3-8A24-348A34832405}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test1</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test4.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{29D6A4E9-5A39-4CD3-8A24-348A34832405}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test1</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test4.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -1,95 +1,172 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test1</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test5.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test1</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\x64\$(Configuration)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test5.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D133C05E-87A6-48C6-A703-188A83B82400}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>test9</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\build\output\test\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3a.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>ws2_32.lib;paho-mqtt3a.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test9.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h" />
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test\test9.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\MQTTAsync.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\MQTTClientPersistence.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
31
build.xml
31
build.xml
|
|
@ -1,4 +1,4 @@
|
|||
<!--*******************************************************************************
|
||||
<!--****************************************************************************
|
||||
Copyright (c) 2012, 2016 IBM Corp.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
</taskdef>
|
||||
|
||||
<property name="output.folder" value="build/output" />
|
||||
<property name="release.version" value="1.0.3" />
|
||||
<property name="release.version" value="1.1.0" />
|
||||
|
||||
<property name="libname" value="mqttv3c" />
|
||||
<property name="libname.ssl" value="mqttv3cs" />
|
||||
|
|
@ -74,16 +74,31 @@
|
|||
|
||||
</target>
|
||||
|
||||
<target name="version" depends="init" description="replace tags in the source with the right levels">
|
||||
<target name="version" depends="init" description="replace tags with the right levels">
|
||||
<property name="build.level" value="${DSTAMP}${TSTAMP}" />
|
||||
<replace file="src/MQTTClient.c" token="##MQTTCLIENT_BUILD_TAG##" value="${build.level}" />
|
||||
<replace file="src/MQTTClient.c" token="##MQTTCLIENT_VERSION_TAG##" value="${release.version}" />
|
||||
<replace file="src/MQTTAsync.c" token="##MQTTCLIENT_BUILD_TAG##" value="${build.level}" />
|
||||
<replace file="src/MQTTAsync.c" token="##MQTTCLIENT_VERSION_TAG##" value="${release.version}" />
|
||||
<copy file="src/VersionInfo.h.in" tofile="src/VersionInfo.h" />
|
||||
<replace file="src/VersionInfo.h" token="@BUILD_TIMESTAMP@" value="${build.level}" />
|
||||
<replace file="src/VersionInfo.h" token="@CLIENT_VERSION@" value="${release.version}" />
|
||||
</target>
|
||||
|
||||
<target name="test" >
|
||||
<foreach target="runAtest" param="aTest" list="test1,test4"/>
|
||||
<!-- display Python version -->
|
||||
<exec executable="python" failonerror="true">
|
||||
<arg line="-V"/>
|
||||
</exec>
|
||||
<exec executable="python" dir="test" spawn="true">
|
||||
<arg value="mqttsas2.py" />
|
||||
<arg value="${test.hostname}" />
|
||||
</exec>
|
||||
<if>
|
||||
<os family="windows"/>
|
||||
<then>
|
||||
<foreach target="runAtest" param="aTest" list="test1,test2,test4,test9"/>
|
||||
</then>
|
||||
<else>
|
||||
<foreach target="runAtest" param="aTest" list="test1,test2,test4,test9"/>
|
||||
</else>
|
||||
</if>
|
||||
<foreach target="runSSLtest" param="aTest" list="test3,test5"/>
|
||||
</target>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
# path to compiler and utilities
|
||||
# specify the cross compiler
|
||||
SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
|
||||
# Name of the target platform
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
SET(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
# Version of the system
|
||||
SET(CMAKE_SYSTEM_VERSION 1)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Name of the target platform
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# Version of the system
|
||||
SET(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
# specify the cross compiler
|
||||
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
|
||||
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
|
||||
SET(CMAKE_RC_COMPILER_ENV_VAR "RC")
|
||||
SET(CMAKE_RC_COMPILER "")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS
|
||||
"-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS
|
||||
"-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Name of the target platform
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# Version of the system
|
||||
SET(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
# specify the cross compiler
|
||||
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||
SET(CMAKE_RC_COMPILER_ENV_VAR "RC")
|
||||
SET(CMAKE_RC_COMPILER "")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS
|
||||
"-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS
|
||||
"-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2015 logi.cals GmbH
|
||||
#
|
||||
# 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:
|
||||
# Rainer Poisel - initial version
|
||||
#*******************************************************************************/
|
||||
|
||||
# Note: on OS X you should install XCode and the associated command-line tools
|
||||
|
||||
### documentation settings
|
||||
FIND_PACKAGE(Doxygen)
|
||||
IF(NOT DOXYGEN_FOUND)
|
||||
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
|
||||
ENDIF()
|
||||
SET(DOXYTARGETS)
|
||||
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)
|
||||
FOREACH(DOXYFILE_SRC DoxyfileV3ClientAPI;DoxyfileV3AsyncAPI;DoxyfileV3ClientInternal)
|
||||
SET(DOXYFILE_IN ${DOXYFILE_SRC}.in)
|
||||
SET(DOXYFILE ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE_SRC})
|
||||
|
||||
CONFIGURE_FILE(${DOXYFILE_IN} ${DOXYFILE} @ONLY)
|
||||
ADD_CUSTOM_TARGET(${DOXYFILE_SRC}.target
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen"
|
||||
VERBATIM
|
||||
)
|
||||
SET(DOXYTARGETS ${DOXYTARGETS} ${DOXYFILE_SRC}.target)
|
||||
ENDFOREACH(DOXYFILE_SRC)
|
||||
ADD_CUSTOM_TARGET(doc ALL DEPENDS ${DOXYTARGETS})
|
||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc DESTINATION share)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -667,6 +667,7 @@ WARN_LOGFILE =
|
|||
|
||||
INPUT = "."
|
||||
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||
# also the default input encoding. Doxygen uses libiconv (or the iconv built
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,97 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2015 logi.cals GmbH
|
||||
#
|
||||
# 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:
|
||||
# Rainer Poisel - initial version
|
||||
#*******************************************************************************/
|
||||
|
||||
# Note: on OS X you should install XCode and the associated command-line tools
|
||||
|
||||
## compilation/linkage settings
|
||||
INCLUDE_DIRECTORIES(
|
||||
.
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
CONFIGURE_FILE(VersionInfo.h.in
|
||||
${CMAKE_BINARY_DIR}/VersionInfo.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
SET(common_src
|
||||
MQTTProtocolClient.c
|
||||
Clients.c
|
||||
utf-8.c
|
||||
StackTrace.c
|
||||
MQTTPacket.c
|
||||
MQTTPacketOut.c
|
||||
Messages.c
|
||||
Tree.c
|
||||
Socket.c
|
||||
Log.c
|
||||
MQTTPersistence.c
|
||||
Thread.c
|
||||
MQTTProtocolOut.c
|
||||
MQTTPersistenceDefault.c
|
||||
SocketBuffer.c
|
||||
Heap.c
|
||||
LinkedList.c
|
||||
)
|
||||
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
SET(LIBS_SYSTEM ws2_32)
|
||||
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
SET(LIBS_SYSTEM dl)
|
||||
ENDIF()
|
||||
|
||||
ADD_EXECUTABLE(MQTTVersion MQTTVersion.c)
|
||||
ADD_LIBRARY(paho-mqtt3c SHARED ${common_src} MQTTClient.c)
|
||||
ADD_LIBRARY(paho-mqtt3a SHARED ${common_src} MQTTAsync.c)
|
||||
TARGET_LINK_LIBRARIES(paho-mqtt3c pthread ${LIBS_SYSTEM})
|
||||
TARGET_LINK_LIBRARIES(paho-mqtt3a pthread ${LIBS_SYSTEM})
|
||||
TARGET_LINK_LIBRARIES(MQTTVersion paho-mqtt3a paho-mqtt3c ${LIBS_SYSTEM})
|
||||
SET_TARGET_PROPERTIES(
|
||||
paho-mqtt3c paho-mqtt3a PROPERTIES
|
||||
VERSION ${CLIENT_VERSION}
|
||||
SOVERSION ${PAHO_VERSION_MAJOR})
|
||||
INSTALL(TARGETS paho-mqtt3c paho-mqtt3a MQTTVersion
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib)
|
||||
INSTALL(FILES MQTTAsync.h MQTTClient.h MQTTClientPersistence.h
|
||||
DESTINATION include)
|
||||
|
||||
IF (PAHO_WITH_SSL)
|
||||
SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL libraries")
|
||||
SET(OPENSSL_INC_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL includes")
|
||||
SET(OPENSSL_LIBRARIES ssl crypto)
|
||||
LINK_DIRECTORIES(
|
||||
${OPENSSL_LIB_SEARCH_PATH}
|
||||
)
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OPENSSL_INC_SEARCH_PATH}
|
||||
)
|
||||
ADD_LIBRARY(paho-mqtt3cs SHARED ${common_src} MQTTClient.c SSLSocket.c)
|
||||
ADD_LIBRARY(paho-mqtt3as SHARED ${common_src} MQTTAsync.c SSLSocket.c)
|
||||
TARGET_LINK_LIBRARIES(paho-mqtt3cs pthread ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
|
||||
TARGET_LINK_LIBRARIES(paho-mqtt3as pthread ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
|
||||
SET_TARGET_PROPERTIES(
|
||||
paho-mqtt3cs paho-mqtt3as PROPERTIES
|
||||
VERSION ${CLIENT_VERSION}
|
||||
SOVERSION ${PAHO_VERSION_MAJOR})
|
||||
INSTALL(TARGETS paho-mqtt3cs
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib)
|
||||
INSTALL(TARGETS paho-mqtt3as
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib)
|
||||
ENDIF()
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ typedef struct
|
|||
char* file; /**< the name of the source file where the storage was allocated */
|
||||
int line; /**< the line no in the source file where it was allocated */
|
||||
void* ptr; /**< pointer to the allocated storage */
|
||||
int size; /**< size of the allocated storage */
|
||||
size_t size; /**< size of the allocated storage */
|
||||
} storageElement;
|
||||
|
||||
static Tree heap; /**< Tree that holds the allocation records */
|
||||
|
|
@ -75,7 +75,7 @@ static char* errmsg = "Memory allocation error";
|
|||
* @param size the size actually needed
|
||||
* @return the rounded up size
|
||||
*/
|
||||
int Heap_roundup(int size)
|
||||
size_t Heap_roundup(size_t size)
|
||||
{
|
||||
static int multsize = 4*sizeof(int);
|
||||
|
||||
|
|
@ -139,8 +139,8 @@ void Heap_check(char* string, void* ptr)
|
|||
void* mymalloc(char* file, int line, size_t size)
|
||||
{
|
||||
storageElement* s = NULL;
|
||||
int space = sizeof(storageElement);
|
||||
int filenamelen = strlen(file)+1;
|
||||
size_t space = sizeof(storageElement);
|
||||
size_t filenamelen = strlen(file)+1;
|
||||
|
||||
Thread_lock_mutex(heap_mutex);
|
||||
size = Heap_roundup(size);
|
||||
|
|
@ -180,7 +180,7 @@ void* mymalloc(char* file, int line, size_t size)
|
|||
}
|
||||
|
||||
|
||||
void checkEyecatchers(char* file, int line, void* p, int size)
|
||||
void checkEyecatchers(char* file, int line, void* p, size_t size)
|
||||
{
|
||||
int *sp = (int*)p;
|
||||
char *cp = (char*)p;
|
||||
|
|
@ -282,8 +282,8 @@ void *myrealloc(char* file, int line, void* p, size_t size)
|
|||
Log(LOG_ERROR, 13, "Failed to reallocate heap item at file %s line %d", file, line);
|
||||
else
|
||||
{
|
||||
int space = sizeof(storageElement);
|
||||
int filenamelen = strlen(file)+1;
|
||||
size_t space = sizeof(storageElement);
|
||||
size_t filenamelen = strlen(file)+1;
|
||||
|
||||
checkEyecatchers(file, line, p, s->size);
|
||||
size = Heap_roundup(size);
|
||||
|
|
@ -393,7 +393,7 @@ heap_info* Heap_get_info()
|
|||
int HeapDumpString(FILE* file, char* str)
|
||||
{
|
||||
int rc = 0;
|
||||
int len = str ? strlen(str) + 1 : 0; /* include the trailing null */
|
||||
size_t len = str ? strlen(str) + 1 : 0; /* include the trailing null */
|
||||
|
||||
if (fwrite(&(str), sizeof(char*), 1, file) != 1)
|
||||
rc = -1;
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
int current_size; /**< current size of the heap in bytes */
|
||||
int max_size; /**< max size the heap has reached in bytes */
|
||||
size_t current_size; /**< current size of the heap in bytes */
|
||||
size_t max_size; /**< max size the heap has reached in bytes */
|
||||
} heap_info;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ List* ListInitialize(void)
|
|||
* @param newel the ListElement to be used in adding the new item
|
||||
* @param size the size of the element
|
||||
*/
|
||||
void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, int size)
|
||||
void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, size_t size)
|
||||
{ /* for heap use */
|
||||
newel->content = content;
|
||||
newel->next = NULL;
|
||||
|
|
@ -88,7 +88,7 @@ void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, int size
|
|||
* @param content the list item content itself
|
||||
* @param size the size of the element
|
||||
*/
|
||||
void ListAppend(List* aList, void* content, int size)
|
||||
void ListAppend(List* aList, void* content, size_t size)
|
||||
{
|
||||
ListElement* newel = malloc(sizeof(ListElement));
|
||||
ListAppendNoMalloc(aList, content, newel, size);
|
||||
|
|
@ -103,7 +103,7 @@ void ListAppend(List* aList, void* content, int size)
|
|||
* @param index the position in the list. If NULL, this function is equivalent
|
||||
* to ListAppend.
|
||||
*/
|
||||
void ListInsert(List* aList, void* content, int size, ListElement* index)
|
||||
void ListInsert(List* aList, void* content, size_t size, ListElement* index)
|
||||
{
|
||||
ListElement* newel = malloc(sizeof(ListElement));
|
||||
|
||||
|
|
@ -359,7 +359,8 @@ void ListEmpty(List* aList)
|
|||
aList->first = first->next;
|
||||
free(first);
|
||||
}
|
||||
aList->count = aList->size = 0;
|
||||
aList->count = 0;
|
||||
aList->size = 0;
|
||||
aList->current = aList->first = aList->last = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,14 @@
|
|||
* Contributors:
|
||||
* Ian Craggs - initial API and implementation and/or initial documentation
|
||||
* Ian Craggs - updates for the async client
|
||||
* Ian Craggs - change size types from int to size_t
|
||||
*******************************************************************************/
|
||||
|
||||
#if !defined(LINKEDLIST_H)
|
||||
#define LINKEDLIST_H
|
||||
|
||||
#include <stdlib.h> // for size_t definition
|
||||
|
||||
/*BE
|
||||
defm defList(T)
|
||||
|
||||
|
|
@ -66,16 +69,16 @@ typedef struct
|
|||
ListElement *first, /**< first element in the list */
|
||||
*last, /**< last element in the list */
|
||||
*current; /**< current element in the list, for iteration */
|
||||
int count, /**< no of items */
|
||||
size; /**< heap storage used */
|
||||
int count; /**< no of items */
|
||||
size_t size; /**< heap storage used */
|
||||
} List;
|
||||
|
||||
void ListZero(List*);
|
||||
List* ListInitialize(void);
|
||||
|
||||
void ListAppend(List* aList, void* content, int size);
|
||||
void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, int size);
|
||||
void ListInsert(List* aList, void* content, int size, ListElement* index);
|
||||
void ListAppend(List* aList, void* content, size_t size);
|
||||
void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, size_t size);
|
||||
void ListInsert(List* aList, void* content, size_t size, ListElement* index);
|
||||
|
||||
int ListRemove(List* aList, void* content);
|
||||
int ListRemoveItem(List* aList, void* content, int(*callback)(void*, void*));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2014 IBM Corp.
|
||||
* Copyright (c) 2009, 2016 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -24,6 +24,12 @@
|
|||
* Ian Craggs - fix for bug 442400: reconnecting after network cable unplugged
|
||||
* Ian Craggs - fix for bug 444934 - incorrect free in freeCommand1
|
||||
* Ian Craggs - fix for bug 445891 - assigning msgid is not thread safe
|
||||
* Ian Craggs - fix for bug 465369 - longer latency than expected
|
||||
* Ian Craggs - fix for bug 444103 - success/failure callbacks not invoked
|
||||
* Ian Craggs - fix for bug 484363 - segfault in getReadySocket
|
||||
* Ian Craggs - automatic reconnect and offline buffering (send while disconnected)
|
||||
* Ian Craggs - fix for bug 472250
|
||||
* Ian Craggs - fix for bug 486548
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
@ -52,12 +58,15 @@
|
|||
|
||||
#define URI_TCP "tcp://"
|
||||
|
||||
#define BUILD_TIMESTAMP "##MQTTCLIENT_BUILD_TAG##"
|
||||
#define CLIENT_VERSION "##MQTTCLIENT_VERSION_TAG##"
|
||||
#include "VersionInfo.h"
|
||||
|
||||
char* client_timestamp_eye = "MQTTAsyncV3_Timestamp " BUILD_TIMESTAMP;
|
||||
char* client_version_eye = "MQTTAsyncV3_Version " CLIENT_VERSION;
|
||||
|
||||
#if !defined(min)
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
extern Sockets s;
|
||||
|
||||
static ClientStates ClientState =
|
||||
|
|
@ -82,6 +91,7 @@ static thread_id_type sendThread_id = 0,
|
|||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
static mutex_type mqttasync_mutex = NULL;
|
||||
static mutex_type socket_mutex = NULL;
|
||||
static mutex_type mqttcommand_mutex = NULL;
|
||||
static sem_type send_sem = NULL;
|
||||
extern mutex_type stack_mutex;
|
||||
|
|
@ -108,6 +118,7 @@ BOOL APIENTRY DllMain(HANDLE hModule,
|
|||
stack_mutex = CreateMutex(NULL, 0, NULL);
|
||||
heap_mutex = CreateMutex(NULL, 0, NULL);
|
||||
log_mutex = CreateMutex(NULL, 0, NULL);
|
||||
socket_mutex = CreateMutex(NULL, 0, NULL);
|
||||
}
|
||||
case DLL_THREAD_ATTACH:
|
||||
Log(TRACE_MAX, -1, "DLL thread attach");
|
||||
|
|
@ -121,8 +132,13 @@ BOOL APIENTRY DllMain(HANDLE hModule,
|
|||
#else
|
||||
static pthread_mutex_t mqttasync_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
static mutex_type mqttasync_mutex = &mqttasync_mutex_store;
|
||||
|
||||
static pthread_mutex_t socket_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
static mutex_type socket_mutex = &socket_mutex_store;
|
||||
|
||||
static pthread_mutex_t mqttcommand_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
static mutex_type mqttcommand_mutex = &mqttcommand_mutex_store;
|
||||
|
||||
static cond_type_struct send_cond_store = { PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER };
|
||||
static cond_type send_cond = &send_cond_store;
|
||||
|
||||
|
|
@ -137,6 +153,13 @@ void MQTTAsync_init()
|
|||
printf("MQTTAsync: error %d initializing async_mutex\n", rc);
|
||||
if ((rc = pthread_mutex_init(mqttcommand_mutex, &attr)) != 0)
|
||||
printf("MQTTAsync: error %d initializing command_mutex\n", rc);
|
||||
if ((rc = pthread_mutex_init(socket_mutex, &attr)) != 0)
|
||||
printf("MQTTClient: error %d initializing socket_mutex\n", rc);
|
||||
|
||||
if ((rc = pthread_cond_init(&send_cond->cond, NULL)) != 0)
|
||||
printf("MQTTAsync: error %d initializing send_cond cond\n", rc);
|
||||
if ((rc = pthread_mutex_init(&send_cond->mutex, &attr)) != 0)
|
||||
printf("MQTTAsync: error %d initializing send_cond mutex\n", rc);
|
||||
}
|
||||
|
||||
#define WINAPI
|
||||
|
|
@ -252,9 +275,6 @@ typedef struct
|
|||
} dis;
|
||||
struct
|
||||
{
|
||||
int timeout;
|
||||
int serverURIcount;
|
||||
char** serverURIs;
|
||||
int currentURI;
|
||||
int MQTTVersion; /**< current MQTT version being used to connect */
|
||||
} conn;
|
||||
|
|
@ -273,9 +293,14 @@ typedef struct MQTTAsync_struct
|
|||
MQTTAsync_messageArrived* ma;
|
||||
MQTTAsync_deliveryComplete* dc;
|
||||
void* context; /* the context to be associated with the main callbacks*/
|
||||
|
||||
MQTTAsync_connected* connected;
|
||||
void* connected_context; /* the context to be associated with the connected callback*/
|
||||
|
||||
MQTTAsync_command connect; /* Connect operation properties */
|
||||
MQTTAsync_command disconnect; /* Disconnect operation properties */
|
||||
/* Each time connect is called, we store the options that were used. These are reused in
|
||||
any call to reconnect, or an automatic reconnect attempt */
|
||||
MQTTAsync_command connect; /* Connect operation properties */
|
||||
MQTTAsync_command disconnect; /* Disconnect operation properties */
|
||||
MQTTAsync_command* pending_write; /* Is there a socket write pending? */
|
||||
|
||||
List* responses;
|
||||
|
|
@ -283,6 +308,23 @@ typedef struct MQTTAsync_struct
|
|||
|
||||
MQTTPacket* pack;
|
||||
|
||||
/* added for offline buffering */
|
||||
MQTTAsync_createOptions* createOptions;
|
||||
int shouldBeConnected;
|
||||
|
||||
/* added for automatic reconnect */
|
||||
int automaticReconnect;
|
||||
int minRetryInterval;
|
||||
int maxRetryInterval;
|
||||
int serverURIcount;
|
||||
char** serverURIs;
|
||||
int connectTimeout;
|
||||
|
||||
int currentInterval;
|
||||
START_TIME_TYPE lastConnectionFailedTime;
|
||||
int retrying;
|
||||
int reconnectNow;
|
||||
|
||||
} MQTTAsyncs;
|
||||
|
||||
|
||||
|
|
@ -341,20 +383,24 @@ void MQTTAsync_unlock_mutex(mutex_type amutex)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Check whether there are any more connect options. If not then we are finished
|
||||
with connect attempts.
|
||||
*/
|
||||
int MQTTAsync_checkConn(MQTTAsync_command* command, MQTTAsyncs* client)
|
||||
{
|
||||
int rc;
|
||||
int rc;
|
||||
|
||||
FUNC_ENTRY;
|
||||
rc = command->details.conn.currentURI < command->details.conn.serverURIcount ||
|
||||
(command->details.conn.MQTTVersion == 4 && client->c->MQTTVersion == MQTTVERSION_DEFAULT);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
FUNC_ENTRY;
|
||||
rc = command->details.conn.currentURI < client->serverURIcount ||
|
||||
(command->details.conn.MQTTVersion == 4 && client->c->MQTTVersion == MQTTVERSION_DEFAULT);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clientId,
|
||||
int persistence_type, void* persistence_context)
|
||||
int MQTTAsync_createWithOptions(MQTTAsync* handle, const char* serverURI, const char* clientId,
|
||||
int persistence_type, void* persistence_context, MQTTAsync_createOptions* options)
|
||||
{
|
||||
int rc = 0;
|
||||
MQTTAsyncs *m = NULL;
|
||||
|
|
@ -374,6 +420,12 @@ int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clien
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if (options && (strncmp(options->struct_id, "MQCO", 4) != 0 || options->struct_version != 0))
|
||||
{
|
||||
rc = MQTTASYNC_BAD_STRUCTURE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
#if defined(HEAP_H)
|
||||
|
|
@ -414,6 +466,13 @@ int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clien
|
|||
m->c->messageQueue = ListInitialize();
|
||||
m->c->clientID = MQTTStrdup(clientId);
|
||||
|
||||
m->shouldBeConnected = 0;
|
||||
if (options)
|
||||
{
|
||||
m->createOptions = malloc(sizeof(MQTTAsync_createOptions));
|
||||
memcpy(m->createOptions, options, sizeof(MQTTAsync_createOptions));
|
||||
}
|
||||
|
||||
#if !defined(NO_PERSISTENCE)
|
||||
rc = MQTTPersistence_create(&(m->c->persistence), persistence_type, persistence_context);
|
||||
if (rc == 0)
|
||||
|
|
@ -435,6 +494,14 @@ exit:
|
|||
}
|
||||
|
||||
|
||||
int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clientId,
|
||||
int persistence_type, void* persistence_context)
|
||||
{
|
||||
return MQTTAsync_createWithOptions(handle, serverURI, clientId, persistence_type,
|
||||
persistence_context, NULL);
|
||||
}
|
||||
|
||||
|
||||
void MQTTAsync_terminate(void)
|
||||
{
|
||||
FUNC_ENTRY;
|
||||
|
|
@ -508,7 +575,7 @@ int MQTTAsync_persistCommand(MQTTAsync_queuedCommand* qcmd)
|
|||
for (i = 0; i < command->details.sub.count; ++i)
|
||||
{
|
||||
bufs[bufindex] = command->details.sub.topics[i];
|
||||
lens[bufindex++] = strlen(command->details.sub.topics[i]) + 1;
|
||||
lens[bufindex++] = (int)strlen(command->details.sub.topics[i]) + 1;
|
||||
bufs[bufindex] = &command->details.sub.qoss[i];
|
||||
lens[bufindex++] = sizeof(command->details.sub.qoss[i]);
|
||||
}
|
||||
|
|
@ -533,7 +600,7 @@ int MQTTAsync_persistCommand(MQTTAsync_queuedCommand* qcmd)
|
|||
for (i = 0; i < command->details.unsub.count; ++i)
|
||||
{
|
||||
bufs[bufindex] = command->details.unsub.topics[i];
|
||||
lens[bufindex++] = strlen(command->details.unsub.topics[i]) + 1;
|
||||
lens[bufindex++] = (int)strlen(command->details.unsub.topics[i]) + 1;
|
||||
}
|
||||
sprintf(key, "%s%d", PERSISTENCE_COMMAND_KEY, ++aclient->command_seqno);
|
||||
break;
|
||||
|
|
@ -551,7 +618,7 @@ int MQTTAsync_persistCommand(MQTTAsync_queuedCommand* qcmd)
|
|||
lens[bufindex++] = sizeof(command->token);
|
||||
|
||||
bufs[bufindex] = command->details.pub.destinationName;
|
||||
lens[bufindex++] = strlen(command->details.pub.destinationName) + 1;
|
||||
lens[bufindex++] = (int)strlen(command->details.pub.destinationName) + 1;
|
||||
|
||||
bufs[bufindex] = &command->details.pub.payloadlen;
|
||||
lens[bufindex++] = sizeof(command->details.pub.payloadlen);
|
||||
|
|
@ -588,7 +655,8 @@ MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int buflen)
|
|||
MQTTAsync_command* command = NULL;
|
||||
MQTTAsync_queuedCommand* qcommand = NULL;
|
||||
char* ptr = buffer;
|
||||
int i, data_size;
|
||||
int i;
|
||||
size_t data_size;
|
||||
|
||||
FUNC_ENTRY;
|
||||
qcommand = malloc(sizeof(MQTTAsync_queuedCommand));
|
||||
|
|
@ -626,7 +694,7 @@ MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int buflen)
|
|||
|
||||
for (i = 0; i < command->details.unsub.count; ++i)
|
||||
{
|
||||
int data_size = strlen(ptr) + 1;
|
||||
size_t data_size = strlen(ptr) + 1;
|
||||
|
||||
command->details.unsub.topics[i] = malloc(data_size);
|
||||
strcpy(command->details.unsub.topics[i], ptr);
|
||||
|
|
@ -760,7 +828,9 @@ int MQTTAsync_addCommand(MQTTAsync_queuedCommand* command, int command_size)
|
|||
}
|
||||
MQTTAsync_unlock_mutex(mqttcommand_mutex);
|
||||
#if !defined(WIN32) && !defined(WIN64)
|
||||
Thread_signal_cond(send_cond);
|
||||
rc = Thread_signal_cond(send_cond);
|
||||
if (rc != 0)
|
||||
Log(LOG_ERROR, 0, "Error %d from signal cond", rc);
|
||||
#else
|
||||
if (!Thread_check_sem(send_sem))
|
||||
Thread_post_sem(send_sem);
|
||||
|
|
@ -770,6 +840,63 @@ int MQTTAsync_addCommand(MQTTAsync_queuedCommand* command, int command_size)
|
|||
}
|
||||
|
||||
|
||||
void MQTTAsync_startConnectRetry(MQTTAsyncs* m)
|
||||
{
|
||||
if (m->automaticReconnect && m->shouldBeConnected)
|
||||
{
|
||||
m->lastConnectionFailedTime = MQTTAsync_start_clock();
|
||||
if (m->retrying)
|
||||
m->currentInterval = min(m->currentInterval * 2, m->maxRetryInterval);
|
||||
else
|
||||
{
|
||||
m->currentInterval = m->minRetryInterval;
|
||||
m->retrying = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int MQTTAsync_reconnect(MQTTAsync handle)
|
||||
{
|
||||
int rc = MQTTASYNC_FAILURE;
|
||||
MQTTAsyncs* m = handle;
|
||||
|
||||
FUNC_ENTRY;
|
||||
MQTTAsync_lock_mutex(mqttasync_mutex);
|
||||
|
||||
if (m->automaticReconnect)
|
||||
{
|
||||
if (m->shouldBeConnected)
|
||||
{
|
||||
m->reconnectNow = 1;
|
||||
if (m->retrying == 0)
|
||||
{
|
||||
m->currentInterval = m->minRetryInterval;
|
||||
m->retrying = 1;
|
||||
}
|
||||
rc = MQTTASYNC_SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* to reconnect, put the connect command to the head of the command queue */
|
||||
MQTTAsync_queuedCommand* conn = malloc(sizeof(MQTTAsync_queuedCommand));
|
||||
memset(conn, '\0', sizeof(MQTTAsync_queuedCommand));
|
||||
conn->client = m;
|
||||
conn->command = m->connect;
|
||||
/* make sure that the version attempts are restarted */
|
||||
if (m->c->MQTTVersion == MQTTVERSION_DEFAULT)
|
||||
conn->command.details.conn.MQTTVersion = 0;
|
||||
MQTTAsync_addCommand(conn, sizeof(m->connect));
|
||||
rc = MQTTASYNC_SUCCESS;
|
||||
}
|
||||
|
||||
MQTTAsync_unlock_mutex(mqttasync_mutex);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
void MQTTAsync_checkDisconnect(MQTTAsync handle, MQTTAsync_command* command)
|
||||
{
|
||||
MQTTAsyncs* m = handle;
|
||||
|
|
@ -780,12 +907,16 @@ void MQTTAsync_checkDisconnect(MQTTAsync handle, MQTTAsync_command* command)
|
|||
{
|
||||
int was_connected = m->c->connected;
|
||||
MQTTAsync_closeSession(m->c);
|
||||
if (command->details.dis.internal && m->cl && was_connected)
|
||||
if (command->details.dis.internal)
|
||||
{
|
||||
Log(TRACE_MIN, -1, "Calling connectionLost for client %s", m->c->clientID);
|
||||
(*(m->cl))(m->context, NULL);
|
||||
if (m->cl && was_connected)
|
||||
{
|
||||
Log(TRACE_MIN, -1, "Calling connectionLost for client %s", m->c->clientID);
|
||||
(*(m->cl))(m->context, NULL);
|
||||
}
|
||||
MQTTAsync_startConnectRetry(m);
|
||||
}
|
||||
else if (!command->details.dis.internal && command->onSuccess)
|
||||
else if (command->onSuccess)
|
||||
{
|
||||
Log(TRACE_MIN, -1, "Calling disconnect complete for client %s", m->c->clientID);
|
||||
(*(command->onSuccess))(command->context, NULL);
|
||||
|
|
@ -823,17 +954,14 @@ void MQTTProtocol_checkPendingWrites()
|
|||
}
|
||||
|
||||
|
||||
void MQTTAsync_freeConnect(MQTTAsync_command command)
|
||||
void MQTTAsync_freeServerURIs(MQTTAsyncs* m)
|
||||
{
|
||||
if (command.type == CONNECT)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < command.details.conn.serverURIcount; ++i)
|
||||
free(command.details.conn.serverURIs[i]);
|
||||
if (command.details.conn.serverURIs)
|
||||
free(command.details.conn.serverURIs);
|
||||
}
|
||||
for (i = 0; i < m->serverURIcount; ++i)
|
||||
free(m->serverURIs[i]);
|
||||
if (m->serverURIs)
|
||||
free(m->serverURIs);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -927,7 +1055,7 @@ void MQTTAsync_writeComplete(int socket)
|
|||
}
|
||||
|
||||
|
||||
void MQTTAsync_processCommand()
|
||||
int MQTTAsync_processCommand()
|
||||
{
|
||||
int rc = 0;
|
||||
MQTTAsync_queuedCommand* command = NULL;
|
||||
|
|
@ -988,20 +1116,21 @@ void MQTTAsync_processCommand()
|
|||
{
|
||||
char* serverURI = command->client->serverURI;
|
||||
|
||||
if (command->command.details.conn.serverURIcount > 0)
|
||||
if (command->client->serverURIcount > 0)
|
||||
{
|
||||
if (command->client->c->MQTTVersion == MQTTVERSION_DEFAULT)
|
||||
{
|
||||
if (command->command.details.conn.MQTTVersion == 3)
|
||||
if (command->command.details.conn.MQTTVersion == MQTTVERSION_3_1)
|
||||
{
|
||||
command->command.details.conn.currentURI++;
|
||||
command->command.details.conn.MQTTVersion = 4;
|
||||
}
|
||||
command->command.details.conn.MQTTVersion = MQTTVERSION_DEFAULT;
|
||||
}
|
||||
}
|
||||
else
|
||||
command->command.details.conn.currentURI++;
|
||||
serverURI = command->command.details.conn.serverURIs[command->command.details.conn.currentURI];
|
||||
|
||||
|
||||
serverURI = command->client->serverURIs[command->command.details.conn.currentURI];
|
||||
|
||||
if (strncmp(URI_TCP, serverURI, strlen(URI_TCP)) == 0)
|
||||
serverURI += strlen(URI_TCP);
|
||||
#if defined(OPENSSL)
|
||||
|
|
@ -1140,6 +1269,7 @@ void MQTTAsync_processCommand()
|
|||
{
|
||||
MQTTAsync_disconnectOptions opts = MQTTAsync_disconnectOptions_initializer;
|
||||
MQTTAsync_disconnect(command->client, &opts); /* not "internal" because we don't want to call connection lost */
|
||||
command->client->shouldBeConnected = 1; /* as above call is not "internal" we need to reset this */
|
||||
}
|
||||
else
|
||||
MQTTAsync_disconnect_internal(command->client, 0);
|
||||
|
|
@ -1157,7 +1287,6 @@ void MQTTAsync_processCommand()
|
|||
Log(TRACE_MIN, -1, "Calling command failure for client %s", command->client->c->clientID);
|
||||
(*(command->command.onFailure))(command->command.context, NULL);
|
||||
}
|
||||
MQTTAsync_freeConnect(command->command);
|
||||
MQTTAsync_freeCommand(command); /* free up the command if necessary */
|
||||
}
|
||||
}
|
||||
|
|
@ -1166,7 +1295,9 @@ void MQTTAsync_processCommand()
|
|||
|
||||
exit:
|
||||
MQTTAsync_unlock_mutex(mqttasync_mutex);
|
||||
FUNC_EXIT;
|
||||
rc = (command != NULL);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1192,7 +1323,7 @@ void MQTTAsync_checkTimeouts()
|
|||
MQTTAsyncs* m = (MQTTAsyncs*)(current->content);
|
||||
|
||||
/* check connect timeout */
|
||||
if (m->c->connect_state != 0 && MQTTAsync_elapsed(m->connect.start_time) > (m->connect.details.conn.timeout * 1000))
|
||||
if (m->c->connect_state != 0 && MQTTAsync_elapsed(m->connect.start_time) > (m->connectTimeout * 1000))
|
||||
{
|
||||
if (MQTTAsync_checkConn(&m->connect, m))
|
||||
{
|
||||
|
|
@ -1210,12 +1341,17 @@ void MQTTAsync_checkTimeouts()
|
|||
else
|
||||
{
|
||||
MQTTAsync_closeSession(m->c);
|
||||
MQTTAsync_freeConnect(m->connect);
|
||||
if (m->connect.onFailure)
|
||||
{
|
||||
MQTTAsync_failureData data;
|
||||
|
||||
data.token = 0;
|
||||
data.code = MQTTASYNC_FAILURE;
|
||||
data.message = "TCP connect timeout";
|
||||
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
|
||||
(*(m->connect.onFailure))(m->connect.context, NULL);
|
||||
(*(m->connect.onFailure))(m->connect.context, &data);
|
||||
}
|
||||
MQTTAsync_startConnectRetry(m);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1245,6 +1381,24 @@ void MQTTAsync_checkTimeouts()
|
|||
}
|
||||
for (i = 0; i < timed_out_count; ++i)
|
||||
ListRemoveHead(m->responses); /* remove the first response in the list */
|
||||
|
||||
if (m->automaticReconnect && m->retrying)
|
||||
{
|
||||
if (m->reconnectNow || MQTTAsync_elapsed(m->lastConnectionFailedTime) > (m->currentInterval * 1000))
|
||||
{
|
||||
/* to reconnect put the connect command to the head of the command queue */
|
||||
MQTTAsync_queuedCommand* conn = malloc(sizeof(MQTTAsync_queuedCommand));
|
||||
memset(conn, '\0', sizeof(MQTTAsync_queuedCommand));
|
||||
conn->client = m;
|
||||
conn->command = m->connect;
|
||||
/* make sure that the version attempts are restarted */
|
||||
if (m->c->MQTTVersion == MQTTVERSION_DEFAULT)
|
||||
conn->command.details.conn.MQTTVersion = 0;
|
||||
Log(TRACE_MIN, -1, "Automatically attempting to reconnect");
|
||||
MQTTAsync_addCommand(conn, sizeof(m->connect));
|
||||
m->reconnectNow = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
MQTTAsync_unlock_mutex(mqttasync_mutex);
|
||||
exit:
|
||||
|
|
@ -1265,13 +1419,10 @@ thread_return_type WINAPI MQTTAsync_sendThread(void* n)
|
|||
|
||||
while (commands->count > 0)
|
||||
{
|
||||
int before = commands->count;
|
||||
MQTTAsync_processCommand();
|
||||
if (before == commands->count)
|
||||
if (MQTTAsync_processCommand() == 0)
|
||||
break; /* no commands were processed, so go into a wait */
|
||||
}
|
||||
#if !defined(WIN32) && !defined(WIN64)
|
||||
rc = Thread_wait_cond(send_cond, 1);
|
||||
if ((rc = Thread_wait_cond(send_cond, 1)) != 0 && rc != ETIMEDOUT)
|
||||
Log(LOG_ERROR, -1, "Error %d waiting for condition variable", rc);
|
||||
#else
|
||||
|
|
@ -1320,11 +1471,26 @@ void MQTTAsync_removeResponsesAndCommands(MQTTAsyncs* m)
|
|||
FUNC_ENTRY;
|
||||
if (m->responses)
|
||||
{
|
||||
ListElement* elem = NULL;
|
||||
ListElement* cur_response = NULL;
|
||||
|
||||
while (ListNextElement(m->responses, &elem))
|
||||
while (ListNextElement(m->responses, &cur_response))
|
||||
{
|
||||
MQTTAsync_freeCommand1((MQTTAsync_queuedCommand*) (elem->content));
|
||||
MQTTAsync_queuedCommand* command = (MQTTAsync_queuedCommand*)(cur_response->content);
|
||||
|
||||
if (command->command.onFailure)
|
||||
{
|
||||
MQTTAsync_failureData data;
|
||||
|
||||
data.token = command->command.token;
|
||||
data.code = MQTTASYNC_OPERATION_INCOMPLETE; /* interrupted return code */
|
||||
data.message = NULL;
|
||||
|
||||
Log(TRACE_MIN, -1, "Calling %s failure for client %s",
|
||||
MQTTPacket_name(command->command.type), m->c->clientID);
|
||||
(*(command->command.onFailure))(command->command.context, &data);
|
||||
}
|
||||
|
||||
MQTTAsync_freeCommand1(command);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1337,12 +1503,26 @@ void MQTTAsync_removeResponsesAndCommands(MQTTAsyncs* m)
|
|||
ListNextElement(commands, &next);
|
||||
while (current)
|
||||
{
|
||||
MQTTAsync_queuedCommand* cmd = (MQTTAsync_queuedCommand*)(current->content);
|
||||
MQTTAsync_queuedCommand* command = (MQTTAsync_queuedCommand*)(current->content);
|
||||
|
||||
if (cmd->client == m)
|
||||
if (command->client == m)
|
||||
{
|
||||
ListDetach(commands, cmd);
|
||||
MQTTAsync_freeCommand(cmd);
|
||||
ListDetach(commands, command);
|
||||
|
||||
if (command->command.onFailure)
|
||||
{
|
||||
MQTTAsync_failureData data;
|
||||
|
||||
data.token = command->command.token;
|
||||
data.code = MQTTASYNC_OPERATION_INCOMPLETE; /* interrupted return code */
|
||||
data.message = NULL;
|
||||
|
||||
Log(TRACE_MIN, -1, "Calling %s failure for client %s",
|
||||
MQTTPacket_name(command->command.type), m->c->clientID);
|
||||
(*(command->command.onFailure))(command->command.context, &data);
|
||||
}
|
||||
|
||||
MQTTAsync_freeCommand(command);
|
||||
count++;
|
||||
}
|
||||
current = next;
|
||||
|
|
@ -1384,6 +1564,9 @@ void MQTTAsync_destroy(MQTTAsync* handle)
|
|||
|
||||
if (m->serverURI)
|
||||
free(m->serverURI);
|
||||
if (m->createOptions)
|
||||
free(m->createOptions);
|
||||
MQTTAsync_freeServerURIs(m);
|
||||
if (!ListRemove(handles, m))
|
||||
Log(LOG_ERROR, -1, "free error");
|
||||
*handle = NULL;
|
||||
|
|
@ -1425,6 +1608,7 @@ int MQTTAsync_completeConnection(MQTTAsyncs* m, MQTTPacket* pack)
|
|||
Log(LOG_PROTOCOL, 1, NULL, m->c->net.socket, m->c->clientID, connack->rc);
|
||||
if ((rc = connack->rc) == MQTTASYNC_SUCCESS)
|
||||
{
|
||||
m->retrying = 0;
|
||||
m->c->connected = 1;
|
||||
m->c->good = 1;
|
||||
m->c->connect_state = 0;
|
||||
|
|
@ -1446,6 +1630,12 @@ int MQTTAsync_completeConnection(MQTTAsyncs* m, MQTTPacket* pack)
|
|||
}
|
||||
free(connack);
|
||||
m->pack = NULL;
|
||||
#if !defined(WIN32) && !defined(WIN64)
|
||||
Thread_signal_cond(send_cond);
|
||||
#else
|
||||
if (!Thread_check_sem(send_sem))
|
||||
Thread_post_sem(send_sem);
|
||||
#endif
|
||||
}
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
|
|
@ -1538,22 +1728,29 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
|
|||
|
||||
if (rc == MQTTASYNC_SUCCESS)
|
||||
{
|
||||
if (m->connect.details.conn.serverURIcount > 0)
|
||||
if (m->serverURIcount > 0)
|
||||
Log(TRACE_MIN, -1, "Connect succeeded to %s",
|
||||
m->connect.details.conn.serverURIs[m->connect.details.conn.currentURI]);
|
||||
MQTTAsync_freeConnect(m->connect);
|
||||
m->serverURIs[m->connect.details.conn.currentURI]);
|
||||
int onSuccess = (m->connect.onSuccess != NULL); /* save setting of onSuccess callback */
|
||||
if (m->connect.onSuccess)
|
||||
{
|
||||
MQTTAsync_successData data;
|
||||
memset(&data, '\0', sizeof(data));
|
||||
Log(TRACE_MIN, -1, "Calling connect success for client %s", m->c->clientID);
|
||||
if (m->connect.details.conn.serverURIcount > 0)
|
||||
data.alt.connect.serverURI = m->connect.details.conn.serverURIs[m->connect.details.conn.currentURI];
|
||||
if (m->serverURIcount > 0)
|
||||
data.alt.connect.serverURI = m->serverURIs[m->connect.details.conn.currentURI];
|
||||
else
|
||||
data.alt.connect.serverURI = m->serverURI;
|
||||
data.alt.connect.MQTTVersion = m->connect.details.conn.MQTTVersion;
|
||||
data.alt.connect.sessionPresent = sessionPresent;
|
||||
(*(m->connect.onSuccess))(m->connect.context, &data);
|
||||
m->connect.onSuccess = NULL; /* don't accidentally call it again */
|
||||
}
|
||||
if (m->connected)
|
||||
{
|
||||
Log(TRACE_MIN, -1, "Calling connected for client %s", m->c->clientID);
|
||||
char* reason = (onSuccess) ? "connect onSuccess called" : "automatic reconnect";
|
||||
(*(m->connected))(m->connected_context, reason);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1574,7 +1771,6 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
|
|||
else
|
||||
{
|
||||
MQTTAsync_closeSession(m->c);
|
||||
MQTTAsync_freeConnect(m->connect);
|
||||
if (m->connect.onFailure)
|
||||
{
|
||||
MQTTAsync_failureData data;
|
||||
|
|
@ -1585,6 +1781,7 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
|
|||
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
|
||||
(*(m->connect.onFailure))(m->connect.context, &data);
|
||||
}
|
||||
MQTTAsync_startConnectRetry(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1758,6 +1955,28 @@ int MQTTAsync_setCallbacks(MQTTAsync handle, void* context,
|
|||
}
|
||||
|
||||
|
||||
int MQTTAsync_setConnected(MQTTAsync handle, void* context, MQTTAsync_connected* connected)
|
||||
{
|
||||
int rc = MQTTASYNC_SUCCESS;
|
||||
MQTTAsyncs* m = handle;
|
||||
|
||||
FUNC_ENTRY;
|
||||
MQTTAsync_lock_mutex(mqttasync_mutex);
|
||||
|
||||
if (m == NULL || m->c->connect_state != 0)
|
||||
rc = MQTTASYNC_FAILURE;
|
||||
else
|
||||
{
|
||||
m->connected_context = context;
|
||||
m->connected = connected;
|
||||
}
|
||||
|
||||
MQTTAsync_unlock_mutex(mqttasync_mutex);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
void MQTTAsync_closeOnly(Clients* client)
|
||||
{
|
||||
FUNC_ENTRY;
|
||||
|
|
@ -1767,10 +1986,12 @@ void MQTTAsync_closeOnly(Clients* client)
|
|||
{
|
||||
if (client->connected)
|
||||
MQTTPacket_send_disconnect(&client->net, client->clientID);
|
||||
Thread_lock_mutex(socket_mutex);
|
||||
#if defined(OPENSSL)
|
||||
SSLSocket_close(&client->net);
|
||||
#endif
|
||||
Socket_close(client->net.socket);
|
||||
Thread_unlock_mutex(socket_mutex);
|
||||
client->net.socket = 0;
|
||||
#if defined(OPENSSL)
|
||||
client->net.ssl = NULL;
|
||||
|
|
@ -1833,16 +2054,13 @@ int MQTTAsync_cleanSession(Clients* client)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int MQTTAsync_deliverMessage(MQTTAsyncs* m, char* topicName, size_t topicLen, MQTTAsync_message* mm)
|
||||
{
|
||||
int rc;
|
||||
|
||||
Log(TRACE_MIN, -1, "Calling messageArrived for client %s, queue depth %d",
|
||||
m->c->clientID, m->c->messageQueue->count);
|
||||
rc = (*(m->ma))(m->context, topicName, topicLen, mm);
|
||||
rc = (*(m->ma))(m->context, topicName, (int)topicLen, mm);
|
||||
/* if 0 (false) is returned by the callback then it failed, so we don't remove the message from
|
||||
* the queue, and it will be retried later. If 1 is returned then the message data may have been freed,
|
||||
* so we must be careful how we use it.
|
||||
|
|
@ -1924,9 +2142,7 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if (strncmp(options->struct_id, "MQTC", 4) != 0 ||
|
||||
(options->struct_version != 0 && options->struct_version != 1 && options->struct_version != 2 &&
|
||||
options->struct_version != 3))
|
||||
if (strncmp(options->struct_id, "MQTC", 4) != 0 || options->struct_version < 0 || options->struct_version > 4)
|
||||
{
|
||||
rc = MQTTASYNC_BAD_STRUCTURE;
|
||||
goto exit;
|
||||
|
|
@ -1962,6 +2178,7 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
|
|||
m->connect.onSuccess = options->onSuccess;
|
||||
m->connect.onFailure = options->onFailure;
|
||||
m->connect.context = options->context;
|
||||
m->connectTimeout = options->connectTimeout;
|
||||
|
||||
tostop = 0;
|
||||
if (sendThread_state != STARTING && sendThread_state != RUNNING)
|
||||
|
|
@ -1982,10 +2199,16 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
|
|||
m->c->keepAliveInterval = options->keepAliveInterval;
|
||||
m->c->cleansession = options->cleansession;
|
||||
m->c->maxInflightMessages = options->maxInflight;
|
||||
if (options->struct_version == 3)
|
||||
if (options->struct_version >= 3)
|
||||
m->c->MQTTVersion = options->MQTTVersion;
|
||||
else
|
||||
m->c->MQTTVersion = 0;
|
||||
if (options->struct_version >= 4)
|
||||
{
|
||||
m->automaticReconnect = options->automaticReconnect;
|
||||
m->minRetryInterval = options->minRetryInterval;
|
||||
m->maxRetryInterval = options->maxRetryInterval;
|
||||
}
|
||||
|
||||
if (m->c->will)
|
||||
{
|
||||
|
|
@ -2042,6 +2265,20 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
|
|||
m->c->username = options->username;
|
||||
m->c->password = options->password;
|
||||
m->c->retryInterval = options->retryInterval;
|
||||
m->shouldBeConnected = 1;
|
||||
|
||||
m->connectTimeout = options->connectTimeout;
|
||||
|
||||
MQTTAsync_freeServerURIs(m);
|
||||
if (options->struct_version >= 2 && options->serverURIcount > 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
m->serverURIcount = options->serverURIcount;
|
||||
m->serverURIs = malloc(options->serverURIcount * sizeof(char*));
|
||||
for (i = 0; i < options->serverURIcount; ++i)
|
||||
m->serverURIs[i] = MQTTStrdup(options->serverURIs[i]);
|
||||
}
|
||||
|
||||
/* Add connect request to operation queue */
|
||||
conn = malloc(sizeof(MQTTAsync_queuedCommand));
|
||||
|
|
@ -2052,20 +2289,9 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
|
|||
conn->command.onSuccess = options->onSuccess;
|
||||
conn->command.onFailure = options->onFailure;
|
||||
conn->command.context = options->context;
|
||||
conn->command.details.conn.timeout = options->connectTimeout;
|
||||
|
||||
if (options->struct_version >= 2 && options->serverURIcount > 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
conn->command.details.conn.serverURIcount = options->serverURIcount;
|
||||
conn->command.details.conn.serverURIs = malloc(options->serverURIcount * sizeof(char*));
|
||||
for (i = 0; i < options->serverURIcount; ++i)
|
||||
conn->command.details.conn.serverURIs[i] = MQTTStrdup(options->serverURIs[i]);
|
||||
conn->command.details.conn.currentURI = 0;
|
||||
}
|
||||
}
|
||||
conn->command.type = CONNECT;
|
||||
conn->command.details.conn.currentURI = 0;
|
||||
rc = MQTTAsync_addCommand(conn, sizeof(conn));
|
||||
|
||||
exit:
|
||||
|
|
@ -2086,6 +2312,8 @@ int MQTTAsync_disconnect1(MQTTAsync handle, const MQTTAsync_disconnectOptions* o
|
|||
rc = MQTTASYNC_FAILURE;
|
||||
goto exit;
|
||||
}
|
||||
if (!internal)
|
||||
m->shouldBeConnected = 0;
|
||||
if (m->c->connected == 0)
|
||||
{
|
||||
rc = MQTTASYNC_DISCONNECTED;
|
||||
|
|
@ -2346,6 +2574,22 @@ int MQTTAsync_unsubscribe(MQTTAsync handle, const char* topic, MQTTAsync_respons
|
|||
}
|
||||
|
||||
|
||||
int MQTTAsync_countBufferedMessages(MQTTAsyncs* m)
|
||||
{
|
||||
ListElement* current = NULL;
|
||||
int count = 0;
|
||||
|
||||
while (ListNextElement(commands, ¤t))
|
||||
{
|
||||
MQTTAsync_queuedCommand* cmd = (MQTTAsync_queuedCommand*)(current->content);
|
||||
|
||||
if (cmd->client == m && cmd->command.type == PUBLISH)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen, void* payload,
|
||||
int qos, int retained, MQTTAsync_responseOptions* response)
|
||||
{
|
||||
|
|
@ -2357,7 +2601,8 @@ int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen
|
|||
FUNC_ENTRY;
|
||||
if (m == NULL || m->c == NULL)
|
||||
rc = MQTTASYNC_FAILURE;
|
||||
else if (m->c->connected == 0)
|
||||
else if (m->c->connected == 0 && (m->createOptions == NULL ||
|
||||
m->createOptions->sendWhileDisconnected == 0 || m->shouldBeConnected == 0))
|
||||
rc = MQTTASYNC_DISCONNECTED;
|
||||
else if (!UTF8_validateString(destinationName))
|
||||
rc = MQTTASYNC_BAD_UTF8_STRING;
|
||||
|
|
@ -2365,6 +2610,8 @@ int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen
|
|||
rc = MQTTASYNC_BAD_QOS;
|
||||
else if (qos > 0 && (msgid = MQTTAsync_assignMsgId(m)) == 0)
|
||||
rc = MQTTASYNC_NO_MORE_MSGIDS;
|
||||
else if (m->createOptions && (MQTTAsync_countBufferedMessages(m) >= m->createOptions->maxBufferedMessages))
|
||||
rc = MQTTASYNC_MAX_BUFFERED_MESSAGES;
|
||||
|
||||
if (rc != MQTTASYNC_SUCCESS)
|
||||
goto exit;
|
||||
|
|
@ -2540,12 +2787,17 @@ exit:
|
|||
else
|
||||
{
|
||||
MQTTAsync_closeSession(m->c);
|
||||
MQTTAsync_freeConnect(m->connect);
|
||||
if (m->connect.onFailure)
|
||||
{
|
||||
MQTTAsync_failureData data;
|
||||
|
||||
data.token = 0;
|
||||
data.code = MQTTASYNC_FAILURE;
|
||||
data.message = "TCP/TLS connect failure";
|
||||
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
|
||||
(*(m->connect.onFailure))(m->connect.context, NULL);
|
||||
(*(m->connect.onFailure))(m->connect.context, &data);
|
||||
}
|
||||
MQTTAsync_startConnectRetry(m);
|
||||
}
|
||||
}
|
||||
FUNC_EXIT_RC(rc);
|
||||
|
|
@ -2558,7 +2810,6 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
|
|||
struct timeval tp = {0L, 0L};
|
||||
static Ack ack;
|
||||
MQTTPacket* pack = NULL;
|
||||
static int nosockets_count = 0;
|
||||
|
||||
FUNC_ENTRY;
|
||||
if (timeout > 0L)
|
||||
|
|
@ -2571,21 +2822,12 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
|
|||
if ((*sock = SSLSocket_getPendingRead()) == -1)
|
||||
{
|
||||
#endif
|
||||
Thread_lock_mutex(socket_mutex);
|
||||
/* 0 from getReadySocket indicates no work to do, -1 == error, but can happen normally */
|
||||
*sock = Socket_getReadySocket(0, &tp);
|
||||
Thread_unlock_mutex(socket_mutex);
|
||||
if (!tostop && *sock == 0 && (tp.tv_sec > 0L || tp.tv_usec > 0L))
|
||||
{
|
||||
MQTTAsync_sleep(100L);
|
||||
#if 0
|
||||
if (s.clientsds->count == 0)
|
||||
{
|
||||
if (++nosockets_count == 50) /* 5 seconds with no sockets */
|
||||
tostop = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
nosockets_count = 0;
|
||||
#if defined(OPENSSL)
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2620,12 +2862,17 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
|
|||
else
|
||||
{
|
||||
MQTTAsync_closeSession(m->c);
|
||||
MQTTAsync_freeConnect(m->connect);
|
||||
if (m->connect.onFailure)
|
||||
{
|
||||
MQTTAsync_failureData data;
|
||||
|
||||
data.token = 0;
|
||||
data.code = MQTTASYNC_FAILURE;
|
||||
data.message = "TCP connect completion failure";
|
||||
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
|
||||
(*(m->connect.onFailure))(m->connect.context, NULL);
|
||||
(*(m->connect.onFailure))(m->connect.context, &data);
|
||||
}
|
||||
MQTTAsync_startConnectRetry(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
126
src/MQTTAsync.h
126
src/MQTTAsync.h
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2015 IBM Corp.
|
||||
* Copyright (c) 2009, 2016 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -15,6 +15,8 @@
|
|||
* Ian Craggs, Allan Stockdill-Mander - SSL connections
|
||||
* Ian Craggs - multiple server connection support
|
||||
* Ian Craggs - MQTT 3.1.1 support
|
||||
* Ian Craggs - fix for bug 444103 - success/failure callbacks not invoked
|
||||
* Ian Craggs - automatic reconnect and offline buffering (send while disconnected)
|
||||
*******************************************************************************/
|
||||
|
||||
/********************************************************************/
|
||||
|
|
@ -23,7 +25,7 @@
|
|||
* @cond MQTTAsync_main
|
||||
* @mainpage Asynchronous MQTT client library for C
|
||||
*
|
||||
* © Copyright IBM Corp. 2009, 2015
|
||||
* © Copyright IBM Corp. 2009, 2016
|
||||
*
|
||||
* @brief An Asynchronous MQTT client library for C.
|
||||
*
|
||||
|
|
@ -149,6 +151,14 @@
|
|||
* Return code: All 65535 MQTT msgids are being used
|
||||
*/
|
||||
#define MQTTASYNC_NO_MORE_MSGIDS -10
|
||||
/**
|
||||
* Return code: the request is being discarded when not complete
|
||||
*/
|
||||
#define MQTTASYNC_OPERATION_INCOMPLETE -11
|
||||
/**
|
||||
* Return code: no more messages can be buffered
|
||||
*/
|
||||
#define MQTTASYNC_MAX_BUFFERED_MESSAGES -12
|
||||
|
||||
/**
|
||||
* Default MQTT version to connect with. Use 3.1.1 then fall back to 3.1
|
||||
|
|
@ -312,6 +322,23 @@ typedef void MQTTAsync_deliveryComplete(void* context, MQTTAsync_token token);
|
|||
*/
|
||||
typedef void MQTTAsync_connectionLost(void* context, char* cause);
|
||||
|
||||
|
||||
/**
|
||||
* This is a callback function, which will be called when the client
|
||||
* library successfully connects. This is superfluous when the connection
|
||||
* is made in response to a MQTTAsync_connect call, because the onSuccess
|
||||
* callback can be used. It is intended for use when automatic reconnect
|
||||
* is enabled, so that when a reconnection attempt succeeds in the background,
|
||||
* the application is notified and can take any required actions.
|
||||
* @param context A pointer to the <i>context</i> value originally passed to
|
||||
* MQTTAsync_setCallbacks(), which contains any application-specific context.
|
||||
* @param cause The reason for the disconnection.
|
||||
* Currently, <i>cause</i> is always set to NULL.
|
||||
*/
|
||||
typedef void MQTTAsync_connected(void* context, char* cause);
|
||||
|
||||
|
||||
|
||||
/** The data returned on completion of an unsuccessful API call in the response callback onFailure. */
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -435,6 +462,32 @@ typedef struct
|
|||
*/
|
||||
DLLExport int MQTTAsync_setCallbacks(MQTTAsync handle, void* context, MQTTAsync_connectionLost* cl,
|
||||
MQTTAsync_messageArrived* ma, MQTTAsync_deliveryComplete* dc);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the MQTTAsync_connected() callback function for a client.
|
||||
* @param handle A valid client handle from a successful call to
|
||||
* MQTTAsync_create().
|
||||
* @param context A pointer to any application-specific context. The
|
||||
* the <i>context</i> pointer is passed to each of the callback functions to
|
||||
* provide access to the context information in the callback.
|
||||
* @param co A pointer to an MQTTAsync_connected() callback
|
||||
* function. NULL removes the callback setting.
|
||||
* @return ::MQTTASYNC_SUCCESS if the callbacks were correctly set,
|
||||
* ::MQTTASYNC_FAILURE if an error occurred.
|
||||
*/
|
||||
DLLExport int MQTTAsync_setConnected(MQTTAsync handle, void* context, MQTTAsync_connected* co);
|
||||
|
||||
|
||||
/**
|
||||
* Reconnects a client with the previously used connect options. Connect
|
||||
* must have previously been called for this to work.
|
||||
* @param handle A valid client handle from a successful call to
|
||||
* MQTTAsync_create().
|
||||
* @return ::MQTTASYNC_SUCCESS if the callbacks were correctly set,
|
||||
* ::MQTTASYNC_FAILURE if an error occurred.
|
||||
*/
|
||||
DLLExport int MQTTAsync_reconnect(MQTTAsync handle);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -483,6 +536,24 @@ DLLExport int MQTTAsync_setCallbacks(MQTTAsync handle, void* context, MQTTAsync_
|
|||
DLLExport int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clientId,
|
||||
int persistence_type, void* persistence_context);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/** The eyecatcher for this structure. must be MQCO. */
|
||||
const char struct_id[4];
|
||||
/** The version number of this structure. Must be 0 */
|
||||
int struct_version;
|
||||
/** Whether to allow messages to be sent when the client library is not connected. */
|
||||
int sendWhileDisconnected;
|
||||
/** the maximum number of messages allowed to be buffered while not connected. */
|
||||
int maxBufferedMessages;
|
||||
} MQTTAsync_createOptions;
|
||||
|
||||
#define MQTTAsync_createOptions_initializer { {'M', 'Q', 'C', 'O'}, 0, 0, 100 }
|
||||
|
||||
|
||||
DLLExport int MQTTAsync_createWithOptions(MQTTAsync* handle, const char* serverURI, const char* clientId,
|
||||
int persistence_type, void* persistence_context, MQTTAsync_createOptions* options);
|
||||
|
||||
/**
|
||||
* MQTTAsync_willOptions defines the MQTT "Last Will and Testament" (LWT) settings for
|
||||
* the client. In the event that a client unexpectedly loses its connection to
|
||||
|
|
@ -578,10 +649,11 @@ typedef struct
|
|||
{
|
||||
/** The eyecatcher for this structure. must be MQTC. */
|
||||
const char struct_id[4];
|
||||
/** The version number of this structure. Must be 0, 1 or 2.
|
||||
/** The version number of this structure. Must be 0, 1, 2, 3 or 4.
|
||||
* 0 signifies no SSL options and no serverURIs
|
||||
* 1 signifies no serverURIs
|
||||
* 2 signifies no MQTTVersion
|
||||
* 3 signifies no automatic reconnect options
|
||||
*/
|
||||
int struct_version;
|
||||
/** The "keep alive" interval, measured in seconds, defines the maximum time
|
||||
|
|
@ -690,10 +762,23 @@ typedef struct
|
|||
* MQTTVERSION_3_1_1 (4) = only try version 3.1.1
|
||||
*/
|
||||
int MQTTVersion;
|
||||
/**
|
||||
* Reconnect automatically in the case of a connection being lost?
|
||||
*/
|
||||
int automaticReconnect;
|
||||
/**
|
||||
* Minimum retry interval in seconds. Doubled on each failed retry.
|
||||
*/
|
||||
int minRetryInterval;
|
||||
/**
|
||||
* Maximum retry interval in seconds. The doubling stops here on failed retries.
|
||||
*/
|
||||
int maxRetryInterval;
|
||||
} MQTTAsync_connectOptions;
|
||||
|
||||
|
||||
#define MQTTAsync_connectOptions_initializer { {'M', 'Q', 'T', 'C'}, 3, 60, 1, 10, NULL, NULL, NULL, 30, 0, NULL, NULL, NULL, NULL, 0, NULL, 0}
|
||||
#define MQTTAsync_connectOptions_initializer { {'M', 'Q', 'T', 'C'}, 4, 60, 1, 10, NULL, NULL, NULL, 30, 0,\
|
||||
NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 1, 60}
|
||||
|
||||
/**
|
||||
* This function attempts to connect a previously-created client (see
|
||||
|
|
@ -908,10 +993,29 @@ DLLExport int MQTTAsync_sendMessage(MQTTAsync handle, const char* destinationNam
|
|||
*/
|
||||
DLLExport int MQTTAsync_getPendingTokens(MQTTAsync handle, MQTTAsync_token **tokens);
|
||||
|
||||
/**
|
||||
* Tests whether a request corresponding to a token is complete.
|
||||
*
|
||||
* @param handle A valid client handle from a successful call to
|
||||
* MQTTAsync_create().
|
||||
* @param token An ::MQTTAsync_token associated with a request.
|
||||
* @return 1 if the request has been completed, 0 if not.
|
||||
*/
|
||||
#define MQTTASYNC_TRUE 1
|
||||
DLLExport int MQTTAsync_isComplete(MQTTAsync handle, MQTTAsync_token dt);
|
||||
DLLExport int MQTTAsync_isComplete(MQTTAsync handle, MQTTAsync_token token);
|
||||
|
||||
DLLExport int MQTTAsync_waitForCompletion(MQTTAsync handle, MQTTAsync_token dt, unsigned long timeout);
|
||||
|
||||
/**
|
||||
* Waits for a request corresponding to a token to complete.
|
||||
*
|
||||
* @param handle A valid client handle from a successful call to
|
||||
* MQTTAsync_create().
|
||||
* @param token An ::MQTTAsync_token associated with a request.
|
||||
* @param timeout the maximum time to wait for completion, in milliseconds
|
||||
* @return ::MQTTASYNC_SUCCESS if the request has been completed in the time allocated,
|
||||
* ::MQTTASYNC_FAILURE if not.
|
||||
*/
|
||||
DLLExport int MQTTAsync_waitForCompletion(MQTTAsync handle, MQTTAsync_token token, unsigned long timeout);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -1007,10 +1111,20 @@ DLLExport MQTTAsync_nameValue* MQTTAsync_getVersionInfo();
|
|||
* The client application runs on several threads.
|
||||
* Processing of handshaking and maintaining
|
||||
* the network connection is performed in the background.
|
||||
* This API is thread safe: functions may be called by multiple application
|
||||
* threads.
|
||||
* Notifications of status and message reception are provided to the client
|
||||
* application using callbacks registered with the library by the call to
|
||||
* MQTTAsync_setCallbacks() (see MQTTAsync_messageArrived(),
|
||||
* MQTTAsync_connectionLost() and MQTTAsync_deliveryComplete()).
|
||||
* In addition, some functions allow success and failure callbacks to be set
|
||||
* for individual requests, in the ::MQTTAsync_responseOptions structure. Applications
|
||||
* can be written as a chain of callback functions. Note that it is a theoretically
|
||||
* possible but unlikely event, that a success or failure callback could be called
|
||||
* before function requesting the callback has returned. In this case the token
|
||||
* delivered in the callback would not yet be known to the application program (see
|
||||
* Race condition for MQTTAsync_token in MQTTAsync.c
|
||||
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=444093)
|
||||
*
|
||||
* @page wildcard Subscription wildcards
|
||||
* Every MQTT message includes a topic that classifies it. MQTT servers use
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2014 IBM Corp.
|
||||
* Copyright (c) 2009, 2015 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -26,6 +26,9 @@
|
|||
* Rong Xiang, Ian Craggs - C++ compatibility
|
||||
* Ian Craggs - fix for bug 443724 - stack corruption
|
||||
* Ian Craggs - fix for bug 447672 - simultaneous access to socket structure
|
||||
* Ian Craggs - fix for bug 459791 - deadlock in WaitForCompletion for bad client
|
||||
* Ian Craggs - fix for bug 474905 - insufficient synchronization for subscribe, unsubscribe, connect
|
||||
* Ian Craggs - make it clear that yield and receive are not intended for multi-threaded mode (bug 474748)
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
@ -59,8 +62,7 @@
|
|||
|
||||
#define URI_TCP "tcp://"
|
||||
|
||||
#define BUILD_TIMESTAMP "##MQTTCLIENT_BUILD_TAG##"
|
||||
#define CLIENT_VERSION "##MQTTCLIENT_VERSION_TAG##"
|
||||
#include "VersionInfo.h"
|
||||
|
||||
char* client_timestamp_eye = "MQTTClientV3_Timestamp " BUILD_TIMESTAMP;
|
||||
char* client_version_eye = "MQTTClientV3_Version " CLIENT_VERSION;
|
||||
|
|
@ -78,6 +80,9 @@ MQTTProtocol state;
|
|||
#if defined(WIN32) || defined(WIN64)
|
||||
static mutex_type mqttclient_mutex = NULL;
|
||||
static mutex_type socket_mutex = NULL;
|
||||
static mutex_type subscribe_mutex = NULL;
|
||||
static mutex_type unsubscribe_mutex = NULL;
|
||||
static mutex_type connect_mutex = NULL;
|
||||
extern mutex_type stack_mutex;
|
||||
extern mutex_type heap_mutex;
|
||||
extern mutex_type log_mutex;
|
||||
|
|
@ -92,6 +97,9 @@ BOOL APIENTRY DllMain(HANDLE hModule,
|
|||
if (mqttclient_mutex == NULL)
|
||||
{
|
||||
mqttclient_mutex = CreateMutex(NULL, 0, NULL);
|
||||
subscribe_mutex = CreateMutex(NULL, 0, NULL);
|
||||
unsubscribe_mutex = CreateMutex(NULL, 0, NULL);
|
||||
connect_mutex = CreateMutex(NULL, 0, NULL);
|
||||
stack_mutex = CreateMutex(NULL, 0, NULL);
|
||||
heap_mutex = CreateMutex(NULL, 0, NULL);
|
||||
log_mutex = CreateMutex(NULL, 0, NULL);
|
||||
|
|
@ -109,9 +117,19 @@ BOOL APIENTRY DllMain(HANDLE hModule,
|
|||
#else
|
||||
static pthread_mutex_t mqttclient_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
static mutex_type mqttclient_mutex = &mqttclient_mutex_store;
|
||||
|
||||
static pthread_mutex_t socket_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
static mutex_type socket_mutex = &socket_mutex_store;
|
||||
|
||||
static pthread_mutex_t subscribe_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
static mutex_type subscribe_mutex = &subscribe_mutex_store;
|
||||
|
||||
static pthread_mutex_t unsubscribe_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
static mutex_type unsubscribe_mutex = &unsubscribe_mutex_store;
|
||||
|
||||
static pthread_mutex_t connect_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
static mutex_type connect_mutex = &connect_mutex_store;
|
||||
|
||||
void MQTTClient_init()
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
|
|
@ -123,6 +141,12 @@ void MQTTClient_init()
|
|||
printf("MQTTClient: error %d initializing client_mutex\n", rc);
|
||||
if ((rc = pthread_mutex_init(socket_mutex, &attr)) != 0)
|
||||
printf("MQTTClient: error %d initializing socket_mutex\n", rc);
|
||||
if ((rc = pthread_mutex_init(subscribe_mutex, &attr)) != 0)
|
||||
printf("MQTTClient: error %d initializing subscribe_mutex\n", rc);
|
||||
if ((rc = pthread_mutex_init(unsubscribe_mutex, &attr)) != 0)
|
||||
printf("MQTTClient: error %d initializing unsubscribe_mutex\n", rc);
|
||||
if ((rc = pthread_mutex_init(connect_mutex, &attr)) != 0)
|
||||
printf("MQTTClient: error %d initializing connect_mutex\n", rc);
|
||||
}
|
||||
|
||||
#define WINAPI
|
||||
|
|
@ -509,11 +533,7 @@ thread_return_type WINAPI MQTTClient_run(void* n)
|
|||
if (rc == SOCKET_ERROR)
|
||||
{
|
||||
if (m->c->connected)
|
||||
{
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
MQTTClient_disconnect_internal(m, 0);
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m->c->connect_state == 2 && !Thread_check_sem(m->connect_sem))
|
||||
|
|
@ -933,11 +953,7 @@ exit:
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
MQTTClient_disconnect1(handle, 0, 0, (MQTTVersion == 3)); /* not "internal" because we don't want to call connection lost */
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
}
|
||||
MQTTClient_disconnect1(handle, 0, 0, (MQTTVersion == 3)); /* don't want to call connection lost */
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -1039,6 +1055,7 @@ int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions* options)
|
|||
int rc = SOCKET_ERROR;
|
||||
|
||||
FUNC_ENTRY;
|
||||
Thread_lock_mutex(connect_mutex);
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
|
||||
if (options == NULL)
|
||||
|
|
@ -1113,12 +1130,16 @@ exit:
|
|||
m->c->will = NULL;
|
||||
}
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
Thread_unlock_mutex(connect_mutex);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int MQTTClient_disconnect1(MQTTClient handle, int timeout, int internal, int stop)
|
||||
/**
|
||||
* mqttclient_mutex must be locked when you call this function, if multi threaded
|
||||
*/
|
||||
int MQTTClient_disconnect1(MQTTClient handle, int timeout, int call_connection_lost, int stop)
|
||||
{
|
||||
MQTTClients* m = handle;
|
||||
START_TIME_TYPE start;
|
||||
|
|
@ -1126,8 +1147,6 @@ int MQTTClient_disconnect1(MQTTClient handle, int timeout, int internal, int sto
|
|||
int was_connected = 0;
|
||||
|
||||
FUNC_ENTRY;
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
|
||||
if (m == NULL || m->c == NULL)
|
||||
{
|
||||
rc = MQTTCLIENT_FAILURE;
|
||||
|
|
@ -1166,23 +1185,28 @@ int MQTTClient_disconnect1(MQTTClient handle, int timeout, int internal, int sto
|
|||
exit:
|
||||
if (stop)
|
||||
MQTTClient_stop();
|
||||
if (internal && m->cl && was_connected)
|
||||
if (call_connection_lost && m->cl && was_connected)
|
||||
{
|
||||
Log(TRACE_MIN, -1, "Calling connectionLost for client %s", m->c->clientID);
|
||||
Thread_start(connectionLost_call, m);
|
||||
}
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mqttclient_mutex must be locked when you call this function, if multi threaded
|
||||
*/
|
||||
int MQTTClient_disconnect_internal(MQTTClient handle, int timeout)
|
||||
{
|
||||
return MQTTClient_disconnect1(handle, timeout, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mqttclient_mutex must be locked when you call this function, if multi threaded
|
||||
*/
|
||||
void MQTTProtocol_closeSession(Clients* c, int sendwill)
|
||||
{
|
||||
MQTTClient_disconnect_internal((MQTTClient)c->context, 0);
|
||||
|
|
@ -1191,7 +1215,12 @@ void MQTTProtocol_closeSession(Clients* c, int sendwill)
|
|||
|
||||
int MQTTClient_disconnect(MQTTClient handle, int timeout)
|
||||
{
|
||||
return MQTTClient_disconnect1(handle, timeout, 0, 1);
|
||||
int rc = 0;
|
||||
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
rc = MQTTClient_disconnect1(handle, timeout, 0, 1);
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1213,13 +1242,14 @@ int MQTTClient_isConnected(MQTTClient handle)
|
|||
int MQTTClient_subscribeMany(MQTTClient handle, int count, char* const* topic, int* qos)
|
||||
{
|
||||
MQTTClients* m = handle;
|
||||
List* topics = ListInitialize();
|
||||
List* qoss = ListInitialize();
|
||||
List* topics = NULL;
|
||||
List* qoss = NULL;
|
||||
int i = 0;
|
||||
int rc = MQTTCLIENT_FAILURE;
|
||||
int msgid = 0;
|
||||
|
||||
FUNC_ENTRY;
|
||||
Thread_lock_mutex(subscribe_mutex);
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
|
||||
if (m == NULL || m->c == NULL)
|
||||
|
|
@ -1252,6 +1282,8 @@ int MQTTClient_subscribeMany(MQTTClient handle, int count, char* const* topic, i
|
|||
goto exit;
|
||||
}
|
||||
|
||||
topics = ListInitialize();
|
||||
qoss = ListInitialize();
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
ListAppend(topics, topic[i], strlen(topic[i]));
|
||||
|
|
@ -1287,16 +1319,13 @@ int MQTTClient_subscribeMany(MQTTClient handle, int count, char* const* topic, i
|
|||
}
|
||||
|
||||
if (rc == SOCKET_ERROR)
|
||||
{
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
MQTTClient_disconnect_internal(handle, 0);
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
}
|
||||
else if (rc == TCPSOCKET_COMPLETE)
|
||||
rc = MQTTCLIENT_SUCCESS;
|
||||
|
||||
exit:
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
Thread_unlock_mutex(subscribe_mutex);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -1319,12 +1348,13 @@ int MQTTClient_subscribe(MQTTClient handle, const char* topic, int qos)
|
|||
int MQTTClient_unsubscribeMany(MQTTClient handle, int count, char* const* topic)
|
||||
{
|
||||
MQTTClients* m = handle;
|
||||
List* topics = ListInitialize();
|
||||
List* topics = NULL;
|
||||
int i = 0;
|
||||
int rc = SOCKET_ERROR;
|
||||
int msgid = 0;
|
||||
|
||||
FUNC_ENTRY;
|
||||
Thread_lock_mutex(unsubscribe_mutex);
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
|
||||
if (m == NULL || m->c == NULL)
|
||||
|
|
@ -1351,6 +1381,7 @@ int MQTTClient_unsubscribeMany(MQTTClient handle, int count, char* const* topic)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
topics = ListInitialize();
|
||||
for (i = 0; i < count; i++)
|
||||
ListAppend(topics, topic[i], strlen(topic[i]));
|
||||
rc = MQTTProtocol_unsubscribe(m->c, topics, msgid);
|
||||
|
|
@ -1373,14 +1404,11 @@ int MQTTClient_unsubscribeMany(MQTTClient handle, int count, char* const* topic)
|
|||
}
|
||||
|
||||
if (rc == SOCKET_ERROR)
|
||||
{
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
MQTTClient_disconnect_internal(handle, 0);
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
}
|
||||
|
||||
exit:
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
Thread_unlock_mutex(unsubscribe_mutex);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -1477,9 +1505,7 @@ int MQTTClient_publish(MQTTClient handle, const char* topicName, int payloadlen,
|
|||
|
||||
if (rc == SOCKET_ERROR)
|
||||
{
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
MQTTClient_disconnect_internal(handle, 0);
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
/* Return success for qos > 0 as the send will be retried automatically */
|
||||
rc = (qos > 0) ? MQTTCLIENT_SUCCESS : MQTTCLIENT_FAILURE;
|
||||
}
|
||||
|
|
@ -1721,7 +1747,8 @@ int MQTTClient_receive(MQTTClient handle, char** topicName, int* topicLen, MQTTC
|
|||
MQTTClients* m = handle;
|
||||
|
||||
FUNC_ENTRY;
|
||||
if (m == NULL || m->c == NULL)
|
||||
if (m == NULL || m->c == NULL
|
||||
|| running) /* receive is not meant to be called in a multi-thread environment */
|
||||
{
|
||||
rc = MQTTCLIENT_FAILURE;
|
||||
goto exit;
|
||||
|
|
@ -1775,7 +1802,7 @@ void MQTTClient_yield(void)
|
|||
int rc = 0;
|
||||
|
||||
FUNC_ENTRY;
|
||||
if (running)
|
||||
if (running) /* yield is not meant to be called in a multi-thread environment */
|
||||
{
|
||||
MQTTClient_sleep(timeout);
|
||||
goto exit;
|
||||
|
|
@ -1786,12 +1813,14 @@ void MQTTClient_yield(void)
|
|||
{
|
||||
int sock = -1;
|
||||
MQTTClient_cycle(&sock, (timeout > elapsed) ? timeout - elapsed : 0L, &rc);
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
if (rc == SOCKET_ERROR && ListFindItem(handles, &sock, clientSockCompare))
|
||||
{
|
||||
MQTTClients* m = (MQTTClient)(handles->current->content);
|
||||
if (m->c->connect_state != -2)
|
||||
MQTTClient_disconnect_internal(m, 0);
|
||||
}
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
elapsed = MQTTClient_elapsed(start);
|
||||
}
|
||||
while (elapsed < timeout);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@
|
|||
*
|
||||
* Both libraries are designed to be sparing in the use of threads. So multiple client objects are
|
||||
* handled by one or two threads, with a select call in Socket_getReadySocket(), used to determine
|
||||
* when a socket has incoming data.
|
||||
* when a socket has incoming data. This API is thread safe: functions may be called by multiple application
|
||||
* threads, with the exception of ::MQTTClient_yield and ::MQTTClient_receive, which are intended
|
||||
* for single threaded environments only.
|
||||
*
|
||||
* @endcond
|
||||
* @cond MQTTClient_main
|
||||
|
|
@ -47,6 +49,7 @@
|
|||
* totally asynchronous API where no calls block, which is especially suitable
|
||||
* for use in windowed environments, see the
|
||||
* <a href="../Casync/index.html">MQTT C Client Asynchronous API Documentation</a>.
|
||||
* The MQTTClient API is not thread safe, whereas the MQTTAsync API is.
|
||||
*
|
||||
* An MQTT client application connects to MQTT-capable servers.
|
||||
* A typical client is responsible for collecting information from a telemetry
|
||||
|
|
@ -936,7 +939,7 @@ DLLExport void MQTTClient_destroy(MQTTClient* handle);
|
|||
* (see @ref qos) message has been successfully delivered, the application
|
||||
* must call the MQTTClient_waitForCompletion() function. An example showing
|
||||
* synchronous publication is shown in @ref pubsync. Receiving messages in
|
||||
* synchronous mode uses the MQTTClient_receive() function. Client applicaitons
|
||||
* synchronous mode uses the MQTTClient_receive() function. Client applications
|
||||
* must call either MQTTClient_receive() or MQTTClient_yield() relatively
|
||||
* frequently in order to allow processing of acknowledgements and the MQTT
|
||||
* "pings" that keep the network connection to the server alive.
|
||||
|
|
@ -949,6 +952,8 @@ DLLExport void MQTTClient_destroy(MQTTClient* handle);
|
|||
* application using callbacks registered with the library by the call to
|
||||
* MQTTClient_setCallbacks() (see MQTTClient_messageArrived(),
|
||||
* MQTTClient_connectionLost() and MQTTClient_deliveryComplete()).
|
||||
* This API is not thread safe however - it is not possible to call it from multiple
|
||||
* threads without synchronization. You can use the MQTTAsync API for that.
|
||||
*
|
||||
* @page wildcard Subscription wildcards
|
||||
* Every MQTT message includes a topic that classifies it. MQTT servers use
|
||||
|
|
|
|||
|
|
@ -96,10 +96,10 @@ void* MQTTPacket_Factory(networkHandles* net, int* error)
|
|||
{
|
||||
char* data = NULL;
|
||||
static Header header;
|
||||
int remaining_length, ptype;
|
||||
size_t remaining_length_new;
|
||||
size_t remaining_length;
|
||||
int ptype;
|
||||
void* pack = NULL;
|
||||
int actual_len = 0;
|
||||
size_t actual_len = 0;
|
||||
|
||||
FUNC_ENTRY;
|
||||
*error = SOCKET_ERROR; /* indicate whether an error occurred, or not */
|
||||
|
|
@ -148,9 +148,8 @@ void* MQTTPacket_Factory(networkHandles* net, int* error)
|
|||
char *buf = malloc(10);
|
||||
buf[0] = header.byte;
|
||||
buf0len = 1 + MQTTPacket_encode(&buf[1], remaining_length);
|
||||
remaining_length_new = remaining_length;
|
||||
*error = MQTTPersistence_put(net->socket, buf, buf0len, 1,
|
||||
&data, &remaining_length_new, header.bits.type, ((Publish *)pack)->msgId, 1);
|
||||
&data, &remaining_length, header.bits.type, ((Publish *)pack)->msgId, 1);
|
||||
free(buf);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -174,7 +173,8 @@ exit:
|
|||
*/
|
||||
int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buflen, int free)
|
||||
{
|
||||
int rc, buf0len;
|
||||
int rc;
|
||||
size_t buf0len;
|
||||
char *buf;
|
||||
|
||||
FUNC_ENTRY;
|
||||
|
|
@ -220,7 +220,8 @@ int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buf
|
|||
*/
|
||||
int MQTTPacket_sends(networkHandles* net, Header header, int count, char** buffers, size_t* buflens, int* frees)
|
||||
{
|
||||
int i, rc, buf0len, total = 0;
|
||||
int i, rc;
|
||||
size_t buf0len, total = 0;
|
||||
char *buf;
|
||||
|
||||
FUNC_ENTRY;
|
||||
|
|
@ -261,7 +262,7 @@ int MQTTPacket_sends(networkHandles* net, Header header, int count, char** buffe
|
|||
* @param length the length to be encoded
|
||||
* @return the number of bytes written to buffer
|
||||
*/
|
||||
int MQTTPacket_encode(char* buf, int length)
|
||||
int MQTTPacket_encode(char* buf, size_t length)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
|
@ -286,7 +287,7 @@ int MQTTPacket_encode(char* buf, int length)
|
|||
* @param value the decoded length returned
|
||||
* @return the number of bytes read from the socket
|
||||
*/
|
||||
int MQTTPacket_decode(networkHandles* net, int* value)
|
||||
int MQTTPacket_decode(networkHandles* net, size_t* value)
|
||||
{
|
||||
int rc = SOCKET_ERROR;
|
||||
char c;
|
||||
|
|
@ -429,8 +430,8 @@ void writeInt(char** pptr, int anInt)
|
|||
*/
|
||||
void writeUTF(char** pptr, const char* string)
|
||||
{
|
||||
int len = strlen(string);
|
||||
writeInt(pptr, len);
|
||||
size_t len = strlen(string);
|
||||
writeInt(pptr, (int)len);
|
||||
memcpy(*pptr, string, len);
|
||||
*pptr += len;
|
||||
}
|
||||
|
|
@ -497,7 +498,7 @@ void* MQTTPacket_publish(unsigned char aHeader, char* data, size_t datalen)
|
|||
else
|
||||
pack->msgId = 0;
|
||||
pack->payload = curdata;
|
||||
pack->payloadlen = datalen-(curdata-data);
|
||||
pack->payloadlen = (int)(datalen-(curdata-data));
|
||||
exit:
|
||||
FUNC_EXIT;
|
||||
return pack;
|
||||
|
|
@ -691,7 +692,7 @@ int MQTTPacket_send_publish(Publish* pack, int dup, int qos, int retained, netwo
|
|||
|
||||
writeInt(&ptr, pack->msgId);
|
||||
ptr = topiclen;
|
||||
writeInt(&ptr, lens[1]);
|
||||
writeInt(&ptr, (int)lens[1]);
|
||||
rc = MQTTPacket_sends(net, header, 4, bufs, lens, frees);
|
||||
if (rc != TCPSOCKET_INTERRUPTED)
|
||||
free(buf);
|
||||
|
|
@ -703,7 +704,7 @@ int MQTTPacket_send_publish(Publish* pack, int dup, int qos, int retained, netwo
|
|||
size_t lens[3] = {2, strlen(pack->topic), pack->payloadlen};
|
||||
int frees[3] = {1, 0, 0};
|
||||
|
||||
writeInt(&ptr, lens[1]);
|
||||
writeInt(&ptr, (int)lens[1]);
|
||||
rc = MQTTPacket_sends(net, header, 3, bufs, lens, frees);
|
||||
}
|
||||
if (rc != TCPSOCKET_INTERRUPTED)
|
||||
|
|
|
|||
|
|
@ -216,8 +216,8 @@ typedef Ack Pubrel;
|
|||
typedef Ack Pubcomp;
|
||||
typedef Ack Unsuback;
|
||||
|
||||
int MQTTPacket_encode(char* buf, int length);
|
||||
int MQTTPacket_decode(networkHandles* net, int* value);
|
||||
int MQTTPacket_encode(char* buf, size_t length);
|
||||
int MQTTPacket_decode(networkHandles* net, size_t* value);
|
||||
int readInt(char** pptr);
|
||||
char* readUTF(char** pptr, char* enddata);
|
||||
unsigned char readChar(char** pptr);
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ int MQTTPacket_send_connect(Clients* client, int MQTTVersion)
|
|||
packet.header.byte = 0;
|
||||
packet.header.bits.type = CONNECT;
|
||||
|
||||
len = ((MQTTVersion == 3) ? 12 : 10) + strlen(client->clientID)+2;
|
||||
len = ((MQTTVersion == 3) ? 12 : 10) + (int)strlen(client->clientID)+2;
|
||||
if (client->will)
|
||||
len += strlen(client->will->topic)+2 + strlen(client->will->msg)+2;
|
||||
len += (int)strlen(client->will->topic)+2 + (int)strlen(client->will->msg)+2;
|
||||
if (client->username)
|
||||
len += strlen(client->username)+2;
|
||||
len += (int)strlen(client->username)+2;
|
||||
if (client->password)
|
||||
len += strlen(client->password)+2;
|
||||
len += (int)strlen(client->password)+2;
|
||||
|
||||
ptr = buf = malloc(len);
|
||||
if (MQTTVersion == 3)
|
||||
|
|
@ -179,7 +179,7 @@ int MQTTPacket_send_subscribe(List* topics, List* qoss, int msgid, int dup, netw
|
|||
|
||||
datalen = 2 + topics->count * 3; // utf length + char qos == 3
|
||||
while (ListNextElement(topics, &elem))
|
||||
datalen += strlen((char*)(elem->content));
|
||||
datalen += (int)strlen((char*)(elem->content));
|
||||
ptr = data = malloc(datalen);
|
||||
|
||||
writeInt(&ptr, msgid);
|
||||
|
|
@ -252,7 +252,7 @@ int MQTTPacket_send_unsubscribe(List* topics, int msgid, int dup, networkHandles
|
|||
|
||||
datalen = 2 + topics->count * 2; // utf length == 2
|
||||
while (ListNextElement(topics, &elem))
|
||||
datalen += strlen((char*)(elem->content));
|
||||
datalen += (int)strlen((char*)(elem->content));
|
||||
ptr = data = malloc(datalen);
|
||||
|
||||
writeInt(&ptr, msgid);
|
||||
|
|
|
|||
|
|
@ -350,13 +350,13 @@ int MQTTPersistence_put(int socket, char* buf0, size_t buf0len, int count,
|
|||
{
|
||||
key = malloc(MESSAGE_FILENAME_LENGTH + 1);
|
||||
nbufs = 1 + count;
|
||||
lens = (int *) malloc(nbufs * sizeof(int));
|
||||
lens = (int *)malloc(nbufs * sizeof(int));
|
||||
bufs = (char **)malloc(nbufs * sizeof(char *));
|
||||
lens[0] = buf0len;
|
||||
lens[0] = (int)buf0len;
|
||||
bufs[0] = buf0;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
lens[i+1] = buflens[i];
|
||||
lens[i+1] = (int)buflens[i];
|
||||
bufs[i+1] = buffers[i];
|
||||
}
|
||||
|
||||
|
|
@ -512,7 +512,7 @@ int MQTTPersistence_persistQueueEntry(Clients* aclient, MQTTPersistence_qEntry*
|
|||
lens[bufindex++] = sizeof(qe->msg->msgid);
|
||||
|
||||
bufs[bufindex] = qe->topicName;
|
||||
lens[bufindex++] = strlen(qe->topicName) + 1;
|
||||
lens[bufindex++] = (int)strlen(qe->topicName) + 1;
|
||||
|
||||
bufs[bufindex] = &qe->topicLen;
|
||||
lens[bufindex++] = sizeof(qe->topicLen);
|
||||
|
|
@ -564,7 +564,7 @@ MQTTPersistence_qEntry* MQTTPersistence_restoreQueueEntry(char* buffer, size_t b
|
|||
qe->msg->msgid = *(int*)ptr;
|
||||
ptr += sizeof(int);
|
||||
|
||||
data_size = strlen(ptr) + 1;
|
||||
data_size = (int)strlen(ptr) + 1;
|
||||
qe->topicName = malloc(data_size);
|
||||
strcpy(qe->topicName, ptr);
|
||||
ptr += data_size;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2014 IBM Corp.
|
||||
* Copyright (c) 2009, 2016 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
* Contributors:
|
||||
* Ian Craggs - initial API and implementation and/or initial documentation
|
||||
* Ian Craggs - async client updates
|
||||
* Ian Craggs - fix for bug 484496
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
@ -73,8 +74,8 @@ int pstopen(void **handle, const char* clientID, const char* serverURI, void* co
|
|||
/* Note that serverURI=address:port, but ":" not allowed in Windows directories */
|
||||
perserverURI = malloc(strlen(serverURI) + 1);
|
||||
strcpy(perserverURI, serverURI);
|
||||
ptraux = strstr(perserverURI, ":");
|
||||
*ptraux = '-' ;
|
||||
while ((ptraux = strstr(perserverURI, ":")) != NULL)
|
||||
*ptraux = '-' ;
|
||||
|
||||
/* consider '/' + '-' + '\0' */
|
||||
clientDir = malloc(strlen(dataDir) + strlen(clientID) + strlen(perserverURI) + 3);
|
||||
|
|
@ -148,8 +149,8 @@ int pstput(void* handle, char* key, int bufcount, char* buffers[], int buflens[]
|
|||
char *clientDir = handle;
|
||||
char *file;
|
||||
FILE *fp;
|
||||
int bytesWritten = 0;
|
||||
int bytesTotal = 0;
|
||||
size_t bytesWritten = 0,
|
||||
bytesTotal = 0;
|
||||
int i;
|
||||
|
||||
FUNC_ENTRY;
|
||||
|
|
@ -169,14 +170,14 @@ int pstput(void* handle, char* key, int bufcount, char* buffers[], int buflens[]
|
|||
for(i=0; i<bufcount; i++)
|
||||
{
|
||||
bytesTotal += buflens[i];
|
||||
bytesWritten += fwrite( buffers[i], sizeof(char), buflens[i], fp );
|
||||
bytesWritten += fwrite(buffers[i], sizeof(char), buflens[i], fp );
|
||||
}
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
} else
|
||||
rc = MQTTCLIENT_PERSISTENCE_ERROR;
|
||||
|
||||
if ( bytesWritten != bytesTotal )
|
||||
if (bytesWritten != bytesTotal)
|
||||
{
|
||||
pstremove(handle, key);
|
||||
rc = MQTTCLIENT_PERSISTENCE_ERROR;
|
||||
|
|
@ -221,7 +222,7 @@ int pstget(void* handle, char* key, char** buffer, int* buflen)
|
|||
fileLen = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
buf=(char *)malloc(fileLen);
|
||||
bytesRead = fread(buf, sizeof(char), fileLen, fp);
|
||||
bytesRead = (int)fread(buf, sizeof(char), fileLen, fp);
|
||||
*buffer = buf;
|
||||
*buflen = bytesRead;
|
||||
if ( bytesRead != fileLen )
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ Publications* MQTTProtocol_storePublication(Publish* publish, int* len)
|
|||
FUNC_ENTRY;
|
||||
p->refcount = 1;
|
||||
|
||||
*len = strlen(publish->topic)+1;
|
||||
*len = (int)strlen(publish->topic)+1;
|
||||
if (Heap_findItem(publish->topic))
|
||||
p->topic = publish->topic;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2014 IBM Corp.
|
||||
* Copyright (c) 2009, 2016 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
* Ian Craggs - fix for buffer overflow in addressPort bug #433290
|
||||
* Ian Craggs - MQTT 3.1.1 support
|
||||
* Rong Xiang, Ian Craggs - C++ compatibility
|
||||
* Ian Craggs - fix for bug 479376
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
@ -45,7 +46,7 @@ char* MQTTProtocol_addressPort(const char* uri, int* port)
|
|||
{
|
||||
char* colon_pos = strrchr(uri, ':'); /* reverse find to allow for ':' in IPv6 addresses */
|
||||
char* buf = (char*)uri;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
FUNC_ENTRY;
|
||||
if (uri[0] == '[')
|
||||
|
|
@ -56,7 +57,7 @@ char* MQTTProtocol_addressPort(const char* uri, int* port)
|
|||
|
||||
if (colon_pos)
|
||||
{
|
||||
int addr_len = colon_pos - uri;
|
||||
size_t addr_len = colon_pos - uri;
|
||||
buf = malloc(addr_len + 1);
|
||||
*port = atoi(colon_pos + 1);
|
||||
MQTTStrncpy(buf, uri, addr_len+1);
|
||||
|
|
@ -102,7 +103,7 @@ int MQTTProtocol_connect(const char* ip_address, Clients* aClient, int MQTTVersi
|
|||
#if defined(OPENSSL)
|
||||
if (ssl)
|
||||
{
|
||||
if (SSLSocket_setSocketForSSL(&aClient->net, aClient->sslopts) != 1)
|
||||
if (SSLSocket_setSocketForSSL(&aClient->net, aClient->sslopts) == 1)
|
||||
{
|
||||
rc = SSLSocket_connect(aClient->net.ssl, aClient->net.socket);
|
||||
if (rc == -1)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ char* FindString(char* filename, char* eyecatcher_input)
|
|||
memset(value, 0, 100);
|
||||
if ((infile = fopen(filename, "rb")) != NULL)
|
||||
{
|
||||
int buflen = strlen(eyecatcher);
|
||||
size_t buflen = strlen(eyecatcher);
|
||||
char* buffer = (char*) malloc(buflen);
|
||||
int count = 0;
|
||||
int c = fgetc(infile);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2014 IBM Corp.
|
||||
* Copyright (c) 2009, 2016 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -14,6 +14,8 @@
|
|||
* Ian Craggs, Allan Stockdill-Mander - initial implementation
|
||||
* Ian Craggs - fix for bug #409702
|
||||
* Ian Craggs - allow compilation for OpenSSL < 1.0
|
||||
* Ian Craggs - fix for bug #453883
|
||||
* Ian Craggs - fix for bug #480363, issue 13
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
@ -294,7 +296,7 @@ int pem_passwd_cb(char* buf, int size, int rwflag, void* userdata)
|
|||
{
|
||||
strncpy(buf, (char*)(userdata), size);
|
||||
buf[size-1] = '\0';
|
||||
rc = strlen(buf);
|
||||
rc = (int)strlen(buf);
|
||||
}
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
|
|
@ -353,7 +355,6 @@ void SSL_destroy_mutex(ssl_mutex_type* mutex)
|
|||
rc = CloseHandle(*mutex);
|
||||
#else
|
||||
rc = pthread_mutex_destroy(mutex);
|
||||
free(mutex);
|
||||
#endif
|
||||
FUNC_EXIT_RC(rc);
|
||||
}
|
||||
|
|
@ -382,10 +383,13 @@ extern unsigned long SSLThread_id(void)
|
|||
|
||||
extern void SSLLocks_callback(int mode, int n, const char *file, int line)
|
||||
{
|
||||
if (mode & CRYPTO_LOCK)
|
||||
SSL_lock_mutex(&sslLocks[n]);
|
||||
else
|
||||
SSL_unlock_mutex(&sslLocks[n]);
|
||||
if (sslLocks)
|
||||
{
|
||||
if (mode & CRYPTO_LOCK)
|
||||
SSL_lock_mutex(&sslLocks[n]);
|
||||
else
|
||||
SSL_unlock_mutex(&sslLocks[n]);
|
||||
}
|
||||
}
|
||||
|
||||
int SSLSocket_initialize()
|
||||
|
|
@ -442,7 +446,19 @@ exit:
|
|||
void SSLSocket_terminate()
|
||||
{
|
||||
FUNC_ENTRY;
|
||||
free(sslLocks);
|
||||
EVP_cleanup();
|
||||
ERR_free_strings();
|
||||
CRYPTO_set_locking_callback(NULL);
|
||||
if (sslLocks)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < CRYPTO_num_locks(); i++)
|
||||
{
|
||||
SSL_destroy_mutex(&sslLocks[i]);
|
||||
}
|
||||
free(sslLocks);
|
||||
}
|
||||
FUNC_EXIT;
|
||||
}
|
||||
|
||||
|
|
@ -628,7 +644,7 @@ exit:
|
|||
* @param actual_len the actual number of bytes read
|
||||
* @return completion code
|
||||
*/
|
||||
char *SSLSocket_getdata(SSL* ssl, int socket, int bytes, int* actual_len)
|
||||
char *SSLSocket_getdata(SSL* ssl, int socket, size_t bytes, size_t* actual_len)
|
||||
{
|
||||
int rc;
|
||||
char* buf;
|
||||
|
|
@ -642,7 +658,7 @@ char *SSLSocket_getdata(SSL* ssl, int socket, int bytes, int* actual_len)
|
|||
|
||||
buf = SocketBuffer_getQueuedData(socket, bytes, actual_len);
|
||||
|
||||
if ((rc = SSL_read(ssl, buf + (*actual_len), (size_t)(bytes - (*actual_len)))) < 0)
|
||||
if ((rc = SSL_read(ssl, buf + (*actual_len), (int)(bytes - (*actual_len)))) < 0)
|
||||
{
|
||||
rc = SSLSocket_error("SSL_read - getdata", ssl, socket, rc);
|
||||
if (rc != SSL_ERROR_WANT_READ && rc != SSL_ERROR_WANT_WRITE)
|
||||
|
|
@ -714,9 +730,9 @@ int SSLSocket_putdatas(SSL* ssl, int socket, char* buf0, size_t buf0len, int cou
|
|||
int sslerror;
|
||||
|
||||
FUNC_ENTRY;
|
||||
iovec.iov_len = buf0len;
|
||||
iovec.iov_len = (ULONG)buf0len;
|
||||
for (i = 0; i < count; i++)
|
||||
iovec.iov_len += buflens[i];
|
||||
iovec.iov_len += (ULONG)buflens[i];
|
||||
|
||||
ptr = iovec.iov_base = (char *)malloc(iovec.iov_len);
|
||||
memcpy(ptr, buf0, buf0len);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ int SSLSocket_initialize();
|
|||
void SSLSocket_terminate();
|
||||
int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts);
|
||||
int SSLSocket_getch(SSL* ssl, int socket, char* c);
|
||||
char *SSLSocket_getdata(SSL* ssl, int socket, int bytes, int* actual_len);
|
||||
char *SSLSocket_getdata(SSL* ssl, int socket, size_t bytes, size_t* actual_len);
|
||||
|
||||
int SSLSocket_close(networkHandles* net);
|
||||
int SSLSocket_putdatas(SSL* ssl, int socket, char* buf0, size_t buf0len, int count, char** buffers, size_t* buflens, int* frees);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2014 IBM Corp.
|
||||
* Copyright (c) 2009, 2016 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
* Contributors:
|
||||
* Ian Craggs - initial implementation and documentation
|
||||
* Ian Craggs - async client updates
|
||||
* Ian Craggs - fix for bug 484496
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
@ -328,7 +329,7 @@ exit:
|
|||
* @param actual_len the actual number of bytes read
|
||||
* @return completion code
|
||||
*/
|
||||
char *Socket_getdata(int socket, int bytes, int* actual_len)
|
||||
char *Socket_getdata(int socket, size_t bytes, size_t* actual_len)
|
||||
{
|
||||
int rc;
|
||||
char* buf;
|
||||
|
|
@ -342,7 +343,7 @@ char *Socket_getdata(int socket, int bytes, int* actual_len)
|
|||
|
||||
buf = SocketBuffer_getQueuedData(socket, bytes, actual_len);
|
||||
|
||||
if ((rc = recv(socket, buf + (*actual_len), (size_t)(bytes - (*actual_len)), 0)) == SOCKET_ERROR)
|
||||
if ((rc = recv(socket, buf + (*actual_len), (int)(bytes - (*actual_len)), 0)) == SOCKET_ERROR)
|
||||
{
|
||||
rc = Socket_error("recv - getdata", socket);
|
||||
if (rc != EAGAIN && rc != EWOULDBLOCK)
|
||||
|
|
@ -438,7 +439,8 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
|
|||
unsigned long bytes = 0L;
|
||||
iobuf iovecs[5];
|
||||
int frees1[5];
|
||||
int rc = TCPSOCKET_INTERRUPTED, i, total = buf0len;
|
||||
int rc = TCPSOCKET_INTERRUPTED, i;
|
||||
size_t total = buf0len;
|
||||
|
||||
FUNC_ENTRY;
|
||||
if (!Socket_noPendingWrites(socket))
|
||||
|
|
@ -452,12 +454,12 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
|
|||
total += buflens[i];
|
||||
|
||||
iovecs[0].iov_base = buf0;
|
||||
iovecs[0].iov_len = buf0len;
|
||||
iovecs[0].iov_len = (ULONG)buf0len;
|
||||
frees1[0] = 1;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
iovecs[i+1].iov_base = buffers[i];
|
||||
iovecs[i+1].iov_len = buflens[i];
|
||||
iovecs[i+1].iov_len = (ULONG)buflens[i];
|
||||
frees1[i+1] = frees[i];
|
||||
}
|
||||
|
||||
|
|
@ -600,6 +602,7 @@ int Socket_new(char* addr, int port, int* sock)
|
|||
|
||||
FUNC_ENTRY;
|
||||
*sock = -1;
|
||||
memset(&address6, '\0', sizeof(address6));
|
||||
|
||||
if (addr[0] == '[')
|
||||
++addr;
|
||||
|
|
@ -608,34 +611,30 @@ int Socket_new(char* addr, int port, int* sock)
|
|||
{
|
||||
struct addrinfo* res = result;
|
||||
|
||||
/* prefer ip4 addresses */
|
||||
while (res)
|
||||
{
|
||||
if (res->ai_family == AF_INET)
|
||||
{
|
||||
result = res;
|
||||
{ /* prefer ip4 addresses */
|
||||
if (res->ai_family == AF_INET || res->ai_next == NULL)
|
||||
break;
|
||||
}
|
||||
res = res->ai_next;
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
if (res == NULL)
|
||||
rc = -1;
|
||||
else
|
||||
#if defined(AF_INET6)
|
||||
if (result->ai_family == AF_INET6)
|
||||
if (res->ai_family == AF_INET6)
|
||||
{
|
||||
address6.sin6_port = htons(port);
|
||||
address6.sin6_family = family = AF_INET6;
|
||||
address6.sin6_addr = ((struct sockaddr_in6*)(result->ai_addr))->sin6_addr;
|
||||
memcpy(&address6.sin6_addr, &((struct sockaddr_in6*)(res->ai_addr))->sin6_addr, sizeof(address6.sin6_addr));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (result->ai_family == AF_INET)
|
||||
if (res->ai_family == AF_INET)
|
||||
{
|
||||
address.sin_port = htons(port);
|
||||
address.sin_family = family = AF_INET;
|
||||
address.sin_addr = ((struct sockaddr_in*)(result->ai_addr))->sin_addr;
|
||||
address.sin_addr = ((struct sockaddr_in*)(res->ai_addr))->sin_addr;
|
||||
}
|
||||
else
|
||||
rc = -1;
|
||||
|
|
@ -649,7 +648,7 @@ int Socket_new(char* addr, int port, int* sock)
|
|||
Log(LOG_ERROR, -1, "%s is not a valid IP address", addr);
|
||||
else
|
||||
{
|
||||
*sock = socket(family, type, 0);
|
||||
*sock = (int)socket(family, type, 0);
|
||||
if (*sock == INVALID_SOCKET)
|
||||
rc = Socket_error("socket", *sock);
|
||||
else
|
||||
|
|
@ -733,8 +732,8 @@ int Socket_continueWrite(int socket)
|
|||
else if (pw->bytes < curbuflen + pw->iovecs[i].iov_len)
|
||||
{ /* if previously written length is in the middle of the buffer we are currently looking at,
|
||||
add some of the buffer */
|
||||
int offset = pw->bytes - curbuflen;
|
||||
iovecs1[++curbuf].iov_len = pw->iovecs[i].iov_len - offset;
|
||||
size_t offset = pw->bytes - curbuflen;
|
||||
iovecs1[++curbuf].iov_len = pw->iovecs[i].iov_len - (ULONG)offset;
|
||||
iovecs1[curbuf].iov_base = pw->iovecs[i].iov_base + offset;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/uio.h>
|
||||
#define ULONG size_t
|
||||
#endif
|
||||
|
||||
/** socket operation completed successfully */
|
||||
|
|
@ -114,7 +115,7 @@ void Socket_outInitialize(void);
|
|||
void Socket_outTerminate(void);
|
||||
int Socket_getReadySocket(int more_work, struct timeval *tp);
|
||||
int Socket_getch(int socket, char* c);
|
||||
char *Socket_getdata(int socket, int bytes, int* actual_len);
|
||||
char *Socket_getdata(int socket, size_t bytes, size_t* actual_len);
|
||||
int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** buffers, size_t* buflens, int* frees);
|
||||
void Socket_close(int socket);
|
||||
int Socket_new(char* addr, int port, int* socket);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ void SocketBuffer_newDefQ(void)
|
|||
def_queue = malloc(sizeof(socket_queue));
|
||||
def_queue->buflen = 1000;
|
||||
def_queue->buf = malloc(def_queue->buflen);
|
||||
def_queue->socket = def_queue->index = def_queue->buflen = def_queue->datalen = 0;
|
||||
def_queue->socket = def_queue->index = 0;
|
||||
def_queue->buflen = def_queue->datalen = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -130,7 +131,10 @@ void SocketBuffer_cleanup(int socket)
|
|||
ListRemove(queues, queues->current->content);
|
||||
}
|
||||
if (def_queue->socket == socket)
|
||||
def_queue->socket = def_queue->index = def_queue->headerlen = def_queue->datalen = 0;
|
||||
{
|
||||
def_queue->socket = def_queue->index = 0;
|
||||
def_queue->headerlen = def_queue->datalen = 0;
|
||||
}
|
||||
FUNC_EXIT;
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +146,7 @@ void SocketBuffer_cleanup(int socket)
|
|||
* @param actual_len the actual length returned
|
||||
* @return the actual data
|
||||
*/
|
||||
char* SocketBuffer_getQueuedData(int socket, int bytes, int* actual_len)
|
||||
char* SocketBuffer_getQueuedData(int socket, size_t bytes, size_t* actual_len)
|
||||
{
|
||||
socket_queue* queue = NULL;
|
||||
|
||||
|
|
@ -215,7 +219,7 @@ exit:
|
|||
* @param socket the socket to get queued data for
|
||||
* @param actual_len the actual length of data that was read
|
||||
*/
|
||||
void SocketBuffer_interrupted(int socket, int actual_len)
|
||||
void SocketBuffer_interrupted(int socket, size_t actual_len)
|
||||
{
|
||||
socket_queue* queue = NULL;
|
||||
|
||||
|
|
@ -249,7 +253,8 @@ char* SocketBuffer_complete(int socket)
|
|||
def_queue = queue;
|
||||
ListDetach(queues, queue);
|
||||
}
|
||||
def_queue->socket = def_queue->index = def_queue->headerlen = def_queue->datalen = 0;
|
||||
def_queue->socket = def_queue->index = 0;
|
||||
def_queue->headerlen = def_queue->datalen = 0;
|
||||
FUNC_EXIT;
|
||||
return def_queue->buf;
|
||||
}
|
||||
|
|
@ -271,7 +276,8 @@ void SocketBuffer_queueChar(int socket, char c)
|
|||
else if (def_queue->socket == 0)
|
||||
{
|
||||
def_queue->socket = socket;
|
||||
def_queue->index = def_queue->datalen = 0;
|
||||
def_queue->index = 0;
|
||||
def_queue->datalen = 0;
|
||||
}
|
||||
else if (def_queue->socket != socket)
|
||||
{
|
||||
|
|
@ -302,9 +308,9 @@ void SocketBuffer_queueChar(int socket, char c)
|
|||
* @param bytes actual data length that was written
|
||||
*/
|
||||
#if defined(OPENSSL)
|
||||
void SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, int total, int bytes)
|
||||
void SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes)
|
||||
#else
|
||||
void SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, int total, int bytes)
|
||||
void SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes)
|
||||
#endif
|
||||
{
|
||||
int i = 0;
|
||||
|
|
|
|||
|
|
@ -37,20 +37,22 @@
|
|||
typedef struct
|
||||
{
|
||||
int socket;
|
||||
int index, headerlen;
|
||||
unsigned int index;
|
||||
size_t headerlen;
|
||||
char fixed_header[5]; /**< header plus up to 4 length bytes */
|
||||
int buflen, /**< total length of the buffer */
|
||||
size_t buflen, /**< total length of the buffer */
|
||||
datalen; /**< current length of data in buf */
|
||||
char* buf;
|
||||
} socket_queue;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int socket, total, count;
|
||||
int socket, count;
|
||||
size_t total;
|
||||
#if defined(OPENSSL)
|
||||
SSL* ssl;
|
||||
#endif
|
||||
unsigned long bytes;
|
||||
size_t bytes;
|
||||
iobuf iovecs[5];
|
||||
int frees[5];
|
||||
} pending_writes;
|
||||
|
|
@ -64,16 +66,16 @@ typedef struct
|
|||
void SocketBuffer_initialize(void);
|
||||
void SocketBuffer_terminate(void);
|
||||
void SocketBuffer_cleanup(int socket);
|
||||
char* SocketBuffer_getQueuedData(int socket, int bytes, int* actual_len);
|
||||
char* SocketBuffer_getQueuedData(int socket, size_t bytes, size_t* actual_len);
|
||||
int SocketBuffer_getQueuedChar(int socket, char* c);
|
||||
void SocketBuffer_interrupted(int socket, int actual_len);
|
||||
void SocketBuffer_interrupted(int socket, size_t actual_len);
|
||||
char* SocketBuffer_complete(int socket);
|
||||
void SocketBuffer_queueChar(int socket, char c);
|
||||
|
||||
#if defined(OPENSSL)
|
||||
void SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, int total, int bytes);
|
||||
void SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes);
|
||||
#else
|
||||
void SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, int total, int bytes);
|
||||
void SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes);
|
||||
#endif
|
||||
pending_writes* SocketBuffer_getWrite(int socket);
|
||||
int SocketBuffer_writeComplete(int socket);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#define THREAD_H
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#define thread_type HANDLE
|
||||
#define thread_id_type DWORD
|
||||
#define thread_return_type DWORD
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ void TreeBalanceAfterAdd(Tree* aTree, Node* curnode, int index)
|
|||
* @param content the list item content itself
|
||||
* @param size the size of the element
|
||||
*/
|
||||
void* TreeAddByIndex(Tree* aTree, void* content, int size, int index)
|
||||
void* TreeAddByIndex(Tree* aTree, void* content, size_t size, int index)
|
||||
{
|
||||
Node* curparent = NULL;
|
||||
Node* curnode = aTree->index[index].root;
|
||||
|
|
@ -249,7 +249,7 @@ void* TreeAddByIndex(Tree* aTree, void* content, int size, int index)
|
|||
}
|
||||
|
||||
|
||||
void* TreeAdd(Tree* aTree, void* content, int size)
|
||||
void* TreeAdd(Tree* aTree, void* content, size_t size)
|
||||
{
|
||||
void* rc = NULL;
|
||||
int i;
|
||||
|
|
@ -399,7 +399,7 @@ void* TreeRemoveNodeIndex(Tree* aTree, Node* curnode, int index)
|
|||
{
|
||||
Node* redundant = curnode;
|
||||
Node* curchild = NULL;
|
||||
int size = curnode->size;
|
||||
size_t size = curnode->size;
|
||||
void* content = curnode->content;
|
||||
|
||||
/* if the node to remove has 0 or 1 children, it can be removed without involving another node */
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
#if !defined(TREE_H)
|
||||
#define TREE_H
|
||||
|
||||
#include <stdlib.h> // for size_t definition
|
||||
|
||||
/*BE
|
||||
defm defTree(T) // macro to define a tree
|
||||
|
||||
|
|
@ -63,7 +65,7 @@ typedef struct NodeStruct
|
|||
struct NodeStruct *parent, /**< pointer to parent tree node, in case we need it */
|
||||
*child[2]; /**< pointers to child tree nodes 0 = left, 1 = right */
|
||||
void* content; /**< pointer to element content */
|
||||
int size; /**< size of content */
|
||||
size_t size; /**< size of content */
|
||||
unsigned int red : 1;
|
||||
} Node;
|
||||
|
||||
|
|
@ -78,9 +80,9 @@ typedef struct
|
|||
Node *root; /**< root node pointer */
|
||||
int (*compare)(void*, void*, int); /**< comparison function */
|
||||
} index[2];
|
||||
int indexes, /**< no of indexes into tree */
|
||||
count, /**< no of items */
|
||||
size; /**< heap storage used */
|
||||
int indexes, /**< no of indexes into tree */
|
||||
count; /**< no of items */
|
||||
size_t size; /**< heap storage used */
|
||||
unsigned int heap_tracking : 1; /**< switch on heap tracking for this tree? */
|
||||
unsigned int allow_duplicates : 1; /**< switch to allow duplicate entries */
|
||||
} Tree;
|
||||
|
|
@ -90,7 +92,7 @@ Tree* TreeInitialize(int(*compare)(void*, void*, int));
|
|||
void TreeInitializeNoMalloc(Tree* aTree, int(*compare)(void*, void*, int));
|
||||
void TreeAddIndex(Tree* aTree, int(*compare)(void*, void*, int));
|
||||
|
||||
void* TreeAdd(Tree* aTree, void* content, int size);
|
||||
void* TreeAdd(Tree* aTree, void* content, size_t size);
|
||||
|
||||
void* TreeRemove(Tree* aTree, void* content);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef VERSIONINFO_H
|
||||
#define VERSIONINFO_H
|
||||
|
||||
#define BUILD_TIMESTAMP "@BUILD_TIMESTAMP@"
|
||||
#define CLIENT_VERSION "@CLIENT_VERSION@"
|
||||
|
||||
#endif /* VERSIONINFO_H */
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2015, 2016 logi.cals GmbH
|
||||
#
|
||||
# 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:
|
||||
# Rainer Poisel - initial version
|
||||
# Ian Craggs - update sample names
|
||||
#*******************************************************************************/
|
||||
|
||||
# Note: on OS X you should install XCode and the associated command-line tools
|
||||
|
||||
## compilation/linkage settings
|
||||
INCLUDE_DIRECTORIES(
|
||||
.
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
# sample files c
|
||||
ADD_EXECUTABLE(paho_c_pub paho_c_pub.c)
|
||||
ADD_EXECUTABLE(paho_c_sub paho_c_sub.c)
|
||||
ADD_EXECUTABLE(paho_cs_pub paho_cs_pub.c)
|
||||
ADD_EXECUTABLE(paho_cs_sub paho_cs_sub.c)
|
||||
|
||||
TARGET_LINK_LIBRARIES(paho_c_pub paho-mqtt3a)
|
||||
TARGET_LINK_LIBRARIES(paho_c_sub paho-mqtt3a)
|
||||
TARGET_LINK_LIBRARIES(paho_cs_pub paho-mqtt3c)
|
||||
TARGET_LINK_LIBRARIES(paho_cs_sub paho-mqtt3c)
|
||||
|
||||
ADD_EXECUTABLE(MQTTAsync_subscribe MQTTAsync_subscribe.c)
|
||||
ADD_EXECUTABLE(MQTTAsync_publish MQTTAsync_publish.c)
|
||||
ADD_EXECUTABLE(MQTTClient_subscribe MQTTClient_subscribe.c)
|
||||
ADD_EXECUTABLE(MQTTClient_publish MQTTClient_publish.c)
|
||||
ADD_EXECUTABLE(MQTTClient_publish_async MQTTClient_publish_async.c)
|
||||
|
||||
TARGET_LINK_LIBRARIES(MQTTAsync_subscribe paho-mqtt3a)
|
||||
TARGET_LINK_LIBRARIES(MQTTAsync_publish paho-mqtt3a)
|
||||
TARGET_LINK_LIBRARIES(MQTTClient_subscribe paho-mqtt3c)
|
||||
TARGET_LINK_LIBRARIES(MQTTClient_publish paho-mqtt3c)
|
||||
TARGET_LINK_LIBRARIES(MQTTClient_publish_async paho-mqtt3c)
|
||||
|
||||
INSTALL(TARGETS paho_c_sub
|
||||
paho_c_pub
|
||||
paho_cs_sub
|
||||
paho_cs_pub
|
||||
MQTTAsync_subscribe
|
||||
MQTTAsync_publish
|
||||
MQTTClient_subscribe
|
||||
MQTTClient_publish
|
||||
MQTTClient_publish_async
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib)
|
||||
|
||||
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#if !defined(WIN32)
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#define ADDRESS "tcp://m2m.eclipse.org:1883"
|
||||
|
|
@ -75,7 +77,7 @@ void onSend(void* context, MQTTAsync_successData* response)
|
|||
if ((rc = MQTTAsync_disconnect(client, &opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start sendMessage, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +110,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
|
|||
if ((rc = MQTTAsync_sendMessage(client, TOPIC, &pubmsg, &opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start sendMessage, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +135,7 @@ int main(int argc, char* argv[])
|
|||
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Waiting for publication of %s\n"
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#if !defined(WIN32)
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#define ADDRESS "tcp://localhost:1883"
|
||||
|
|
@ -124,7 +126,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
|
|||
if ((rc = MQTTAsync_subscribe(client, TOPIC, QOS, &opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start subscribe, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +153,7 @@ int main(int argc, char* argv[])
|
|||
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (!subscribed)
|
||||
|
|
@ -173,7 +175,7 @@ int main(int argc, char* argv[])
|
|||
if ((rc = MQTTAsync_disconnect(client, &disc_opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start disconnect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while (!disc_finished)
|
||||
#if defined(WIN32)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ int main(int argc, char* argv[])
|
|||
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
printf("Failed to connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pubmsg.payload = PAYLOAD;
|
||||
pubmsg.payloadlen = strlen(PAYLOAD);
|
||||
|
|
@ -78,7 +78,7 @@ int main(int argc, char* argv[])
|
|||
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
printf("Failed to connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pubmsg.payload = PAYLOAD;
|
||||
pubmsg.payloadlen = strlen(PAYLOAD);
|
||||
|
|
@ -77,7 +77,7 @@ int main(int argc, char* argv[])
|
|||
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
printf("Failed to connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("Subscribing to topic %s\nfor client %s using QoS%d\n\n"
|
||||
"Press Q<Enter> to quit\n\n", TOPIC, CLIENTID, QOS);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012, 2013 IBM Corp.
|
||||
* Copyright (c) 2012, 2016 IBM Corp.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Ian Craggs - initial contribution
|
||||
* Guilherme Maciel Ferreira - add keep alive option
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
|
|
@ -27,8 +28,9 @@
|
|||
--port 1883
|
||||
--qos 0
|
||||
--delimiters \n
|
||||
--clientid stdin_publisher
|
||||
--clientid stdin-publisher-async
|
||||
--maxdatalen 100
|
||||
--keepalive 10
|
||||
|
||||
--userid none
|
||||
--password none
|
||||
|
|
@ -54,31 +56,6 @@
|
|||
volatile int toStop = 0;
|
||||
|
||||
|
||||
void usage()
|
||||
{
|
||||
printf("MQTT stdin publisher\n");
|
||||
printf("Usage: stdinpub topicname <options>, where options are:\n");
|
||||
printf(" --host <hostname> (default is localhost)\n");
|
||||
printf(" --port <port> (default is 1883)\n");
|
||||
printf(" --qos <qos> (default is 0)\n");
|
||||
printf(" --retained (default is off)\n");
|
||||
printf(" --delimiter <delim> (default is \\n)");
|
||||
printf(" --clientid <clientid> (default is hostname+timestamp)");
|
||||
printf(" --maxdatalen 100\n");
|
||||
printf(" --username none\n");
|
||||
printf(" --password none\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cfinish(int sig)
|
||||
{
|
||||
signal(SIGINT, NULL);
|
||||
toStop = 1;
|
||||
}
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
char* clientid;
|
||||
|
|
@ -90,12 +67,39 @@ struct
|
|||
char* password;
|
||||
char* host;
|
||||
char* port;
|
||||
int verbose;
|
||||
int verbose;
|
||||
int keepalive;
|
||||
} opts =
|
||||
{
|
||||
"publisher", "\n", 100, 0, 0, NULL, NULL, "localhost", "1883", 0
|
||||
"stdin-publisher-async", "\n", 100, 0, 0, NULL, NULL, "localhost", "1883", 0, 10
|
||||
};
|
||||
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
printf("MQTT stdin publisher\n");
|
||||
printf("Usage: stdinpub topicname <options>, where options are:\n");
|
||||
printf(" --host <hostname> (default is %s)\n", opts.host);
|
||||
printf(" --port <port> (default is %s)\n", opts.port);
|
||||
printf(" --qos <qos> (default is %d)\n", opts.qos);
|
||||
printf(" --retained (default is %s)\n", opts.retained ? "on" : "off");
|
||||
printf(" --delimiter <delim> (default is \\n)\n");
|
||||
printf(" --clientid <clientid> (default is %s)\n", opts.clientid);
|
||||
printf(" --maxdatalen <bytes> (default is %d)\n", opts.maxdatalen);
|
||||
printf(" --username none\n");
|
||||
printf(" --password none\n");
|
||||
printf(" --keepalive <seconds> (default is 10 seconds)\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cfinish(int sig)
|
||||
{
|
||||
signal(SIGINT, NULL);
|
||||
toStop = 1;
|
||||
}
|
||||
|
||||
void getopts(int argc, char** argv);
|
||||
|
||||
int messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* m)
|
||||
|
|
@ -114,11 +118,15 @@ void onDisconnect(void* context, MQTTAsync_successData* response)
|
|||
|
||||
|
||||
static int connected = 0;
|
||||
void myconnect(MQTTAsync* client);
|
||||
|
||||
void onConnectFailure(void* context, MQTTAsync_failureData* response)
|
||||
{
|
||||
printf("Connect failed, rc %d\n", response ? -1 : response->code);
|
||||
printf("Connect failed, rc %d\n", response ? response->code : -1);
|
||||
connected = -1;
|
||||
|
||||
MQTTAsync client = (MQTTAsync)context;
|
||||
myconnect(client);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -131,7 +139,6 @@ void onConnect(void* context, MQTTAsync_successData* response)
|
|||
connected = 1;
|
||||
}
|
||||
|
||||
|
||||
void myconnect(MQTTAsync* client)
|
||||
{
|
||||
MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
|
||||
|
|
@ -139,7 +146,7 @@ void myconnect(MQTTAsync* client)
|
|||
int rc = 0;
|
||||
|
||||
printf("Connecting\n");
|
||||
conn_opts.keepAliveInterval = 10;
|
||||
conn_opts.keepAliveInterval = opts.keepalive;
|
||||
conn_opts.cleansession = 1;
|
||||
conn_opts.username = opts.username;
|
||||
conn_opts.password = opts.password;
|
||||
|
|
@ -148,18 +155,13 @@ void myconnect(MQTTAsync* client)
|
|||
conn_opts.context = client;
|
||||
ssl_opts.enableServerCertAuth = 0;
|
||||
conn_opts.ssl = &ssl_opts;
|
||||
conn_opts.automaticReconnect = 1;
|
||||
connected = 0;
|
||||
if ((rc = MQTTAsync_connect(*client, &conn_opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while (connected == 0)
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(10000L);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -201,124 +203,16 @@ void connectionLost(void* context, char* cause)
|
|||
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(_WINDOWS)
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#define MAXHOSTNAMELEN 256
|
||||
#define EAGAIN WSAEWOULDBLOCK
|
||||
#define EINTR WSAEINTR
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define ENOTCONN WSAENOTCONN
|
||||
#define ECONNRESET WSAECONNRESET
|
||||
#define setenv(a, b, c) _putenv_s(a, b)
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(SOCKET_ERROR)
|
||||
#define SOCKET_ERROR -1
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int socket;
|
||||
time_t lastContact;
|
||||
#if defined(OPENSSL)
|
||||
SSL* ssl;
|
||||
SSL_CTX* ctx;
|
||||
#endif
|
||||
} networkHandles;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* clientID; /**< the string id of the client */
|
||||
char* username; /**< MQTT v3.1 user name */
|
||||
char* password; /**< MQTT v3.1 password */
|
||||
unsigned int cleansession : 1; /**< MQTT clean session flag */
|
||||
unsigned int connected : 1; /**< whether it is currently connected */
|
||||
unsigned int good : 1; /**< if we have an error on the socket we turn this off */
|
||||
unsigned int ping_outstanding : 1;
|
||||
int connect_state : 4;
|
||||
networkHandles net;
|
||||
/* ... */
|
||||
} Clients;
|
||||
|
||||
|
||||
typedef struct MQTTAsync_struct
|
||||
{
|
||||
char* serverURI;
|
||||
int ssl;
|
||||
Clients* c;
|
||||
|
||||
/* "Global", to the client, callback definitions */
|
||||
MQTTAsync_connectionLost* cl;
|
||||
MQTTAsync_messageArrived* ma;
|
||||
MQTTAsync_deliveryComplete* dc;
|
||||
void* context; /* the context to be associated with the main callbacks*/
|
||||
#if 0
|
||||
MQTTAsync_command connect; /* Connect operation properties */
|
||||
MQTTAsync_command disconnect; /* Disconnect operation properties */
|
||||
MQTTAsync_command* pending_write; /* Is there a socket write pending? */
|
||||
|
||||
List* responses;
|
||||
unsigned int command_seqno;
|
||||
|
||||
MQTTPacket* pack;
|
||||
#endif
|
||||
} MQTTAsyncs;
|
||||
|
||||
int test6_socket_error(char* aString, int sock)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
int errno;
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
errno = WSAGetLastError();
|
||||
#endif
|
||||
if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK)
|
||||
{
|
||||
if (strcmp(aString, "shutdown") != 0 || (errno != ENOTCONN && errno != ECONNRESET))
|
||||
printf("Socket error %d in %s for socket %d", errno, aString, sock);
|
||||
}
|
||||
return errno;
|
||||
}
|
||||
|
||||
|
||||
int test6_socket_close(int socket)
|
||||
{
|
||||
int rc;
|
||||
|
||||
#if defined(WIN32)
|
||||
if (shutdown(socket, SD_BOTH) == SOCKET_ERROR)
|
||||
test6_socket_error("shutdown", socket);
|
||||
if ((rc = closesocket(socket)) == SOCKET_ERROR)
|
||||
test6_socket_error("close", socket);
|
||||
#else
|
||||
if (shutdown(socket, SHUT_RDWR) == SOCKET_ERROR)
|
||||
test6_socket_error("shutdown", socket);
|
||||
if ((rc = close(socket)) == SOCKET_ERROR)
|
||||
test6_socket_error("close", socket);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
MQTTAsync_disconnectOptions disc_opts = MQTTAsync_disconnectOptions_initializer;
|
||||
MQTTAsync_responseOptions pub_opts = MQTTAsync_responseOptions_initializer;
|
||||
MQTTAsync_createOptions create_opts = MQTTAsync_createOptions_initializer;
|
||||
MQTTAsync client;
|
||||
char* topic = NULL;
|
||||
char* buffer = NULL;
|
||||
|
|
@ -337,7 +231,8 @@ int main(int argc, char** argv)
|
|||
topic = argv[1];
|
||||
printf("Using topic %s\n", topic);
|
||||
|
||||
rc = MQTTAsync_create(&client, url, opts.clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL);
|
||||
create_opts.sendWhileDisconnected = 1;
|
||||
rc = MQTTAsync_createWithOptions(&client, url, opts.clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL, &create_opts);
|
||||
|
||||
signal(SIGINT, cfinish);
|
||||
signal(SIGTERM, cfinish);
|
||||
|
|
@ -371,19 +266,9 @@ int main(int argc, char** argv)
|
|||
pub_opts.onFailure = onPublishFailure;
|
||||
do
|
||||
{
|
||||
published = 0;
|
||||
rc = MQTTAsync_send(client, topic, data_len, buffer, opts.qos, opts.retained, &pub_opts);
|
||||
while (published == 0)
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(1000L);
|
||||
#endif
|
||||
if (published == -1)
|
||||
myconnect(&client);
|
||||
test6_socket_close(((MQTTAsyncs*)client)->c->net.socket);
|
||||
}
|
||||
while (published != 1);
|
||||
while (rc != MQTTASYNC_SUCCESS);
|
||||
}
|
||||
|
||||
printf("Stopping\n");
|
||||
|
|
@ -394,7 +279,7 @@ int main(int argc, char** argv)
|
|||
if ((rc = MQTTAsync_disconnect(client, &disc_opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start disconnect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (!disconnected)
|
||||
|
|
@ -404,9 +289,9 @@ int main(int argc, char** argv)
|
|||
usleep(10000L);
|
||||
#endif
|
||||
|
||||
MQTTAsync_destroy(&client);
|
||||
MQTTAsync_destroy(&client);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void getopts(int argc, char** argv)
|
||||
|
|
@ -484,6 +369,13 @@ void getopts(int argc, char** argv)
|
|||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--keepalive") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.keepalive = atoi(argv[count]);
|
||||
else
|
||||
usage();
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
* Contributors:
|
||||
* Ian Craggs - initial contribution
|
||||
* Ian Craggs - fix for bug 413429 - connectionLost not called
|
||||
* Guilherme Maciel Ferreira - add keep alive option
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
|
|
@ -29,7 +30,9 @@
|
|||
--port 1883
|
||||
--qos 2
|
||||
--delimiter \n
|
||||
--clientid stdout_subscriber
|
||||
--clientid stdout-subscriber-async
|
||||
--showtopics off
|
||||
--keepalive 10
|
||||
|
||||
--userid none
|
||||
--password none
|
||||
|
|
@ -45,7 +48,7 @@
|
|||
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#define sleep Sleep
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
|
|
@ -70,33 +73,35 @@ void cfinish(int sig)
|
|||
struct
|
||||
{
|
||||
char* clientid;
|
||||
int nodelimiter;
|
||||
int nodelimiter;
|
||||
char delimiter;
|
||||
int qos;
|
||||
char* username;
|
||||
char* password;
|
||||
char* host;
|
||||
char* port;
|
||||
int showtopics;
|
||||
int showtopics;
|
||||
int keepalive;
|
||||
} opts =
|
||||
{
|
||||
"stdout-subscriber", 1, '\n', 2, NULL, NULL, "localhost", "1883", 0
|
||||
"stdout-subscriber-async", 1, '\n', 2, NULL, NULL, "localhost", "1883", 0, 10
|
||||
};
|
||||
|
||||
|
||||
void usage()
|
||||
void usage(void)
|
||||
{
|
||||
printf("MQTT stdout subscriber\n");
|
||||
printf("Usage: stdoutsub topicname <options>, where options are:\n");
|
||||
printf(" --host <hostname> (default is localhost)\n");
|
||||
printf(" --port <port> (default is 1883)\n");
|
||||
printf(" --qos <qos> (default is 2)\n");
|
||||
printf(" --host <hostname> (default is %s)\n", opts.host);
|
||||
printf(" --port <port> (default is %s)\n", opts.port);
|
||||
printf(" --qos <qos> (default is %d)\n", opts.qos);
|
||||
printf(" --delimiter <delim> (default is no delimiter)\n");
|
||||
printf(" --clientid <clientid> (default is hostname+timestamp)\n");
|
||||
printf(" --clientid <clientid> (default is %s)\n", opts.clientid);
|
||||
printf(" --username none\n");
|
||||
printf(" --password none\n");
|
||||
printf(" --showtopics <on or off> (default is on if the topic has a wildcard, else off)\n");
|
||||
exit(-1);
|
||||
printf(" --keepalive <seconds> (default is 10 seconds)\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -184,6 +189,13 @@ void getopts(int argc, char** argv)
|
|||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--keepalive") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.keepalive = atoi(argv[count]);
|
||||
else
|
||||
usage();
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +213,7 @@ int messageArrived(void *context, char *topicName, int topicLen, MQTTAsync_messa
|
|||
fflush(stdout);
|
||||
MQTTAsync_freeMessage(&message);
|
||||
MQTTAsync_free(topicName);
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -247,7 +259,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
|
|||
if ((rc = MQTTAsync_subscribe(client, topic, opts.qos, &ropts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start subscribe, return code %d\n", rc);
|
||||
finished = 1;
|
||||
finished = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +308,7 @@ int main(int argc, char** argv)
|
|||
signal(SIGINT, cfinish);
|
||||
signal(SIGTERM, cfinish);
|
||||
|
||||
conn_opts.keepAliveInterval = 10;
|
||||
conn_opts.keepAliveInterval = opts.keepalive;
|
||||
conn_opts.cleansession = 1;
|
||||
conn_opts.username = opts.username;
|
||||
conn_opts.password = opts.password;
|
||||
|
|
@ -306,7 +318,7 @@ int main(int argc, char** argv)
|
|||
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (!subscribed)
|
||||
|
|
@ -330,10 +342,10 @@ int main(int argc, char** argv)
|
|||
if ((rc = MQTTAsync_disconnect(client, &disc_opts)) != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
printf("Failed to start disconnect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (!disconnected)
|
||||
while (!disconnected)
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
|
|
@ -343,7 +355,7 @@ int main(int argc, char** argv)
|
|||
exit:
|
||||
MQTTAsync_destroy(&client);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
volatile int toStop = 0;
|
||||
|
||||
|
||||
void usage()
|
||||
void usage(void)
|
||||
{
|
||||
printf("MQTT stdin publisher\n");
|
||||
printf("Usage: stdinpub topicname <options>, where options are:\n");
|
||||
|
|
@ -68,7 +68,7 @@ void usage()
|
|||
printf(" --maxdatalen 100\n");
|
||||
printf(" --username none\n");
|
||||
printf(" --password none\n");
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ void myconnect(MQTTClient* client, MQTTClient_connectOptions* opts)
|
|||
if (MQTTClient_connect(*client, opts) != 0)
|
||||
{
|
||||
printf("Failed to connect\n");
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("Connected\n");
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ int main(int argc, char** argv)
|
|||
|
||||
MQTTClient_destroy(&client);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void getopts(int argc, char** argv)
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
* Contributors:
|
||||
* Ian Craggs - initial contribution
|
||||
* Ian Craggs - change delimiter option from char to string
|
||||
* Guilherme Maciel Ferreira - add keep alive option
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
|
|
@ -29,7 +30,9 @@
|
|||
--port 1883
|
||||
--qos 2
|
||||
--delimiter \n
|
||||
--clientid stdout_subscriber
|
||||
--clientid stdout-subscriber
|
||||
--showtopics off
|
||||
--keepalive 10
|
||||
|
||||
--userid none
|
||||
--password none
|
||||
|
|
@ -44,7 +47,7 @@
|
|||
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#define sleep Sleep
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
|
|
@ -55,19 +58,38 @@
|
|||
volatile int toStop = 0;
|
||||
|
||||
|
||||
void usage()
|
||||
struct opts_struct
|
||||
{
|
||||
char* clientid;
|
||||
int nodelimiter;
|
||||
char* delimiter;
|
||||
int qos;
|
||||
char* username;
|
||||
char* password;
|
||||
char* host;
|
||||
char* port;
|
||||
int showtopics;
|
||||
int keepalive;
|
||||
} opts =
|
||||
{
|
||||
"stdout-subscriber", 0, "\n", 2, NULL, NULL, "localhost", "1883", 0, 10
|
||||
};
|
||||
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
printf("MQTT stdout subscriber\n");
|
||||
printf("Usage: stdoutsub topicname <options>, where options are:\n");
|
||||
printf(" --host <hostname> (default is localhost)\n");
|
||||
printf(" --port <port> (default is 1883)\n");
|
||||
printf(" --qos <qos> (default is 2)\n");
|
||||
printf(" --host <hostname> (default is %s)\n", opts.host);
|
||||
printf(" --port <port> (default is %s)\n", opts.port);
|
||||
printf(" --qos <qos> (default is %d)\n", opts.qos);
|
||||
printf(" --delimiter <delim> (default is \\n)\n");
|
||||
printf(" --clientid <clientid> (default is hostname+timestamp)\n");
|
||||
printf(" --clientid <clientid> (default is %s)\n", opts.clientid);
|
||||
printf(" --username none\n");
|
||||
printf(" --password none\n");
|
||||
printf(" --showtopics <on or off> (default is on if the topic has a wildcard, else off)\n");
|
||||
exit(-1);
|
||||
printf(" --showtopics <on or off> (default is on if the topic has a wildcard, else off)\n");
|
||||
printf(" --keepalive <seconds> (default is %d seconds)\n", opts.keepalive);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -77,7 +99,7 @@ void myconnect(MQTTClient* client, MQTTClient_connectOptions* opts)
|
|||
if ((rc = MQTTClient_connect(*client, opts)) != 0)
|
||||
{
|
||||
printf("Failed to connect, return code %d\n", rc);
|
||||
exit(-1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -88,23 +110,6 @@ void cfinish(int sig)
|
|||
toStop = 1;
|
||||
}
|
||||
|
||||
|
||||
struct opts_struct
|
||||
{
|
||||
char* clientid;
|
||||
int nodelimiter;
|
||||
char* delimiter;
|
||||
int qos;
|
||||
char* username;
|
||||
char* password;
|
||||
char* host;
|
||||
char* port;
|
||||
int showtopics;
|
||||
} opts =
|
||||
{
|
||||
"stdout-subscriber", 0, "\n", 2, NULL, NULL, "localhost", "1883", 0
|
||||
};
|
||||
|
||||
void getopts(int argc, char** argv);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
|
@ -120,9 +125,9 @@ int main(int argc, char** argv)
|
|||
|
||||
topic = argv[1];
|
||||
|
||||
if (strchr(topic, '#') || strchr(topic, '+'))
|
||||
if (strchr(topic, '#') || strchr(topic, '+'))
|
||||
opts.showtopics = 1;
|
||||
if (opts.showtopics)
|
||||
if (opts.showtopics)
|
||||
printf("topic is %s\n", topic);
|
||||
|
||||
getopts(argc, argv);
|
||||
|
|
@ -133,7 +138,7 @@ int main(int argc, char** argv)
|
|||
signal(SIGINT, cfinish);
|
||||
signal(SIGTERM, cfinish);
|
||||
|
||||
conn_opts.keepAliveInterval = 10;
|
||||
conn_opts.keepAliveInterval = opts.keepalive;
|
||||
conn_opts.reliable = 0;
|
||||
conn_opts.cleansession = 1;
|
||||
conn_opts.username = opts.username;
|
||||
|
|
@ -154,7 +159,7 @@ int main(int argc, char** argv)
|
|||
{
|
||||
if (opts.showtopics)
|
||||
printf("%s\t", topicName);
|
||||
if (opts.nodelimiter)
|
||||
if (opts.nodelimiter)
|
||||
printf("%.*s", message->payloadlen, (char*)message->payload);
|
||||
else
|
||||
printf("%.*s%s", message->payloadlen, (char*)message->payload, opts.delimiter);
|
||||
|
|
@ -170,9 +175,9 @@ int main(int argc, char** argv)
|
|||
|
||||
MQTTClient_disconnect(client, 0);
|
||||
|
||||
MQTTClient_destroy(&client);
|
||||
MQTTClient_destroy(&client);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void getopts(int argc, char** argv)
|
||||
|
|
@ -253,6 +258,13 @@ void getopts(int argc, char** argv)
|
|||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--keepalive") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.keepalive = atoi(argv[count]);
|
||||
else
|
||||
usage();
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
|
|
@ -1,275 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012, 2013 IBM Corp.
|
||||
*
|
||||
* 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:
|
||||
* Ian Craggs - initial contribution
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
stdin publisher
|
||||
|
||||
compulsory parameters:
|
||||
|
||||
--topic topic to publish on
|
||||
|
||||
defaulted parameters:
|
||||
|
||||
--host localhost
|
||||
--port 1883
|
||||
--qos 0
|
||||
--delimiters \n
|
||||
--clientid stdin_publisher
|
||||
--maxdatalen 100
|
||||
|
||||
--userid none
|
||||
--password none
|
||||
|
||||
*/
|
||||
|
||||
#include "MQTTClient.h"
|
||||
#include "MQTTClientPersistence.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <memory.h>
|
||||
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <Windows.h>
|
||||
#define sleep Sleep
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
volatile int toStop = 0;
|
||||
|
||||
|
||||
void usage()
|
||||
{
|
||||
printf("MQTT stdin publisher\n");
|
||||
printf("Usage: stdinpub topicname <options>, where options are:\n");
|
||||
printf(" --host <hostname> (default is localhost)\n");
|
||||
printf(" --port <port> (default is 1883)\n");
|
||||
printf(" --qos <qos> (default is 0)\n");
|
||||
printf(" --retained (default is off)\n");
|
||||
printf(" --delimiter <delim> (default is \\n)");
|
||||
printf(" --clientid <clientid> (default is hostname+timestamp)");
|
||||
printf(" --maxdatalen 100\n");
|
||||
printf(" --username none\n");
|
||||
printf(" --password none\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
void myconnect(MQTTClient* client, MQTTClient_connectOptions* opts)
|
||||
{
|
||||
printf("Connecting\n");
|
||||
if (MQTTClient_connect(*client, opts) != 0)
|
||||
{
|
||||
printf("Failed to connect\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cfinish(int sig)
|
||||
{
|
||||
signal(SIGINT, NULL);
|
||||
toStop = 1;
|
||||
}
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
char* clientid;
|
||||
char* delimiter;
|
||||
int maxdatalen;
|
||||
int qos;
|
||||
int retained;
|
||||
char* username;
|
||||
char* password;
|
||||
char* host;
|
||||
char* port;
|
||||
int verbose;
|
||||
} opts =
|
||||
{
|
||||
"publisher", "\n", 100, 0, 0, NULL, NULL, "localhost", "1883", 0
|
||||
};
|
||||
|
||||
void getopts(int argc, char** argv);
|
||||
|
||||
int messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m)
|
||||
{
|
||||
/* not expecting any messages */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
MQTTClient client;
|
||||
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
|
||||
char* topic = NULL;
|
||||
char* buffer = NULL;
|
||||
int rc = 0;
|
||||
char url[100];
|
||||
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
getopts(argc, argv);
|
||||
|
||||
sprintf(url, "%s:%s", opts.host, opts.port);
|
||||
if (opts.verbose)
|
||||
printf("URL is %s\n", url);
|
||||
|
||||
topic = argv[1];
|
||||
printf("Using topic %s\n", topic);
|
||||
|
||||
rc = MQTTClient_create(&client, url, opts.clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL);
|
||||
|
||||
signal(SIGINT, cfinish);
|
||||
signal(SIGTERM, cfinish);
|
||||
|
||||
rc = MQTTClient_setCallbacks(client, NULL, NULL, messageArrived, NULL);
|
||||
|
||||
conn_opts.keepAliveInterval = 10;
|
||||
conn_opts.reliable = 0;
|
||||
conn_opts.cleansession = 1;
|
||||
conn_opts.username = opts.username;
|
||||
conn_opts.password = opts.password;
|
||||
|
||||
myconnect(&client, &conn_opts);
|
||||
|
||||
buffer = malloc(opts.maxdatalen);
|
||||
|
||||
while (!toStop)
|
||||
{
|
||||
int data_len = 0;
|
||||
int delim_len = 0;
|
||||
|
||||
delim_len = strlen(opts.delimiter);
|
||||
do
|
||||
{
|
||||
buffer[data_len++] = getchar();
|
||||
if (data_len > delim_len)
|
||||
{
|
||||
//printf("comparing %s %s\n", opts.delimiter, &buffer[data_len - delim_len]);
|
||||
if (strncmp(opts.delimiter, &buffer[data_len - delim_len], delim_len) == 0)
|
||||
break;
|
||||
}
|
||||
} while (data_len < opts.maxdatalen);
|
||||
|
||||
if (opts.verbose)
|
||||
printf("Publishing data of length %d\n", data_len);
|
||||
rc = MQTTClient_publish(client, topic, data_len, buffer, opts.qos, opts.retained, NULL);
|
||||
if (rc != 0)
|
||||
{
|
||||
myconnect(&client, &conn_opts);
|
||||
rc = MQTTClient_publish(client, topic, data_len, buffer, opts.qos, opts.retained, NULL);
|
||||
}
|
||||
if (opts.qos > 0)
|
||||
MQTTClient_yield();
|
||||
}
|
||||
|
||||
printf("Stopping\n");
|
||||
|
||||
free(buffer);
|
||||
|
||||
MQTTClient_disconnect(client, 0);
|
||||
|
||||
MQTTClient_destroy(&client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void getopts(int argc, char** argv)
|
||||
{
|
||||
int count = 2;
|
||||
|
||||
while (count < argc)
|
||||
{
|
||||
if (strcmp(argv[count], "--retained") == 0)
|
||||
opts.retained = 1;
|
||||
if (strcmp(argv[count], "--verbose") == 0)
|
||||
opts.verbose = 1;
|
||||
else if (strcmp(argv[count], "--qos") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
{
|
||||
if (strcmp(argv[count], "0") == 0)
|
||||
opts.qos = 0;
|
||||
else if (strcmp(argv[count], "1") == 0)
|
||||
opts.qos = 1;
|
||||
else if (strcmp(argv[count], "2") == 0)
|
||||
opts.qos = 2;
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--host") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.host = argv[count];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--port") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.port = argv[count];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--clientid") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.clientid = argv[count];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--username") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.username = argv[count];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--password") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.password = argv[count];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--maxdatalen") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.maxdatalen = atoi(argv[count]);
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--delimiter") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
opts.delimiter = argv[count];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ int UTF8_validateString(const char* string)
|
|||
int rc = 0;
|
||||
|
||||
FUNC_ENTRY;
|
||||
rc = UTF8_validate(strlen(string), string);
|
||||
rc = UTF8_validate((int)strlen(string), string);
|
||||
FUNC_EXIT_RC(rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,920 @@
|
|||
"""
|
||||
*******************************************************************
|
||||
Copyright (c) 2013, 2014 IBM Corp.
|
||||
|
||||
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:
|
||||
Ian Craggs - initial implementation and/or documentation
|
||||
*******************************************************************
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
Assertions are used to validate incoming data, but are omitted from outgoing packets. This is
|
||||
so that the tests that use this package can send invalid data for error testing.
|
||||
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("mqttsas")
|
||||
|
||||
# Low-level protocol interface
|
||||
|
||||
class MQTTException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# Message types
|
||||
CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, \
|
||||
PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, \
|
||||
PINGREQ, PINGRESP, DISCONNECT = range(1, 15)
|
||||
|
||||
packetNames = [ "reserved", \
|
||||
"Connect", "Connack", "Publish", "Puback", "Pubrec", "Pubrel", \
|
||||
"Pubcomp", "Subscribe", "Suback", "Unsubscribe", "Unsuback", \
|
||||
"Pingreq", "Pingresp", "Disconnect"]
|
||||
|
||||
classNames = [ "reserved", \
|
||||
"Connects", "Connacks", "Publishes", "Pubacks", "Pubrecs", "Pubrels", \
|
||||
"Pubcomps", "Subscribes", "Subacks", "Unsubscribes", "Unsubacks", \
|
||||
"Pingreqs", "Pingresps", "Disconnects"]
|
||||
|
||||
|
||||
def MessageType(byte):
|
||||
if byte != None:
|
||||
rc = byte[0] >> 4
|
||||
else:
|
||||
rc = None
|
||||
return rc
|
||||
|
||||
|
||||
def getPacket(aSocket):
|
||||
"receive the next packet"
|
||||
buf = aSocket.recv(1) # get the first byte fixed header
|
||||
if buf == b"":
|
||||
return None
|
||||
if str(aSocket).find("[closed]") != -1:
|
||||
closed = True
|
||||
else:
|
||||
closed = False
|
||||
if closed:
|
||||
return None
|
||||
# now get the remaining length
|
||||
multiplier = 1
|
||||
remlength = 0
|
||||
while 1:
|
||||
next = aSocket.recv(1)
|
||||
while len(next) == 0:
|
||||
next = aSocket.recv(1)
|
||||
buf += next
|
||||
digit = buf[-1]
|
||||
remlength += (digit & 127) * multiplier
|
||||
if digit & 128 == 0:
|
||||
break
|
||||
multiplier *= 128
|
||||
# receive the remaining length if there is any
|
||||
rest = bytes([])
|
||||
if remlength > 0:
|
||||
while len(rest) < remlength:
|
||||
rest += aSocket.recv(remlength-len(rest))
|
||||
assert len(rest) == remlength
|
||||
return buf + rest
|
||||
|
||||
|
||||
class FixedHeaders:
|
||||
|
||||
def __init__(self, aMessageType):
|
||||
self.MessageType = aMessageType
|
||||
self.DUP = False
|
||||
self.QoS = 0
|
||||
self.RETAIN = False
|
||||
self.remainingLength = 0
|
||||
|
||||
def __eq__(self, fh):
|
||||
return self.MessageType == fh.MessageType and \
|
||||
self.DUP == fh.DUP and \
|
||||
self.QoS == fh.QoS and \
|
||||
self.RETAIN == fh.RETAIN # and \
|
||||
# self.remainingLength == fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
"return printable representation of our data"
|
||||
return classNames[self.MessageType]+'(DUP='+repr(self.DUP)+ \
|
||||
", QoS="+repr(self.QoS)+", Retain="+repr(self.RETAIN)
|
||||
|
||||
def pack(self, length):
|
||||
"pack data into string buffer ready for transmission down socket"
|
||||
buffer = bytes([(self.MessageType << 4) | (self.DUP << 3) |\
|
||||
(self.QoS << 1) | self.RETAIN])
|
||||
self.remainingLength = length
|
||||
buffer += self.encode(length)
|
||||
return buffer
|
||||
|
||||
def encode(self, x):
|
||||
assert 0 <= x <= 268435455
|
||||
buffer = b''
|
||||
while 1:
|
||||
digit = x % 128
|
||||
x //= 128
|
||||
if x > 0:
|
||||
digit |= 0x80
|
||||
buffer += bytes([digit])
|
||||
if x == 0:
|
||||
break
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
"unpack data from string buffer into separate fields"
|
||||
b0 = buffer[0]
|
||||
self.MessageType = b0 >> 4
|
||||
self.DUP = ((b0 >> 3) & 0x01) == 1
|
||||
self.QoS = (b0 >> 1) & 0x03
|
||||
self.RETAIN = (b0 & 0x01) == 1
|
||||
(self.remainingLength, bytes) = self.decode(buffer[1:])
|
||||
return bytes + 1 # length of fixed header
|
||||
|
||||
def decode(self, buffer):
|
||||
multiplier = 1
|
||||
value = 0
|
||||
bytes = 0
|
||||
while 1:
|
||||
bytes += 1
|
||||
digit = buffer[0]
|
||||
buffer = buffer[1:]
|
||||
value += (digit & 127) * multiplier
|
||||
if digit & 128 == 0:
|
||||
break
|
||||
multiplier *= 128
|
||||
return (value, bytes)
|
||||
|
||||
|
||||
def writeInt16(length):
|
||||
return bytes([length // 256, length % 256])
|
||||
|
||||
def readInt16(buf):
|
||||
return buf[0]*256 + buf[1]
|
||||
|
||||
def writeUTF(data):
|
||||
# data could be a string, or bytes. If string, encode into bytes with utf-8
|
||||
return writeInt16(len(data)) + (data if type(data) == type(b"") else bytes(data, "utf-8"))
|
||||
|
||||
def readUTF(buffer, maxlen):
|
||||
if maxlen >= 2:
|
||||
length = readInt16(buffer)
|
||||
else:
|
||||
raise MQTTException("Not enough data to read string length")
|
||||
maxlen -= 2
|
||||
if length > maxlen:
|
||||
raise MQTTException("Length delimited string too long")
|
||||
buf = buffer[2:2+length].decode("utf-8")
|
||||
logger.info("[MQTT-4.7.3-2] topic names and filters not include null")
|
||||
zz = buf.find("\x00") # look for null in the UTF string
|
||||
if zz != -1:
|
||||
raise MQTTException("[MQTT-1.5.3-2] Null found in UTF data "+buf)
|
||||
for c in range (0xD800, 0xDFFF):
|
||||
zz = buf.find(chr(c)) # look for D800-DFFF in the UTF string
|
||||
if zz != -1:
|
||||
raise MQTTException("[MQTT-1.5.3-1] D800-DFFF found in UTF data "+buf)
|
||||
if buf.find("\uFEFF") != -1:
|
||||
logger.info("[MQTT-1.5.3-3] U+FEFF in UTF string")
|
||||
return buf
|
||||
|
||||
def writeBytes(buffer):
|
||||
return writeInt16(len(buffer)) + buffer
|
||||
|
||||
def readBytes(buffer):
|
||||
length = readInt16(buffer)
|
||||
return buffer[2:2+length]
|
||||
|
||||
|
||||
class Packets:
|
||||
|
||||
def pack(self):
|
||||
buffer = self.fh.pack(0)
|
||||
return buffer
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)
|
||||
|
||||
def __eq__(self, packet):
|
||||
return self.fh == packet.fh if packet else False
|
||||
|
||||
|
||||
class Connects(Packets):
|
||||
|
||||
def __init__(self, buffer = None):
|
||||
self.fh = FixedHeaders(CONNECT)
|
||||
|
||||
# variable header
|
||||
self.ProtocolName = "MQTT"
|
||||
self.ProtocolVersion = 4
|
||||
self.CleanSession = True
|
||||
self.WillFlag = False
|
||||
self.WillQoS = 0
|
||||
self.WillRETAIN = 0
|
||||
self.KeepAliveTimer = 30
|
||||
self.usernameFlag = False
|
||||
self.passwordFlag = False
|
||||
|
||||
# Payload
|
||||
self.ClientIdentifier = "" # UTF-8
|
||||
self.WillTopic = None # UTF-8
|
||||
self.WillMessage = None # binary
|
||||
self.username = None # UTF-8
|
||||
self.password = None # binary
|
||||
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
connectFlags = bytes([(self.CleanSession << 1) | (self.WillFlag << 2) | \
|
||||
(self.WillQoS << 3) | (self.WillRETAIN << 5) | \
|
||||
(self.usernameFlag << 6) | (self.passwordFlag << 7)])
|
||||
buffer = writeUTF(self.ProtocolName) + bytes([self.ProtocolVersion]) + \
|
||||
connectFlags + writeInt16(self.KeepAliveTimer)
|
||||
buffer += writeUTF(self.ClientIdentifier)
|
||||
if self.WillFlag:
|
||||
buffer += writeUTF(self.WillTopic)
|
||||
buffer += writeBytes(self.WillMessage)
|
||||
if self.usernameFlag:
|
||||
buffer += writeUTF(self.username)
|
||||
if self.passwordFlag:
|
||||
buffer += writeBytes(self.password)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == CONNECT
|
||||
|
||||
try:
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
packlen = fhlen + self.fh.remainingLength
|
||||
assert len(buffer) >= packlen, "buffer length %d packet length %d" % (len(buffer), packlen)
|
||||
curlen = fhlen # points to after header + remaining length
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS was not 0, was %d" % self.fh.QoS
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
|
||||
self.ProtocolName = readUTF(buffer[curlen:], packlen - curlen)
|
||||
curlen += len(self.ProtocolName) + 2
|
||||
assert self.ProtocolName == "MQTT", "Wrong protocol name %s" % self.ProtocolName
|
||||
|
||||
self.ProtocolVersion = buffer[curlen]
|
||||
curlen += 1
|
||||
|
||||
connectFlags = buffer[curlen]
|
||||
assert (connectFlags & 0x01) == 0, "[MQTT-3.1.2-3] reserved connect flag must be 0"
|
||||
self.CleanSession = ((connectFlags >> 1) & 0x01) == 1
|
||||
self.WillFlag = ((connectFlags >> 2) & 0x01) == 1
|
||||
self.WillQoS = (connectFlags >> 3) & 0x03
|
||||
self.WillRETAIN = (connectFlags >> 5) & 0x01
|
||||
self.passwordFlag = ((connectFlags >> 6) & 0x01) == 1
|
||||
self.usernameFlag = ((connectFlags >> 7) & 0x01) == 1
|
||||
curlen +=1
|
||||
|
||||
if self.WillFlag:
|
||||
assert self.WillQoS in [0, 1, 2], "[MQTT-3.1.2-14] will qos must not be 3"
|
||||
else:
|
||||
assert self.WillQoS == 0, "[MQTT-3.1.2-13] will qos must be 0, if will flag is false"
|
||||
assert self.WillRETAIN == False, "[MQTT-3.1.2-14] will retain must be false, if will flag is false"
|
||||
|
||||
self.KeepAliveTimer = readInt16(buffer[curlen:])
|
||||
curlen += 2
|
||||
logger.info("[MQTT-3.1.3-3] Clientid must be present, and first field")
|
||||
logger.info("[MQTT-3.1.3-4] Clientid must be Unicode, and between 0 and 65535 bytes long")
|
||||
self.ClientIdentifier = readUTF(buffer[curlen:], packlen - curlen)
|
||||
curlen += len(self.ClientIdentifier) + 2
|
||||
|
||||
if self.WillFlag:
|
||||
self.WillTopic = readUTF(buffer[curlen:], packlen - curlen)
|
||||
curlen += len(self.WillTopic) + 2
|
||||
self.WillMessage = readBytes(buffer[curlen:])
|
||||
curlen += len(self.WillMessage) + 2
|
||||
logger.info("[[MQTT-3.1.2-9] will topic and will message fields must be present")
|
||||
else:
|
||||
self.WillTopic = self.WillMessage = None
|
||||
|
||||
if self.usernameFlag:
|
||||
assert len(buffer) > curlen+2, "Buffer too short to read username length"
|
||||
self.username = readUTF(buffer[curlen:], packlen - curlen)
|
||||
curlen += len(self.username) + 2
|
||||
logger.info("[MQTT-3.1.2-19] username must be in payload if user name flag is 1")
|
||||
else:
|
||||
logger.info("[MQTT-3.1.2-18] username must not be in payload if user name flag is 0")
|
||||
assert self.passwordFlag == False, "[MQTT-3.1.2-22] password flag must be 0 if username flag is 0"
|
||||
|
||||
if self.passwordFlag:
|
||||
assert len(buffer) > curlen+2, "Buffer too short to read password length"
|
||||
self.password = readBytes(buffer[curlen:])
|
||||
curlen += len(self.password) + 2
|
||||
logger.info("[MQTT-3.1.2-21] password must be in payload if password flag is 0")
|
||||
else:
|
||||
logger.info("[MQTT-3.1.2-20] password must not be in payload if password flag is 0")
|
||||
|
||||
if self.WillFlag and self.usernameFlag and self.passwordFlag:
|
||||
logger.info("[MQTT-3.1.3-1] clientid, will topic, will message, username and password all present")
|
||||
|
||||
assert curlen == packlen, "Packet is wrong length curlen %d != packlen %d"
|
||||
except:
|
||||
logger.exception("[MQTT-3.1.4-1] server must validate connect packet and close connection without connack if it does not conform")
|
||||
raise
|
||||
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
buf = repr(self.fh)+", ProtocolName="+str(self.ProtocolName)+", ProtocolVersion=" +\
|
||||
repr(self.ProtocolVersion)+", CleanSession="+repr(self.CleanSession) +\
|
||||
", WillFlag="+repr(self.WillFlag)+", KeepAliveTimer=" +\
|
||||
repr(self.KeepAliveTimer)+", ClientId="+str(self.ClientIdentifier) +\
|
||||
", usernameFlag="+repr(self.usernameFlag)+", passwordFlag="+repr(self.passwordFlag)
|
||||
if self.WillFlag:
|
||||
buf += ", WillQoS=" + repr(self.WillQoS) +\
|
||||
", WillRETAIN=" + repr(self.WillRETAIN) +\
|
||||
", WillTopic='"+ self.WillTopic +\
|
||||
"', WillMessage='"+str(self.WillMessage)+"'"
|
||||
if self.username:
|
||||
buf += ", username="+self.username
|
||||
if self.password:
|
||||
buf += ", password="+str(self.password)
|
||||
return buf+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
rc = Packets.__eq__(self, packet) and \
|
||||
self.ProtocolName == packet.ProtocolName and \
|
||||
self.ProtocolVersion == packet.ProtocolVersion and \
|
||||
self.CleanSession == packet.CleanSession and \
|
||||
self.WillFlag == packet.WillFlag and \
|
||||
self.KeepAliveTimer == packet.KeepAliveTimer and \
|
||||
self.ClientIdentifier == packet.ClientIdentifier and \
|
||||
self.WillFlag == packet.WillFlag
|
||||
if rc and self.WillFlag:
|
||||
rc = self.WillQoS == packet.WillQoS and \
|
||||
self.WillRETAIN == packet.WillRETAIN and \
|
||||
self.WillTopic == packet.WillTopic and \
|
||||
self.WillMessage == packet.WillMessage
|
||||
return rc
|
||||
|
||||
|
||||
class Connacks(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, ReturnCode=0):
|
||||
self.fh = FixedHeaders(CONNACK)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
self.flags = 0
|
||||
self.returnCode = ReturnCode
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = bytes([self.flags, self.returnCode])
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 4
|
||||
assert MessageType(buffer) == CONNACK
|
||||
self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 2, "Connack packet is wrong length %d" % self.fh.remainingLength
|
||||
assert buffer[2] in [0, 1], "Connect Acknowledge Flags"
|
||||
self.returnCode = buffer[3]
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", Session present="+str((self.flags & 0x01) == 1)+", ReturnCode="+repr(self.returnCode)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.returnCode == packet.returnCode
|
||||
|
||||
|
||||
class Disconnects(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
|
||||
self.fh = FixedHeaders(DISCONNECT)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == DISCONNECT
|
||||
self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 0, "Disconnect packet is wrong length %d" % self.fh.remainingLength
|
||||
logger.info("[MQTT-3.14.1-1] disconnect reserved bits must be 0")
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+")"
|
||||
|
||||
|
||||
class Publishes(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0, TopicName="", Payload=b""):
|
||||
self.fh = FixedHeaders(PUBLISH)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.topicName = TopicName
|
||||
self.messageIdentifier = MsgId
|
||||
# payload
|
||||
self.data = Payload
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeUTF(self.topicName)
|
||||
if self.fh.QoS != 0:
|
||||
buffer += writeInt16(self.messageIdentifier)
|
||||
buffer += self.data
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBLISH
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.QoS in [0, 1, 2], "QoS in Publish must be 0, 1, or 2"
|
||||
packlen = fhlen + self.fh.remainingLength
|
||||
assert len(buffer) >= packlen
|
||||
curlen = fhlen
|
||||
try:
|
||||
self.topicName = readUTF(buffer[fhlen:], packlen - curlen)
|
||||
except UnicodeDecodeError:
|
||||
logger.info("[MQTT-3.3.2-1] topic name in publish must be utf-8")
|
||||
raise
|
||||
curlen += len(self.topicName) + 2
|
||||
if self.fh.QoS != 0:
|
||||
self.messageIdentifier = readInt16(buffer[curlen:])
|
||||
logger.info("[MQTT-2.3.1-1] packet indentifier must be in publish if QoS is 1 or 2")
|
||||
curlen += 2
|
||||
assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
|
||||
else:
|
||||
logger.info("[MQTT-2.3.1-5] no packet indentifier in publish if QoS is 0")
|
||||
self.messageIdentifier = 0
|
||||
self.data = buffer[curlen:fhlen + self.fh.remainingLength]
|
||||
if self.fh.QoS == 0:
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-4]"
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
rc = repr(self.fh)
|
||||
if self.fh.QoS != 0:
|
||||
rc += ", MsgId="+repr(self.messageIdentifier)
|
||||
rc += ", TopicName="+repr(self.topicName)+", Payload="+repr(self.data)+")"
|
||||
return rc
|
||||
|
||||
def __eq__(self, packet):
|
||||
rc = Packets.__eq__(self, packet) and \
|
||||
self.topicName == packet.topicName and \
|
||||
self.data == packet.data
|
||||
if rc and self.fh.QoS != 0:
|
||||
rc = self.messageIdentifier == packet.messageIdentifier
|
||||
return rc
|
||||
|
||||
|
||||
class Pubacks(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(PUBACK)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBACK
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 2, "Puback packet is wrong length %d" % self.fh.remainingLength
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
|
||||
return fhlen + 2
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId "+repr(self.messageIdentifier)
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Pubrecs(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(PUBREC)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBREC
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 2, "Pubrec packet is wrong length %d" % self.fh.remainingLength
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
|
||||
return fhlen + 2
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Pubrels(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(PUBREL)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBREL
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 2, "Pubrel packet is wrong length %d" % self.fh.remainingLength
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be False in PUBREL"
|
||||
assert self.fh.QoS == 1, "[MQTT-2.1.2-1] QoS should be 1 in PUBREL"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] RETAIN should be False in PUBREL"
|
||||
logger.info("[MQTT-3.6.1-1] bits in fixed header for pubrel are ok")
|
||||
return fhlen + 2
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Pubcomps(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(PUBCOMP)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBCOMP
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
assert self.fh.remainingLength == 2, "Pubcomp packet is wrong length %d" % self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be False in Pubcomp"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS should be 0 in Pubcomp"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Retain should be false in Pubcomp"
|
||||
return fhlen + 2
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Subscribes(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0, Data=[]):
|
||||
self.fh = FixedHeaders(SUBSCRIBE)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
# payload - list of topic, qos pairs
|
||||
self.data = Data[:]
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
for d in self.data:
|
||||
buffer += writeUTF(d[0]) + bytes([d[1]])
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == SUBSCRIBE
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
logger.info("[MQTT-2.3.1-1] packet indentifier must be in subscribe")
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
|
||||
leftlen = self.fh.remainingLength - 2
|
||||
self.data = []
|
||||
while leftlen > 0:
|
||||
topic = readUTF(buffer[-leftlen:], leftlen)
|
||||
leftlen -= len(topic) + 2
|
||||
qos = buffer[-leftlen]
|
||||
assert qos in [0, 1, 2], "[MQTT-3-8.3-2] reserved bits must be zero"
|
||||
leftlen -= 1
|
||||
self.data.append((topic, qos))
|
||||
assert len(self.data) > 0, "[MQTT-3.8.3-1] at least one topic, qos pair must be in subscribe"
|
||||
assert leftlen == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP must be false in subscribe"
|
||||
assert self.fh.QoS == 1, "[MQTT-2.1.2-1] QoS must be 1 in subscribe"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] RETAIN must be false in subscribe"
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
|
||||
", Data="+repr(self.data)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier and \
|
||||
self.data == packet.data
|
||||
|
||||
|
||||
class Subacks(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0, Data=[]):
|
||||
self.fh = FixedHeaders(SUBACK)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
# payload - list of qos
|
||||
self.data = Data[:]
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
for d in self.data:
|
||||
buffer += bytes([d])
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == SUBACK
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
leftlen = self.fh.remainingLength - 2
|
||||
self.data = []
|
||||
while leftlen > 0:
|
||||
qos = buffer[-leftlen]
|
||||
assert qos in [0, 1, 2, 0x80], "[MQTT-3.9.3-2] return code in QoS must be 0, 1, 2 or 0x80"
|
||||
leftlen -= 1
|
||||
self.data.append(qos)
|
||||
assert leftlen == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be false in suback"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS should be 0 in suback"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Retain should be false in suback"
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
|
||||
", Data="+repr(self.data)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier and \
|
||||
self.data == packet.data
|
||||
|
||||
|
||||
class Unsubscribes(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0, Data=[]):
|
||||
self.fh = FixedHeaders(UNSUBSCRIBE)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
# payload - list of topics
|
||||
self.data = Data[:]
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
for d in self.data:
|
||||
buffer += writeUTF(d)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == UNSUBSCRIBE
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
logger.info("[MQTT-2.3.1-1] packet indentifier must be in unsubscribe")
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
|
||||
leftlen = self.fh.remainingLength - 2
|
||||
self.data = []
|
||||
while leftlen > 0:
|
||||
topic = readUTF(buffer[-leftlen:], leftlen)
|
||||
leftlen -= len(topic) + 2
|
||||
self.data.append(topic)
|
||||
assert leftlen == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 1, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
logger.info("[MQTT-3-10.1-1] fixed header bits are 0,0,1,0")
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
|
||||
", Data="+repr(self.data)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier and \
|
||||
self.data == packet.data
|
||||
|
||||
|
||||
class Unsubacks(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(UNSUBACK)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == UNSUBACK
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Pingreqs(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
|
||||
self.fh = FixedHeaders(PINGREQ)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PINGREQ
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
return fhlen
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+")"
|
||||
|
||||
|
||||
class Pingresps(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
|
||||
self.fh = FixedHeaders(PINGRESP)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PINGRESP
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
return fhlen
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+")"
|
||||
|
||||
classes = [None, Connects, Connacks, Publishes, Pubacks, Pubrecs,
|
||||
Pubrels, Pubcomps, Subscribes, Subacks, Unsubscribes,
|
||||
Unsubacks, Pingreqs, Pingresps, Disconnects]
|
||||
|
||||
def unpackPacket(buffer):
|
||||
if MessageType(buffer) != None:
|
||||
packet = classes[MessageType(buffer)]()
|
||||
packet.unpack(buffer)
|
||||
else:
|
||||
packet = None
|
||||
return packet
|
||||
|
||||
if __name__ == "__main__":
|
||||
fh = FixedHeaders(CONNECT)
|
||||
tests = [0, 56, 127, 128, 8888, 16383, 16384, 65535, 2097151, 2097152,
|
||||
20555666, 268435454, 268435455]
|
||||
for x in tests:
|
||||
try:
|
||||
assert x == fh.decode(fh.encode(x))[0]
|
||||
except AssertionError:
|
||||
print("Test failed for x =", x, fh.decode(fh.encode(x)))
|
||||
try:
|
||||
fh.decode(fh.encode(268435456))
|
||||
print("Error")
|
||||
except AssertionError:
|
||||
pass
|
||||
|
||||
for packet in classes[1:]:
|
||||
before = str(packet())
|
||||
after = str(unpackPacket(packet().pack()))
|
||||
try:
|
||||
assert before == after
|
||||
except:
|
||||
print("before:", before, "\nafter:", after)
|
||||
print("End")
|
||||
|
||||
|
|
@ -0,0 +1,923 @@
|
|||
"""
|
||||
*******************************************************************
|
||||
Copyright (c) 2013, 2014 IBM Corp.
|
||||
|
||||
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:
|
||||
Ian Craggs - initial implementation and/or documentation
|
||||
*******************************************************************
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
"""
|
||||
|
||||
Assertions are used to validate incoming data, but are omitted from outgoing packets. This is
|
||||
so that the tests that use this package can send invalid data for error testing.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("mqttsas")
|
||||
|
||||
# Low-level protocol interface
|
||||
|
||||
class MQTTException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# Message types
|
||||
CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, \
|
||||
PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, \
|
||||
PINGREQ, PINGRESP, DISCONNECT = range(1, 15)
|
||||
|
||||
packetNames = [ "reserved", \
|
||||
"Connect", "Connack", "Publish", "Puback", "Pubrec", "Pubrel", \
|
||||
"Pubcomp", "Subscribe", "Suback", "Unsubscribe", "Unsuback", \
|
||||
"Pingreq", "Pingresp", "Disconnect"]
|
||||
|
||||
classNames = [ "reserved", \
|
||||
"Connects", "Connacks", "Publishes", "Pubacks", "Pubrecs", "Pubrels", \
|
||||
"Pubcomps", "Subscribes", "Subacks", "Unsubscribes", "Unsubacks", \
|
||||
"Pingreqs", "Pingresps", "Disconnects"]
|
||||
|
||||
|
||||
def MessageType(byte):
|
||||
if byte != None:
|
||||
rc = ord(byte[0]) >> 4
|
||||
else:
|
||||
rc = None
|
||||
return rc
|
||||
|
||||
|
||||
def getPacket(aSocket):
|
||||
"receive the next packet"
|
||||
buf = aSocket.recv(1) # get the first byte fixed header
|
||||
if buf == b"":
|
||||
return None
|
||||
if str(aSocket).find("[closed]") != -1:
|
||||
closed = True
|
||||
else:
|
||||
closed = False
|
||||
if closed:
|
||||
return None
|
||||
# now get the remaining length
|
||||
multiplier = 1
|
||||
remlength = 0
|
||||
while 1:
|
||||
next = aSocket.recv(1)
|
||||
while len(next) == 0:
|
||||
next = aSocket.recv(1)
|
||||
buf += next
|
||||
digit = ord(buf[-1])
|
||||
remlength += (digit & 127) * multiplier
|
||||
if digit & 128 == 0:
|
||||
break
|
||||
multiplier *= 128
|
||||
# receive the remaining length if there is any
|
||||
rest = ''
|
||||
if remlength > 0:
|
||||
while len(rest) < remlength:
|
||||
rest += aSocket.recv(remlength-len(rest))
|
||||
assert len(rest) == remlength
|
||||
return buf + rest
|
||||
|
||||
|
||||
class FixedHeaders:
|
||||
|
||||
def __init__(self, aMessageType):
|
||||
self.MessageType = aMessageType
|
||||
self.DUP = False
|
||||
self.QoS = 0
|
||||
self.RETAIN = False
|
||||
self.remainingLength = 0
|
||||
|
||||
def __eq__(self, fh):
|
||||
return self.MessageType == fh.MessageType and \
|
||||
self.DUP == fh.DUP and \
|
||||
self.QoS == fh.QoS and \
|
||||
self.RETAIN == fh.RETAIN # and \
|
||||
# self.remainingLength == fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
"return printable representation of our data"
|
||||
return classNames[self.MessageType]+'(DUP='+repr(self.DUP)+ \
|
||||
", QoS="+repr(self.QoS)+", Retain="+repr(self.RETAIN)
|
||||
|
||||
def pack(self, length):
|
||||
"pack data into string buffer ready for transmission down socket"
|
||||
buffer = bytes([(self.MessageType << 4) | (self.DUP << 3) |\
|
||||
(self.QoS << 1) | self.RETAIN])
|
||||
self.remainingLength = length
|
||||
buffer += self.encode(length)
|
||||
return buffer
|
||||
|
||||
def encode(self, x):
|
||||
assert 0 <= x <= 268435455
|
||||
buffer = b''
|
||||
while 1:
|
||||
digit = x % 128
|
||||
x //= 128
|
||||
if x > 0:
|
||||
digit |= 0x80
|
||||
buffer += bytes([digit])
|
||||
if x == 0:
|
||||
break
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
"unpack data from string buffer into separate fields"
|
||||
b0 = ord(buffer[0])
|
||||
self.MessageType = b0 >> 4
|
||||
self.DUP = ((b0 >> 3) & 0x01) == 1
|
||||
self.QoS = (b0 >> 1) & 0x03
|
||||
self.RETAIN = (b0 & 0x01) == 1
|
||||
(self.remainingLength, bytes) = self.decode(buffer[1:])
|
||||
return bytes + 1 # length of fixed header
|
||||
|
||||
def decode(self, buffer):
|
||||
multiplier = 1
|
||||
value = 0
|
||||
bytes = 0
|
||||
while 1:
|
||||
bytes += 1
|
||||
digit = ord(buffer[0])
|
||||
buffer = buffer[1:]
|
||||
value += (digit & 127) * multiplier
|
||||
if digit & 128 == 0:
|
||||
break
|
||||
multiplier *= 128
|
||||
return (value, bytes)
|
||||
|
||||
|
||||
def writeInt16(length):
|
||||
return bytes([length // 256, length % 256])
|
||||
|
||||
def readInt16(buf):
|
||||
return ord(buf[0])*256 + ord(buf[1])
|
||||
|
||||
def writeUTF(data):
|
||||
# data could be a string, or bytes. If string, encode into bytes with utf-8
|
||||
return writeInt16(len(data)) + (data if type(data) == type(b"") else bytes(data, "utf-8"))
|
||||
|
||||
def readUTF(buffer, maxlen):
|
||||
if maxlen >= 2:
|
||||
length = readInt16(buffer)
|
||||
else:
|
||||
raise MQTTException("Not enough data to read string length")
|
||||
maxlen -= 2
|
||||
if length > maxlen:
|
||||
raise MQTTException("Length delimited string too long")
|
||||
buf = buffer[2:2+length].decode("utf-8")
|
||||
logger.info("[MQTT-4.7.3-2] topic names and filters not include null")
|
||||
zz = buf.find("\x00") # look for null in the UTF string
|
||||
if zz != -1:
|
||||
raise MQTTException("[MQTT-1.5.3-2] Null found in UTF data "+buf)
|
||||
"""for c in range (0xD800, 0xDFFF):
|
||||
zz = buf.find(chr(c)) # look for D800-DFFF in the UTF string
|
||||
if zz != -1:
|
||||
raise MQTTException("[MQTT-1.5.3-1] D800-DFFF found in UTF data "+buf)
|
||||
"""
|
||||
if buf.find("\uFEFF") != -1:
|
||||
logger.info("[MQTT-1.5.3-3] U+FEFF in UTF string")
|
||||
return buf
|
||||
|
||||
def writeBytes(buffer):
|
||||
return writeInt16(len(buffer)) + buffer
|
||||
|
||||
def readBytes(buffer):
|
||||
length = readInt16(buffer)
|
||||
return buffer[2:2+length]
|
||||
|
||||
|
||||
class Packets:
|
||||
|
||||
def pack(self):
|
||||
buffer = self.fh.pack(0)
|
||||
return buffer
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)
|
||||
|
||||
def __eq__(self, packet):
|
||||
return self.fh == packet.fh if packet else False
|
||||
|
||||
|
||||
class Connects(Packets):
|
||||
|
||||
def __init__(self, buffer = None):
|
||||
self.fh = FixedHeaders(CONNECT)
|
||||
|
||||
# variable header
|
||||
self.ProtocolName = "MQTT"
|
||||
self.ProtocolVersion = 4
|
||||
self.CleanSession = True
|
||||
self.WillFlag = False
|
||||
self.WillQoS = 0
|
||||
self.WillRETAIN = 0
|
||||
self.KeepAliveTimer = 30
|
||||
self.usernameFlag = False
|
||||
self.passwordFlag = False
|
||||
|
||||
# Payload
|
||||
self.ClientIdentifier = "" # UTF-8
|
||||
self.WillTopic = None # UTF-8
|
||||
self.WillMessage = None # binary
|
||||
self.username = None # UTF-8
|
||||
self.password = None # binary
|
||||
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
connectFlags = bytes([(self.CleanSession << 1) | (self.WillFlag << 2) | \
|
||||
(self.WillQoS << 3) | (self.WillRETAIN << 5) | \
|
||||
(self.usernameFlag << 6) | (self.passwordFlag << 7)])
|
||||
buffer = writeUTF(self.ProtocolName) + bytes([self.ProtocolVersion]) + \
|
||||
connectFlags + writeInt16(self.KeepAliveTimer)
|
||||
buffer += writeUTF(self.ClientIdentifier)
|
||||
if self.WillFlag:
|
||||
buffer += writeUTF(self.WillTopic)
|
||||
buffer += writeBytes(self.WillMessage)
|
||||
if self.usernameFlag:
|
||||
buffer += writeUTF(self.username)
|
||||
if self.passwordFlag:
|
||||
buffer += writeBytes(self.password)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == CONNECT
|
||||
|
||||
try:
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
packlen = fhlen + self.fh.remainingLength
|
||||
assert len(buffer) >= packlen, "buffer length %d packet length %d" % (len(buffer), packlen)
|
||||
curlen = fhlen # points to after header + remaining length
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS was not 0, was %d" % self.fh.QoS
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
|
||||
self.ProtocolName = readUTF(buffer[curlen:], packlen - curlen)
|
||||
curlen += len(self.ProtocolName) + 2
|
||||
assert self.ProtocolName == "MQTT", "Wrong protocol name %s" % self.ProtocolName
|
||||
|
||||
self.ProtocolVersion = ord(buffer[curlen])
|
||||
curlen += 1
|
||||
|
||||
connectFlags = ord(buffer[curlen])
|
||||
assert (connectFlags & 0x01) == 0, "[MQTT-3.1.2-3] reserved connect flag must be 0"
|
||||
self.CleanSession = ((connectFlags >> 1) & 0x01) == 1
|
||||
self.WillFlag = ((connectFlags >> 2) & 0x01) == 1
|
||||
self.WillQoS = (connectFlags >> 3) & 0x03
|
||||
self.WillRETAIN = (connectFlags >> 5) & 0x01
|
||||
self.passwordFlag = ((connectFlags >> 6) & 0x01) == 1
|
||||
self.usernameFlag = ((connectFlags >> 7) & 0x01) == 1
|
||||
curlen +=1
|
||||
|
||||
if self.WillFlag:
|
||||
assert self.WillQoS in [0, 1, 2], "[MQTT-3.1.2-14] will qos must not be 3"
|
||||
else:
|
||||
assert self.WillQoS == 0, "[MQTT-3.1.2-13] will qos must be 0, if will flag is false"
|
||||
assert self.WillRETAIN == False, "[MQTT-3.1.2-14] will retain must be false, if will flag is false"
|
||||
|
||||
self.KeepAliveTimer = readInt16(buffer[curlen:])
|
||||
curlen += 2
|
||||
logger.info("[MQTT-3.1.3-3] Clientid must be present, and first field")
|
||||
logger.info("[MQTT-3.1.3-4] Clientid must be Unicode, and between 0 and 65535 bytes long")
|
||||
self.ClientIdentifier = readUTF(buffer[curlen:], packlen - curlen)
|
||||
curlen += len(self.ClientIdentifier) + 2
|
||||
|
||||
if self.WillFlag:
|
||||
self.WillTopic = readUTF(buffer[curlen:], packlen - curlen)
|
||||
curlen += len(self.WillTopic) + 2
|
||||
self.WillMessage = readBytes(buffer[curlen:])
|
||||
curlen += len(self.WillMessage) + 2
|
||||
logger.info("[[MQTT-3.1.2-9] will topic and will message fields must be present")
|
||||
else:
|
||||
self.WillTopic = self.WillMessage = None
|
||||
|
||||
if self.usernameFlag:
|
||||
assert len(buffer) > curlen+2, "Buffer too short to read username length"
|
||||
self.username = readUTF(buffer[curlen:], packlen - curlen)
|
||||
curlen += len(self.username) + 2
|
||||
logger.info("[MQTT-3.1.2-19] username must be in payload if user name flag is 1")
|
||||
else:
|
||||
logger.info("[MQTT-3.1.2-18] username must not be in payload if user name flag is 0")
|
||||
assert self.passwordFlag == False, "[MQTT-3.1.2-22] password flag must be 0 if username flag is 0"
|
||||
|
||||
if self.passwordFlag:
|
||||
assert len(buffer) > curlen+2, "Buffer too short to read password length"
|
||||
self.password = readBytes(buffer[curlen:])
|
||||
curlen += len(self.password) + 2
|
||||
logger.info("[MQTT-3.1.2-21] password must be in payload if password flag is 0")
|
||||
else:
|
||||
logger.info("[MQTT-3.1.2-20] password must not be in payload if password flag is 0")
|
||||
|
||||
if self.WillFlag and self.usernameFlag and self.passwordFlag:
|
||||
logger.info("[MQTT-3.1.3-1] clientid, will topic, will message, username and password all present")
|
||||
|
||||
assert curlen == packlen, "Packet is wrong length curlen %d != packlen %d"
|
||||
except:
|
||||
logger.exception("[MQTT-3.1.4-1] server must validate connect packet and close connection without connack if it does not conform")
|
||||
raise
|
||||
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
buf = repr(self.fh)+", ProtocolName="+str(self.ProtocolName)+", ProtocolVersion=" +\
|
||||
repr(self.ProtocolVersion)+", CleanSession="+repr(self.CleanSession) +\
|
||||
", WillFlag="+repr(self.WillFlag)+", KeepAliveTimer=" +\
|
||||
repr(self.KeepAliveTimer)+", ClientId="+str(self.ClientIdentifier) +\
|
||||
", usernameFlag="+repr(self.usernameFlag)+", passwordFlag="+repr(self.passwordFlag)
|
||||
if self.WillFlag:
|
||||
buf += ", WillQoS=" + repr(self.WillQoS) +\
|
||||
", WillRETAIN=" + repr(self.WillRETAIN) +\
|
||||
", WillTopic='"+ self.WillTopic +\
|
||||
"', WillMessage='"+str(self.WillMessage)+"'"
|
||||
if self.username:
|
||||
buf += ", username="+self.username
|
||||
if self.password:
|
||||
buf += ", password="+str(self.password)
|
||||
return buf+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
rc = Packets.__eq__(self, packet) and \
|
||||
self.ProtocolName == packet.ProtocolName and \
|
||||
self.ProtocolVersion == packet.ProtocolVersion and \
|
||||
self.CleanSession == packet.CleanSession and \
|
||||
self.WillFlag == packet.WillFlag and \
|
||||
self.KeepAliveTimer == packet.KeepAliveTimer and \
|
||||
self.ClientIdentifier == packet.ClientIdentifier and \
|
||||
self.WillFlag == packet.WillFlag
|
||||
if rc and self.WillFlag:
|
||||
rc = self.WillQoS == packet.WillQoS and \
|
||||
self.WillRETAIN == packet.WillRETAIN and \
|
||||
self.WillTopic == packet.WillTopic and \
|
||||
self.WillMessage == packet.WillMessage
|
||||
return rc
|
||||
|
||||
|
||||
class Connacks(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, ReturnCode=0):
|
||||
self.fh = FixedHeaders(CONNACK)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
self.flags = 0
|
||||
self.returnCode = ReturnCode
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = bytes([self.flags, self.returnCode])
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 4
|
||||
assert MessageType(buffer) == CONNACK
|
||||
self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 2, "Connack packet is wrong length %d" % self.fh.remainingLength
|
||||
assert ord(buffer[2]) in [0, 1], "Connect Acknowledge Flags"
|
||||
self.returnCode = ord(buffer[3])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", Session present="+str((self.flags & 0x01) == 1)+", ReturnCode="+repr(self.returnCode)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.returnCode == packet.returnCode
|
||||
|
||||
|
||||
class Disconnects(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
|
||||
self.fh = FixedHeaders(DISCONNECT)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == DISCONNECT
|
||||
self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 0, "Disconnect packet is wrong length %d" % self.fh.remainingLength
|
||||
logger.info("[MQTT-3.14.1-1] disconnect reserved bits must be 0")
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+")"
|
||||
|
||||
|
||||
class Publishes(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0, TopicName="", Payload=b""):
|
||||
self.fh = FixedHeaders(PUBLISH)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.topicName = TopicName
|
||||
self.messageIdentifier = MsgId
|
||||
# payload
|
||||
self.data = Payload
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeUTF(self.topicName)
|
||||
if self.fh.QoS != 0:
|
||||
buffer += writeInt16(self.messageIdentifier)
|
||||
buffer += self.data
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBLISH
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.QoS in [0, 1, 2], "QoS in Publish must be 0, 1, or 2"
|
||||
packlen = fhlen + self.fh.remainingLength
|
||||
assert len(buffer) >= packlen
|
||||
curlen = fhlen
|
||||
try:
|
||||
self.topicName = readUTF(buffer[fhlen:], packlen - curlen)
|
||||
except UnicodeDecodeError:
|
||||
logger.info("[MQTT-3.3.2-1] topic name in publish must be utf-8")
|
||||
raise
|
||||
curlen += len(self.topicName) + 2
|
||||
if self.fh.QoS != 0:
|
||||
self.messageIdentifier = readInt16(buffer[curlen:])
|
||||
logger.info("[MQTT-2.3.1-1] packet indentifier must be in publish if QoS is 1 or 2")
|
||||
curlen += 2
|
||||
assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
|
||||
else:
|
||||
logger.info("[MQTT-2.3.1-5] no packet indentifier in publish if QoS is 0")
|
||||
self.messageIdentifier = 0
|
||||
self.data = buffer[curlen:fhlen + self.fh.remainingLength]
|
||||
if self.fh.QoS == 0:
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-4]"
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
rc = repr(self.fh)
|
||||
if self.fh.QoS != 0:
|
||||
rc += ", MsgId="+repr(self.messageIdentifier)
|
||||
rc += ", TopicName="+repr(self.topicName)+", Payload="+repr(self.data)+")"
|
||||
return rc
|
||||
|
||||
def __eq__(self, packet):
|
||||
rc = Packets.__eq__(self, packet) and \
|
||||
self.topicName == packet.topicName and \
|
||||
self.data == packet.data
|
||||
if rc and self.fh.QoS != 0:
|
||||
rc = self.messageIdentifier == packet.messageIdentifier
|
||||
return rc
|
||||
|
||||
|
||||
class Pubacks(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(PUBACK)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBACK
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 2, "Puback packet is wrong length %d" % self.fh.remainingLength
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
|
||||
return fhlen + 2
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId "+repr(self.messageIdentifier)
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Pubrecs(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(PUBREC)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBREC
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 2, "Pubrec packet is wrong length %d" % self.fh.remainingLength
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
|
||||
return fhlen + 2
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Pubrels(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(PUBREL)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBREL
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 2, "Pubrel packet is wrong length %d" % self.fh.remainingLength
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be False in PUBREL"
|
||||
assert self.fh.QoS == 1, "[MQTT-2.1.2-1] QoS should be 1 in PUBREL"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] RETAIN should be False in PUBREL"
|
||||
logger.info("[MQTT-3.6.1-1] bits in fixed header for pubrel are ok")
|
||||
return fhlen + 2
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Pubcomps(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(PUBCOMP)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PUBCOMP
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
assert self.fh.remainingLength == 2, "Pubcomp packet is wrong length %d" % self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be False in Pubcomp"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS should be 0 in Pubcomp"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Retain should be false in Pubcomp"
|
||||
return fhlen + 2
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Subscribes(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0, Data=[]):
|
||||
self.fh = FixedHeaders(SUBSCRIBE)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
# payload - list of topic, qos pairs
|
||||
self.data = Data[:]
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
for d in self.data:
|
||||
buffer += writeUTF(d[0]) + bytes([d[1]])
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == SUBSCRIBE
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
logger.info("[MQTT-2.3.1-1] packet indentifier must be in subscribe")
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
|
||||
leftlen = self.fh.remainingLength - 2
|
||||
self.data = []
|
||||
while leftlen > 0:
|
||||
topic = readUTF(buffer[-leftlen:], leftlen)
|
||||
leftlen -= len(topic) + 2
|
||||
qos = ord(buffer[-leftlen])
|
||||
assert qos in [0, 1, 2], "[MQTT-3-8.3-2] reserved bits must be zero"
|
||||
leftlen -= 1
|
||||
self.data.append((topic, qos))
|
||||
assert len(self.data) > 0, "[MQTT-3.8.3-1] at least one topic, qos pair must be in subscribe"
|
||||
assert leftlen == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP must be false in subscribe"
|
||||
assert self.fh.QoS == 1, "[MQTT-2.1.2-1] QoS must be 1 in subscribe"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] RETAIN must be false in subscribe"
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
|
||||
", Data="+repr(self.data)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier and \
|
||||
self.data == packet.data
|
||||
|
||||
|
||||
class Subacks(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0, Data=[]):
|
||||
self.fh = FixedHeaders(SUBACK)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
# payload - list of qos
|
||||
self.data = Data[:]
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
for d in self.data:
|
||||
buffer += bytes([d])
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == SUBACK
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
leftlen = self.fh.remainingLength - 2
|
||||
self.data = []
|
||||
while leftlen > 0:
|
||||
qos = buffer[-leftlen]
|
||||
assert qos in [0, 1, 2, 0x80], "[MQTT-3.9.3-2] return code in QoS must be 0, 1, 2 or 0x80"
|
||||
leftlen -= 1
|
||||
self.data.append(qos)
|
||||
assert leftlen == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be false in suback"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS should be 0 in suback"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Retain should be false in suback"
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
|
||||
", Data="+repr(self.data)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier and \
|
||||
self.data == packet.data
|
||||
|
||||
|
||||
class Unsubscribes(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0, Data=[]):
|
||||
self.fh = FixedHeaders(UNSUBSCRIBE)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
# payload - list of topics
|
||||
self.data = Data[:]
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
for d in self.data:
|
||||
buffer += writeUTF(d)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == UNSUBSCRIBE
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
logger.info("[MQTT-2.3.1-1] packet indentifier must be in unsubscribe")
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
|
||||
leftlen = self.fh.remainingLength - 2
|
||||
self.data = []
|
||||
while leftlen > 0:
|
||||
topic = readUTF(buffer[-leftlen:], leftlen)
|
||||
leftlen -= len(topic) + 2
|
||||
self.data.append(topic)
|
||||
assert leftlen == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 1, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
logger.info("[MQTT-3-10.1-1] fixed header bits are 0,0,1,0")
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
|
||||
", Data="+repr(self.data)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier and \
|
||||
self.data == packet.data
|
||||
|
||||
|
||||
class Unsubacks(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
|
||||
self.fh = FixedHeaders(UNSUBACK)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
# variable header
|
||||
self.messageIdentifier = MsgId
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def pack(self):
|
||||
buffer = writeInt16(self.messageIdentifier)
|
||||
buffer = self.fh.pack(len(buffer)) + buffer
|
||||
return buffer
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == UNSUBACK
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert len(buffer) >= fhlen + self.fh.remainingLength
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
|
||||
self.messageIdentifier = readInt16(buffer[fhlen:])
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
return fhlen + self.fh.remainingLength
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
|
||||
|
||||
def __eq__(self, packet):
|
||||
return Packets.__eq__(self, packet) and \
|
||||
self.messageIdentifier == packet.messageIdentifier
|
||||
|
||||
|
||||
class Pingreqs(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
|
||||
self.fh = FixedHeaders(PINGREQ)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PINGREQ
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
return fhlen
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+")"
|
||||
|
||||
|
||||
class Pingresps(Packets):
|
||||
|
||||
def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
|
||||
self.fh = FixedHeaders(PINGRESP)
|
||||
self.fh.DUP = DUP
|
||||
self.fh.QoS = QoS
|
||||
self.fh.Retain = Retain
|
||||
if buffer != None:
|
||||
self.unpack(buffer)
|
||||
|
||||
def unpack(self, buffer):
|
||||
assert len(buffer) >= 2
|
||||
assert MessageType(buffer) == PINGRESP
|
||||
fhlen = self.fh.unpack(buffer)
|
||||
assert self.fh.remainingLength == 0
|
||||
assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
|
||||
assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
|
||||
return fhlen
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.fh)+")"
|
||||
|
||||
classes = [None, Connects, Connacks, Publishes, Pubacks, Pubrecs,
|
||||
Pubrels, Pubcomps, Subscribes, Subacks, Unsubscribes,
|
||||
Unsubacks, Pingreqs, Pingresps, Disconnects]
|
||||
|
||||
def unpackPacket(buffer):
|
||||
if MessageType(buffer) != None:
|
||||
packet = classes[MessageType(buffer)]()
|
||||
packet.unpack(buffer)
|
||||
else:
|
||||
packet = None
|
||||
return packet
|
||||
|
||||
if __name__ == "__main__":
|
||||
fh = FixedHeaders(CONNECT)
|
||||
tests = [0, 56, 127, 128, 8888, 16383, 16384, 65535, 2097151, 2097152,
|
||||
20555666, 268435454, 268435455]
|
||||
for x in tests:
|
||||
try:
|
||||
assert x == fh.decode(fh.encode(x))[0]
|
||||
except AssertionError:
|
||||
print("Test failed for x =", x, fh.decode(fh.encode(x)))
|
||||
try:
|
||||
fh.decode(fh.encode(268435456))
|
||||
print("Error")
|
||||
except AssertionError:
|
||||
pass
|
||||
|
||||
for packet in classes[1:]:
|
||||
before = str(packet())
|
||||
after = str(unpackPacket(packet().pack()))
|
||||
try:
|
||||
assert before == after
|
||||
except:
|
||||
print("before:", before, "\nafter:", after)
|
||||
print("End")
|
||||
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
"""
|
||||
*******************************************************************
|
||||
Copyright (c) 2013, 2016 IBM Corp.
|
||||
|
||||
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:
|
||||
Ian Craggs - initial implementation and/or documentation
|
||||
*******************************************************************
|
||||
"""
|
||||
|
||||
# Trace MQTT traffic
|
||||
import MQTTV311 as MQTTV3
|
||||
|
||||
import socket, sys, select, traceback, datetime, os, socketserver
|
||||
|
||||
logging = True
|
||||
myWindow = None
|
||||
|
||||
|
||||
def timestamp():
|
||||
now = datetime.datetime.now()
|
||||
return now.strftime('%Y%m%d %H%M%S')+str(float("."+str(now.microsecond)))[1:]
|
||||
|
||||
|
||||
class MyHandler(socketserver.StreamRequestHandler):
|
||||
|
||||
def handle(self):
|
||||
if not hasattr(self, "ids"):
|
||||
self.ids = {}
|
||||
if not hasattr(self, "versions"):
|
||||
self.versions = {}
|
||||
inbuf = True
|
||||
i = o = e = None
|
||||
try:
|
||||
clients = self.request
|
||||
brokers = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
brokers.connect((brokerhost, brokerport))
|
||||
while inbuf != None:
|
||||
(i, o, e) = select.select([clients, brokers], [], [])
|
||||
for s in i:
|
||||
if s == clients:
|
||||
inbuf = MQTTV3.getPacket(clients) # get one packet
|
||||
if inbuf == None:
|
||||
break
|
||||
try:
|
||||
packet = MQTTV3.unpackPacket(inbuf)
|
||||
if packet.fh.MessageType == MQTTV3.PUBLISH and \
|
||||
packet.topicName == "MQTTSAS topic" and \
|
||||
packet.data == b"TERMINATE":
|
||||
print("Terminating client", self.ids[id(clients)])
|
||||
brokers.close()
|
||||
clients.close()
|
||||
break
|
||||
elif packet.fh.MessageType == MQTTV3.CONNECT:
|
||||
self.ids[id(clients)] = packet.ClientIdentifier
|
||||
self.versions[id(clients)] = 3
|
||||
print(timestamp() , "C to S", self.ids[id(clients)], repr(packet))
|
||||
print([hex(b) for b in inbuf])
|
||||
print(inbuf)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
brokers.send(inbuf) # pass it on
|
||||
elif s == brokers:
|
||||
inbuf = MQTTV3.getPacket(brokers) # get one packet
|
||||
if inbuf == None:
|
||||
break
|
||||
try:
|
||||
print(timestamp(), "S to C", self.ids[id(clients)], repr(MQTTV3.unpackPacket(inbuf)))
|
||||
except:
|
||||
traceback.print_exc()
|
||||
clients.send(inbuf)
|
||||
print(timestamp()+" client "+self.ids[id(clients)]+" connection closing")
|
||||
except:
|
||||
print(repr((i, o, e)), repr(inbuf))
|
||||
traceback.print_exc()
|
||||
if id(clients) in self.ids.keys():
|
||||
del self.ids[id(clients)]
|
||||
elif id(clients) in self.versions.keys():
|
||||
del self.versions[id(clients)]
|
||||
|
||||
class ThreadingTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||
pass
|
||||
|
||||
def run():
|
||||
global brokerhost, brokerport
|
||||
myhost = 'localhost'
|
||||
if len(sys.argv) > 1:
|
||||
brokerhost = sys.argv[1]
|
||||
else:
|
||||
brokerhost = 'localhost'
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
brokerport = int(sys.argv[2])
|
||||
else:
|
||||
brokerport = 1883
|
||||
|
||||
if brokerhost == myhost:
|
||||
myport = brokerport + 1
|
||||
else:
|
||||
myport = 1883
|
||||
|
||||
print("Listening on port", str(myport)+", broker on port", brokerport)
|
||||
s = ThreadingTCPServer(("", myport), MyHandler)
|
||||
s.serve_forever()
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
"""
|
||||
*******************************************************************
|
||||
Copyright (c) 2013, 2016 IBM Corp.
|
||||
|
||||
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:
|
||||
Ian Craggs - initial implementation and/or documentation
|
||||
*******************************************************************
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
# Trace MQTT traffic
|
||||
import MQTTV3112 as MQTTV3
|
||||
|
||||
import socket, sys, select, traceback, datetime, os
|
||||
import SocketServer as socketserver
|
||||
|
||||
logging = True
|
||||
myWindow = None
|
||||
|
||||
|
||||
def timestamp():
|
||||
now = datetime.datetime.now()
|
||||
return now.strftime('%Y%m%d %H%M%S')+str(float("."+str(now.microsecond)))[1:]
|
||||
|
||||
|
||||
class MyHandler(socketserver.StreamRequestHandler):
|
||||
|
||||
def handle(self):
|
||||
if not hasattr(self, "ids"):
|
||||
self.ids = {}
|
||||
if not hasattr(self, "versions"):
|
||||
self.versions = {}
|
||||
inbuf = True
|
||||
i = o = e = None
|
||||
try:
|
||||
clients = self.request
|
||||
brokers = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
brokers.connect((brokerhost, brokerport))
|
||||
while inbuf != None:
|
||||
(i, o, e) = select.select([clients, brokers], [], [])
|
||||
for s in i:
|
||||
if s == clients:
|
||||
inbuf = MQTTV3.getPacket(clients) # get one packet
|
||||
if inbuf == None:
|
||||
break
|
||||
try:
|
||||
packet = MQTTV3.unpackPacket(inbuf)
|
||||
if packet.fh.MessageType == MQTTV3.PUBLISH and \
|
||||
packet.topicName == "MQTTSAS topic" and \
|
||||
packet.data == b"TERMINATE":
|
||||
print("Terminating client", self.ids[id(clients)])
|
||||
brokers.close()
|
||||
clients.close()
|
||||
break
|
||||
elif packet.fh.MessageType == MQTTV3.CONNECT:
|
||||
self.ids[id(clients)] = packet.ClientIdentifier
|
||||
self.versions[id(clients)] = 3
|
||||
print(timestamp() , "C to S", self.ids[id(clients)], repr(packet))
|
||||
#print([hex(b) for b in inbuf])
|
||||
#print(inbuf)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
brokers.send(inbuf) # pass it on
|
||||
elif s == brokers:
|
||||
inbuf = MQTTV3.getPacket(brokers) # get one packet
|
||||
if inbuf == None:
|
||||
break
|
||||
try:
|
||||
print(timestamp(), "S to C", self.ids[id(clients)], repr(MQTTV3.unpackPacket(inbuf)))
|
||||
except:
|
||||
traceback.print_exc()
|
||||
clients.send(inbuf)
|
||||
print(timestamp()+" client "+self.ids[id(clients)]+" connection closing")
|
||||
except:
|
||||
print(repr((i, o, e)), repr(inbuf))
|
||||
traceback.print_exc()
|
||||
if id(clients) in self.ids.keys():
|
||||
del self.ids[id(clients)]
|
||||
elif id(clients) in self.versions.keys():
|
||||
del self.versions[id(clients)]
|
||||
|
||||
class ThreadingTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||
pass
|
||||
|
||||
def run():
|
||||
global brokerhost, brokerport
|
||||
myhost = 'localhost'
|
||||
if len(sys.argv) > 1:
|
||||
brokerhost = sys.argv[1]
|
||||
else:
|
||||
brokerhost = 'localhost'
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
brokerport = int(sys.argv[2])
|
||||
else:
|
||||
brokerport = 1883
|
||||
|
||||
if brokerhost == myhost:
|
||||
myport = brokerport + 1
|
||||
else:
|
||||
myport = 1883
|
||||
|
||||
print("Listening on port", str(myport)+", broker on port", brokerport)
|
||||
s = ThreadingTCPServer(("", myport), MyHandler)
|
||||
s.serve_forever()
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,693 @@
|
|||
#include <Python.h>
|
||||
|
||||
#include "MQTTClient.h"
|
||||
#include "LinkedList.h"
|
||||
|
||||
static PyObject *MqttV3Error;
|
||||
|
||||
static PyObject* mqttv3_create(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
char* serverURI;
|
||||
char* clientId;
|
||||
int persistence_option = MQTTCLIENT_PERSISTENCE_DEFAULT;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss|i", &serverURI, &clientId,
|
||||
&persistence_option))
|
||||
return NULL;
|
||||
|
||||
if (persistence_option != MQTTCLIENT_PERSISTENCE_DEFAULT
|
||||
&& persistence_option != MQTTCLIENT_PERSISTENCE_NONE)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "persistence must be DEFAULT or NONE");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = MQTTClient_create(&c, serverURI, clientId, persistence_option, NULL);
|
||||
|
||||
printf("create MQTTClient pointer %p\n", c);
|
||||
|
||||
return Py_BuildValue("ik", rc, c);
|
||||
}
|
||||
|
||||
static List* callbacks = NULL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
MQTTClient c;
|
||||
PyObject *context;
|
||||
PyObject *cl, *ma, *dc;
|
||||
} CallbackEntry;
|
||||
|
||||
int clientCompare(void* a, void* b)
|
||||
{
|
||||
CallbackEntry* e = (CallbackEntry*) a;
|
||||
return e->c == (MQTTClient) b;
|
||||
}
|
||||
|
||||
void connectionLost(void* context, char* cause)
|
||||
{
|
||||
/* call the right Python function, using the context */
|
||||
PyObject *arglist;
|
||||
PyObject *result;
|
||||
CallbackEntry* e = context;
|
||||
PyGILState_STATE gstate;
|
||||
|
||||
gstate = PyGILState_Ensure();
|
||||
arglist = Py_BuildValue("Os", e->context, cause);
|
||||
result = PyEval_CallObject(e->cl, arglist);
|
||||
Py_DECREF(arglist);
|
||||
PyGILState_Release(gstate);
|
||||
}
|
||||
|
||||
int messageArrived(void* context, char* topicName, int topicLen,
|
||||
MQTTClient_message* message)
|
||||
{
|
||||
PyObject *result = NULL;
|
||||
CallbackEntry* e = context;
|
||||
int rc = -99;
|
||||
PyGILState_STATE gstate;
|
||||
|
||||
//printf("messageArrived %s %s %d %.*s\n", PyString_AsString(e->context), topicName, topicLen,
|
||||
// message->payloadlen, (char*)message->payload);
|
||||
|
||||
gstate = PyGILState_Ensure();
|
||||
if (topicLen == 0)
|
||||
result = PyEval_CallFunction(e->ma, "Os{ss#sisisisi}", e->context,
|
||||
topicName, "payload", message->payload, message->payloadlen,
|
||||
"qos", message->qos, "retained", message->retained, "dup",
|
||||
message->dup, "msgid", message->msgid);
|
||||
else
|
||||
result = PyEval_CallFunction(e->ma, "Os#{ss#sisisisi}", e->context,
|
||||
topicName, topicLen, "payload", message->payload,
|
||||
message->payloadlen, "qos", message->qos, "retained",
|
||||
message->retained, "dup", message->dup, "msgid",
|
||||
message->msgid);
|
||||
if (result)
|
||||
{
|
||||
if (PyInt_Check(result))
|
||||
rc = (int) PyInt_AsLong(result);
|
||||
Py_DECREF(result);
|
||||
}
|
||||
PyGILState_Release(gstate);
|
||||
MQTTClient_free(topicName);
|
||||
MQTTClient_freeMessage(&message);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void deliveryComplete(void* context, MQTTClient_deliveryToken dt)
|
||||
{
|
||||
PyObject *arglist;
|
||||
PyObject *result;
|
||||
CallbackEntry* e = context;
|
||||
PyGILState_STATE gstate;
|
||||
|
||||
gstate = PyGILState_Ensure();
|
||||
arglist = Py_BuildValue("Oi", e->context, dt);
|
||||
result = PyEval_CallObject(e->dc, arglist);
|
||||
Py_DECREF(arglist);
|
||||
PyGILState_Release(gstate);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_setcallbacks(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
CallbackEntry* e = NULL;
|
||||
int rc;
|
||||
|
||||
e = malloc(sizeof(CallbackEntry));
|
||||
|
||||
if (!PyArg_ParseTuple(args, "kOOOO", &c, (PyObject**) &e->context, &e->cl,
|
||||
&e->ma, &e->dc))
|
||||
return NULL;
|
||||
e->c = c;
|
||||
|
||||
printf("setCallbacks MQTTClient pointer %p\n", c);
|
||||
|
||||
if ((e->cl != Py_None && !PyCallable_Check(e->cl))
|
||||
|| (e->ma != Py_None && !PyCallable_Check(e->ma))
|
||||
|| (e->dc != Py_None && !PyCallable_Check(e->dc)))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"3rd, 4th and 5th parameters must be callable or None");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_setCallbacks(c, e, connectionLost,
|
||||
messageArrived, deliveryComplete);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (rc == MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
ListElement* temp = NULL;
|
||||
if ((temp = ListFindItem(callbacks, c, clientCompare)) != NULL)
|
||||
{
|
||||
ListDetach(callbacks, temp->content);
|
||||
free(temp->content);
|
||||
}
|
||||
ListAppend(callbacks, e, sizeof(e));
|
||||
Py_XINCREF(e->cl);
|
||||
Py_XINCREF(e->ma);
|
||||
Py_XINCREF(e->dc);
|
||||
Py_XINCREF(e->context);
|
||||
}
|
||||
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_connect(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
PyObject *pyoptions = NULL, *temp;
|
||||
MQTTClient_connectOptions options = MQTTClient_connectOptions_initializer;
|
||||
MQTTClient_willOptions woptions = MQTTClient_willOptions_initializer;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "k|O", &c, &pyoptions))
|
||||
return NULL;
|
||||
|
||||
printf("connect MQTTClient pointer %p\n", c);
|
||||
if (!pyoptions)
|
||||
goto skip;
|
||||
|
||||
if (!PyDict_Check(pyoptions))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "2nd parameter must be a dictionary");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((temp = PyDict_GetItemString(pyoptions, "keepAliveInterval")) != NULL)
|
||||
{
|
||||
if (PyInt_Check(temp))
|
||||
options.keepAliveInterval = (int) PyInt_AsLong(temp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"keepAliveLiveInterval value must be int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((temp = PyDict_GetItemString(pyoptions, "cleansession")) != NULL)
|
||||
{
|
||||
if (PyInt_Check(temp))
|
||||
options.cleansession = (int) PyInt_AsLong(temp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "cleansession value must be int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((temp = PyDict_GetItemString(pyoptions, "reliable")) != NULL)
|
||||
{
|
||||
if (PyInt_Check(temp))
|
||||
options.reliable = (int) PyInt_AsLong(temp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "reliable value must be int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((temp = PyDict_GetItemString(pyoptions, "will")) != NULL)
|
||||
{
|
||||
if (PyDict_Check(temp))
|
||||
{
|
||||
PyObject *wtemp = NULL;
|
||||
if ((wtemp = PyDict_GetItemString(temp, "topicName")) == NULL)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"will topicName value must be set");
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PyString_Check(wtemp))
|
||||
woptions.topicName = PyString_AsString(wtemp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"will topicName value must be string");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if ((wtemp = PyDict_GetItemString(temp, "message")) == NULL)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"will message value must be set");
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PyString_Check(wtemp))
|
||||
woptions.message = PyString_AsString(wtemp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"will message value must be string");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if ((wtemp = PyDict_GetItemString(temp, "retained")) != NULL)
|
||||
{
|
||||
if (PyInt_Check(wtemp))
|
||||
woptions.retained = (int) PyInt_AsLong(wtemp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"will retained value must be int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if ((wtemp = PyDict_GetItemString(temp, "qos")) != NULL)
|
||||
{
|
||||
if (PyInt_Check(wtemp))
|
||||
woptions.qos = (int) PyInt_AsLong(wtemp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"will qos value must be int");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
options.will = &woptions;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "will value must be dictionary");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((temp = PyDict_GetItemString(pyoptions, "username")) != NULL)
|
||||
{
|
||||
if (PyString_Check(temp))
|
||||
options.username = PyString_AsString(temp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "username value must be string");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((temp = PyDict_GetItemString(pyoptions, "password")) != NULL)
|
||||
{
|
||||
if (PyString_Check(temp))
|
||||
options.username = PyString_AsString(temp);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "password value must be string");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
skip: Py_BEGIN_ALLOW_THREADS rc = MQTTClient_connect(c, &options);
|
||||
Py_END_ALLOW_THREADS
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_disconnect(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
int timeout = 0;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "k|i", &c, &timeout))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_disconnect(c, timeout);
|
||||
Py_END_ALLOW_THREADS
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_isConnected(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "k", &c))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_isConnected(c);
|
||||
Py_END_ALLOW_THREADS
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_subscribe(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
char* topic;
|
||||
int qos = 2;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ks|i", &c, &topic, &qos))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_subscribe(c, topic, qos);
|
||||
Py_END_ALLOW_THREADS
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_subscribeMany(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
PyObject* topicList;
|
||||
PyObject* qosList;
|
||||
|
||||
int count;
|
||||
char** topics;
|
||||
int* qoss;
|
||||
|
||||
int i, rc = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "kOO", &c, &topicList, &qosList))
|
||||
return NULL;
|
||||
|
||||
if (!PySequence_Check(topicList) || !PySequence_Check(qosList))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"3rd and 4th parameters must be sequences");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((count = PySequence_Length(topicList)) != PySequence_Length(qosList))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"3rd and 4th parameters must be sequences of the same length");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
topics = malloc(count * sizeof(char*));
|
||||
for (i = 0; i < count; ++i)
|
||||
topics[i] = PyString_AsString(PySequence_GetItem(topicList, i));
|
||||
|
||||
qoss = malloc(count * sizeof(int));
|
||||
for (i = 0; i < count; ++i)
|
||||
qoss[i] = (int) PyInt_AsLong(PySequence_GetItem(qosList, i));
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_subscribeMany(c, count, topics,
|
||||
qoss);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
PySequence_SetItem(qosList, i, PyInt_FromLong((long) qoss[i]));
|
||||
|
||||
free(topics);
|
||||
free(qoss);
|
||||
|
||||
if (rc == MQTTCLIENT_SUCCESS)
|
||||
return Py_BuildValue("iO", rc, qosList);
|
||||
else
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_unsubscribe(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
char* topic;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ks", &c, &topic))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_unsubscribe(c, topic);
|
||||
Py_END_ALLOW_THREADS
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_unsubscribeMany(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
PyObject* topicList;
|
||||
|
||||
int count;
|
||||
char** topics;
|
||||
|
||||
int i, rc = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "kOO", &c, &topicList))
|
||||
return NULL;
|
||||
|
||||
if (!PySequence_Check(topicList))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "3rd parameter must be sequences");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
count = PySequence_Length(topicList);
|
||||
topics = malloc(count * sizeof(char*));
|
||||
for (i = 0; i < count; ++i)
|
||||
topics[i] = PyString_AsString(PySequence_GetItem(topicList, i));
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_unsubscribeMany(c, count, topics);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
free( topics);
|
||||
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_publish(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
char* topicName;
|
||||
int payloadlen;
|
||||
void* payload;
|
||||
int qos = 0;
|
||||
int retained = 0;
|
||||
MQTTClient_deliveryToken dt;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "kss#|ii", &c, &topicName, &payload,
|
||||
&payloadlen, &qos, &retained))
|
||||
return NULL;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_publish(c, topicName, payloadlen,
|
||||
payload, qos, retained, &dt);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (rc == MQTTCLIENT_SUCCESS && qos > 0)
|
||||
return Py_BuildValue("ii", rc, dt);
|
||||
else
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_publishMessage(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
char* topicName;
|
||||
PyObject *message, *temp;
|
||||
MQTTClient_message msg = MQTTClient_message_initializer;
|
||||
MQTTClient_deliveryToken dt;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ksO", &c, &topicName, &message))
|
||||
return NULL;
|
||||
|
||||
if (!PyDict_Check(message))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "3rd parameter must be a dictionary");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((temp = PyDict_GetItemString(message, "payload")) == NULL)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "dictionary must have payload key");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (PyString_Check(temp))
|
||||
PyString_AsStringAndSize(temp, (char**) &msg.payload,
|
||||
(Py_ssize_t*) &msg.payloadlen);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "payload value must be string");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((temp = PyDict_GetItemString(message, "qos")) == NULL)
|
||||
msg.qos = (int) PyInt_AsLong(temp);
|
||||
|
||||
if ((temp = PyDict_GetItemString(message, "retained")) == NULL)
|
||||
msg.retained = (int) PyInt_AsLong(temp);
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_publishMessage(c, topicName, &msg,
|
||||
&dt);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (rc == MQTTCLIENT_SUCCESS && msg.qos > 0)
|
||||
return Py_BuildValue("ii", rc, dt);
|
||||
else
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_waitForCompletion(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
unsigned long timeout = 1000L;
|
||||
MQTTClient_deliveryToken dt;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ki|i", &c, &dt, &timeout))
|
||||
return NULL;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_waitForCompletion(c, dt, timeout);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_getPendingDeliveryTokens(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
MQTTClient_deliveryToken* tokens;
|
||||
int rc;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "k", &c))
|
||||
return NULL;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_getPendingDeliveryTokens(c, &tokens);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (rc == MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
int i = 0;
|
||||
PyObject* dts = PyList_New(0);
|
||||
|
||||
while (tokens[i] != -1)
|
||||
PyList_Append(dts, PyInt_FromLong((long) tokens[i]));
|
||||
|
||||
return Py_BuildValue("iO", rc, dts);
|
||||
}
|
||||
else
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_yield(PyObject* self, PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
MQTTClient_yield();
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
Py_INCREF( Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_receive(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
unsigned long timeout = 1000L;
|
||||
int rc;
|
||||
PyObject* temp = NULL;
|
||||
|
||||
char* topicName;
|
||||
int topicLen;
|
||||
MQTTClient_message* message;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "k|k", &c, &timeout))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS rc = MQTTClient_receive(c, &topicName, &topicLen,
|
||||
&message, timeout);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (message)
|
||||
{
|
||||
temp = Py_BuildValue("is#{ss#sisisisi}", rc, topicName, topicLen,
|
||||
"payload", message->payload, message->payloadlen, "qos",
|
||||
message->qos, "retained", message->retained, "dup",
|
||||
message->dup, "msgid", message->msgid);
|
||||
free(topicName);
|
||||
MQTTClient_freeMessage(&message);
|
||||
}
|
||||
else
|
||||
temp = Py_BuildValue("iz", rc, NULL);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
static PyObject* mqttv3_destroy(PyObject* self, PyObject *args)
|
||||
{
|
||||
MQTTClient c;
|
||||
ListElement* temp = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "k", &c))
|
||||
return NULL;
|
||||
|
||||
if ((temp = ListFindItem(callbacks, c, clientCompare)) != NULL)
|
||||
{
|
||||
ListDetach(callbacks, temp->content);
|
||||
free(temp->content);
|
||||
}
|
||||
|
||||
MQTTClient_destroy(&c);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyMethodDef MqttV3Methods[] =
|
||||
{
|
||||
{ "create", mqttv3_create, METH_VARARGS, "Create an MQTTv3 client." },
|
||||
{ "setcallbacks", mqttv3_setcallbacks, METH_VARARGS,
|
||||
"Sets the callback functions for a particular client." },
|
||||
{ "connect", mqttv3_connect, METH_VARARGS,
|
||||
"Connects to a server using the specified options." },
|
||||
{ "disconnect", mqttv3_disconnect, METH_VARARGS,
|
||||
"Disconnects from a server." },
|
||||
{ "isConnected", mqttv3_isConnected, METH_VARARGS,
|
||||
"Determines if this client is currently connected to the server." },
|
||||
{ "subscribe", mqttv3_subscribe, METH_VARARGS,
|
||||
"Subscribe to the given topic." },
|
||||
{ "subscribeMany", mqttv3_subscribeMany, METH_VARARGS,
|
||||
"Subscribe to the given topics." },
|
||||
{ "unsubscribe", mqttv3_unsubscribe, METH_VARARGS,
|
||||
"Unsubscribe from the given topic." },
|
||||
{ "unsubscribeMany", mqttv3_unsubscribeMany, METH_VARARGS,
|
||||
"Unsubscribe from the given topics." },
|
||||
{ "publish", mqttv3_publish, METH_VARARGS,
|
||||
"Publish a message to the given topic." },
|
||||
{ "publishMessage", mqttv3_publishMessage, METH_VARARGS,
|
||||
"Publish a message to the given topic." },
|
||||
{ "waitForCompletion", mqttv3_waitForCompletion, METH_VARARGS,
|
||||
"Waits for the completion of the delivery of the message represented by a delivery token." },
|
||||
{ "getPendingDeliveryTokens", mqttv3_getPendingDeliveryTokens,
|
||||
METH_VARARGS,
|
||||
"Returns the delivery tokens pending of completion." },
|
||||
{ "yield", mqttv3_yield, METH_VARARGS,
|
||||
"Single-thread keep alive but don't receive message." },
|
||||
{ "receive", mqttv3_receive, METH_VARARGS,
|
||||
"Single-thread receive message if available." },
|
||||
{ "destroy", mqttv3_destroy, METH_VARARGS,
|
||||
"Free memory allocated to a MQTT client. It is the opposite to create." },
|
||||
{ NULL, NULL, 0, NULL } /* Sentinel */
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC initpaho_mqtt3c(void)
|
||||
{
|
||||
PyObject *m;
|
||||
|
||||
PyEval_InitThreads();
|
||||
|
||||
callbacks = ListInitialize();
|
||||
|
||||
m = Py_InitModule("paho_mqtt3c", MqttV3Methods);
|
||||
if (m == NULL)
|
||||
return;
|
||||
|
||||
MqttV3Error = PyErr_NewException("paho_mqtt3c.error", NULL, NULL);
|
||||
Py_INCREF(MqttV3Error);
|
||||
PyModule_AddObject(m, "error", MqttV3Error);
|
||||
|
||||
PyModule_AddIntConstant(m, "SUCCESS", MQTTCLIENT_SUCCESS);
|
||||
PyModule_AddIntConstant(m, "FAILURE", MQTTCLIENT_FAILURE);
|
||||
PyModule_AddIntConstant(m, "DISCONNECTED", MQTTCLIENT_DISCONNECTED);
|
||||
PyModule_AddIntConstant(m, "MAX_MESSAGES_INFLIGHT", MQTTCLIENT_MAX_MESSAGES_INFLIGHT);
|
||||
PyModule_AddIntConstant(m, "BAD_UTF8_STRING", MQTTCLIENT_BAD_UTF8_STRING);
|
||||
PyModule_AddIntConstant(m, "BAD_NULL_PARAMETER", MQTTCLIENT_NULL_PARAMETER);
|
||||
PyModule_AddIntConstant(m, "BAD_TOPICNAME_TRUNCATED", MQTTCLIENT_TOPICNAME_TRUNCATED);
|
||||
PyModule_AddIntConstant(m, "PERSISTENCE_DEFAULT", MQTTCLIENT_PERSISTENCE_DEFAULT);
|
||||
PyModule_AddIntConstant(m, "PERSISTENCE_NONE", MQTTCLIENT_PERSISTENCE_NONE);
|
||||
PyModule_AddIntConstant(m, "PERSISTENCE_USER", MQTTCLIENT_PERSISTENCE_USER);
|
||||
PyModule_AddIntConstant(m, "PERSISTENCE_ERROR",
|
||||
MQTTCLIENT_PERSISTENCE_ERROR);
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
from distutils.core import setup, Extension
|
||||
|
||||
paho_mqtt3c = Extension('paho_mqtt3c',
|
||||
define_macros = [('NO_HEAP_TRACKING', '1')],
|
||||
sources = ['mqttclient_module.c', '../../src/LinkedList.c'],
|
||||
libraries = ['paho-mqtt3c'],
|
||||
library_dirs = ['../../build/output'],
|
||||
include_dirs = ['../../src'])
|
||||
|
||||
paho_mqtt3a = Extension('paho_mqtt3a',
|
||||
define_macros = [('NO_HEAP_TRACKING', '1')],
|
||||
sources = ['mqttasync_module.c', '../../src/LinkedList.c'],
|
||||
libraries = ['paho-mqtt3a'],
|
||||
library_dirs = ['../../build/output'],
|
||||
include_dirs = ['../../src'])
|
||||
|
||||
setup (name = 'EclipsePahoMQTTClient',
|
||||
version = '1.0',
|
||||
description = 'Binding to the Eclipse Paho C clients',
|
||||
ext_modules = [paho_mqtt3c, paho_mqtt3a])
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
import paho_mqtt3c as mqttv3, time, random
|
||||
|
||||
print dir(mqttv3)
|
||||
|
||||
host = "localhost"
|
||||
clientid = "myclientid"
|
||||
noclients = 4
|
||||
|
||||
def deliveryComplete(context, msgid):
|
||||
print "deliveryComplete", msgid
|
||||
|
||||
def connectionLost(context, cause):
|
||||
print "connectionLost"
|
||||
print "rc from reconnect is", mqttv3.connect(self.client)
|
||||
|
||||
def messageArrived(context, topicName, message):
|
||||
print "clientid", context
|
||||
print "topicName", topicName
|
||||
print "message", message
|
||||
return 1
|
||||
|
||||
print messageArrived
|
||||
|
||||
myclientid = None
|
||||
clients = []
|
||||
for i in range(noclients):
|
||||
myclientid = clientid+str(i)
|
||||
rc, client = mqttv3.create("tcp://"+host+":1883", myclientid)
|
||||
print "client is", hex(client)
|
||||
print "rc from create is", rc
|
||||
print "rc from setcallbacks is", mqttv3.setcallbacks(client, client, connectionLost, messageArrived, deliveryComplete)
|
||||
print "client is", hex(client)
|
||||
print "rc from connect is", mqttv3.connect(client, {})
|
||||
clients.append(client)
|
||||
|
||||
for client in clients:
|
||||
print "rc from subscribe is", mqttv3.subscribe(client, "$SYS/#")
|
||||
|
||||
for client in clients:
|
||||
print "rc from publish is", mqttv3.publish(client, "a topic", "a message")
|
||||
print "rc from publish is", mqttv3.publish(client, "a topic", "a message", 1)
|
||||
print "rc from publish is", mqttv3.publish(client, "a topic", "a message", 2)
|
||||
|
||||
print "about to sleep"
|
||||
time.sleep(10)
|
||||
print "finished sleeping"
|
||||
|
||||
for client in clients:
|
||||
print "rc from isConnected is", mqttv3.isConnected(client)
|
||||
print "rc from disconnect is", mqttv3.disconnect(client)
|
||||
mqttv3.destroy(client)
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
import paho_mqtt3a as mqttv3, time, random
|
||||
import contextlib
|
||||
|
||||
print dir(mqttv3)
|
||||
|
||||
hostname = "localhost"
|
||||
clientid = "myclientid"
|
||||
topic = "test2_topic"
|
||||
|
||||
def deliveryComplete(context, msgid):
|
||||
print "deliveryComplete", msgid
|
||||
|
||||
def connectionLost(context, cause):
|
||||
print "connectionLost"
|
||||
print "rc from reconnect is", mqttv3.connect(self.client)
|
||||
|
||||
def messageArrived(context, topicName, message):
|
||||
print "messageArrived", message
|
||||
#print "clientid", context
|
||||
#print "topicName", topicName
|
||||
return 1
|
||||
|
||||
def onSuccess(context, successData):
|
||||
print "onSuccess for", context["clientid"], context["state"], successData
|
||||
responseOptions = {"context": context, "onSuccess": onSuccess, "onFailure" : onFailure}
|
||||
#responseOptions = {"context": context}
|
||||
if context["state"] == "connecting":
|
||||
context["state"] = "subscribing"
|
||||
print "rc from subscribe is", mqttv3.subscribe(client, topic, 2, responseOptions)
|
||||
elif context["state"] == "subscribing":
|
||||
context["state"] = "publishing qos 0"
|
||||
print "rc from publish is", mqttv3.send(client, topic, "a QoS 0 message", 0, 0, responseOptions)
|
||||
elif context["state"] == "publishing qos 0":
|
||||
context["state"] = "publishing qos 1"
|
||||
print "rc from publish is", mqttv3.send(client, topic, "a QoS 1 message", 1, 0, responseOptions)
|
||||
elif context["state"] == "publishing qos 1":
|
||||
context["state"] = "publishing qos 2"
|
||||
print "rc from publish is", mqttv3.send(client, topic, "a QoS 2 message", 2, 0, responseOptions)
|
||||
elif context["state"] == "publishing qos 2":
|
||||
context["state"] = "finished"
|
||||
print "leaving onSuccess"
|
||||
|
||||
def onFailure(context, failureData):
|
||||
print "onFailure for", context["clientid"]
|
||||
context["state"] = "finished"
|
||||
|
||||
noclients = 1
|
||||
myclientid = None
|
||||
clients = []
|
||||
for i in range(noclients):
|
||||
myclientid = clientid+str(i)
|
||||
rc, client = mqttv3.create("tcp://"+hostname+":1883", myclientid)
|
||||
#print "client is", hex(client)
|
||||
print "rc from create is", rc
|
||||
print "rc from setcallbacks is", mqttv3.setcallbacks(client, client, connectionLost, messageArrived, deliveryComplete)
|
||||
|
||||
context = {"client" : client, "clientid" : clientid, "state" : "connecting"}
|
||||
|
||||
print "rc from connect is", mqttv3.connect(client, {"context": context, "onSuccess": onSuccess, "onFailure": onFailure})
|
||||
|
||||
clients.append(context)
|
||||
|
||||
while [x for x in clients if x["state"] != "finished"]:
|
||||
print [x for x in clients if x["state"] != "finished"]
|
||||
time.sleep(1)
|
||||
|
||||
for client in clients:
|
||||
if mqttv3.isConnected(client["client"]):
|
||||
print "rc from disconnect is", mqttv3.disconnect(client["client"], 1000)
|
||||
time.sleep(1)
|
||||
mqttv3.destroy(client["client"])
|
||||
print "after destroy"
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
import paho_mqtt3a as mqttv3, time, random
|
||||
import contextlib
|
||||
|
||||
print dir(mqttv3)
|
||||
|
||||
hostname = "localhost"
|
||||
clientid = "myclientid"
|
||||
topic = "test2_topic"
|
||||
|
||||
def deliveryComplete(context, msgid):
|
||||
print "deliveryComplete", msgid
|
||||
|
||||
def connectionLost(context, cause):
|
||||
print "connectionLost", cause
|
||||
client = context
|
||||
responseOptions = {"context": context, "onSuccess": onSuccess, "onFailure" : onFailure}
|
||||
print "rc from publish while disconnected is", mqttv3.send(client, topic, "message while disconnected", 2, 0, responseOptions)
|
||||
|
||||
def messageArrived(context, topicName, message):
|
||||
print "messageArrived", message
|
||||
#print "clientid", context
|
||||
#print "topicName", topicName
|
||||
return 1
|
||||
|
||||
def connected(context, cause):
|
||||
print "connected", cause
|
||||
|
||||
def onSuccess(context, successData):
|
||||
print "onSuccess for", context["clientid"], context["state"], successData
|
||||
responseOptions = {"context": context, "onSuccess": onSuccess, "onFailure" : onFailure}
|
||||
if context["state"] == "connecting":
|
||||
context["state"] = "subscribing"
|
||||
print "rc from subscribe is", mqttv3.subscribe(client, topic, 2, responseOptions)
|
||||
elif context["state"] == "subscribing":
|
||||
context["state"] = "publishing qos 0"
|
||||
print "rc from publish is", mqttv3.send(client, topic, "a QoS 0 message", 0, 0, responseOptions)
|
||||
elif context["state"] == "publishing qos 0":
|
||||
context["state"] = "publishing qos 1"
|
||||
print "rc from publish is", mqttv3.send(client, topic, "a QoS 1 message", 1, 0, responseOptions)
|
||||
elif context["state"] == "publishing qos 1":
|
||||
context["state"] = "publishing qos 2"
|
||||
print "rc from publish is", mqttv3.send(client, topic, "a QoS 2 message", 2, 0, responseOptions)
|
||||
elif context["state"] == "publishing qos 2":
|
||||
context["state"] = "finished"
|
||||
print "leaving onSuccess"
|
||||
|
||||
def onFailure(context, failureData):
|
||||
print "onFailure for", context["clientid"]
|
||||
context["state"] = "finished"
|
||||
|
||||
noclients = 1
|
||||
myclientid = None
|
||||
clients = []
|
||||
for i in range(noclients):
|
||||
myclientid = clientid+str(i)
|
||||
rc, client = mqttv3.create("tcp://"+hostname+":1883", myclientid, mqttv3.PERSISTENCE_DEFAULT, {"sendWhileDisconnected" : 1})
|
||||
#print "client is", hex(client)
|
||||
print "rc from create is", rc
|
||||
print "rc from setcallbacks is", mqttv3.setcallbacks(client, client, connectionLost, messageArrived, deliveryComplete)
|
||||
|
||||
print "rc from setconnected is", mqttv3.setconnected(client, client, connected)
|
||||
|
||||
|
||||
context = {"client" : client, "clientid" : clientid, "state" : "connecting"}
|
||||
|
||||
print "rc from connect is", mqttv3.connect(client, {"cleansession" : 0, "automaticReconnect": 1, "context": context, "onSuccess": onSuccess, "onFailure": onFailure})
|
||||
|
||||
clients.append(context)
|
||||
|
||||
while [x for x in clients if x["state"] != "finished"]:
|
||||
print [x for x in clients if x["state"] != "finished"]
|
||||
time.sleep(1)
|
||||
|
||||
print "waiting for 60 seconds"
|
||||
time.sleep(60)
|
||||
|
||||
for client in clients:
|
||||
if mqttv3.isConnected(client["client"]):
|
||||
print "rc from disconnect is", mqttv3.disconnect(client["client"], 1000)
|
||||
time.sleep(1)
|
||||
mqttv3.destroy(client["client"])
|
||||
print "after destroy"
|
||||
|
||||
|
|
@ -0,0 +1,709 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2016 IBM Corp.
|
||||
*
|
||||
* 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:
|
||||
* Ian Craggs - initial API and implementation and/or initial documentation
|
||||
* Ian Craggs - fix thread id display
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Multi-threaded tests for the MQ Telemetry MQTT C client
|
||||
*/
|
||||
|
||||
#include "MQTTClient.h"
|
||||
#include "Thread.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(_WINDOWS)
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#define WINAPI
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#define MAXHOSTNAMELEN 256
|
||||
#define EAGAIN WSAEWOULDBLOCK
|
||||
#define EINTR WSAEINTR
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define ENOTCONN WSAENOTCONN
|
||||
#define ECONNRESET WSAECONNRESET
|
||||
#define setenv(a, b, c) _putenv_s(a, b)
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
void usage()
|
||||
{
|
||||
printf("help!!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct Options
|
||||
{
|
||||
char* connection; /**< connection to system under test. */
|
||||
char** haconnections;
|
||||
int hacount;
|
||||
int verbose;
|
||||
int test_no;
|
||||
int MQTTVersion;
|
||||
int iterations;
|
||||
} options =
|
||||
{
|
||||
"tcp://m2m.eclipse.org:1883",
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
MQTTVERSION_DEFAULT,
|
||||
1,
|
||||
};
|
||||
|
||||
void getopts(int argc, char** argv)
|
||||
{
|
||||
int count = 1;
|
||||
|
||||
while (count < argc)
|
||||
{
|
||||
if (strcmp(argv[count], "--test_no") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
options.test_no = atoi(argv[count]);
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--connection") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
{
|
||||
options.connection = argv[count];
|
||||
printf("\nSetting connection to %s\n", options.connection);
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--haconnections") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
{
|
||||
char* tok = strtok(argv[count], " ");
|
||||
options.hacount = 0;
|
||||
options.haconnections = malloc(sizeof(char*) * 5);
|
||||
while (tok)
|
||||
{
|
||||
options.haconnections[options.hacount] = malloc(strlen(tok) + 1);
|
||||
strcpy(options.haconnections[options.hacount], tok);
|
||||
options.hacount++;
|
||||
tok = strtok(NULL, " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--MQTTversion") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
{
|
||||
options.MQTTVersion = atoi(argv[count]);
|
||||
printf("setting MQTT version to %d\n", options.MQTTVersion);
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--iterations") == 0)
|
||||
{
|
||||
if (++count < argc)
|
||||
options.iterations = atoi(argv[count]);
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if (strcmp(argv[count], "--verbose") == 0)
|
||||
{
|
||||
options.verbose = 1;
|
||||
printf("\nSetting verbose on\n");
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define LOGA_DEBUG 0
|
||||
#define LOGA_INFO 1
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <sys/timeb.h>
|
||||
void MyLog(int LOGA_level, char* format, ...)
|
||||
{
|
||||
static char msg_buf[256];
|
||||
va_list args;
|
||||
struct timeb ts;
|
||||
|
||||
struct tm *timeinfo;
|
||||
|
||||
if (LOGA_level == LOGA_DEBUG && options.verbose == 0)
|
||||
return;
|
||||
|
||||
ftime(&ts);
|
||||
timeinfo = localtime(&ts.time);
|
||||
strftime(msg_buf, 80, "%Y%m%d %H%M%S", timeinfo);
|
||||
|
||||
sprintf(&msg_buf[strlen(msg_buf)], ".%.3hu ", ts.millitm);
|
||||
|
||||
va_start(args, format);
|
||||
vsnprintf(&msg_buf[strlen(msg_buf)], sizeof(msg_buf) - strlen(msg_buf), format, args);
|
||||
va_end(args);
|
||||
|
||||
printf("%s\n", msg_buf);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
#if defined(WIN32) || defined(_WINDOWS)
|
||||
#define mqsleep(A) Sleep(1000*A)
|
||||
#define START_TIME_TYPE DWORD
|
||||
static DWORD start_time = 0;
|
||||
START_TIME_TYPE start_clock(void)
|
||||
{
|
||||
return GetTickCount();
|
||||
}
|
||||
#elif defined(AIX)
|
||||
#define mqsleep sleep
|
||||
#define START_TIME_TYPE struct timespec
|
||||
START_TIME_TYPE start_clock(void)
|
||||
{
|
||||
static struct timespec start;
|
||||
clock_gettime(CLOCK_REALTIME, &start);
|
||||
return start;
|
||||
}
|
||||
#else
|
||||
#define mqsleep sleep
|
||||
#define START_TIME_TYPE struct timeval
|
||||
/* TODO - unused - remove? static struct timeval start_time; */
|
||||
START_TIME_TYPE start_clock(void)
|
||||
{
|
||||
struct timeval start_time;
|
||||
gettimeofday(&start_time, NULL);
|
||||
return start_time;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WIN32)
|
||||
long elapsed(START_TIME_TYPE start_time)
|
||||
{
|
||||
return GetTickCount() - start_time;
|
||||
}
|
||||
#elif defined(AIX)
|
||||
#define assert(a)
|
||||
long elapsed(struct timespec start)
|
||||
{
|
||||
struct timespec now, res;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
ntimersub(now, start, res);
|
||||
return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L;
|
||||
}
|
||||
#else
|
||||
long elapsed(START_TIME_TYPE start_time)
|
||||
{
|
||||
struct timeval now, res;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
timersub(&now, &start_time, &res);
|
||||
return (res.tv_sec)*1000 + (res.tv_usec)/1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d)
|
||||
#define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e)
|
||||
|
||||
int tests = 0;
|
||||
int failures = 0;
|
||||
FILE* xml;
|
||||
START_TIME_TYPE global_start_time;
|
||||
char output[3000];
|
||||
char* cur_output = output;
|
||||
|
||||
|
||||
void write_test_result()
|
||||
{
|
||||
long duration = elapsed(global_start_time);
|
||||
|
||||
fprintf(xml, " time=\"%ld.%.3ld\" >\n", duration / 1000, duration % 1000);
|
||||
if (cur_output != output)
|
||||
{
|
||||
fprintf(xml, "%s", output);
|
||||
cur_output = output;
|
||||
}
|
||||
fprintf(xml, "</testcase>\n");
|
||||
}
|
||||
|
||||
|
||||
void myassert(char* filename, int lineno, char* description, int value, char* format, ...)
|
||||
{
|
||||
++tests;
|
||||
if (!value)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
++failures;
|
||||
MyLog(LOGA_INFO, "Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description);
|
||||
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
|
||||
cur_output += sprintf(cur_output, "<failure type=\"%s\">file %s, line %d </failure>\n",
|
||||
description, filename, lineno);
|
||||
}
|
||||
else
|
||||
MyLog(LOGA_DEBUG, "Assertion succeeded, file %s, line %d, description: %s", filename, lineno, description);
|
||||
}
|
||||
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
mutex_type deliveryCompleted_mutex = NULL;
|
||||
#else
|
||||
pthread_mutex_t deliveryCompleted_mutex_store = PTHREAD_MUTEX_INITIALIZER;
|
||||
mutex_type deliveryCompleted_mutex = &deliveryCompleted_mutex_store;
|
||||
#endif
|
||||
|
||||
void lock_mutex(mutex_type amutex)
|
||||
{
|
||||
int rc = Thread_lock_mutex(amutex);
|
||||
if (rc != 0)
|
||||
MyLog(LOGA_INFO, "Error %s locking mutex", strerror(rc));
|
||||
}
|
||||
|
||||
void unlock_mutex(mutex_type amutex)
|
||||
{
|
||||
int rc = Thread_unlock_mutex(amutex);
|
||||
if (rc != 0)
|
||||
MyLog(LOGA_INFO, "Error %s unlocking mutex", strerror(rc));
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
Test1: multiple threads to single client object
|
||||
|
||||
*********************************************************************/
|
||||
volatile int test1_arrivedcount = 0;
|
||||
volatile int test1_arrivedcount_qos[3] = {0, 0, 0};
|
||||
volatile int test1_deliveryCompleted = 0;
|
||||
MQTTClient_message test1_pubmsg_check = MQTTClient_message_initializer;
|
||||
|
||||
|
||||
void test1_deliveryComplete(void* context, MQTTClient_deliveryToken dt)
|
||||
{
|
||||
lock_mutex(deliveryCompleted_mutex);
|
||||
MyLog(LOGA_DEBUG, "Delivery complete for token %d", dt);
|
||||
++test1_deliveryCompleted;
|
||||
unlock_mutex(deliveryCompleted_mutex);
|
||||
}
|
||||
|
||||
int test1_messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m)
|
||||
{
|
||||
++(test1_arrivedcount_qos[m->qos]);
|
||||
++test1_arrivedcount;
|
||||
|
||||
MyLog(LOGA_DEBUG, "messageArrived: %d message received on topic %s is %.*s.",
|
||||
test1_arrivedcount, topicName, m->payloadlen, (char*)(m->payload));
|
||||
if (test1_pubmsg_check.payloadlen != m->payloadlen ||
|
||||
memcmp(m->payload, test1_pubmsg_check.payload, m->payloadlen) != 0)
|
||||
{
|
||||
failures++;
|
||||
MyLog(LOGA_INFO, "Error: wrong data received lengths %d %d\n", test1_pubmsg_check.payloadlen, m->payloadlen);
|
||||
}
|
||||
MQTTClient_free(topicName);
|
||||
MQTTClient_freeMessage(&m);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
struct thread_parms
|
||||
{
|
||||
MQTTClient* c;
|
||||
int qos;
|
||||
char* test_topic;
|
||||
};
|
||||
|
||||
static int iterations = 50;
|
||||
|
||||
thread_return_type WINAPI test1_sendAndReceive(void* n)
|
||||
{
|
||||
MQTTClient_deliveryToken dt;
|
||||
int i = 0;
|
||||
int rc = 0;
|
||||
int wait_seconds = 30;
|
||||
MQTTClient_message test1_pubmsg = MQTTClient_message_initializer;
|
||||
int subsqos = 2;
|
||||
|
||||
struct thread_parms *parms = n;
|
||||
MQTTClient* c = parms->c;
|
||||
int qos = parms->qos;
|
||||
char* test_topic = parms->test_topic;
|
||||
|
||||
rc = MQTTClient_subscribe(c, test_topic, subsqos);
|
||||
assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
MyLog(LOGA_INFO, "Thread %u, %d messages at QoS %d", Thread_getid(), iterations, qos);
|
||||
test1_pubmsg.payload = test1_pubmsg_check.payload;
|
||||
test1_pubmsg.payloadlen = test1_pubmsg_check.payloadlen;
|
||||
test1_pubmsg.retained = 0;
|
||||
test1_pubmsg.qos = qos;
|
||||
|
||||
for (i = 1; i <= iterations; ++i)
|
||||
{
|
||||
if (i % 10 == 0)
|
||||
rc = MQTTClient_publish(c, test_topic, test1_pubmsg.payloadlen, test1_pubmsg.payload,
|
||||
qos, test1_pubmsg.retained, &dt);
|
||||
else
|
||||
rc = MQTTClient_publishMessage(c, test_topic, &test1_pubmsg, &dt);
|
||||
assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(100000L);
|
||||
#endif
|
||||
|
||||
wait_seconds = 30;
|
||||
while ((test1_arrivedcount_qos[qos] < i) && (wait_seconds-- > 0))
|
||||
{
|
||||
MyLog(LOGA_DEBUG, "Arrived %d count %d", test1_arrivedcount_qos[qos], i);
|
||||
#if defined(WIN32)
|
||||
Sleep(1000);
|
||||
#else
|
||||
usleep(1000000L);
|
||||
#endif
|
||||
}
|
||||
assert("Message Arrived", wait_seconds > 0,
|
||||
"Timed out waiting for message %d\n", i);
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
return 0;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int test1(struct Options options)
|
||||
{
|
||||
MQTTClient c;
|
||||
MQTTClient_connectOptions opts = MQTTClient_connectOptions_initializer;
|
||||
MQTTClient_willOptions wopts = MQTTClient_willOptions_initializer;
|
||||
int rc = 0;
|
||||
char* test_topic = "C client test1";
|
||||
|
||||
fprintf(xml, "<testcase classname=\"test1\" name=\"multiple threads using same client object\"");
|
||||
global_start_time = start_clock();
|
||||
failures = 0;
|
||||
MyLog(LOGA_INFO, "Starting test 1 - multiple threads using same client object");
|
||||
|
||||
rc = MQTTClient_create(&c, options.connection, "single_object, multiple threads",
|
||||
MQTTCLIENT_PERSISTENCE_NONE, NULL);
|
||||
assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc);
|
||||
if (rc != MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
MQTTClient_destroy(&c);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rc = MQTTClient_setCallbacks(c, NULL, NULL, test1_messageArrived, test1_deliveryComplete);
|
||||
assert("Good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
opts.keepAliveInterval = 20;
|
||||
opts.cleansession = 1;
|
||||
opts.username = "testuser";
|
||||
opts.password = "testpassword";
|
||||
opts.MQTTVersion = options.MQTTVersion;
|
||||
if (options.haconnections != NULL)
|
||||
{
|
||||
opts.serverURIs = options.haconnections;
|
||||
opts.serverURIcount = options.hacount;
|
||||
}
|
||||
|
||||
opts.will = &wopts;
|
||||
opts.will->message = "will message";
|
||||
opts.will->qos = 1;
|
||||
opts.will->retained = 0;
|
||||
opts.will->topicName = "will topic";
|
||||
opts.will = NULL;
|
||||
|
||||
MyLog(LOGA_DEBUG, "Connecting");
|
||||
rc = MQTTClient_connect(c, &opts);
|
||||
assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
if (rc != MQTTCLIENT_SUCCESS)
|
||||
goto exit;
|
||||
|
||||
test1_pubmsg_check.payload = "a much longer message that we can shorten to the extent that we need to";
|
||||
test1_pubmsg_check.payloadlen = 27;
|
||||
test1_deliveryCompleted = test1_arrivedcount = 0;
|
||||
|
||||
struct thread_parms parms0 = {c, 0, test_topic};
|
||||
Thread_start(test1_sendAndReceive, (void*)&parms0);
|
||||
|
||||
struct thread_parms parms1 = {c, 1, test_topic};
|
||||
Thread_start(test1_sendAndReceive, (void*)&parms1);
|
||||
|
||||
struct thread_parms parms2 = {c, 2, test_topic};
|
||||
Thread_start(test1_sendAndReceive, (void*)&parms2);
|
||||
|
||||
/* MQTT servers can send a message to a subscriber before the server has
|
||||
completed the QoS 2 handshake with the publisher. For QoS 1 and 2,
|
||||
allow time for the final delivery complete callback before checking
|
||||
that all expected callbacks have been made */
|
||||
|
||||
int wait_seconds = 90;
|
||||
while (((test1_arrivedcount < iterations*3) || (test1_deliveryCompleted < iterations*2)) && (wait_seconds-- > 0))
|
||||
{
|
||||
#if defined(WIN32)
|
||||
Sleep(1000);
|
||||
#else
|
||||
usleep(1000000L);
|
||||
#endif
|
||||
}
|
||||
assert("Arrived count == 150", test1_arrivedcount == iterations*3, "arrivedcount was %d", test1_arrivedcount);
|
||||
assert("All Deliveries Complete", test1_deliveryCompleted == iterations*2,
|
||||
"Number of deliveryCompleted callbacks was %d\n", test1_deliveryCompleted);
|
||||
|
||||
MyLog(LOGA_DEBUG, "Stopping\n");
|
||||
|
||||
rc = MQTTClient_unsubscribe(c, test_topic);
|
||||
assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
rc = MQTTClient_disconnect(c, 0);
|
||||
assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
/* Just to make sure we can connect again */
|
||||
rc = MQTTClient_connect(c, &opts);
|
||||
assert("Connect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
rc = MQTTClient_disconnect(c, 0);
|
||||
assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
MQTTClient_destroy(&c);
|
||||
|
||||
exit:
|
||||
MyLog(LOGA_INFO, "TEST1: test %s. %d tests run, %d failures.",
|
||||
(failures == 0) ? "passed" : "failed", tests, failures);
|
||||
write_test_result();
|
||||
return failures;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
Test2: multiple client objects used from multiple threads
|
||||
|
||||
*********************************************************************/
|
||||
volatile int test2_arrivedcount = 0;
|
||||
|
||||
volatile int test2_deliveryCompleted = 0;
|
||||
|
||||
MQTTClient_message test2_pubmsg = MQTTClient_message_initializer;
|
||||
|
||||
void test2_deliveryComplete(void* context, MQTTClient_deliveryToken dt)
|
||||
{
|
||||
lock_mutex(deliveryCompleted_mutex);
|
||||
MyLog(LOGA_DEBUG, "Delivery complete for token %d", dt);
|
||||
++test2_deliveryCompleted;
|
||||
unlock_mutex(deliveryCompleted_mutex);
|
||||
}
|
||||
|
||||
int test2_messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m)
|
||||
{
|
||||
++test2_arrivedcount;
|
||||
MyLog(LOGA_DEBUG, "Callback: %d message received on topic %s is %.*s.",
|
||||
test2_arrivedcount, topicName, m->payloadlen, (char*)(m->payload));
|
||||
if (test2_pubmsg.payloadlen != m->payloadlen ||
|
||||
memcmp(m->payload, test2_pubmsg.payload, m->payloadlen) != 0)
|
||||
{
|
||||
failures++;
|
||||
MyLog(LOGA_INFO, "Error: wrong data received lengths %d %d\n", test2_pubmsg.payloadlen, m->payloadlen);
|
||||
}
|
||||
MQTTClient_free(topicName);
|
||||
MQTTClient_freeMessage(&m);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void test2_sendAndReceive(MQTTClient* c, int qos, char* test_topic)
|
||||
{
|
||||
MQTTClient_deliveryToken dt;
|
||||
int i = 0;
|
||||
int iterations = 50;
|
||||
int rc = 0;
|
||||
int wait_seconds = 0;
|
||||
|
||||
test2_deliveryCompleted = 0;
|
||||
|
||||
MyLog(LOGA_INFO, "%d messages at QoS %d", iterations, qos);
|
||||
test2_pubmsg.payload = "a much longer message that we can shorten to the extent that we need to";
|
||||
test2_pubmsg.payloadlen = 27;
|
||||
test2_pubmsg.qos = qos;
|
||||
test2_pubmsg.retained = 0;
|
||||
|
||||
for (i = 1; i <= iterations; ++i)
|
||||
{
|
||||
if (i % 10 == 0)
|
||||
rc = MQTTClient_publish(c, test_topic, test2_pubmsg.payloadlen, test2_pubmsg.payload,
|
||||
test2_pubmsg.qos, test2_pubmsg.retained, NULL);
|
||||
else
|
||||
rc = MQTTClient_publishMessage(c, test_topic, &test2_pubmsg, &dt);
|
||||
assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(100000L);
|
||||
#endif
|
||||
|
||||
wait_seconds = 10;
|
||||
while ((test2_arrivedcount < i) && (wait_seconds-- > 0))
|
||||
{
|
||||
MyLog(LOGA_DEBUG, "Arrived %d count %d", test2_arrivedcount, i);
|
||||
#if defined(WIN32)
|
||||
Sleep(1000);
|
||||
#else
|
||||
usleep(1000000L);
|
||||
#endif
|
||||
}
|
||||
assert("Message Arrived", wait_seconds > 0,
|
||||
"Time out waiting for message %d\n", i );
|
||||
}
|
||||
if (qos > 0)
|
||||
{
|
||||
/* MQ Telemetry can send a message to a subscriber before the server has
|
||||
completed the QoS 2 handshake with the publisher. For QoS 1 and 2,
|
||||
allow time for the final delivery complete callback before checking
|
||||
that all expected callbacks have been made */
|
||||
wait_seconds = 40;
|
||||
while ((test2_deliveryCompleted < iterations) && (wait_seconds-- > 0))
|
||||
{
|
||||
MyLog(LOGA_DEBUG, "Delivery Completed %d count %d", test2_deliveryCompleted, i);
|
||||
#if defined(WIN32)
|
||||
Sleep(1000);
|
||||
#else
|
||||
usleep(1000000L);
|
||||
#endif
|
||||
}
|
||||
assert("All Deliveries Complete", test2_deliveryCompleted == iterations,
|
||||
"Number of deliveryCompleted callbacks was %d\n",
|
||||
test2_deliveryCompleted);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int test2(struct Options options)
|
||||
{
|
||||
char* testname = "test2";
|
||||
int subsqos = 2;
|
||||
/* TODO - usused - remove ? MQTTClient_deliveryToken* dt = NULL; */
|
||||
MQTTClient c;
|
||||
MQTTClient_connectOptions opts = MQTTClient_connectOptions_initializer;
|
||||
int rc = 0;
|
||||
char* test_topic = "C client test2";
|
||||
|
||||
fprintf(xml, "<testcase classname=\"test1\" name=\"multi-threaded client using callbacks\"");
|
||||
MyLog(LOGA_INFO, "Starting test 2 - multi-threaded client using callbacks");
|
||||
global_start_time = start_clock();
|
||||
failures = 0;
|
||||
|
||||
MQTTClient_create(&c, options.connection, "multi_threaded_sample", MQTTCLIENT_PERSISTENCE_NONE, NULL);
|
||||
|
||||
opts.keepAliveInterval = 20;
|
||||
opts.cleansession = 1;
|
||||
opts.MQTTVersion = options.MQTTVersion;
|
||||
if (options.haconnections != NULL)
|
||||
{
|
||||
opts.serverURIs = options.haconnections;
|
||||
opts.serverURIcount = options.hacount;
|
||||
}
|
||||
|
||||
rc = MQTTClient_setCallbacks(c, NULL, NULL, test2_messageArrived, test2_deliveryComplete);
|
||||
assert("Good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
MyLog(LOGA_DEBUG, "Connecting");
|
||||
rc = MQTTClient_connect(c, &opts);
|
||||
assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
if (rc != MQTTCLIENT_SUCCESS)
|
||||
goto exit;
|
||||
|
||||
rc = MQTTClient_subscribe(c, test_topic, subsqos);
|
||||
assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
test2_sendAndReceive(c, 0, test_topic);
|
||||
test2_sendAndReceive(c, 1, test_topic);
|
||||
test2_sendAndReceive(c, 2, test_topic);
|
||||
|
||||
MyLog(LOGA_DEBUG, "Stopping");
|
||||
|
||||
rc = MQTTClient_unsubscribe(c, test_topic);
|
||||
assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
rc = MQTTClient_disconnect(c, 0);
|
||||
assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
|
||||
|
||||
MQTTClient_destroy(&c);
|
||||
|
||||
exit:
|
||||
MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.",
|
||||
(failures == 0) ? "passed" : "failed", testname, tests, failures);
|
||||
write_test_result();
|
||||
return failures;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int rc = 0;
|
||||
int (*tests[])() = {NULL, test1};
|
||||
int i;
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
deliveryCompleted_mutex = CreateMutex(NULL, 0, NULL);
|
||||
#endif
|
||||
|
||||
xml = fopen("TEST-test2.xml", "w");
|
||||
fprintf(xml, "<testsuite name=\"test1\" tests=\"%d\">\n", (int)(ARRAY_SIZE(tests) - 1));
|
||||
|
||||
setenv("MQTT_C_CLIENT_TRACE", "ON", 1);
|
||||
setenv("MQTT_C_CLIENT_TRACE_LEVEL", "ERROR", 1);
|
||||
|
||||
getopts(argc, argv);
|
||||
|
||||
for (i = 0; i < options.iterations; ++i)
|
||||
{
|
||||
if (options.test_no == 0)
|
||||
{ /* run all the tests */
|
||||
for (options.test_no = 1; options.test_no < ARRAY_SIZE(tests); ++options.test_no)
|
||||
rc += tests[options.test_no](options); /* return number of failures. 0 = test succeeded */
|
||||
}
|
||||
else
|
||||
rc = tests[options.test_no](options); /* run just the selected test */
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
MyLog(LOGA_INFO, "verdict pass");
|
||||
else
|
||||
MyLog(LOGA_INFO, "verdict fail");
|
||||
|
||||
fprintf(xml, "</testsuite>\n");
|
||||
fclose(xml);
|
||||
return rc;
|
||||
}
|
||||
263
test/test4.c
263
test/test4.c
|
|
@ -13,6 +13,7 @@
|
|||
* Contributors:
|
||||
* Ian Craggs - initial API and implementation and/or initial documentation
|
||||
* Ian Craggs - MQTT 3.1.1 support
|
||||
* Ian Craggs - test8 - failure callbacks
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
|
|
@ -22,12 +23,6 @@
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
#if !defined(_RTSHEADER)
|
||||
#include <rts.h>
|
||||
#endif
|
||||
*/
|
||||
|
||||
#include "MQTTAsync.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -1329,7 +1324,7 @@ int test7(struct Options options)
|
|||
rc = MQTTAsync_send(c, test_topic, pubmsg.payloadlen, pubmsg.payload, pubmsg.qos, pubmsg.retained, &ropts);
|
||||
MyLog(LOGA_DEBUG, "Token was %d", ropts.token);
|
||||
rc = MQTTAsync_isComplete(c, ropts.token);
|
||||
assert("0 rc from isComplete", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
/*assert("0 rc from isComplete", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);*/
|
||||
rc = MQTTAsync_waitForCompletion(c, ropts.token, 5000L);
|
||||
assert("Good rc from waitForCompletion", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
rc = MQTTAsync_isComplete(c, ropts.token);
|
||||
|
|
@ -1440,6 +1435,258 @@ exit:
|
|||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
Test8: Incomplete commands and requests
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
char* test8_topic = "C client test8";
|
||||
int test8_messageCount = 0;
|
||||
int test8_subscribed = 0;
|
||||
int test8_publishFailures = 0;
|
||||
|
||||
void test8_onPublish(void* context, MQTTAsync_successData* response)
|
||||
{
|
||||
MQTTAsync c = (MQTTAsync)context;
|
||||
|
||||
MyLog(LOGA_DEBUG, "In publish onSuccess callback %p token %d", c, response->token);
|
||||
|
||||
}
|
||||
|
||||
void test8_onPublishFailure(void* context, MQTTAsync_failureData* response)
|
||||
{
|
||||
MQTTAsync c = (MQTTAsync)context;
|
||||
MyLog(LOGA_DEBUG, "In onPublish failure callback %p", c);
|
||||
|
||||
assert("Response code should be interrupted", response->code == MQTTASYNC_OPERATION_INCOMPLETE,
|
||||
"rc was %d", response->code);
|
||||
|
||||
test8_publishFailures++;
|
||||
}
|
||||
|
||||
|
||||
void test8_onDisconnectFailure(void* context, MQTTAsync_failureData* response)
|
||||
{
|
||||
MQTTAsync c = (MQTTAsync)context;
|
||||
MyLog(LOGA_DEBUG, "In onDisconnect failure callback %p", c);
|
||||
|
||||
assert("Successful disconnect", 0, "disconnect failed", 0);
|
||||
|
||||
test_finished = 1;
|
||||
}
|
||||
|
||||
|
||||
void test8_onDisconnect(void* context, MQTTAsync_successData* response)
|
||||
{
|
||||
MQTTAsync c = (MQTTAsync)context;
|
||||
MyLog(LOGA_DEBUG, "In onDisconnect callback %p", c);
|
||||
test_finished = 1;
|
||||
}
|
||||
|
||||
|
||||
void test8_onSubscribe(void* context, MQTTAsync_successData* response)
|
||||
{
|
||||
MQTTAsync c = (MQTTAsync)context;
|
||||
|
||||
MyLog(LOGA_DEBUG, "In subscribe onSuccess callback %p granted qos %d", c, response->alt.qos);
|
||||
|
||||
test8_subscribed = 1;
|
||||
}
|
||||
|
||||
|
||||
void test8_onConnect(void* context, MQTTAsync_successData* response)
|
||||
{
|
||||
MQTTAsync c = (MQTTAsync)context;
|
||||
MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
|
||||
int rc;
|
||||
|
||||
MyLog(LOGA_DEBUG, "In connect onSuccess callback, context %p", context);
|
||||
opts.onSuccess = test8_onSubscribe;
|
||||
opts.context = c;
|
||||
|
||||
rc = MQTTAsync_subscribe(c, test8_topic, 2, &opts);
|
||||
assert("Good rc from subscribe", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
if (rc != MQTTASYNC_SUCCESS)
|
||||
test_finished = 1;
|
||||
}
|
||||
|
||||
int test8_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* message)
|
||||
{
|
||||
MQTTAsync c = (MQTTAsync)context;
|
||||
static int message_count = 0;
|
||||
|
||||
MyLog(LOGA_DEBUG, "Test8: received message id %d", message->msgid);
|
||||
|
||||
test8_messageCount++;
|
||||
|
||||
MQTTAsync_freeMessage(&message);
|
||||
MQTTAsync_free(topicName);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int test8(struct Options options)
|
||||
{
|
||||
int subsqos = 2;
|
||||
MQTTAsync c;
|
||||
MQTTAsync_connectOptions opts = MQTTAsync_connectOptions_initializer;
|
||||
int rc = 0;
|
||||
MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
|
||||
MQTTAsync_responseOptions ropts = MQTTAsync_responseOptions_initializer;
|
||||
MQTTAsync_disconnectOptions dopts = MQTTAsync_disconnectOptions_initializer;
|
||||
MQTTAsync_token* tokens = NULL;
|
||||
int msg_count = 6;
|
||||
|
||||
MyLog(LOGA_INFO, "Starting test 8 - incomplete commands");
|
||||
fprintf(xml, "<testcase classname=\"test4\" name=\"incomplete commands\"");
|
||||
global_start_time = start_clock();
|
||||
test_finished = 0;
|
||||
|
||||
rc = MQTTAsync_create(&c, options.connection, "async_test8",
|
||||
MQTTCLIENT_PERSISTENCE_DEFAULT, NULL);
|
||||
assert("good rc from create", rc == MQTTASYNC_SUCCESS, "rc was %d\n", rc);
|
||||
if (rc != MQTTASYNC_SUCCESS)
|
||||
{
|
||||
MQTTAsync_destroy(&c);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rc = MQTTAsync_setCallbacks(c, c, NULL, test8_messageArrived, NULL);
|
||||
assert("Good rc from setCallbacks", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
|
||||
opts.keepAliveInterval = 20;
|
||||
opts.username = "testuser";
|
||||
opts.password = "testpassword";
|
||||
opts.MQTTVersion = options.MQTTVersion;
|
||||
|
||||
opts.onFailure = NULL;
|
||||
opts.context = c;
|
||||
|
||||
MyLog(LOGA_DEBUG, "Connecting");
|
||||
opts.cleansession = 1;
|
||||
opts.onSuccess = test8_onConnect;
|
||||
rc = MQTTAsync_connect(c, &opts);
|
||||
rc = 0;
|
||||
assert("Good rc from connect", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
if (rc != MQTTASYNC_SUCCESS)
|
||||
goto exit;
|
||||
|
||||
while (!test8_subscribed)
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(10000L);
|
||||
#endif
|
||||
|
||||
int i = 0;
|
||||
pubmsg.qos = 2;
|
||||
ropts.onSuccess = test8_onPublish;
|
||||
ropts.onFailure = test8_onPublishFailure;
|
||||
ropts.context = c;
|
||||
for (i = 0; i < msg_count; ++i)
|
||||
{
|
||||
pubmsg.payload = "a much longer message that we can shorten to the extent that we need to payload up to 11";
|
||||
pubmsg.payloadlen = 11;
|
||||
pubmsg.qos = (pubmsg.qos == 2) ? 1 : 2; /* alternate */
|
||||
pubmsg.retained = 0;
|
||||
rc = MQTTAsync_sendMessage(c, test8_topic, &pubmsg, &ropts);
|
||||
assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
}
|
||||
/* disconnect immediately without completing the commands */
|
||||
dopts.timeout = 0;
|
||||
dopts.onSuccess = test8_onDisconnect;
|
||||
dopts.context = c;
|
||||
rc = MQTTAsync_disconnect(c, &dopts); /* now there should be incomplete commands */
|
||||
assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
|
||||
while (!test_finished)
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(10000L);
|
||||
#endif
|
||||
test_finished = 0;
|
||||
|
||||
rc = MQTTAsync_getPendingTokens(c, &tokens);
|
||||
assert("getPendingTokens rc == 0", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
assert("should get no tokens back", tokens == NULL, "tokens was %p", tokens);
|
||||
|
||||
assert("test8_publishFailures > 0", test8_publishFailures > 0,
|
||||
"test8_publishFailures = %d", test8_publishFailures);
|
||||
|
||||
/* Now elicit failure callbacks on destroy */
|
||||
|
||||
test8_subscribed = test8_publishFailures = 0;
|
||||
|
||||
MyLog(LOGA_DEBUG, "Connecting");
|
||||
opts.cleansession = 0;
|
||||
opts.onSuccess = test8_onConnect;
|
||||
rc = MQTTAsync_connect(c, &opts);
|
||||
rc = 0;
|
||||
assert("Good rc from connect", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
if (rc != MQTTASYNC_SUCCESS)
|
||||
goto exit;
|
||||
|
||||
while (!test8_subscribed)
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(10000L);
|
||||
#endif
|
||||
|
||||
i = 0;
|
||||
pubmsg.qos = 2;
|
||||
ropts.onSuccess = test8_onPublish;
|
||||
ropts.onFailure = test8_onPublishFailure;
|
||||
ropts.context = c;
|
||||
for (i = 0; i < msg_count; ++i)
|
||||
{
|
||||
pubmsg.payload = "a much longer message that we can shorten to the extent that we need to payload up to 11";
|
||||
pubmsg.payloadlen = 11;
|
||||
pubmsg.qos = (pubmsg.qos == 2) ? 1 : 2; /* alternate */
|
||||
pubmsg.retained = 0;
|
||||
rc = MQTTAsync_sendMessage(c, test8_topic, &pubmsg, &ropts);
|
||||
assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
}
|
||||
/* disconnect immediately without completing the commands */
|
||||
dopts.timeout = 0;
|
||||
dopts.onSuccess = test8_onDisconnect;
|
||||
dopts.context = c;
|
||||
rc = MQTTAsync_disconnect(c, &dopts); /* now there should be incomplete commands */
|
||||
assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
|
||||
while (!test_finished)
|
||||
#if defined(WIN32)
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(10000L);
|
||||
#endif
|
||||
test_finished = 0;
|
||||
|
||||
rc = MQTTAsync_getPendingTokens(c, &tokens);
|
||||
assert("getPendingTokens rc == 0", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
|
||||
assert("should get some tokens back", tokens != NULL, "tokens was %p", tokens);
|
||||
MQTTAsync_free(tokens);
|
||||
|
||||
assert("test8_publishFailures == 0", test8_publishFailures == 0,
|
||||
"test8_publishFailures = %d", test8_publishFailures);
|
||||
|
||||
MQTTAsync_destroy(&c);
|
||||
|
||||
assert("test8_publishFailures > 0", test8_publishFailures > 0,
|
||||
"test8_publishFailures = %d", test8_publishFailures);
|
||||
|
||||
exit:
|
||||
MyLog(LOGA_INFO, "TEST8: test %s. %d tests run, %d failures.",
|
||||
(failures == 0) ? "passed" : "failed", tests, failures);
|
||||
write_test_result();
|
||||
return failures;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void trace_callback(enum MQTTASYNC_TRACE_LEVELS level, char* message)
|
||||
{
|
||||
printf("Trace : %d, %s\n", level, message);
|
||||
|
|
@ -1451,7 +1698,7 @@ void trace_callback(enum MQTTASYNC_TRACE_LEVELS level, char* message)
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
int rc = 0;
|
||||
int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6, test7}; /* indexed starting from 1 */
|
||||
int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6, test7, test8}; /* indexed starting from 1 */
|
||||
MQTTAsync_nameValue* info;
|
||||
int i;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue