TV Screens platform.

Toggle navigation Yatta Solutions Logo Eclipse Paho MQTT C/C++ client (0) by EvensMaxPierrelouis0979 Private Profile Group Profile Public Profile Eclipse Paho MQTT C++ client library This is the latest development code for the Paho C++ library, destined to be the v1.0 release of the library with the overall Paho 1.3 group, targeted for June 2017. As such it requires the version of the Paho C library which is also currently under development, and available in the develop branch of that library on GitHub: This will not compile against the current release version of the Paho C library! DESCRIPTION This repository contains the source code for the Eclipse Paho MQTT C++ client library on memory managed operating systems such as Linux/Posix and Windows. This code builds a library which enables C++11 applications to connect to an MQTT broker to publish messages, and to subscribe to topics and receive published messages. Both synchronous and asynchronous modes of operation are supported. This code requires the Paho C library by Ian Craggs, et al. BUILDING FROM SOURCE Paho MQTT C++ supports the following building systems: CMake Autotools GNU Make CMAKE CMake is a cross-platform building system suitable for Unix and non-Unix platforms, like Microsoft Windows. Unix and GNU/Linux On Unix systems CMake creates Makefiles. Build requirements The build process currently supports a number of Unix and Linux flavors. The build process requires the following tools: CMake ( GNU Make ( GCC ( 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 The documentation requires doxygen and optionally graphviz: apt-get install doxygen graphviz Build instructions Before compiling, determine the value of some variables in order to configure features, library locations, and other options: Variable Default Value Description PAHO_MQTT_C_PATH “” Add a path paho.mqtt.c library and headers PAHO_BUILD_STATIC FALSE Whether to build the static library PAHO_BUILD_DOCUMENTATION FALSE Create and install the HTML based API documentation (requires Doxygen) PAHO_BUILD_SAMPLES FALSE Build sample programs PAHO_WITH_SSL TRUE Flag that defines whether to build ssl-enabled binaries too Using these variables CMake can be used to generate your Makefiles. The out-of-source build is the default on CMake. Therefore it is recommended to invoke all build commands inside your chosen build directory. An example build session targeting the build platform could look like this: $ git clone $ cd paho.mqtt.cpp $ mkdir build $ cd build $ cmake -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_MQTT_C_PATH=../../paho.mqtt.c .. $ make or $ cmake -DCMAKE_INSTALL_PREFIX=/tmp/paho-cpp -DPAHO_MQTT_C_PATH=/tmp/paho-c \ -DPAHO_BUILD_SAMPLES:BOOL=ON -DPAHO_BUILD_STATIC:BOOL=ON \ -DPAHO_BUILD_DOCUMENTATION:BOOL=ON $ make Invoking cmake and specifying build options can also be performed using cmake-gui or ccmake (see For example: $ ccmake .. $ make To use another compiler: $ cmake -DCMAKE_CXX_COMPILER=clang++ $ make Windows On Windows systems CMake creates Visual Studio project files. Build requirements The build process currently supports a number Windows versions. The build process requires the following tools: CMake GUI ( Visual Studio ( Build instructions First install and open the cmake-gui application. This tutorial is based on cmake-gui 3.5.2. Second, select the path to the Paho MQTT C library (PAHO_MQTT_C_PATH). Remember that the Paho MQTT C must be installed on the system. Next, choose if it is supposed to build the documentation (PAHO_BUILD_DOCUMENTATION) and/or the sample applications (PAHO_BUILD_SAMPLES). Once the configuration is done, click on the Configure button, select the version of the Visual Studio, and then click on Generate button. At the end of this process you have a Visual Studio solution. Updating CMake on Ubuntu 14.04 / Mint 17 (LTS) The version of cmake on Ubuntu 14.04 LTS is pretty old and has some problems with Paho C++ library. A newer version can be added by downloading the source and building it. If the older cmake can be removed from the system using the package manager, or it can be kept, using the Ububtu alternatives to chose between the versions. For example: $ wget $ tar -xvzf cmake-3.6.3.tar.gz $ cd cmake-3.6.3/ $ ./configure $ make $ sudo make install $ sudo mv /usr/bin/cmake /usr/bin/cmake-2.8 $ sudo update-alternatives –install /usr/bin/cmake cmake /usr/local/bin/cmake 100 $ sudo update-alternatives –install /usr/bin/cmake cmake /usr/bin/cmake-2.8 200 $ cmake –version cmake version 3.6.3 You can speed up the build on multi-core systems, by specifying parallel buid jobs for the configure and make steps, above, such as the following for a 4-core system: $ ./configure –parallel=4 $ make -j4 AUTOTOOLS (ON LINUX AND UNIX) The GNU Build System is the preferred building system on POSIX-compliant systems. Build requirements The build process supports any POSIX-compliant system. The following tools must be installed: Autoconf ( Automake ( Libtool ( GNU Make ( GCC ( or Clang/LLVM ( You can instruct Autotools to use another compiler besides the one default by the system: $ $PAHO_DIR/configure CC=clang CXX=clang++ The library uses C++11 features, and thus requires a conforming compiler such as g++ 4.8 or above. The Paho MQTT C++ library can be built against the current release version of the Paho MQTT C library or the latest development tree. Build instructions (current release on systems with Autotools) In order to build against the release version of the Paho MQTT C library, you must download, build, and install the library as described here After the Paho MQTT C library is installed on your system, clone the Paho MQTT C++ library: $ git clone $ cd paho.mqtt.cpp Then run the bootstrap script to create Autotools’ scripts: $ ./bootstrap To avoid problems with the existing Makefile, build in a seperate directory (known as VPATH build or out-of-tree build): $ mkdir mybuild && cd mybuild $ export PAHO_DIR=$PWD Next, configure the features you want to be available in the library and build: $ ./configure [Options] $ make Option Default Value Description –[en/dis]able-shared yes Build as shared library –[en/dis]able-static yes Build as static library –[en/dis]able-samples no Build sample programs –[en/dis]able-doc no Build documentation –[en/dis]able-peak-warnings no Compile with peak warnings level –with-paho-mqtt-c Path to a non-standard Paho MQTT C library –with[out]-ssl with Build with OpenSSL support For example, in order to build only the static library: (under the assumption that “$PAHO_DIR” points to the directory which contains the paho.mqtt.c source tree) $ $PAHO_DIR/configure –disable-shared –enable-static $ make Build instructions (development tree on systems with Autotools) In order to build against the latest Paho MQTT C development branch, first clone the C library repository. Then checkout the develop branch and build in-place (you don’t need to install). $ git clone $ cd paho.mqtt.c $ git checkout -t origin/develop $ make $ export PAHO_MQTT_C_PATH=$PWD $ export LD_LIBRARY_PATH=$PWD/build/output $ cd .. Then clone the Paho MQTT C++ library and build it, passing the path to the Paho MQTT C library: $ git clone $ cd paho.mqtt.cpp $ ./bootstrap $ $PAHO_DIR/configure –with-paho-mqtt-c=$PAHO_MQTT_C_PATH $ make This will use the latest Paho MQTT C headers and libraries from the local workspace (PAHO_MQTT_C_PATH). Build instructions (on systems without Autotools) The dist target generates a tarball to build on systems where Autotools isn’t installed. You must generate a distribution package on a system with Autotools installed: $ make dist The command above will create the package paho-mqtt-cpp-0.0.2.tar.gz. This package can be compiled on systems without Autotools. Use the following commands: $ tar xzf paho-mqtt-cpp-0.0.2.tar.gz $ cd paho-mqtt-cpp-0.0.2 $ ./configure –with-paho-mqtt-c=$PAHO_MQTT_C_PATH $ make Cross compilation The Autotools cross compilation is performed through –host option. For example, to build the library for one of the ARM platforms: $ $PAHO_DIR/configure –host=arm-linux-gnueabi EXAMPLE Sample applications can be found in src/samples. int main(int argc, char* argv[]) { sample_mem_persistence persist; mqtt::client client(ADDRESS, CLIENTID, &persist); callback cb; client.set_callback(cb); mqtt::connect_options connOpts; connOpts.set_keep_alive_interval(20); connOpts.set_clean_session(true); try { client.connect(connOpts); // First use a message pointer. mqtt::message_ptr pubmsg = mqtt::make_message(PAYLOAD1); pubmsg->set_qos(QOS); client.publish(TOPIC, pubmsg); // Now try with itemized publish. client.publish(TOPIC, PAYLOAD2, strlen(PAYLOAD2)+1, 0, false); // Disconnect client.disconnect(); } catch (const mqtt::persistence_exception& exc) { cerr
Jul 18, 2017

One thought on “TV Screens platform.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s