User Manual

Serial.println();
Serial.println("-----------------------------");
Serial.println("DISCONNECTED FROM MQTT BROKER");
Serial.println("-----------------------------");
Serial.println();
}
/**************************************************************************/
/*!
@brief The setup function runs once when the board comes out of reset
*/
/**************************************************************************/
void setup()
{
Serial.begin(115200);
// Wait for the USB serial port to connect. Needed for native USB port only
while (!Serial) delay(1);
Serial.println("MQTT Subscribe Example\r\n");
// Print all software versions
Feather.printVersions();
while ( !connectAP() )
{
delay(500); // delay between each attempt
}
// Connected: Print network info
Feather.printNetwork();
// Tell the MQTT client to auto print error codes and halt on errors
mqtt.err_actions(true, true);
// Set ClientID if defined
#ifdef CLIENTID
mqtt.clientID(CLIENTID);
#endif
// Last will must be set before connecting since it is part of the connection data
mqtt.will(WILL_TOPIC, WILL_MESSAGE, MQTT_QOS_AT_LEAST_ONCE);
// Set the disconnect callback handler
mqtt.setDisconnectCallback(disconnect_callback);
Serial.printf("Connecting to " BROKER_HOST " port %d ... ", BROKER_PORT);
if (USE_TLS)
{
// Disable default RootCA to save SRAM since we don't need to
// access any other site except test.mosquitto.org
Feather.useDefaultRootCA(false);
// mosquitto CA is pre-generated using pycert.py
Feather.addRootCA(rootca_certs, ROOTCA_CERTS_LEN);
// Connect with SSL/TLS
mqtt.connectSSL(BROKER_HOST, BROKER_PORT);
}else
{
mqtt.connect(BROKER_HOST, BROKER_PORT);
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 135 of 202