User Manual
}
}
}
/**************************************************************************/
/*!
@brief MQTT subscribe event callback handler
@param topic The topic causing this callback to fire
@param message The new value associated with 'topic'
@note 'topic' and 'message' are UTF8Strings (byte array), which means
they are not null-terminated like C-style strings. You can
access its data and len using .data & .len, although there is
also a Serial.print override to handle UTF8String data types.
*/
/**************************************************************************/
void subscribed_callback(UTF8String topic, UTF8String message)
{
// Copy received data to 'value'
memcpy(&value, message.data, 1);
// Print out topic name and message
Serial.printf("["); Serial.print(topic); Serial.printf("]");
Serial.print(" : value = ") ;
Serial.println(value);
// Increase value by 1
value++;
// wrap around
if (value > '9') value = '0';
// Unsubscribe if we received an "stop" message
// Won't be able to echo anymore
if ( message == "stop" )
{
Serial.print("Unsubscribing ... ");
mqttTopic.unsubscribe(); // Will halt if fails
Serial.println("OK");
}
}
/**************************************************************************/
/*!
@brief Connect to defined Access Point
*/
/**************************************************************************/
bool connectAP(void)
{
// Attempt to connect to an AP
Serial.print("Attempting to connect to: ");
Serial.println(WLAN_SSID);
if ( Feather.connect(WLAN_SSID, WLAN_PASS) )
{
Serial.println("Connected!");
}
else
{
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 128 of 202










