This project demonstrates a MQTT client that runs EK-TM4C1294XL evaluation board.

Prerequisites:

- Download Mosquitto (simple v3.1.1 MQTT client/broker) from https://mosquitto.org/download/
- Double-click the installation file
- Follow on-screen instructions (OpenSSL-Win32 installation and pthreadVC2.dll)
- For testing purposes, it is not recommended to install Mosquitto as a service. Uncheck "Service" checkbox
- Choose your destination folder. It is recommended to keep the default installation directory: C:\Program Files (x86)\mosquitto
- Complete the installation process
- Copy pthreadVC2.dll to C:\Program Files (x86)\mosquitto
- Install OpenSSL-Win32 Light with all default parameters
- Copy the following DLLs from C:\OpenSSL-Win32 to C:\Program Files (x86)\mosquitto:
    libcrypto-1_1.dll
    libeay32.dll
    libssl-1_1.dll
    libssl32.dll

Instructions to run the demo (using a remote MQTT broker):

- Compile the project and run a debug session
- Connect a terminal (115200 bauds, no parity, no flow control) to the virtual COM port of the ICD debugger to output log messages
- Plug Ethernet cable
- The board acquires an IPv4 address (using DHCP), a link-local IPv6 address and a global IPv6 address (using SLAAC)
- The board will automatically connect to a test MQTT broker (iot.eclipse.org)
- Open a terminal and go to the Mosquitto installation directory:
    cd C:\Program Files (x86)\mosquitto
- Subscribe to the "board/buttons/1" topic to get button pressed/released events
    mosquitto_sub -v -h iot.eclipse.org -q 1 -t board/buttons/1
- All subscribers should received a notification when any change occurs
- Subscribe to the wilcard topic "board/#". The subscriber will received all notifications from the board
    mosquitto_sub -v -h iot.eclipse.org -q 1 -t board/#
- Change the state of the LEDs by executing one the following commands:
    mosquitto_pub -h iot.eclipse.org -q 1 -t board/leds/1 -m "toggle"
	mosquitto_pub -h iot.eclipse.org -q 1 -t board/leds/1 -m "on"
    mosquitto_pub -h iot.eclipse.org -q 1 -t board/leds/1 -m "off"

Instructions to run the demo (using a local MQTT broker):

- Open a terminal and go to the Mosquitto installation directory:
    cd C:\Program Files (x86)\mosquitto
- Start the MQTT broker with the following command:
    mosquitto -v
- Pick up the IP address of the PC where the MQTT broker is running (using ipconfig /all comand). For example 192.168.0.100
- Edit main.c and change the APP_SERVER_NAME macro at the top of the file
- Compile the project and run a debug session
- The board acquires an IPv4 address (using DHCP), a link-local IPv6 address and a global IPv6 address (using SLAAC)
- The board will automatically connect to a test MQTT broker (192.168.0.100)
- Open a terminal and go to the Mosquitto installation directory:
    cd C:\Program Files (x86)\mosquitto
- Subscribe to the wilcard topic "board/#"
    mosquitto_sub -v -h iot.eclipse.org -q 1 -t board/#
- All subscribers should received a notification when any change occurs
- Change the state of the LEDs by executing one the following commands:
    mosquitto_pub -q 1 -t board/leds/1 -m "toggle"
	mosquitto_pub -q 1 -t board/leds/1 -m "on"
    mosquitto_pub -q 1 -t board/leds/1 -m "off"

Instructions to run the demo (TLS secure communication):

- If you want to connect securely to a remote MQTT server using SSL/TLS, you must switch the MQTT port to 8883:
    //MQTT server port
    //#define APP_SERVER_PORT 1883 //MQTT over TCP
    #define APP_SERVER_PORT 8883 //MQTT over SSL/TLS
    //#define APP_SERVER_PORT 8080 //MQTT over WebSocket
    //#define APP_SERVER_PORT 8081 //MQTT over secure WebSocket

- Make sure the relevant CA certificate is provided to the tlsSetTrustedCaList() function. If you
do not known the CA, you may comment the call to tlsSetTrustedCaList in main.c to disable the
verification of the server certificate chain (for testing purpose only!).

- You have to ensure that the APP_SERVER_NAME macro matches the exact name of the remote MQTT
server. To disable server name verification, you may comment the call to tlsSetServerName in
main.c (for testing purpose only!).

Instructions to run the demo (WebSocket transport):

- The MQTT client from CycloneTCP can also operate over WebSockets (ws://) or secure WebSockets (wss://). 
    //MQTT server port
    //#define APP_SERVER_PORT 1883 //MQTT over TCP
    //#define APP_SERVER_PORT 8883 //MQTT over SSL/TLS
    #define APP_SERVER_PORT 8080 //MQTT over WebSocket
    //#define APP_SERVER_PORT 8081 //MQTT over secure WebSocket
