1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/mqtt-client/minimal-mqtt-client
Andy Green b3131fdfdd cmakelist: Augean Stables refactor
Establish a new distributed CMake architecture with CMake code related to
a source directory moving to be in the subdir in its own CMakeLists.txt.
In particular, there's now one in ./lib which calls through to ones
further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc.

This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction,
and it's much easier to maintain sub-CMakeLists.txt that are in the same
directory as the sources they manage, and conceal all the details that that
level.

Child CMakelists.txt become responsible for:

 - include_directories() definition (this is not supported by CMake
   directly, it passes it back up via PARENT_SCOPE vars in helper
   macros)

 - Addition child CMakeLists.txt inclusion, for example toplevel ->
   role -> role subdir

 - Source file addition to the build

 - Dependent library path resolution... this is now a private thing
   in the child CMakeLists.txt, it just passes back any adaptations
   to include_directories() and the LIB_LIST without filling the
   parent namespace with the details
2020-05-27 08:40:12 +01:00
..
CMakeLists.txt cmakelist: Augean Stables refactor 2020-05-27 08:40:12 +01:00
minimal-mqtt-client.c windows: pthreads 2020-04-07 14:05:21 +01:00
mosq-ca.crt client: MQTT 2020-03-04 12:17:49 +00:00
mosq-server.crt client: MQTT 2020-03-04 12:17:49 +00:00
mosq-server.key client: MQTT 2020-03-04 12:17:49 +00:00
README.md client: MQTT 2020-03-04 12:17:49 +00:00

lws minimal MQTT client

The application connects to a broker at localhost 1883 (unencrypted) or 8883 (tls)

build

 $ cmake . && make

usage

Commandline option Meaning
-d Debug verbosity in decimal, eg, -d15
-s Use tls and connect to port 8883 instead of 1883

Start mosquitto server locally

$ mosquitto

Run the example

[2020/01/31 10:40:23:7789] U: LWS minimal MQTT client unencrypted [-d<verbosity>][-s]
[2020/01/31 10:40:23:8539] N: lws_mqtt_generate_id: User space provided a client ID 'lwsMqttClient'
[2020/01/31 10:40:23:9893] N: _lws_mqtt_rx_parser: migrated nwsi 0x50febd0 to sid 1 0x5106820
[2020/01/31 10:40:23:9899] U: callback_mqtt: MQTT_CLIENT_ESTABLISHED
[2020/01/31 10:40:23:9967] U: callback_mqtt: WRITEABLE: Subscribing
[2020/01/31 10:40:24:0068] U: callback_mqtt: MQTT_SUBSCRIBED

Send something to the test client

mosquitto_pub -h 127.0.0.1 -p 1883 -t test/topic0 -m "hello"

Observe it received at the test client

[2020/01/31 10:40:27:1845] U: callback_mqtt: MQTT_CLIENT_RX
[2020/01/31 10:40:27:1870] N: 
[2020/01/31 10:40:27:1945] N: 0000: 74 65 73 74 2F 74 6F 70 69 63 30                   test/topic0     
[2020/01/31 10:40:27:1952] N: