simplify and no progmem on yun demo
This commit is contained in:
parent
fe3aebdad8
commit
f8ec7fc08f
@ -22,7 +22,6 @@
|
|||||||
#include "Adafruit_MQTT.h"
|
#include "Adafruit_MQTT.h"
|
||||||
#include "Adafruit_MQTT_Client.h"
|
#include "Adafruit_MQTT_Client.h"
|
||||||
|
|
||||||
|
|
||||||
/************************* Adafruit.io Setup *********************************/
|
/************************* Adafruit.io Setup *********************************/
|
||||||
|
|
||||||
#define AIO_SERVER "io.adafruit.com"
|
#define AIO_SERVER "io.adafruit.com"
|
||||||
@ -30,30 +29,23 @@
|
|||||||
#define AIO_USERNAME "...your AIO username (see https://accounts.adafruit.com)..."
|
#define AIO_USERNAME "...your AIO username (see https://accounts.adafruit.com)..."
|
||||||
#define AIO_KEY "...your AIO key..."
|
#define AIO_KEY "...your AIO key..."
|
||||||
|
|
||||||
|
|
||||||
/************ Global State (you don't need to change this!) ******************/
|
/************ Global State (you don't need to change this!) ******************/
|
||||||
|
|
||||||
// Create a YunClient instance to communicate using the Yun's brighe & Linux OS.
|
// Create a YunClient instance to communicate using the Yun's bridge & Linux OS.
|
||||||
YunClient client;
|
YunClient client;
|
||||||
|
|
||||||
// Store the MQTT server, username, and password in flash memory.
|
|
||||||
// This is required for using the Adafruit MQTT library.
|
|
||||||
const char MQTT_SERVER[] PROGMEM = AIO_SERVER;
|
|
||||||
const char MQTT_USERNAME[] PROGMEM = AIO_USERNAME;
|
|
||||||
const char MQTT_PASSWORD[] PROGMEM = AIO_KEY;
|
|
||||||
|
|
||||||
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
|
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
|
||||||
Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_USERNAME, MQTT_PASSWORD);
|
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
|
||||||
|
|
||||||
/****************************** Feeds ***************************************/
|
/****************************** Feeds ***************************************/
|
||||||
|
|
||||||
// Setup a feed called 'photocell' for publishing.
|
// Setup a feed called 'photocell' for publishing.
|
||||||
// Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname>
|
// Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname>
|
||||||
const char PHOTOCELL_FEED[] PROGMEM = AIO_USERNAME "/feeds/photocell";
|
Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/photocell");
|
||||||
Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, PHOTOCELL_FEED);
|
|
||||||
|
|
||||||
// Setup a feed called 'onoff' for subscribing to changes.
|
// Setup a feed called 'onoff' for subscribing to changes.
|
||||||
const char ONOFF_FEED[] PROGMEM = AIO_USERNAME "/feeds/onoff";
|
Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/onoff");
|
||||||
Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, ONOFF_FEED);
|
|
||||||
|
|
||||||
/*************************** Sketch Code ************************************/
|
/*************************** Sketch Code ************************************/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user