[![Build Status](https://travis-ci.org/eclipse/paho.mqtt.c.svg?branch=master)](https://travis-ci.org/eclipse/paho.mqtt.c)
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/eclipse/paho.mqtt.c.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/eclipse/paho.mqtt.c/alerts/)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/2339/badge.svg)](https://scan.coverity.com/projects/paho-c)
# Eclipse Paho C Client Library for the MQTT Protocol
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.
Synchronous and various asynchronous programming models are supported.
## Information About MQTT
* [MQTT website](http://mqtt.org)
* [The MQTT 3.1.1 standard](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html)
* [The MQTT 5.0 standard](https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html)
* [HiveMQ introduction to MQTT](https://www.hivemq.com/mqtt/)
* [OASIS Introduction to MQTT presentation](https://www.oasis-open.org/committees/download.php/49205/MQTT-OASIS-Webinar.pdf)
## Libraries
The Paho C client comprises four variant libraries, shared or static:
* paho-mqtt3a - asynchronous (MQTTAsync)
* paho-mqtt3as - asynchronous with SSL/TLS (MQTTAsync)
* paho-mqtt3c - "classic" / synchronous (MQTTClient)
* paho-mqtt3cs - "classic" / synchronous with SSL/TLS (MQTTClient)
[Which Paho C API to use, with some history, for context](https://modelbasedtesting.co.uk/2013/10/13/which-paho-mqtt-c-api-to-use-and-some-history/)
## Usage and API
Detailed API documentation [is available online](https://eclipse.github.io/paho.mqtt.c/MQTTClient/html/). It is also available by building the Doxygen docs in the ``doc`` directory.
Samples are available in the Doxygen docs and also in `src/samples` for reference. These are:
- *paho_c_pub.c* and *paho_c_sub.c:* command line utilities to publish and subscribe, -h will give help
- *paho_cs_pub.c* and *paho_cs_sub.c:* command line utilities using MQTTClient to publish and subscribe
- *MQTTClient_publish.c, MQTTClient_subscribe.c* and *MQTTClient_publish_async.c:* MQTTClient simple code examples
- *MQTTAsync_publish.c* and *MQTTAsync_subscribe.c:* MQTTAsync simple code examples
Some potentially useful blog posts:
- [Paho client MQTT 5.0 support and command line utilities](https://modelbasedtesting.co.uk/2018/08/08/paho-c-client-mqtt-5-0-and-command-line-utilities/)
- [MQTT, QoS and persistence](https://modelbasedtesting.co.uk/2013/11/24/mqtt-qos-and-persistence/)
- [A story of MQTT 5.0](https://modelbasedtesting.co.uk/2018/04/09/a-story-of-mqtt-5-0/)
[Various MQTT and MQTT-SN talks I've given.](https://modelbasedtesting.co.uk/talks-ive-given/)
## 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).
Follow Eclipse Paho on Twitter: [@eclipsepaho](https://twitter.com/eclipsepaho)
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 more information available via the [MQTT community site](http://mqtt.org).
## Building with CMake
The 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)
* [GNU Make](https://www.gnu.org/software/make/) or [Ninja](https://martine.github.io/ninja/)
* A conforming C compiler, such as [gcc](https://gcc.gnu.org/), [Clang](https://clang.llvm.org/), etc
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 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/TLS 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
```
### Building your application with CMake
If the Paho C library was built with CMake and is already installed on the system, it is relatively easy to set up a CMake build for your application. (If it's not already built and installed read the next section).
The library can be built with several options which create variations of the library for asynchronous or synchronous use; encryption (SSL/TLS) support or not; and whether the library is shared or static. CMake exports all of the libraries that were built as targets, and the user can chose which is best suited for an application.
The package is named: **eclipse-paho-mqtt-c**
The namespace for all the targets is also: **eclipse-paho-mqtt-c**
The target names are the same as the library names. The static libraries append *-static* to the target name even for platforms that use the same base name for shared and static libraries. So:
Target|Description
------|-----------
paho-mqtt3a | asynchronous, no encryption
paho-mqtt3as | asynchronous with SSL/TLS support
paho-mqtt3c | synchronous, no encryption
paho-mqtt3cs | synchronous with SSL/TLS support
paho-mqtt3a-static | asynchronous, no encryption, static linkage
paho-mqtt3as-static | asynchronous with SSL/TLS support, static linkage
paho-mqtt3c-static | synchronous, no encryption, static linkage
paho-mqtt3cs-static | synchronous with SSL/TLS support, static linkage
Remember, though, that not all of these targets may be available. It depends on how the library was built.
A sample *CMakeLists.txt* for an application that uses the asynchronous library with encryption support *(paho-mqtt3as)* might look like this:
```
cmake_minimum_required(VERSION 3.5)
project(MyMQTTApp VERSION 1.0.0 LANGUAGES C)
find_package(eclipse-paho-mqtt-c REQUIRED)
add_executable(MyMQTTApp MyMQTTApp.c)
target_link_libraries(MQTTVersion eclipse-paho-mqtt-c::paho-mqtt3as)
```
If the library was installed to a non-traditional location, you may need to tell CMake where to find it using `CMAKE_PREFIX_PATH`. For example, if you installed it in */opt/mqtt/paho.mqtt.c*
```
$ cmake -DCMAKE_PREFIX_PATH=/opt/mqtt/paho.mqtt.c ..
```
### Building the Paho C library with CMake
Before compiling, determine the value of some variables in order to configure features, library locations, and other options:
Variable | Default Value | Description
------------ | ------------- | -------------
PAHO_BUILD_SHARED | TRUE | Build a shared version of the libraries
PAHO_BUILD_STATIC | FALSE | Build a static version of the libraries
PAHO_HIGH_PERFORMANCE | FALSE | W
没有合适的资源?快使用搜索试试~ 我知道了~
VS2015编译的基于paho.mqtt.c动态库开发的mqtt客户端
共83个文件
c:11个
h:9个
tlog:6个
需积分: 5 1 下载量 171 浏览量
2024-08-20
10:41:58
上传
评论
收藏 3.33MB ZIP 举报
温馨提示
VS2015编译的基于paho.mqtt.c动态库开发的mqtt客户端
资源推荐
资源详情
资源评论
收起资源包目录
mqtt-demo.zip (83个子文件)
mqtt-demo
stdafx.h 234B
mqtt-demo.VC.db 2.51MB
include
MQTTClient.h 87KB
doc
Eclipse Paho C
notice.html 9KB
samples
MQTTAsync_subscribe.c 5KB
MQTTAsync_publish.c 5KB
paho_c_pub.c 13KB
MQTTClient_publish_async.c 4KB
pubsub_opts.c 15KB
MQTTAsync_publish_time.c 6KB
MQTTClient_subscribe.c 3KB
paho_cs_pub.c 9KB
paho_cs_sub.c 7KB
paho_c_sub.c 9KB
MQTTClient_publish.c 3KB
CONTRIBUTING.md 4KB
edl-v10 2KB
epl-v20 14KB
README.md 15KB
MQTTClientPersistence.h 12KB
MQTTProperties.h 10KB
MQTTReasonCodes.h 3KB
MQTTExportDeclarations.h 1KB
MQTTAsync.h 98KB
MQTTSubscribeOpts.h 2KB
lib
paho-mqtt3a.lib 14KB
paho-mqtt3c.dll 320KB
paho-mqtt3c.lib 14KB
paho-mqtt3a.dll 369KB
.gitattributes 3KB
.git
index 832B
HEAD 23B
refs
heads
master 41B
tags
objects
1f
f0c423042b46cb1d617b81efb715defbe8054d 751B
cc
1308415a8d25e689b0cea688aa60b8e66cba6d 198B
e8
5b75e04f90d58b58b2dc5c1dd5af3140858038 185B
0d
76fe4328089e5b63a9c4190badacfc35ef2624 89B
a5
eab59661b69ecbb78d9c1dd1d04a0a823370d6 124B
41
6cebf89fd0df8216693b65bba536a1436754e7 205B
pack
info
51
9a9a05c31cbd69c44aadbe99e7cae8e1241ca7 158B
ba
a4bbc621f3abfbc1726da79a84e54dbd5309f8 203B
08
2f85c709d86cecb6fa05184e6b99017137714c 438B
ac
72866277ec51643e6933374d823fea563605c5 345B
fb
c2e21af96ed2d717797dddd868254a67f47043 1KB
02
c2f8a093ca2089f8984f1b00e27e14d417c53d 671B
1c
9a181a44b4f9a105f0dc71a40ad0284ab6a7c4 2KB
90
c32d42c589aa7a8560943ee84d1a9ed85f2208 565B
description 73B
info
exclude 113B
logs
HEAD 342B
refs
heads
master 342B
ms-persist.xml 150B
hooks
README.sample 177B
config 691B
.vs
mqtt-demo
v14
.suo 25KB
mqtt-demo.cpp 3KB
x64
Debug
mqtt-demo.log 439B
mqtt-demo.pch 3.25MB
mqtt-demo.tlog
CL.write.1.tlog 966B
mqtt-demo.lastbuildstate 197B
CL.command.1.tlog 1KB
link.command.1.tlog 1KB
link.read.1.tlog 3KB
link.write.1.tlog 600B
CL.read.1.tlog 7KB
mqtt-demo.obj 18KB
stdafx.obj 12KB
vc140.idb 139KB
vc140.pdb 156KB
mqtt-demo.sln 1KB
ReadMe.txt 1KB
bin
x64
debug
paho-mqtt3c.dll 320KB
mqtt-demo.ilk 368KB
mqtt-demo.pdb 700KB
paho-mqtt3a.dll 369KB
mqtt-demo.exe 61KB
ipch
MQTT-DEMO-36bf604b
MQTT-DEMO-ca460204.ipch 3.25MB
MQTT-DEMO-a1c3df62.ipch 3.44MB
.gitignore 4KB
mqtt-demo.vcxproj 8KB
mqtt-demo.vcxproj.filters 1KB
stdafx.cpp 213B
targetver.h 240B
共 83 条
- 1
资源评论
沙漠中的独行者
- 粉丝: 29
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功