90 lines
2.5 KiB
C++
90 lines
2.5 KiB
C++
#include <Arduino.h>
|
||
#line 1 "c:\\Users\\32244\\Documents\\Arduino\\generated_examples\\Blinker01\\Blinker01.ino"
|
||
#define BLINKER_ESP_TASK
|
||
#define BLINKER_WIFI
|
||
|
||
#define ON HIGH
|
||
#define OFF LOW
|
||
|
||
#include <Blinker.h>
|
||
#include <WiFi.h>
|
||
#include <freertos/FreeRTOSConfig.h>
|
||
#include "httpslei.h"
|
||
|
||
void button1_callback(const String & state);
|
||
void none_callback(const String & data);
|
||
void ot_callback(const String & state);
|
||
|
||
char *auth = "05e4cd637e1f";
|
||
char *ssid = "101_lei";
|
||
char *pswd = "leiyun1314";
|
||
|
||
BlinkerButton Button1("btn-abc",button1_callback);
|
||
BlinkerButton ButtonOta("ota",ot_callback);
|
||
BlinkerNumber Num("num-yr0");
|
||
//////////////////////////////
|
||
#line 24 "c:\\Users\\32244\\Documents\\Arduino\\generated_examples\\Blinker01\\Blinker01.ino"
|
||
void setup();
|
||
#line 38 "c:\\Users\\32244\\Documents\\Arduino\\generated_examples\\Blinker01\\Blinker01.ino"
|
||
void loop();
|
||
#line 77 "c:\\Users\\32244\\Documents\\Arduino\\generated_examples\\Blinker01\\Blinker01.ino"
|
||
void otaSuccess();
|
||
#line 24 "c:\\Users\\32244\\Documents\\Arduino\\generated_examples\\Blinker01\\Blinker01.ino"
|
||
void setup() {
|
||
Serial.begin(115200);
|
||
Blinker.begin(auth, ssid, pswd);
|
||
BLINKER_DEBUG.stream(Serial);
|
||
pinMode(LED_BUILTIN, OUTPUT);
|
||
BLINKER_TAST_INIT(); //保持Blinker连接的函<E79A84>?
|
||
Blinker.attachData(none_callback); //绑定数据输入,但是没有绑定的控件的回调函<E8B083>?
|
||
httpsOtaTurnOn();
|
||
while (!Blinker.connected()) {
|
||
Serial.printf("connect to ssid: %s failed\n",ssid);
|
||
delay(1000);
|
||
}
|
||
}
|
||
/****************************/
|
||
void loop(){
|
||
delay(5000);
|
||
}
|
||
//////////////////////////////////
|
||
|
||
void button1_callback(const String & state){
|
||
static int cont = 0;
|
||
|
||
if(cont<100) cont++;
|
||
else cont = 0;
|
||
Serial.println("Firmware local version");
|
||
if(state=="on"){ //开灯
|
||
digitalWrite(LED_BUILTIN,ON);
|
||
BLINKER_LOG("get button state:", state);
|
||
Button1.icon("fa-light fa-lightbulb-on");
|
||
Button1.print("on");
|
||
}else{ //关灯
|
||
digitalWrite(LED_BUILTIN,OFF);
|
||
BLINKER_LOG("get button state:", state);
|
||
Button1.icon("fa-light fa-lightbulb");
|
||
Button1.print("off");
|
||
}
|
||
Num.print(cont);
|
||
}
|
||
void none_callback(const String & data){
|
||
|
||
Serial.println(data.c_str());
|
||
}
|
||
void ot_callback(const String & state){
|
||
if (state=="on")
|
||
{
|
||
Blinker.print("hello\n");
|
||
ButtonOta.print("on");
|
||
httpsOtaStart();
|
||
}else if (state == "off")
|
||
{
|
||
ButtonOta.print("off");
|
||
}
|
||
}
|
||
void otaSuccess(){
|
||
Blinker.print("OTA Success...\n");
|
||
Blinker.print("Latter will restart...");
|
||
}
|