User Manual
* It will connect to a public MQTT server (with/without TLS)
* and subscribe to TOPIC_SUBSCRIBE (defined below).
*
* - When a message is received, it will echo back to TOPIC_ECHO
* - If the received message is "stop", we will
* unsubscribe from TOPIC_SUBSCRIBE and you won't be able to
* echo content back to the broker any longer.
*
* Note: TOPIC_SUBSCRIBE and TOPIC_ECHO must not be the same topic!
* Ex. They must not be "adafruit/+" and "adafruit/echo", since this will
* cause an infinite loop (received -> echo -> received -> ....)
*
* For details on the MQTT broker server see http://test.mosquitto.org/
* - Port 1883 : MQTT, unencrypted
* - Port 8883 : MQTT, encrypted (TLS)
*
* Note: may You need an MQTT desktop client such as the lightweight
* Java client included in this repo: org.eclipse.paho.mqtt.utility-1.0.0.jar
*
* For information on configuring your system to work with MQTT see:
* - https://learn.adafruit.com/desktop-mqtt-client-for-adafruit-io/installing-software
*
* To run this demo
* 1. Change the WLAN_SSID/WLAN_PASS to match your access point
* 2. Decide whether you want to use TLS/SSL or not (USE_TLS)
* 3. Change TOPIC*, WILL*, enable CLIENTID if needed
* 4. Compile and run
* 5. Use an MQTT desktop client to connect to the same MQTT broker and
* publish to any topic beginning with "adafruit/feather/" (depending
* on TOPIC_SUBSCRIBE). To be able to recieve the echo message, please
* also subcribe to "adafruit/feather_echo" (TOPIC_ECHO).
*/
#define WLAN_SSID "yourSSID"
#define WLAN_PASS "yourPass"
#define USE_TLS 0
#define BROKER_HOST "test.mosquitto.org"
#define BROKER_PORT (USE_TLS ? 8883 : 1883)
// Uncomment to set your own ClientID, otherwise a random ClientID is used
//#define CLIENTID "Adafruit Feather"
#define TOPIC_SUBSCRIBE "adafruit/feather/+"
#define TOPIC_ECHO "adafruit/feather_echo"
#define WILL_TOPIC "adafruit/feather"
#define WILL_MESSAGE "Goodbye!!"
AdafruitMQTT mqtt;
/**************************************************************************/
/*!
@brief Disconnect handler for MQTT broker connection
*/
/**************************************************************************/
void disconnect_callback(void)
{
Serial.println();
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 134 of 202










