Mqtt Client Server
Table of Contents
Example Summary
This example introduce the user to the MQTT Client and MQTT Server Library.
Example Usage
- Connect to AP (Client Side)
- AP information is set in network_if.h file
- In case hard coded AP SSID connection is failed, the user will be requested to fill the SSID of an open AP to connect to.
- If no AP is available or connection failed, the example reset and try to connect again.
- After connection
- The application have two MQTT entities
- MQTT Client - Can connect to remote broker (remote broker address is configured in mqtt_server.c (SERVER_ADDRESS)
- MQTT Broker - Broker that is ready for external client connection, Broker Address is device IP, on port 1883
- The MQTT client and Broker have internal loopback to allow topic forwarding.
- The application have two MQTT entities
- Client Topics
- The Client is subscribed to topic “/Broker/To/cc32xx”
- The Client publish the following topic “/cc32xx/ButtonPressEvtSw2” - the topic will be published by pressing SW2 on the board
- Client Server Topics
- The Client enrolled (loopback topic) to “/cc32xx/To/Broker”
Each client connected to the Broker, can publish on that topic, and the internal client will receive that topic
- The Client enrolled (loopback topic) to “/cc32xx/To/Broker”
- Special handling
- In case the internal client will disconnect (for any reason) from the remote broker, the MQTT will be restarted, The user can change that behavior
- Secured socket
- In order to activate the client secured example, SECURE_CLIENT should be enabled ( certificates should be programmed )
- In order to activate the server secured example, SECURE_SERVER should be enabled ( certificates should be programmed )
- In order to activate the client secured example, SECURE_CLIENT should be enabled ( certificates should be programmed )
Application Design Details
This example provides users the ability to work with Both Client and Server (Broker) MQTT Entities By combine the two entities to one example, we also allow the user to provide a loop back between internal and external clients (using the enrolled topic)
Server/Broker Allows full Broker capabilities (up to 4 clients)
Clients can connect/subscribed/publish to the broker at any timeClient Allows full mqtt client abilities
The Client can connect to remote broker, subscribe and publishLoopback The internal Client will be connected to the internal Broker, with enrolled topic (subscribed).
Any published data on that topic, that arrived to the broker, will be passed to the internal client, and will be forward to the remote broker.
Any topic that the client is subscribed to at the remote broker, that was published, will be followed to the internal broker, and from there to all subscribed clients This will allow full forwarding of topics.