paho.mqtt.c-master

所属分类:通讯编程
开发工具:C/C++
文件大小:617KB
下载次数:8
上传日期:2018-08-09 16:47:19
上 传 者qqqqq!a
说明:  包含了mqtt协议的底层和接口,适用于物联网开发
(It includes the bottom and interface of mqtt protocol, which is suitable for the development of Internet of things.)

文件列表:
.cproject (17617, 2018-08-04)
.project (985, 2018-08-04)
.pydevproject (302, 2018-08-04)
.settings (0, 2018-08-04)
.settings\org.eclipse.cdt.core.prefs (4289, 2018-08-04)
.travis.yml (1946, 2018-08-04)
CMakeLists.txt (3678, 2018-08-04)
CODE_OF_CONDUCT.md (116, 2018-08-04)
CONTRIBUTING.md (3612, 2018-08-04)
LICENSE (491, 2018-08-04)
Makefile (14408, 2018-08-04)
Windows Build (0, 2018-08-04)
Windows Build\MQTTVersion (0, 2018-08-04)
Windows Build\MQTTVersion\MQTTVersion.vcxproj (7842, 2018-08-04)
Windows Build\MQTTVersion\MQTTVersion.vcxproj.filters (1358, 2018-08-04)
Windows Build\MQTTVersion\MQTTVersion.vcxproj.user (162, 2018-08-04)
Windows Build\Paho C MQTT APIs.sln (10657, 2018-08-04)
Windows Build\paho-mqtt3a (0, 2018-08-04)
Windows Build\paho-mqtt3a\paho-mqtt3a.vcxproj (10107, 2018-08-04)
Windows Build\paho-mqtt3a\paho-mqtt3a.vcxproj.filters (5372, 2018-08-04)
Windows Build\paho-mqtt3a\paho-mqtt3a.vcxproj.user (141, 2018-08-04)
Windows Build\paho-mqtt3as (0, 2018-08-04)
Windows Build\paho-mqtt3as\paho-mqtt3as.vcxproj (11179, 2018-08-04)
Windows Build\paho-mqtt3as\paho-mqtt3as.vcxproj.filters (5166, 2018-08-04)
Windows Build\paho-mqtt3as\paho-mqtt3as.vcxproj.user (162, 2018-08-04)
Windows Build\paho-mqtt3c (0, 2018-08-04)
Windows Build\paho-mqtt3c\paho-mqtt3c.vcxproj (9127, 2018-08-04)
Windows Build\paho-mqtt3c\paho-mqtt3c.vcxproj.filters (2882, 2018-08-04)
Windows Build\paho-mqtt3c\paho-mqtt3c.vcxproj.user (141, 2018-08-04)
Windows Build\paho-mqtt3cs (0, 2018-08-04)
Windows Build\paho-mqtt3cs\paho-mqtt3cs.vcxproj (11383, 2018-08-04)
Windows Build\paho-mqtt3cs\paho-mqtt3cs.vcxproj.filters (5167, 2018-08-04)
Windows Build\paho-mqtt3cs\paho-mqtt3cs.vcxproj.user (162, 2018-08-04)
Windows Build\stdoutsub (0, 2018-08-04)
Windows Build\stdoutsub\stdoutsub.vcxproj (8914, 2018-08-04)
Windows Build\stdoutsub\stdoutsub.vcxproj.filters (1199, 2018-08-04)
... ...

# Eclipse Paho MQTT C client This repository contains the source code for the [Eclipse Paho](http://eclipse.org/paho) MQTT C client library. This code builds libraries which enable applications to connect to an [MQTT](http://mqtt.org) broker to publish messages, and to subscribe to topics and receive published messages. Both synchronous and asynchronous modes of operation are supported. ## Build Status Linux Build Status: [![Linux Build Status](https://travis-ci.org/eclipse/paho.mqtt.c.svg?branch=master)](https://travis-ci.org/eclipse/paho.mqtt.c) ## Libraries The Paho C client comprises four shared libraries: * libmqttv3a.so - asynchronous * libmqttv3as.so - asynchronous with SSL * libmqttv3c.so - "classic" / synchronous * libmqttv3cs.so - "classic" / synchronous with SSL Optionally, using the CMake build, you can build static versions of those libraries. ## Build instructions for GNU Make Ensure the OpenSSL development package is installed. Then from the client library base directory run: ``` make sudo make install ``` This will build and install the libraries. To uninstall: ``` sudo make uninstall ``` To build the documentation requires doxygen and optionally graphviz. ``` make html ``` 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 ## Build requirements / compilation using CMake 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/) or GNU Make (https://www.gnu.org/software/make/), and * gcc (https://gcc.gnu.org/). On Debian based systems this would mean that the following packages have to be installed: ``` apt-get install build-essential gcc make cmake cmake-gui cmake-curses-gui ``` Also, in order to build a debian package from the source code, the following packages have to be installed ``` apt-get install fakeroot fakeroot devscripts dh-make lsb-release ``` 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 ``` The documentation requires doxygen and optionally graphviz: ``` 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_BUILD_STATIC | FALSE | Build a static version of the libraries PAHO_WITH_SSL | FALSE | Flag that defines whether to build ssl-enabled binaries too. OPENSSL_SEARCH_PATH | "" (system default) | Directory containing your OpenSSL installation (i.e. `/usr/local` when headers are in `/usr/local/include` and libraries are in `/usr/local/lib`) PAHO_BUILD_DOCUMENTATION | FALSE | Create and install the HTML based API documentation (requires Doxygen) PAHO_BUILD_SAMPLES | FALSE | Build sample programs MQTT_TEST_BROKER | tcp://localhost:1883 | MQTT connection URL for a broker to use during test execution MQTT_TEST_PROXY | tcp://localhost:1883 | Hostname of the test proxy to use MQTT_SSL_HOSTNAME | localhost | Hostname of a test SSL MQTT broker to use PAHO_BUILD_DEB_PACKAGE | FALSE | Build debian package 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 package` after CMake. To simply compile/link invoke `ninja` or `make -j `. ### 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 ``` ### Running the tests Test code is available in the ``test`` directory. The tests can be built and executed with the CMake build system. The test execution requires a MQTT broker running. By default, the build system uses ```localhost```, however it is possible to configure the build to use an external broker. These parameters are documented in the Build Requirements section above. After ensuring a MQTT broker is available, it is possible to execute the tests by starting the proxy and running `ctest` as described below: ``` python ../test/mqttsas2.py & ctest -VV ``` ### 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_*** * 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 *** bit: ``` cmake -GNinja -DPAHO_BUILD_SAMPLES=TRUE -DCMAKE_TOOLCHAIN_FILE=~/git/org.eclipse.paho.mqtt.c/cmake/toolchain.win***.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-w***-x86-*** gcc-mingw-w***-i686 ``` ## Usage and API Detailed API documentation is available by building the Doxygen docs in the ``doc`` directory. A [snapshot is also available online](https://www.eclipse.org/paho/files/mqttdoc/MQTTClient/html/index.html). Samples are available in the Doxygen docs and also in ``src/samples`` for reference. Note that using the C headers from a C++ program requires the following declaration as part of the C++ code: ``` extern "C" { #include "MQTTClient.h" #include "MQTTClientPersistence.h" } ``` ## Runtime tracing A number of environment variables control runtime tracing of the C library. Tracing is switched on using ``MQTT_C_CLIENT_TRACE`` (a value of ON traces to stdout, any other value should specify a file to trace to). The verbosity of the output is controlled using the ``MQTT_C_CLIENT_TRACE_LEVEL`` environment variable - valid values are ERROR, PROTOCOL, MINIMUM, MEDIUM and MAXIMUM (from least to most verbose). The variable ``MQTT_C_CLIENT_TRACE_MAX_LINES`` limits the number of lines of trace that are output. ``` export MQTT_C_CLIENT_TRACE=ON export MQTT_C_CLIENT_TRACE_LEVEL=PROTOCOL ``` ## Reporting bugs Please open issues in the Github project: https://github.com/eclipse/paho.mqtt.c/issues. ## More information Discussion of the Paho clients takes place on the [Eclipse paho-dev mailing list](https://dev.eclipse.org/mailman/listinfo/paho-dev). General questions about the MQTT protocol are discussed in the [MQTT Google Group](https://groups.google.com/forum/?hl=en-US&fromgroups#!forum/mqtt). There is much more information available via the [MQTT community site](http://mqtt.org).

近期下载者

相关文件


收藏者