first commit
This commit is contained in:
1
blinker-library/examples/Blinker_PRO/.pydio
Normal file
1
blinker-library/examples/Blinker_PRO/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
65284a9e-4a26-4140-8e2f-8d008aa8d552
|
||||
@@ -0,0 +1 @@
|
||||
5832cbcf-f223-4242-abf3-3f272f70feb3
|
||||
@@ -0,0 +1,163 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_AIR202
|
||||
// #define BLINKER_BUTTON
|
||||
// #define BLINKER_BUTTON_PIN D7
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
// Blinker.print("hello", "blinker");
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
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);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin();
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
c565f625-fbb7-488a-b4e4-1688adcbc7fa
|
||||
@@ -0,0 +1,174 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#define BLINKER_SERVER_HTTPS "https://iot.diandeng.tech"
|
||||
|
||||
#define BLINKER_SERVER_HOST "iot.diandeng.tech"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret 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));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
2a3c9f01-f4ac-4d9d-82e8-0daa3210ddd3
|
||||
@@ -0,0 +1,170 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret 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));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
65108938-a1a1-4f8c-b2ea-347220a70890
|
||||
@@ -0,0 +1,182 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret 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));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.apConfigInit();
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
2d7ca55d-a1e0-4482-976a-f0a264dc80e6
|
||||
@@ -0,0 +1 @@
|
||||
aa7dbde7-4224-4429-8056-55a4db17f013
|
||||
@@ -0,0 +1,181 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret 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));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
|
||||
BlinkerEvent.warning("button click!");
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
25c1101c-e164-4fd7-93f7-46691f20f843
|
||||
@@ -0,0 +1,181 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret 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));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
|
||||
BlinkerEvent.message("button click!");
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
3dfce2de-e679-404d-9843-bcd4d6d62040
|
||||
@@ -0,0 +1,181 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret 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));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
|
||||
BlinkerEvent.warning("button click!");
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
640c8e68-17e4-4cca-84c8-8440336f5a31
|
||||
@@ -0,0 +1 @@
|
||||
18c5bb91-c842-49e7-b323-6fde537b99cd
|
||||
@@ -0,0 +1,184 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
#define BLINKER_OTA_BLINK_TIME 500
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
uint32_t os_time;
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
// void otaStatus(uint32_t load_size, uint32_t total_size)
|
||||
// {
|
||||
// if (millis() - os_time >= BLINKER_OTA_BLINK_TIME)
|
||||
// {
|
||||
// os_time = millis();
|
||||
|
||||
// digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
// }
|
||||
// }
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
// BlinkerUpdater.onProgress(otaStatus);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
072d0936-ad7e-45a2-ab83-8f8d59a88c2c
|
||||
@@ -0,0 +1,163 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_SIM7020
|
||||
// #define BLINKER_BUTTON
|
||||
// #define BLINKER_BUTTON_PIN D7
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
// Blinker.print("hello", "blinker");
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
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);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin();
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
362b3899-6d40-4d91-9147-1525e76adf96
|
||||
@@ -0,0 +1,211 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#define BLINKER_BUTTON_LONGPRESS_POWERDOWN
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret 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));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When long press start, device will call this function
|
||||
*/
|
||||
void longPressStart()
|
||||
{
|
||||
BLINKER_LOG("Button long press start!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When during long press, device will call this function
|
||||
*/
|
||||
void duringLongPress()
|
||||
{
|
||||
// BLINKER_LOG("During button long press!");
|
||||
|
||||
uint16_t pressed_time = Blinker.pressedTime();
|
||||
|
||||
if (pressed_time >= 5000 && Blinker.configType() != BLINKER_AP_CONFIG)
|
||||
{
|
||||
Blinker.esptouchInit();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
Blinker.attachLongPressStart(longPressStart);
|
||||
Blinker.attachDuringLongPress(duringLongPress);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
Reference in New Issue
Block a user