From b71e2afd278ced1049a6ab3e9910a1e9cee6bf87 Mon Sep 17 00:00:00 2001 From: i3water <121024123@qq.com> Date: Sun, 16 Dec 2018 23:38:14 +0800 Subject: [PATCH] update codes, upgrade BLINKER WIF & MQTT codes --- examples/Blinker_AHRS/AHRS_WiFi/AHRS_WiFi.ino | 3 +- .../APCONFIG_WiFi/APCONFIG_WiFi.ino | 4 +- .../AQI_MQTT.ino => AQI_WiFi/AQI_WiFi.ino} | 140 ++++++++-------- .../AT_Firmware_WiFi.ino} | 0 .../AUTO_MQTT.ino => AUTO_WiFi/AUTO_WiFi.ino} | 156 +++++++++--------- .../AliGenie_LIGHT/AliGenie_LIGHT.ino | 4 +- .../AliGenie_OUTLET/AliGenie_OUTLET.ino | 4 +- .../AliGenie_SENSOR/AliGenie_SENSOR.ino | 4 +- .../ArduinoJson_WiFi.ino} | 4 +- .../Bridge_WiFi.ino} | 126 +++++++------- .../Button_WiFi/Button_WiFi.ino | 3 +- .../CLOUDCONFIG_WiFi.ino} | 4 +- .../CLOUDDATA_WiFi.ino} | 142 ++++++++-------- examples/Blinker_DHT/DHT_WiFi/DHT_WiFi.ino | 3 +- .../DuerOS_LIGHT/DuerOS_LIGHT.ino | 75 +++++++-- .../DuerOS_OUTLET/DuerOS_OUTLET.ino | 4 +- .../DuerOS_SENSOR/DuerOS_SENSOR.ino | 4 +- .../ESPTOUCH_MQTT/ESPTOUCH_MQTT.ino | 65 -------- .../ESPTOUCH_WiFi/ESPTOUCH_WiFi.ino | 4 +- examples/Blinker_GPS/GPS_WiFi/GPS_WiFi.ino | 3 +- .../Heartbeat_WiFi/Heartbeat_WiFi.ino | 13 +- .../{Hello_MQTT => Hello_WiFi}/Hello_MQTT.ino | 23 ++- .../Blinker_Hello/Hello_WiFi/Hello_WiFi.ino | 72 -------- .../Joystick_WiFi/Joystick_WiFi.ino | 3 +- examples/Blinker_MQTT/MQTT_WiFi/MQTT_WiFi.ino | 4 +- .../Notify_WiFi/Notify_WiFi.ino | 3 +- .../Number_WiFi/Number_WiFi.ino | 3 +- .../OTA_MQTT.ino => OTA_WiFi/OTA_WiFi.ino} | 6 +- .../PUSH_MQTT.ino => PUSH_WiFi/PUSH_WiFi.ino} | 4 +- .../Blinker_Print/Print_WiFi/Print_WiFi.ino | 3 +- examples/Blinker_RGB/RGB_WiFi/RGB_WiFi.ino | 3 +- .../SMS_MQTT.ino => SMS_WiFi/SMS_WiFi.ino} | 138 ++++++++-------- examples/Blinker_SR04/SR04_WiFi/SR04_WiFi.ino | 3 +- .../Slider_WiFi/Slider_WiFi.ino | 3 +- .../Summary_MQTT/Summary_MQTT.ino | 103 ------------ .../Summary_WiFi/Summary_WiFi.ino} | 4 +- .../Switch_WiFi/Switch_WiFi.ino | 3 +- examples/Blinker_TEXT/TEXT_WiFi/TEXT_WiFi.ino | 3 +- examples/Blinker_Time/Time_WiFi/Time_WiFi.ino | 3 +- .../Timer_WiFi_countdown.ino | 67 -------- .../Timer_WiFi_loop/Timer_WiFi_loop.ino | 67 -------- .../Timer_WiFi_timing/Timer_WiFi_timing.ino | 71 -------- .../WS2812_WiFi/WS2812_WiFi.ino | 3 +- .../Blinker_WeChat/Blinker_Wechat.ino | 78 --------- .../Weather_WiFi.ino} | 140 ++++++++-------- src/Blinker.h | 81 ++++----- 46 files changed, 617 insertions(+), 1039 deletions(-) rename examples/Blinker_AQI/{AQI_MQTT/AQI_MQTT.ino => AQI_WiFi/AQI_WiFi.ino} (93%) rename examples/Blinker_AT_Firmware/{AT_Firmware_MQTT/AT_Firmware_MQTT.ino => AT_Firmware_WiFi/AT_Firmware_WiFi.ino} (100%) rename examples/Blinker_AUTO/{AUTO_MQTT/AUTO_MQTT.ino => AUTO_WiFi/AUTO_WiFi.ino} (94%) rename examples/Blinker_ArduinoJson/{ArduinoJson_MQTT/ArduinoJson_MQTT.ino => ArduinoJson_WiFi/ArduinoJson_WiFi.ino} (97%) rename examples/Blinker_Bridge/{Bridge_MQTT/Bridge_MQTT.ino => Bridge_WiFi/Bridge_WiFi.ino} (90%) rename examples/Blinker_CLOUDCONFIG/{CLOUDCONFIG_MQTT/CLOUDCONFIG_MQTT.ino => CLOUDCONFIG_WiFi/CLOUDCONFIG_WiFi.ino} (96%) rename examples/Blinker_CLOUDDATA/{CLOUDDATA_MQTT/CLOUDDATA_MQTT.ino => CLOUDDATA_WiFi/CLOUDDATA_WiFi.ino} (93%) delete mode 100644 examples/Blinker_ESPTOUCH/ESPTOUCH_MQTT/ESPTOUCH_MQTT.ino rename examples/Blinker_Hello/{Hello_MQTT => Hello_WiFi}/Hello_MQTT.ino (81%) delete mode 100644 examples/Blinker_Hello/Hello_WiFi/Hello_WiFi.ino rename examples/Blinker_OTA/{OTA_MQTT/OTA_MQTT.ino => OTA_WiFi/OTA_WiFi.ino} (95%) rename examples/Blinker_PUSH/{PUSH_MQTT/PUSH_MQTT.ino => PUSH_WiFi/PUSH_WiFi.ino} (96%) rename examples/Blinker_SMS/{SMS_MQTT/SMS_MQTT.ino => SMS_WiFi/SMS_WiFi.ino} (93%) delete mode 100644 examples/Blinker_Summary/Summary_MQTT/Summary_MQTT.ino rename examples/{Blinker_Heartbeat/Heartbeat_MQTT/Heartbeat_MQTT.ino => Blinker_Summary/Summary_WiFi/Summary_WiFi.ino} (97%) delete mode 100644 examples/Blinker_Timer/Timer_WiFi_countdown/Timer_WiFi_countdown.ino delete mode 100644 examples/Blinker_Timer/Timer_WiFi_loop/Timer_WiFi_loop.ino delete mode 100644 examples/Blinker_Timer/Timer_WiFi_timing/Timer_WiFi_timing.ino delete mode 100644 examples/Blinker_WeChat/Blinker_WeChat/Blinker_Wechat.ino rename examples/Blinker_Weather/{Weather_MQTT/Weather_MQTT.ino => Weather_WiFi/Weather_WiFi.ino} (93%) diff --git a/examples/Blinker_AHRS/AHRS_WiFi/AHRS_WiFi.ino b/examples/Blinker_AHRS/AHRS_WiFi/AHRS_WiFi.ino index e284666a..4650744f 100644 --- a/examples/Blinker_AHRS/AHRS_WiFi/AHRS_WiFi.ino +++ b/examples/Blinker_AHRS/AHRS_WiFi/AHRS_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -55,7 +56,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); Blinker.attachAhrs(); } diff --git a/examples/Blinker_APCONFIG/APCONFIG_WiFi/APCONFIG_WiFi.ino b/examples/Blinker_APCONFIG/APCONFIG_WiFi/APCONFIG_WiFi.ino index e7694e85..e0776cc7 100644 --- a/examples/Blinker_APCONFIG/APCONFIG_WiFi/APCONFIG_WiFi.ino +++ b/examples/Blinker_APCONFIG/APCONFIG_WiFi/APCONFIG_WiFi.ino @@ -31,6 +31,8 @@ #include +char auth[] = "Your Device Secret Key"; + void dataRead(const String & data) { BLINKER_LOG("Blinker readString: ", data); @@ -53,7 +55,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(); + Blinker.begin(auth); Blinker.attachData(dataRead); } diff --git a/examples/Blinker_AQI/AQI_MQTT/AQI_MQTT.ino b/examples/Blinker_AQI/AQI_WiFi/AQI_WiFi.ino similarity index 93% rename from examples/Blinker_AQI/AQI_MQTT/AQI_MQTT.ino rename to examples/Blinker_AQI/AQI_WiFi/AQI_WiFi.ino index a3d7e341..bcedee02 100644 --- a/examples/Blinker_AQI/AQI_MQTT/AQI_MQTT.ino +++ b/examples/Blinker_AQI/AQI_WiFi/AQI_WiFi.ino @@ -1,71 +1,71 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_MQTT - -#include - -char auth[] = "Your MQTT Secret Key"; -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -void dataRead(const String & data) -{ - BLINKER_LOG("Blinker readString: ", data); - - uint32_t BlinkerTime = millis(); - - Blinker.vibrate(); - Blinker.print("millis", BlinkerTime); - - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); - String get_aqi = Blinker.aqi(); - BLINKER_LOG("AQI: ", get_aqi); - - Blinker.delay(60000); -} - -void setup() -{ - Serial.begin(115200); - - #if defined(BLINKER_PRINT) - BLINKER_DEBUG.stream(BLINKER_PRINT); - #endif - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(auth, ssid, pswd); - Blinker.attachData(dataRead); -} - -void loop() -{ - Blinker.run(); +/* ***************************************************************** + * + * Download latest Blinker library here: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * + * Blinker is a platform with iOS and Android apps to + * control embedded hardware like Arduino, Raspberrt Pi. + * You can easily build graphic interfaces for all your + * projects by simply dragging and dropping widgets. + * + * Docs: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * ***************************************************************** + * + * Blinker 库下载地址: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 + * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 + * + * 文档: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * *****************************************************************/ + +#define BLINKER_PRINT Serial +#define BLINKER_WIFI + +#include + +char auth[] = "Your Device Secret Key"; +char ssid[] = "Your WiFi network SSID or name"; +char pswd[] = "Your WiFi network WPA password or WEP key"; + +void dataRead(const String & data) +{ + BLINKER_LOG("Blinker readString: ", data); + + uint32_t BlinkerTime = millis(); + + Blinker.vibrate(); + Blinker.print("millis", BlinkerTime); + + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + String get_aqi = Blinker.aqi(); + BLINKER_LOG("AQI: ", get_aqi); + + Blinker.delay(60000); +} + +void setup() +{ + Serial.begin(115200); + + #if defined(BLINKER_PRINT) + BLINKER_DEBUG.stream(BLINKER_PRINT); + #endif + + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + Blinker.begin(auth, ssid, pswd); + Blinker.attachData(dataRead); +} + +void loop() +{ + Blinker.run(); } \ No newline at end of file diff --git a/examples/Blinker_AT_Firmware/AT_Firmware_MQTT/AT_Firmware_MQTT.ino b/examples/Blinker_AT_Firmware/AT_Firmware_WiFi/AT_Firmware_WiFi.ino similarity index 100% rename from examples/Blinker_AT_Firmware/AT_Firmware_MQTT/AT_Firmware_MQTT.ino rename to examples/Blinker_AT_Firmware/AT_Firmware_WiFi/AT_Firmware_WiFi.ino diff --git a/examples/Blinker_AUTO/AUTO_MQTT/AUTO_MQTT.ino b/examples/Blinker_AUTO/AUTO_WiFi/AUTO_WiFi.ino similarity index 94% rename from examples/Blinker_AUTO/AUTO_MQTT/AUTO_MQTT.ino rename to examples/Blinker_AUTO/AUTO_WiFi/AUTO_WiFi.ino index 4abb946f..c775bf03 100644 --- a/examples/Blinker_AUTO/AUTO_MQTT/AUTO_MQTT.ino +++ b/examples/Blinker_AUTO/AUTO_WiFi/AUTO_WiFi.ino @@ -1,79 +1,79 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -/* - * - * This example not complete at all, TODO. - * - * / - -// #define BLINKER_PRINT Serial -// #define BLINKER_MQTT - -// #include - -// char auth[] = "Your MQTT Secret Key"; -// char ssid[] = "Your WiFi network SSID or name"; -// char pswd[] = "Your WiFi network WPA password or WEP key"; - -// #define BUTTON_1 "ButtonKey" - -// void setup() { -// Serial.begin(115200); - -// pinMode(LED_BUILTIN, OUTPUT); -// digitalWrite(LED_BUILTIN, LOW); - -// Blinker.begin(auth, ssid, pswd); -// Blinker.beginAuto(); -// Blinker.wInit(BUTTON_1, W_BUTTON); -// } - -// void loop() -// { -// Blinker.run(); - -// if (Blinker.available()) { -// BLINKER_LOG("Blinker readString: ", data); - -// uint32_t BlinkerTime = millis(); - -// Blinker.beginFormat(); -// Blinker.vibrate(); -// Blinker.print("millis", BlinkerTime); -// Blinker.endFormat(); -// } - -// if (Blinker.button(BUTTON_1)) { -// digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); -// } - -// Blinker.autoInput("key", "value"); -// Blinker.autoRun(); - -// Blinker.delay(1000); +/* ***************************************************************** + * + * Download latest Blinker library here: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * + * Blinker is a platform with iOS and Android apps to + * control embedded hardware like Arduino, Raspberrt Pi. + * You can easily build graphic interfaces for all your + * projects by simply dragging and dropping widgets. + * + * Docs: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * ***************************************************************** + * + * Blinker 库下载地址: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 + * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 + * + * 文档: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * *****************************************************************/ + +/* + * + * This example not complete at all, TODO. + * + * / + +// #define BLINKER_PRINT Serial +// #define BLINKER_MQTT + +// #include + +// char auth[] = "Your Device Secret Key"; +// char ssid[] = "Your WiFi network SSID or name"; +// char pswd[] = "Your WiFi network WPA password or WEP key"; + +// #define BUTTON_1 "ButtonKey" + +// void setup() { +// Serial.begin(115200); + +// pinMode(LED_BUILTIN, OUTPUT); +// digitalWrite(LED_BUILTIN, LOW); + +// Blinker.begin(auth, ssid, pswd); +// Blinker.beginAuto(); +// Blinker.wInit(BUTTON_1, W_BUTTON); +// } + +// void loop() +// { +// Blinker.run(); + +// if (Blinker.available()) { +// BLINKER_LOG("Blinker readString: ", data); + +// uint32_t BlinkerTime = millis(); + +// Blinker.beginFormat(); +// Blinker.vibrate(); +// Blinker.print("millis", BlinkerTime); +// Blinker.endFormat(); +// } + +// if (Blinker.button(BUTTON_1)) { +// digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); +// } + +// Blinker.autoInput("key", "value"); +// Blinker.autoRun(); + +// Blinker.delay(1000); // } \ No newline at end of file diff --git a/examples/Blinker_AliGenie/AliGenie_LIGHT/AliGenie_LIGHT.ino b/examples/Blinker_AliGenie/AliGenie_LIGHT/AliGenie_LIGHT.ino index 66c193da..c448fed0 100644 --- a/examples/Blinker_AliGenie/AliGenie_LIGHT/AliGenie_LIGHT.ino +++ b/examples/Blinker_AliGenie/AliGenie_LIGHT/AliGenie_LIGHT.ino @@ -26,12 +26,12 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #define BLINKER_ALIGENIE_LIGHT #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_AliGenie/AliGenie_OUTLET/AliGenie_OUTLET.ino b/examples/Blinker_AliGenie/AliGenie_OUTLET/AliGenie_OUTLET.ino index 34c0787a..c59385c3 100644 --- a/examples/Blinker_AliGenie/AliGenie_OUTLET/AliGenie_OUTLET.ino +++ b/examples/Blinker_AliGenie/AliGenie_OUTLET/AliGenie_OUTLET.ino @@ -26,12 +26,12 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #define BLINKER_ALIGENIE_OUTLET #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_AliGenie/AliGenie_SENSOR/AliGenie_SENSOR.ino b/examples/Blinker_AliGenie/AliGenie_SENSOR/AliGenie_SENSOR.ino index bb6b99ff..53d38241 100644 --- a/examples/Blinker_AliGenie/AliGenie_SENSOR/AliGenie_SENSOR.ino +++ b/examples/Blinker_AliGenie/AliGenie_SENSOR/AliGenie_SENSOR.ino @@ -26,12 +26,12 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #define BLINKER_ALIGENIE_SENSOR #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_ArduinoJson/ArduinoJson_MQTT/ArduinoJson_MQTT.ino b/examples/Blinker_ArduinoJson/ArduinoJson_WiFi/ArduinoJson_WiFi.ino similarity index 97% rename from examples/Blinker_ArduinoJson/ArduinoJson_MQTT/ArduinoJson_MQTT.ino rename to examples/Blinker_ArduinoJson/ArduinoJson_WiFi/ArduinoJson_WiFi.ino index f1263080..1413baee 100644 --- a/examples/Blinker_ArduinoJson/ArduinoJson_MQTT/ArduinoJson_MQTT.ino +++ b/examples/Blinker_ArduinoJson/ArduinoJson_WiFi/ArduinoJson_WiFi.ino @@ -26,11 +26,11 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_Bridge/Bridge_MQTT/Bridge_MQTT.ino b/examples/Blinker_Bridge/Bridge_WiFi/Bridge_WiFi.ino similarity index 90% rename from examples/Blinker_Bridge/Bridge_MQTT/Bridge_MQTT.ino rename to examples/Blinker_Bridge/Bridge_WiFi/Bridge_WiFi.ino index e61bd207..b6980c27 100644 --- a/examples/Blinker_Bridge/Bridge_MQTT/Bridge_MQTT.ino +++ b/examples/Blinker_Bridge/Bridge_WiFi/Bridge_WiFi.ino @@ -1,63 +1,63 @@ -// /* ***************************************************************** -// * -// * Download latest Blinker library here: -// * https://github.com/blinker-iot/blinker-library/archive/master.zip -// * -// * -// * Blinker is a platform with iOS and Android apps to -// * control embedded hardware like Arduino, Raspberrt Pi. -// * You can easily build graphic interfaces for all your -// * projects by simply dragging and dropping widgets. -// * -// * Docs: https://doc.blinker.app/ -// * https://github.com/blinker-iot/blinker-doc/wiki -// * -// * ***************************************************************** -// * -// * Blinker 库下载地址: -// * https://github.com/blinker-iot/blinker-library/archive/master.zip -// * -// * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 -// * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 -// * -// * 文档: https://doc.blinker.app/ -// * https://github.com/blinker-iot/blinker-doc/wiki -// * -// * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_MQTT - -#include - -char auth[] = "Your MQTT Secret Key"; -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -#define BRIDGE_1 "Your MQTT Secret Key of bridge to device" - -BlinkerBridge BridgeDevice1(BRIDGE_1); - -void bridge1Read(const String & data) -{ - BLINKER_LOG("BridgeDevice1 readString: ", data); - - // must print Json data - BridgeDevice1.print("{\"hello\":\"bridge\"}"); -} - -void setup() { - Serial.begin(115200); - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(auth, ssid, pswd); - - BridgeDevice1.attach(bridge1Read); -} - -void loop() -{ - Blinker.run(); -} +// /* ***************************************************************** +// * +// * Download latest Blinker library here: +// * https://github.com/blinker-iot/blinker-library/archive/master.zip +// * +// * +// * Blinker is a platform with iOS and Android apps to +// * control embedded hardware like Arduino, Raspberrt Pi. +// * You can easily build graphic interfaces for all your +// * projects by simply dragging and dropping widgets. +// * +// * Docs: https://doc.blinker.app/ +// * https://github.com/blinker-iot/blinker-doc/wiki +// * +// * ***************************************************************** +// * +// * Blinker 库下载地址: +// * https://github.com/blinker-iot/blinker-library/archive/master.zip +// * +// * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 +// * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 +// * +// * 文档: https://doc.blinker.app/ +// * https://github.com/blinker-iot/blinker-doc/wiki +// * +// * *****************************************************************/ + +#define BLINKER_PRINT Serial +#define BLINKER_WIFI + +#include + +char auth[] = "Your Device Secret Key"; +char ssid[] = "Your WiFi network SSID or name"; +char pswd[] = "Your WiFi network WPA password or WEP key"; + +#define BRIDGE_1 "Your Device Secret Key of bridge to device" + +BlinkerBridge BridgeDevice1(BRIDGE_1); + +void bridge1Read(const String & data) +{ + BLINKER_LOG("BridgeDevice1 readString: ", data); + + // must print Json data + BridgeDevice1.print("{\"hello\":\"bridge\"}"); +} + +void setup() { + Serial.begin(115200); + + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + Blinker.begin(auth, ssid, pswd); + + BridgeDevice1.attach(bridge1Read); +} + +void loop() +{ + Blinker.run(); +} diff --git a/examples/Blinker_Button/Button_WiFi/Button_WiFi.ino b/examples/Blinker_Button/Button_WiFi/Button_WiFi.ino index 7a6d625c..5206291c 100644 --- a/examples/Blinker_Button/Button_WiFi/Button_WiFi.ino +++ b/examples/Blinker_Button/Button_WiFi/Button_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -118,7 +119,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); Button1.attach(button1_callback); } diff --git a/examples/Blinker_CLOUDCONFIG/CLOUDCONFIG_MQTT/CLOUDCONFIG_MQTT.ino b/examples/Blinker_CLOUDCONFIG/CLOUDCONFIG_WiFi/CLOUDCONFIG_WiFi.ino similarity index 96% rename from examples/Blinker_CLOUDCONFIG/CLOUDCONFIG_MQTT/CLOUDCONFIG_MQTT.ino rename to examples/Blinker_CLOUDCONFIG/CLOUDCONFIG_WiFi/CLOUDCONFIG_WiFi.ino index eeb147ec..8bce3806 100644 --- a/examples/Blinker_CLOUDCONFIG/CLOUDCONFIG_MQTT/CLOUDCONFIG_MQTT.ino +++ b/examples/Blinker_CLOUDCONFIG/CLOUDCONFIG_WiFi/CLOUDCONFIG_WiFi.ino @@ -26,11 +26,11 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_CLOUDDATA/CLOUDDATA_MQTT/CLOUDDATA_MQTT.ino b/examples/Blinker_CLOUDDATA/CLOUDDATA_WiFi/CLOUDDATA_WiFi.ino similarity index 93% rename from examples/Blinker_CLOUDDATA/CLOUDDATA_MQTT/CLOUDDATA_MQTT.ino rename to examples/Blinker_CLOUDDATA/CLOUDDATA_WiFi/CLOUDDATA_WiFi.ino index b4cd69c1..c77a1764 100644 --- a/examples/Blinker_CLOUDDATA/CLOUDDATA_MQTT/CLOUDDATA_MQTT.ino +++ b/examples/Blinker_CLOUDDATA/CLOUDDATA_WiFi/CLOUDDATA_WiFi.ino @@ -1,72 +1,72 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_MQTT - -#include - -char auth[] = "Your MQTT Secret Key"; -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -void dataRead(const String & data) -{ - BLINKER_LOG("Blinker readString: ", data); - - uint32_t BlinkerTime = millis(); - - Blinker.vibrate(); - Blinker.print("millis", BlinkerTime); - - Blinker.dataUpdate(); - - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); - - Blinker.dataStorage("data1", random(0,120)); - Blinker.dataStorage("data2", random(0,120)/2.0); -} - -void setup() -{ - Serial.begin(115200); - - #if defined(BLINKER_PRINT) - BLINKER_DEBUG.stream(BLINKER_PRINT); - #endif - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(auth, ssid, pswd); - Blinker.attachData(dataRead); -} - -void loop() -{ - Blinker.run(); +/* ***************************************************************** + * + * Download latest Blinker library here: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * + * Blinker is a platform with iOS and Android apps to + * control embedded hardware like Arduino, Raspberrt Pi. + * You can easily build graphic interfaces for all your + * projects by simply dragging and dropping widgets. + * + * Docs: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * ***************************************************************** + * + * Blinker 库下载地址: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 + * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 + * + * 文档: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * *****************************************************************/ + +#define BLINKER_PRINT Serial +#define BLINKER_WIFI + +#include + +char auth[] = "Your Device Secret Key"; +char ssid[] = "Your WiFi network SSID or name"; +char pswd[] = "Your WiFi network WPA password or WEP key"; + +void dataRead(const String & data) +{ + BLINKER_LOG("Blinker readString: ", data); + + uint32_t BlinkerTime = millis(); + + Blinker.vibrate(); + Blinker.print("millis", BlinkerTime); + + Blinker.dataUpdate(); + + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + + Blinker.dataStorage("data1", random(0,120)); + Blinker.dataStorage("data2", random(0,120)/2.0); +} + +void setup() +{ + Serial.begin(115200); + + #if defined(BLINKER_PRINT) + BLINKER_DEBUG.stream(BLINKER_PRINT); + #endif + + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + Blinker.begin(auth, ssid, pswd); + Blinker.attachData(dataRead); +} + +void loop() +{ + Blinker.run(); } \ No newline at end of file diff --git a/examples/Blinker_DHT/DHT_WiFi/DHT_WiFi.ino b/examples/Blinker_DHT/DHT_WiFi/DHT_WiFi.ino index 44262703..c4f41d8f 100644 --- a/examples/Blinker_DHT/DHT_WiFi/DHT_WiFi.ino +++ b/examples/Blinker_DHT/DHT_WiFi/DHT_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -65,7 +66,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); dht.begin(); } diff --git a/examples/Blinker_DuerOS/DuerOS_LIGHT/DuerOS_LIGHT.ino b/examples/Blinker_DuerOS/DuerOS_LIGHT/DuerOS_LIGHT.ino index 725f01cc..7054a612 100644 --- a/examples/Blinker_DuerOS/DuerOS_LIGHT/DuerOS_LIGHT.ino +++ b/examples/Blinker_DuerOS/DuerOS_LIGHT/DuerOS_LIGHT.ino @@ -26,12 +26,12 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #define BLINKER_DUEROS_LIGHT #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -132,15 +132,64 @@ void duerPowerState(const String & state) pixelShow(); } -void duerColor(int32_t color) +void duerColor(const String & color) { BLINKER_LOG("need set color: ", color); - colorR = color >> 16 & 0xFF; - colorG = color >> 8 & 0xFF; - colorB = color & 0xFF; + if (color == "Red") { + colorR = 255; + colorG = 0; + colorB = 0; + } + else if (color == "Yellow") { + colorR = 255; + colorG = 255; + colorB = 0; + } + else if (color == "Blue") { + colorR = 0; + colorG = 0; + colorB = 255; + } + else if (color == "Green") { + colorR = 0; + colorG = 255; + colorB = 0; + } + else if (color == "White") { + colorR = 255; + colorG = 255; + colorB = 255; + } + else if (color == "Black") { + colorR = 0; + colorG = 0; + colorB = 0; + } + else if (color == "Cyan") { + colorR = 0; + colorG = 255; + colorB = 255; + } + else if (color == "Purple") { + colorR = 128; + colorG = 0; + colorB = 128; + } + else if (color == "Orange") { + colorR = 255; + colorG = 165; + colorB = 0; + } - BLINKER_LOG("colorR: ", colorR, ", colorG: ", colorG, ", colorB: ", colorB); + if (wsState == false) { + wsState = true; + colorW = 255; + } + + if (colorW == 0) { + colorW = 255; + } pixelShow(); @@ -152,22 +201,22 @@ void duerMode(const String & mode) { BLINKER_LOG("need set mode: ", mode); - if (mode == BLINKER_CMD_DUEROS_READING) { + if (cmode == BLINKER_CMD_DUEROS_READING) { // Your mode function } - else if (mode == BLINKER_CMD_DUEROS_SLEEP) { + else if (cmode == BLINKER_CMD_DUEROS_SLEEP) { // Your mode function } - else if (mode == BLINKER_CMD_DUEROS_ALARM) { + else if (cmode == BLINKER_CMD_DUEROS_ALARM) { // Your mode function } - else if (mode == BLINKER_CMD_DUEROS_NIGHT_LIGHT) { + else if (cmode == BLINKER_CMD_DUEROS_NIGHT_LIGHT) { // Your mode function } - else if (mode == BLINKER_CMD_DUEROS_ROMANTIC) { + else if (cmode == BLINKER_CMD_DUEROS_ROMANTIC) { // Your mode function } - else if (mode == BLINKER_CMD_DUEROS_READING) { + else if (cmode == BLINKER_CMD_DUEROS_READING) { // Your mode function } diff --git a/examples/Blinker_DuerOS/DuerOS_OUTLET/DuerOS_OUTLET.ino b/examples/Blinker_DuerOS/DuerOS_OUTLET/DuerOS_OUTLET.ino index ff0b38b8..7ff8b5a2 100644 --- a/examples/Blinker_DuerOS/DuerOS_OUTLET/DuerOS_OUTLET.ino +++ b/examples/Blinker_DuerOS/DuerOS_OUTLET/DuerOS_OUTLET.ino @@ -26,12 +26,12 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #define BLINKER_DUEROS_OUTLET #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_DuerOS/DuerOS_SENSOR/DuerOS_SENSOR.ino b/examples/Blinker_DuerOS/DuerOS_SENSOR/DuerOS_SENSOR.ino index 7daa6ba7..cd8e0403 100644 --- a/examples/Blinker_DuerOS/DuerOS_SENSOR/DuerOS_SENSOR.ino +++ b/examples/Blinker_DuerOS/DuerOS_SENSOR/DuerOS_SENSOR.ino @@ -26,12 +26,12 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #define BLINKER_DUEROS_SENSOR #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_ESPTOUCH/ESPTOUCH_MQTT/ESPTOUCH_MQTT.ino b/examples/Blinker_ESPTOUCH/ESPTOUCH_MQTT/ESPTOUCH_MQTT.ino deleted file mode 100644 index 818f2ccc..00000000 --- a/examples/Blinker_ESPTOUCH/ESPTOUCH_MQTT/ESPTOUCH_MQTT.ino +++ /dev/null @@ -1,65 +0,0 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_MQTT -#define BLINKER_ESP_SMARTCONFIG - -#include - -char auth[] = "Your MQTT Secret Key"; - -void dataRead(const String & data) -{ - BLINKER_LOG("Blinker readString: ", data); - - Blinker.vibrate(); - - uint32_t BlinkerTime = millis(); - Blinker.print(BlinkerTime); - Blinker.print("millis", BlinkerTime); -} - -void setup() -{ - Serial.begin(115200); - - #if defined(BLINKER_PRINT) - BLINKER_DEBUG.stream(BLINKER_PRINT); - #endif - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(auth); - Blinker.attachData(dataRead); -} - -void loop() -{ - Blinker.run(); -} \ No newline at end of file diff --git a/examples/Blinker_ESPTOUCH/ESPTOUCH_WiFi/ESPTOUCH_WiFi.ino b/examples/Blinker_ESPTOUCH/ESPTOUCH_WiFi/ESPTOUCH_WiFi.ino index 2814bc85..bbfb35fa 100644 --- a/examples/Blinker_ESPTOUCH/ESPTOUCH_WiFi/ESPTOUCH_WiFi.ino +++ b/examples/Blinker_ESPTOUCH/ESPTOUCH_WiFi/ESPTOUCH_WiFi.ino @@ -31,6 +31,8 @@ #include +char auth[] = "Your Device Secret Key"; + void dataRead(const String & data) { BLINKER_LOG("Blinker readString: ", data); @@ -53,7 +55,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(); + Blinker.begin(auth); Blinker.attachData(dataRead); } diff --git a/examples/Blinker_GPS/GPS_WiFi/GPS_WiFi.ino b/examples/Blinker_GPS/GPS_WiFi/GPS_WiFi.ino index 7aafa044..8d318149 100644 --- a/examples/Blinker_GPS/GPS_WiFi/GPS_WiFi.ino +++ b/examples/Blinker_GPS/GPS_WiFi/GPS_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -55,7 +56,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); } diff --git a/examples/Blinker_Heartbeat/Heartbeat_WiFi/Heartbeat_WiFi.ino b/examples/Blinker_Heartbeat/Heartbeat_WiFi/Heartbeat_WiFi.ino index f93d99ff..53cb1850 100644 --- a/examples/Blinker_Heartbeat/Heartbeat_WiFi/Heartbeat_WiFi.ino +++ b/examples/Blinker_Heartbeat/Heartbeat_WiFi/Heartbeat_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -59,6 +60,13 @@ void heartbeat() else BUILTIN_SWITCH.print("off"); } +String summary() +{ + String data = "online, switch: " + STRING_format(switch_state ? "on" : "off"); + + return data; +} + void dataRead(const String & data) { BLINKER_LOG("Blinker readString: ", data); @@ -81,9 +89,10 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); - Blinker.attachData(dataRead); + Blinker.begin(auth, ssid, pswd); + Blinker.attachData(dataRead); Blinker.attachHeartbeat(heartbeat); + Blinker.attachSummary(summary); BUILTIN_SWITCH.attach(switch_callback); } diff --git a/examples/Blinker_Hello/Hello_MQTT/Hello_MQTT.ino b/examples/Blinker_Hello/Hello_WiFi/Hello_MQTT.ino similarity index 81% rename from examples/Blinker_Hello/Hello_MQTT/Hello_MQTT.ino rename to examples/Blinker_Hello/Hello_WiFi/Hello_MQTT.ino index 19e4c79b..19b99d30 100644 --- a/examples/Blinker_Hello/Hello_MQTT/Hello_MQTT.ino +++ b/examples/Blinker_Hello/Hello_WiFi/Hello_MQTT.ino @@ -26,11 +26,11 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -38,6 +38,10 @@ char pswd[] = "Your WiFi network WPA password or WEP key"; BlinkerButton Button1("btn-abc"); BlinkerNumber Number1("num-abc"); +#define BLINKER_OTA_BLINK_TIME 500 + +uint32_t os_time; + int counter = 0; // 按下按键即会执行该函数 @@ -55,6 +59,17 @@ void dataRead(const String & data) Number1.print(counter); } +void otaStatus(uint32_t load_size, uint32_t total_size) +{ + BLINKER_LOG(load_size/total_size); + // if (millis() - os_time >= BLINKER_OTA_BLINK_TIME) + // { + // os_time = millis(); + + // digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + // } +} + void setup() { // 初始化串口 @@ -62,6 +77,7 @@ void setup() #if defined(BLINKER_PRINT) BLINKER_DEBUG.stream(BLINKER_PRINT); + BLINKER_DEBUG.debugAll(); #endif // 初始化有LED的IO @@ -69,9 +85,12 @@ void setup() digitalWrite(LED_BUILTIN, HIGH); // 初始化blinker Blinker.begin(auth, ssid, pswd); + // Blinker.begin(auth); Blinker.attachData(dataRead); Button1.attach(button1_callback); + + BlinkerUpdater.onProgress(otaStatus); } void loop() { diff --git a/examples/Blinker_Hello/Hello_WiFi/Hello_WiFi.ino b/examples/Blinker_Hello/Hello_WiFi/Hello_WiFi.ino deleted file mode 100644 index 6b2584ab..00000000 --- a/examples/Blinker_Hello/Hello_WiFi/Hello_WiFi.ino +++ /dev/null @@ -1,72 +0,0 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_WIFI - -#include - -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -BlinkerButton Button1("btn-abc"); -BlinkerNumber Number1("num-abc"); - -int counter = 0; - -void button1_callback(const String & state) -{ - BLINKER_LOG("get button state: ", state); - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); -} - -void dataRead(const String & data) -{ - BLINKER_LOG("Blinker readString: ", data); - counter++; - Number1.print(counter); -} - -void setup() { - Serial.begin(115200); - - #if defined(BLINKER_PRINT) - BLINKER_DEBUG.stream(BLINKER_PRINT); - #endif - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, HIGH); - - Blinker.begin(ssid, pswd); - Blinker.attachData(dataRead); - - Button1.attach(button1_callback); -} - -void loop() { - Blinker.run(); -} \ No newline at end of file diff --git a/examples/Blinker_Joystick/Joystick_WiFi/Joystick_WiFi.ino b/examples/Blinker_Joystick/Joystick_WiFi/Joystick_WiFi.ino index 3d5490a7..885ac531 100644 --- a/examples/Blinker_Joystick/Joystick_WiFi/Joystick_WiFi.ino +++ b/examples/Blinker_Joystick/Joystick_WiFi/Joystick_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -65,7 +66,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); JOY1.attach(joystick1_callback); diff --git a/examples/Blinker_MQTT/MQTT_WiFi/MQTT_WiFi.ino b/examples/Blinker_MQTT/MQTT_WiFi/MQTT_WiFi.ino index 6b777fc3..76849eed 100644 --- a/examples/Blinker_MQTT/MQTT_WiFi/MQTT_WiFi.ino +++ b/examples/Blinker_MQTT/MQTT_WiFi/MQTT_WiFi.ino @@ -26,11 +26,11 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_Notify/Notify_WiFi/Notify_WiFi.ino b/examples/Blinker_Notify/Notify_WiFi/Notify_WiFi.ino index 3273f10b..a6e3c2b7 100644 --- a/examples/Blinker_Notify/Notify_WiFi/Notify_WiFi.ino +++ b/examples/Blinker_Notify/Notify_WiFi/Notify_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -58,7 +59,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); } diff --git a/examples/Blinker_Number/Number_WiFi/Number_WiFi.ino b/examples/Blinker_Number/Number_WiFi/Number_WiFi.ino index a764d860..24adcb37 100644 --- a/examples/Blinker_Number/Number_WiFi/Number_WiFi.ino +++ b/examples/Blinker_Number/Number_WiFi/Number_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -66,7 +67,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); } diff --git a/examples/Blinker_OTA/OTA_MQTT/OTA_MQTT.ino b/examples/Blinker_OTA/OTA_WiFi/OTA_WiFi.ino similarity index 95% rename from examples/Blinker_OTA/OTA_MQTT/OTA_MQTT.ino rename to examples/Blinker_OTA/OTA_WiFi/OTA_WiFi.ino index 165be1f1..f31068a0 100644 --- a/examples/Blinker_OTA/OTA_MQTT/OTA_MQTT.ino +++ b/examples/Blinker_OTA/OTA_WiFi/OTA_WiFi.ino @@ -26,12 +26,12 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #define BLINKER_OTA_VERSION_CODE "0.1.1" #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -74,7 +74,7 @@ void setup() Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); - BlinkerUpdater.onProgress(otaStatus); + BlinkerUpdater.onProgress(ota); } void loop() diff --git a/examples/Blinker_PUSH/PUSH_MQTT/PUSH_MQTT.ino b/examples/Blinker_PUSH/PUSH_WiFi/PUSH_WiFi.ino similarity index 96% rename from examples/Blinker_PUSH/PUSH_MQTT/PUSH_MQTT.ino rename to examples/Blinker_PUSH/PUSH_WiFi/PUSH_WiFi.ino index 2cc30cf2..8ac914a8 100644 --- a/examples/Blinker_PUSH/PUSH_MQTT/PUSH_MQTT.ino +++ b/examples/Blinker_PUSH/PUSH_WiFi/PUSH_WiFi.ino @@ -26,11 +26,11 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_Print/Print_WiFi/Print_WiFi.ino b/examples/Blinker_Print/Print_WiFi/Print_WiFi.ino index 55f37c75..94b5d1cf 100644 --- a/examples/Blinker_Print/Print_WiFi/Print_WiFi.ino +++ b/examples/Blinker_Print/Print_WiFi/Print_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -55,7 +56,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); } diff --git a/examples/Blinker_RGB/RGB_WiFi/RGB_WiFi.ino b/examples/Blinker_RGB/RGB_WiFi/RGB_WiFi.ino index 20903330..f7ecc6c4 100644 --- a/examples/Blinker_RGB/RGB_WiFi/RGB_WiFi.ino +++ b/examples/Blinker_RGB/RGB_WiFi/RGB_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -71,7 +72,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); RGB1.attach(rgb1_callback); diff --git a/examples/Blinker_SMS/SMS_MQTT/SMS_MQTT.ino b/examples/Blinker_SMS/SMS_WiFi/SMS_WiFi.ino similarity index 93% rename from examples/Blinker_SMS/SMS_MQTT/SMS_MQTT.ino rename to examples/Blinker_SMS/SMS_WiFi/SMS_WiFi.ino index e2cc49ad..17f5159c 100644 --- a/examples/Blinker_SMS/SMS_MQTT/SMS_MQTT.ino +++ b/examples/Blinker_SMS/SMS_WiFi/SMS_WiFi.ino @@ -1,70 +1,70 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_MQTT - -#include - -char auth[] = "Your MQTT Secret Key"; -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -void dataRead(const String & data) -{ - BLINKER_LOG("Blinker readString: ", data); - - uint32_t BlinkerTime = millis(); - - Blinker.vibrate(); - Blinker.print("millis", BlinkerTime); - - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); - Blinker.sms("Hello blinker!"); - - Blinker.delay(60000); -} - -void setup() -{ - Serial.begin(115200); - - #if defined(BLINKER_PRINT) - BLINKER_DEBUG.stream(BLINKER_PRINT); - #endif - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(auth, ssid, pswd); - Blinker.attachData(dataRead); -} - -void loop() -{ - Blinker.run(); +/* ***************************************************************** + * + * Download latest Blinker library here: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * + * Blinker is a platform with iOS and Android apps to + * control embedded hardware like Arduino, Raspberrt Pi. + * You can easily build graphic interfaces for all your + * projects by simply dragging and dropping widgets. + * + * Docs: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * ***************************************************************** + * + * Blinker 库下载地址: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 + * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 + * + * 文档: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * *****************************************************************/ + +#define BLINKER_PRINT Serial +#define BLINKER_WIFI + +#include + +char auth[] = "Your Device Secret Key"; +char ssid[] = "Your WiFi network SSID or name"; +char pswd[] = "Your WiFi network WPA password or WEP key"; + +void dataRead(const String & data) +{ + BLINKER_LOG("Blinker readString: ", data); + + uint32_t BlinkerTime = millis(); + + Blinker.vibrate(); + Blinker.print("millis", BlinkerTime); + + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + Blinker.sms("Hello blinker!"); + + Blinker.delay(60000); +} + +void setup() +{ + Serial.begin(115200); + + #if defined(BLINKER_PRINT) + BLINKER_DEBUG.stream(BLINKER_PRINT); + #endif + + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + Blinker.begin(auth, ssid, pswd); + Blinker.attachData(dataRead); +} + +void loop() +{ + Blinker.run(); } \ No newline at end of file diff --git a/examples/Blinker_SR04/SR04_WiFi/SR04_WiFi.ino b/examples/Blinker_SR04/SR04_WiFi/SR04_WiFi.ino index 80650c8b..75182425 100644 --- a/examples/Blinker_SR04/SR04_WiFi/SR04_WiFi.ino +++ b/examples/Blinker_SR04/SR04_WiFi/SR04_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -48,7 +49,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); } void loop() diff --git a/examples/Blinker_Slider/Slider_WiFi/Slider_WiFi.ino b/examples/Blinker_Slider/Slider_WiFi/Slider_WiFi.ino index 48d4ee27..3724a964 100644 --- a/examples/Blinker_Slider/Slider_WiFi/Slider_WiFi.ino +++ b/examples/Blinker_Slider/Slider_WiFi/Slider_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -68,7 +69,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); Slider1.attach(slider1_callback); diff --git a/examples/Blinker_Summary/Summary_MQTT/Summary_MQTT.ino b/examples/Blinker_Summary/Summary_MQTT/Summary_MQTT.ino deleted file mode 100644 index 5ba63f01..00000000 --- a/examples/Blinker_Summary/Summary_MQTT/Summary_MQTT.ino +++ /dev/null @@ -1,103 +0,0 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_MQTT - -#include - -char auth[] = "Your MQTT Secret Key"; -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -bool switch_state = false; - -void switch_callback(const String & state) -{ - BLINKER_LOG("get switch state: ", state); - - if (state == BLINKER_CMD_ON) { - switch_state = true; - digitalWrite(LED_BUILTIN, HIGH); - - BUILTIN_SWITCH.print("on"); - } - else if (state == BLINKER_CMD_OFF) { - switch_state = false; - digitalWrite(LED_BUILTIN, LOW); - - BUILTIN_SWITCH.print("off"); - } -} - -void heartbeat() -{ - if (switch_state) BUILTIN_SWITCH.print("on"); - else BUILTIN_SWITCH.print("off"); -} - -String summary() -{ - String data = "online, switch: " + STRING_format(switch_state ? "on" : "off"); - - return data; -} - -void dataRead(const String & data) -{ - BLINKER_LOG("Blinker readString: ", data); - - Blinker.vibrate(); - - uint32_t BlinkerTime = millis(); - Blinker.print(BlinkerTime); - Blinker.print("millis", BlinkerTime); -} - -void setup() -{ - Serial.begin(115200); - - #if defined(BLINKER_PRINT) - BLINKER_DEBUG.stream(BLINKER_PRINT); - #endif - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(auth, ssid, pswd); - Blinker.attachData(dataRead); - Blinker.attachHeartbeat(heartbeat); - Blinker.attachSummary(summary); - - BUILTIN_SWITCH.attach(switch_callback); -} - -void loop() -{ - Blinker.run(); -} diff --git a/examples/Blinker_Heartbeat/Heartbeat_MQTT/Heartbeat_MQTT.ino b/examples/Blinker_Summary/Summary_WiFi/Summary_WiFi.ino similarity index 97% rename from examples/Blinker_Heartbeat/Heartbeat_MQTT/Heartbeat_MQTT.ino rename to examples/Blinker_Summary/Summary_WiFi/Summary_WiFi.ino index 5ba63f01..53cb1850 100644 --- a/examples/Blinker_Heartbeat/Heartbeat_MQTT/Heartbeat_MQTT.ino +++ b/examples/Blinker_Summary/Summary_WiFi/Summary_WiFi.ino @@ -26,11 +26,11 @@ * *****************************************************************/ #define BLINKER_PRINT Serial -#define BLINKER_MQTT +#define BLINKER_WIFI #include -char auth[] = "Your MQTT Secret Key"; +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; diff --git a/examples/Blinker_Switch/Switch_WiFi/Switch_WiFi.ino b/examples/Blinker_Switch/Switch_WiFi/Switch_WiFi.ino index 3a1ee416..639ed64d 100644 --- a/examples/Blinker_Switch/Switch_WiFi/Switch_WiFi.ino +++ b/examples/Blinker_Switch/Switch_WiFi/Switch_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -58,7 +59,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); BUILTIN_SWITCH.attach(switch_callback); } diff --git a/examples/Blinker_TEXT/TEXT_WiFi/TEXT_WiFi.ino b/examples/Blinker_TEXT/TEXT_WiFi/TEXT_WiFi.ino index aab2630a..c3383541 100644 --- a/examples/Blinker_TEXT/TEXT_WiFi/TEXT_WiFi.ino +++ b/examples/Blinker_TEXT/TEXT_WiFi/TEXT_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -63,7 +64,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); } diff --git a/examples/Blinker_Time/Time_WiFi/Time_WiFi.ino b/examples/Blinker_Time/Time_WiFi/Time_WiFi.ino index 944a6bb2..ff053b56 100644 --- a/examples/Blinker_Time/Time_WiFi/Time_WiFi.ino +++ b/examples/Blinker_Time/Time_WiFi/Time_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -67,7 +68,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); Blinker.attachData(dataRead); Blinker.setTimezone(8.0); diff --git a/examples/Blinker_Timer/Timer_WiFi_countdown/Timer_WiFi_countdown.ino b/examples/Blinker_Timer/Timer_WiFi_countdown/Timer_WiFi_countdown.ino deleted file mode 100644 index f8182ab4..00000000 --- a/examples/Blinker_Timer/Timer_WiFi_countdown/Timer_WiFi_countdown.ino +++ /dev/null @@ -1,67 +0,0 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_WIFI - -#include - -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -BlinkerTimer BlinkerCountDown; - -void blink() { - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); -} - -void setup() -{ - Serial.begin(115200); - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(ssid, pswd); - - BlinkerCountDown.countdown(5, blink); -} - -void loop() -{ - Blinker.run(); - - if (Blinker.available()) { - BLINKER_LOG("Blinker readString: ", data); - - Blinker.vibrate(); - - uint32_t BlinkerTime = millis(); - Blinker.print(BlinkerTime); - Blinker.print("millis", BlinkerTime); - } -} diff --git a/examples/Blinker_Timer/Timer_WiFi_loop/Timer_WiFi_loop.ino b/examples/Blinker_Timer/Timer_WiFi_loop/Timer_WiFi_loop.ino deleted file mode 100644 index def8c1ed..00000000 --- a/examples/Blinker_Timer/Timer_WiFi_loop/Timer_WiFi_loop.ino +++ /dev/null @@ -1,67 +0,0 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_WIFI - -#include - -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -BlinkerTimer BlinkerLoop; - -void blink() { - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); -} - -void setup() -{ - Serial.begin(115200); - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(ssid, pswd); - - BlinkerLoop.loop(1, blink); -} - -void loop() -{ - Blinker.run(); - - if (Blinker.available()) { - BLINKER_LOG("Blinker readString: ", data); - - Blinker.vibrate(); - - uint32_t BlinkerTime = millis(); - Blinker.print(BlinkerTime); - Blinker.print("millis", BlinkerTime); - } -} diff --git a/examples/Blinker_Timer/Timer_WiFi_timing/Timer_WiFi_timing.ino b/examples/Blinker_Timer/Timer_WiFi_timing/Timer_WiFi_timing.ino deleted file mode 100644 index 56bd6911..00000000 --- a/examples/Blinker_Timer/Timer_WiFi_timing/Timer_WiFi_timing.ino +++ /dev/null @@ -1,71 +0,0 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_WIFI - -#include - -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -BlinkerTimer BlinkerTiming; - -void blink_high() { - digitalWrite(LED_BUILTIN, HIGH); -} - -void blink_low() { - digitalWrite(LED_BUILTIN, LOW); -} - -void setup() -{ - Serial.begin(115200); - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(ssid, pswd); - - BlinkerTiming.timing(5, blink_high, 10, blink_low); -} - -void loop() -{ - Blinker.run(); - - if (Blinker.available()) { - BLINKER_LOG("Blinker readString: ", data); - - Blinker.vibrate(); - - uint32_t BlinkerTime = millis(); - Blinker.print(BlinkerTime); - Blinker.print("millis", BlinkerTime); - } -} diff --git a/examples/Blinker_WS2812/WS2812_WiFi/WS2812_WiFi.ino b/examples/Blinker_WS2812/WS2812_WiFi/WS2812_WiFi.ino index e141d149..38e68107 100644 --- a/examples/Blinker_WS2812/WS2812_WiFi/WS2812_WiFi.ino +++ b/examples/Blinker_WS2812/WS2812_WiFi/WS2812_WiFi.ino @@ -30,6 +30,7 @@ #include +char auth[] = "Your Device Secret Key"; char ssid[] = "Your WiFi network SSID or name"; char pswd[] = "Your WiFi network WPA password or WEP key"; @@ -75,7 +76,7 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - Blinker.begin(ssid, pswd); + Blinker.begin(auth, ssid, pswd); pixels.begin(); diff --git a/examples/Blinker_WeChat/Blinker_WeChat/Blinker_Wechat.ino b/examples/Blinker_WeChat/Blinker_WeChat/Blinker_Wechat.ino deleted file mode 100644 index 2ac83591..00000000 --- a/examples/Blinker_WeChat/Blinker_WeChat/Blinker_Wechat.ino +++ /dev/null @@ -1,78 +0,0 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_MQTT - -#include - -char auth[] = "Your MQTT Secret Key"; -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -BlinkerButton Button1("btn-abc"); -BlinkerNumber Number1("num-abc"); - -int counter = 0; - -void button1_callback(const String & state) -{ - BLINKER_LOG("get button state: ", state); - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); - - Blinker.wechat("Title: button", "State: " + state, "Message: hello blinker"); -} - -void dataRead(const String & data) -{ - BLINKER_LOG("Blinker readString: ", data); - counter++; - Number1.print(counter); - - Blinker.wechat("hello blinker"); -} - -void setup() -{ - Serial.begin(115200); - - #if defined(BLINKER_PRINT) - BLINKER_DEBUG.stream(BLINKER_PRINT); - #endif - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, HIGH); - - Blinker.begin(auth, ssid, pswd); - Blinker.attachData(dataRead); - - Button1.attach(button1_callback); -} - -void loop() { - Blinker.run(); -} diff --git a/examples/Blinker_Weather/Weather_MQTT/Weather_MQTT.ino b/examples/Blinker_Weather/Weather_WiFi/Weather_WiFi.ino similarity index 93% rename from examples/Blinker_Weather/Weather_MQTT/Weather_MQTT.ino rename to examples/Blinker_Weather/Weather_WiFi/Weather_WiFi.ino index 59641aa9..249a38ee 100644 --- a/examples/Blinker_Weather/Weather_MQTT/Weather_MQTT.ino +++ b/examples/Blinker_Weather/Weather_WiFi/Weather_WiFi.ino @@ -1,71 +1,71 @@ -/* ***************************************************************** - * - * Download latest Blinker library here: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * - * Blinker is a platform with iOS and Android apps to - * control embedded hardware like Arduino, Raspberrt Pi. - * You can easily build graphic interfaces for all your - * projects by simply dragging and dropping widgets. - * - * Docs: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * ***************************************************************** - * - * Blinker 库下载地址: - * https://github.com/blinker-iot/blinker-library/archive/master.zip - * - * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 - * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 - * - * 文档: https://doc.blinker.app/ - * https://github.com/blinker-iot/blinker-doc/wiki - * - * *****************************************************************/ - -#define BLINKER_PRINT Serial -#define BLINKER_MQTT - -#include - -char auth[] = "Your MQTT Secret Key"; -char ssid[] = "Your WiFi network SSID or name"; -char pswd[] = "Your WiFi network WPA password or WEP key"; - -void dataRead(const String & data) -{ - BLINKER_LOG("Blinker readString: ", data); - - uint32_t BlinkerTime = millis(); - - Blinker.vibrate(); - Blinker.print("millis", BlinkerTime); - - digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); - String get_weather = Blinker.weather(); - BLINKER_LOG("weather: ", get_weather); - - Blinker.delay(60000); -} - -void setup() -{ - Serial.begin(115200); - - #if defined(BLINKER_PRINT) - BLINKER_DEBUG.stream(BLINKER_PRINT); - #endif - - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); - - Blinker.begin(auth, ssid, pswd); - Blinker.attachData(dataRead); -} - -void loop() -{ - Blinker.run(); +/* ***************************************************************** + * + * Download latest Blinker library here: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * + * Blinker is a platform with iOS and Android apps to + * control embedded hardware like Arduino, Raspberrt Pi. + * You can easily build graphic interfaces for all your + * projects by simply dragging and dropping widgets. + * + * Docs: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * ***************************************************************** + * + * Blinker 库下载地址: + * https://github.com/blinker-iot/blinker-library/archive/master.zip + * + * Blinker 是一个运行在 IOS 和 Android 上用于控制嵌入式硬件的应用程序。 + * 你可以通过拖放控制组件,轻松地为你的项目建立图形化控制界面。 + * + * 文档: https://doc.blinker.app/ + * https://github.com/blinker-iot/blinker-doc/wiki + * + * *****************************************************************/ + +#define BLINKER_PRINT Serial +#define BLINKER_WIFI + +#include + +char auth[] = "Your Device Secret Key"; +char ssid[] = "Your WiFi network SSID or name"; +char pswd[] = "Your WiFi network WPA password or WEP key"; + +void dataRead(const String & data) +{ + BLINKER_LOG("Blinker readString: ", data); + + uint32_t BlinkerTime = millis(); + + Blinker.vibrate(); + Blinker.print("millis", BlinkerTime); + + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + String get_weather = Blinker.weather(); + BLINKER_LOG("weather: ", get_weather); + + Blinker.delay(60000); +} + +void setup() +{ + Serial.begin(115200); + + #if defined(BLINKER_PRINT) + BLINKER_DEBUG.stream(BLINKER_PRINT); + #endif + + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + Blinker.begin(auth, ssid, pswd); + Blinker.attachData(dataRead); +} + +void loop() +{ + Blinker.run(); } \ No newline at end of file diff --git a/src/Blinker.h b/src/Blinker.h index 80997ac3..91affc91 100644 --- a/src/Blinker.h +++ b/src/Blinker.h @@ -27,75 +27,80 @@ BlinkerSerialBLE Blinker(_blinkerTransport); #endif -#elif defined(BLINKER_WIFI) +#elif defined(BLINKER_WIFI) || defined(BLINKER_MQTT) - #if defined(BLINKER_ALIGENIE_LIGHT) || defined(BLINKER_ALIGENIE_OUTLET) || \ - defined(BLINKER_ALIGENIE_SWITCH)|| defined(BLINKER_ALIGENIE_SENSOR) - #error This code is intended to run on the BLINKER_MQTT mode! Please check your mode setting. + #if defined(BLINKER_WIFI) + #undef BLINKER_WIFI + #define BLINKER_MQTT #endif - #if defined(BLINKER_DUEROS_LIGHT) || defined(BLINKER_DUEROS_OUTLET) || \ - defined(BLINKER_DUEROS_SWITCH)|| defined(BLINKER_DUEROS_SENSOR) - #error This code is intended to run on the BLINKER_MQTT mode! Please check your mode setting. - #endif +// #if defined(BLINKER_ALIGENIE_LIGHT) || defined(BLINKER_ALIGENIE_OUTLET) || \ +// defined(BLINKER_ALIGENIE_SWITCH)|| defined(BLINKER_ALIGENIE_SENSOR) +// #error This code is intended to run on the BLINKER_MQTT mode! Please check your mode setting. +// #endif - #if defined(ESP8266) || defined(ESP32) - #include "Blinker/BlinkerDebug.h" - #include "BlinkerESPWiFi.h" +// #if defined(BLINKER_DUEROS_LIGHT) || defined(BLINKER_DUEROS_OUTLET) || \ +// defined(BLINKER_DUEROS_SWITCH)|| defined(BLINKER_DUEROS_SENSOR) +// #error This code is intended to run on the BLINKER_MQTT mode! Please check your mode setting. +// #endif - static BlinkerWiFi _blinkerTransport; - BlinkerESPWiFi Blinker(_blinkerTransport); - #else - #error This code is intended to run on the ESP8266/ESP32 platform! Please check your Tools->Board setting. - #endif +// #if defined(ESP8266) || defined(ESP32) +// #include "Blinker/BlinkerDebug.h" +// #include "BlinkerESPWiFi.h" + +// static BlinkerWiFi _blinkerTransport; +// BlinkerESPWiFi Blinker(_blinkerTransport); +// #else +// #error This code is intended to run on the ESP8266/ESP32 platform! Please check your Tools->Board setting. +// #endif -#elif defined(BLINKER_MQTT) +// #elif defined(BLINKER_MQTT) #if defined(BLINKER_ALIGENIE_LIGHT) #if defined(BLINKER_ALIGENIE_OUTLET) - #undef(BLINKER_ALIGENIE_OUTLET) + #undef BLINKER_ALIGENIE_OUTLET #endif #if defined(BLINKER_ALIGENIE_SWITCH) - #undef(BLINKER_ALIGENIE_SWITCH) + #undef BLINKER_ALIGENIE_SWITCH #endif #if defined(BLINKER_ALIGENIE_SENSOR) - #undef(BLINKER_ALIGENIE_SENSOR) + #undef BLINKER_ALIGENIE_SENSOR #endif #define BLINKER_ALIGENIE #elif defined(BLINKER_ALIGENIE_OUTLET) #if defined(BLINKER_ALIGENIE_LIGHT) - #undef(BLINKER_ALIGENIE_LIGHT) + #undef BLINKER_ALIGENIE_LIGHT #endif #if defined(BLINKER_ALIGENIE_SWITCH) - #undef(BLINKER_ALIGENIE_SWITCH) + #undef BLINKER_ALIGENIE_SWITCH #endif #if defined(BLINKER_ALIGENIE_SENSOR) - #undef(BLINKER_ALIGENIE_SENSOR) + #undef BLINKER_ALIGENIE_SENSOR #endif #define BLINKER_ALIGENIE #elif defined(BLINKER_ALIGENIE_SWITCH) #if defined(BLINKER_ALIGENIE_LIGHT) - #undef(BLINKER_ALIGENIE_LIGHT) + #undef BLINKER_ALIGENIE_LIGHT #endif #if defined(BLINKER_ALIGENIE_OUTLET) - #undef(BLINKER_ALIGENIE_OUTLET) + #undef BLINKER_ALIGENIE_OUTLET #endif #if defined(BLINKER_ALIGENIE_SENSOR) - #undef(BLINKER_ALIGENIE_SENSOR) + #undef BLINKER_ALIGENIE_SENSOR #endif #define BLINKER_ALIGENIE #elif defined(BLINKER_ALIGENIE_SENSOR) #if defined(BLINKER_ALIGENIE_LIGHT) - #undef(BLINKER_ALIGENIE_LIGHT) + #undef BLINKER_ALIGENIE_LIGHT #endif #if defined(BLINKER_ALIGENIE_OUTLET) - #undef(BLINKER_ALIGENIE_OUTLET) + #undef BLINKER_ALIGENIE_OUTLET #endif #if defined(BLINKER_ALIGENIE_SWITCH) - #undef(BLINKER_ALIGENIE_SWITCH) + #undef BLINKER_ALIGENIE_SWITCH #endif #define BLINKER_ALIGENIE @@ -103,37 +108,37 @@ #if defined(BLINKER_DUEROS_LIGHT) #if defined(BLINKER_DUEROS_OUTLET) - #undef(BLINKER_DUEROS_OUTLET) + #undef BLINKER_DUEROS_OUTLET #endif #if defined(BLINKER_DUEROS_SWITCH) - #undef(BLINKER_DUEROS_SWITCH) + #undef BLINKER_DUEROS_SWITCH #endif #if defined(BLINKER_DUEROS_SENSOR) - #undef(BLINKER_DUEROS_SENSOR) + #undef BLINKER_DUEROS_SENSOR #endif #define BLINKER_DUEROS #elif defined(BLINKER_DUEROS_OUTLET) #if defined(BLINKER_DUEROS_LIGHT) - #undef(BLINKER_DUEROS_LIGHT) + #undef BLINKER_DUEROS_LIGHT #endif #if defined(BLINKER_DUEROS_SWITCH) - #undef(BLINKER_DUEROS_SWITCH) + #undef BLINKER_DUEROS_SWITCH #endif #if defined(BLINKER_DUEROS_SENSOR) - #undef(BLINKER_DUEROS_SENSOR) + #undef BLINKER_DUEROS_SENSOR #endif #define BLINKER_DUEROS #elif defined(BLINKER_DUEROS_SENSOR) #if defined(BLINKER_DUEROS_LIGHT) - #undef(BLINKER_DUEROS_LIGHT) + #undef BLINKER_DUEROS_LIGHT #endif #if defined(BLINKER_DUEROS_SWITCH) - #undef(BLINKER_DUEROS_SWITCH) + #undef BLINKER_DUEROS_SWITCH #endif #if defined(BLINKER_DUEROS_OUTLET) - #undef(BLINKER_DUEROS_OUTLET) + #undef BLINKER_DUEROS_OUTLET #endif #define BLINKER_DUEROS