User Manual

Feather.printNetwork();
// Tell the MQTT client to auto print error codes and halt on errors
aio.err_actions(true, true);
// Set ClientID if defined
#ifdef CLIENTID
aio.clientID(CLIENTID);
#endif
Serial.print("Connecting to io.adafruit.com ... ");
if ( USE_TLS )
{
aio.connectSSL(); // Will halted if an error occurs
}else
{
aio.connect(); // Will halted if an error occurs
}
Serial.println("OK");
// 'Follow' the onoff feed to capture any state changes
onoff.follow(feed_callback);
}
/**************************************************************************/
/*!
@brief This loop function runs over and over again
*/
/**************************************************************************/
void loop()
{
value = (value+1) % 100;
Serial.print("Updating feed " PHOTOCELL_FEED " : ");
Serial.print(value);
photocell.print(value);
Serial.println(" ... OK");
delay(5000);
}
/**************************************************************************/
/*!
@brief 'follow' event callback handler
@param message The new value associated with this feed
@note 'message' is a UTF8String (byte array), which means
it is 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 feed_callback(UTF8String message)
{
// Print message
Serial.print("[ONOFF Feed] : ");
Serial.println(message);
}
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 141 of 202