modified: httpslei.cpp
parent
e0769ef4c4
commit
19d9bd7585
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -27,8 +27,8 @@ void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Blinker.begin(auth, ssid, pswd);
|
Blinker.begin(auth, ssid, pswd);
|
||||||
pinMode(5, 0x03);
|
pinMode(5, 0x03);
|
||||||
BLINKER_TAST_INIT(); //保持Blinker连接的函数
|
BLINKER_TAST_INIT(); //保持Blinker连接的函数
|
||||||
Blinker.attachData(none_callback); //绑定数据输入,但是没有绑定的控件的回调函数
|
Blinker.attachData(none_callback); //绑定数据输入,但是没有绑定的控件的回调函数
|
||||||
httpsOtaTurnOn();
|
httpsOtaTurnOn();
|
||||||
while (!Blinker.connected()) {
|
while (!Blinker.connected()) {
|
||||||
Serial.printf("connect to ssid: %s failed\n",ssid);
|
Serial.printf("connect to ssid: %s failed\n",ssid);
|
||||||
|
@ -47,12 +47,12 @@ void button1_callback(const String & state){
|
||||||
if(cont<100) cont++;
|
if(cont<100) cont++;
|
||||||
else cont = 0;
|
else cont = 0;
|
||||||
Serial.println("Firmware online version");
|
Serial.println("Firmware online version");
|
||||||
if(state=="on"){ //开灯
|
if(state=="on"){ //开灯
|
||||||
digitalWrite(5,0x1);
|
digitalWrite(5,0x1);
|
||||||
BLINKER_LOG("get button state:", state);
|
BLINKER_LOG("get button state:", state);
|
||||||
Button1.icon("fa-light fa-lightbulb-on");
|
Button1.icon("fa-light fa-lightbulb-on");
|
||||||
Button1.print("on");
|
Button1.print("on");
|
||||||
}else{ //关灯
|
}else{ //关灯
|
||||||
digitalWrite(5,0x0);
|
digitalWrite(5,0x0);
|
||||||
BLINKER_LOG("get button state:", state);
|
BLINKER_LOG("get button state:", state);
|
||||||
Button1.icon("fa-light fa-lightbulb");
|
Button1.icon("fa-light fa-lightbulb");
|
||||||
|
|
|
@ -33,8 +33,8 @@ void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Blinker.begin(auth, ssid, pswd);
|
Blinker.begin(auth, ssid, pswd);
|
||||||
pinMode(LED_PIN_LEI, OUTPUT);
|
pinMode(LED_PIN_LEI, OUTPUT);
|
||||||
BLINKER_TAST_INIT(); //保持Blinker连接的函数
|
BLINKER_TAST_INIT(); //保持Blinker连接的函数
|
||||||
Blinker.attachData(none_callback); //绑定数据输入,但是没有绑定的控件的回调函数
|
Blinker.attachData(none_callback); //绑定数据输入,但是没有绑定的控件的回调函数
|
||||||
httpsOtaTurnOn();
|
httpsOtaTurnOn();
|
||||||
while (!Blinker.connected()) {
|
while (!Blinker.connected()) {
|
||||||
Serial.printf("connect to ssid: %s failed\n",ssid);
|
Serial.printf("connect to ssid: %s failed\n",ssid);
|
||||||
|
@ -53,12 +53,12 @@ void button1_callback(const String & state){
|
||||||
if(cont<100) cont++;
|
if(cont<100) cont++;
|
||||||
else cont = 0;
|
else cont = 0;
|
||||||
Serial.println("Firmware online version");
|
Serial.println("Firmware online version");
|
||||||
if(state=="on"){ //开灯
|
if(state=="on"){ //开灯
|
||||||
digitalWrite(LED_PIN_LEI,ON);
|
digitalWrite(LED_PIN_LEI,ON);
|
||||||
BLINKER_LOG("get button state:", state);
|
BLINKER_LOG("get button state:", state);
|
||||||
Button1.icon("fa-light fa-lightbulb-on");
|
Button1.icon("fa-light fa-lightbulb-on");
|
||||||
Button1.print("on");
|
Button1.print("on");
|
||||||
}else{ //关灯
|
}else{ //关灯
|
||||||
digitalWrite(LED_PIN_LEI,OFF);
|
digitalWrite(LED_PIN_LEI,OFF);
|
||||||
BLINKER_LOG("get button state:", state);
|
BLINKER_LOG("get button state:", state);
|
||||||
Button1.icon("fa-light fa-lightbulb");
|
Button1.icon("fa-light fa-lightbulb");
|
||||||
|
|
|
@ -30,7 +30,7 @@ CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n\
|
||||||
-----END CERTIFICATE-----\n";
|
-----END CERTIFICATE-----\n";
|
||||||
|
|
||||||
HttpsOTAStatus_t otastatus;
|
HttpsOTAStatus_t otastatus;
|
||||||
extern EventGroupHandle_t *ota_status_pointer;
|
extern EventGroupHandle_t *ota_status_pointer; // which is defined in C:\Users\32244\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.4\libraries\Update\src\HttpsOTAUpdate.cpp
|
||||||
void HttpEvent(HttpEvent_t *event)
|
void HttpEvent(HttpEvent_t *event)
|
||||||
{
|
{
|
||||||
switch(event->event_id) {
|
switch(event->event_id) {
|
||||||
|
@ -83,9 +83,9 @@ void httpsOtaStart(){
|
||||||
xTaskCreate(readStaus,"readStaus", 1200,NULL,2, NULL);
|
xTaskCreate(readStaus,"readStaus", 1200,NULL,2, NULL);
|
||||||
}
|
}
|
||||||
void httpsOtaTurnOn(){
|
void httpsOtaTurnOn(){
|
||||||
HttpsOTA.onHttpEvent(HttpEvent); //启用OTA升级
|
HttpsOTA.onHttpEvent(HttpEvent); //启用OTA升级
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
第一步:在setup中调用 httpsOtaTurnOn()
|
第一步:在setup中调用 httpsOtaTurnOn()
|
||||||
第二步:在需要升级的时候调用 httpsOtaStart();
|
第二步:在需要升级的时候调用 httpsOtaStart();
|
||||||
*/
|
*/
|
|
@ -79,7 +79,7 @@ void readStaus(void *p){
|
||||||
}
|
}
|
||||||
void httpsOtaStart(){
|
void httpsOtaStart(){
|
||||||
HttpsOTA.begin(url,server_certificate);
|
HttpsOTA.begin(url,server_certificate);
|
||||||
xTaskCreate(readStaus,"readStaus", 1200,NULL,2, NULL);
|
xTaskCreate(readStaus,"readStaus", 2048,NULL,2, NULL);
|
||||||
}
|
}
|
||||||
void httpsOtaTurnOn(){
|
void httpsOtaTurnOn(){
|
||||||
HttpsOTA.onHttpEvent(HttpEvent); //启用OTA升级
|
HttpsOTA.onHttpEvent(HttpEvent); //启用OTA升级
|
||||||
|
|
Loading…
Reference in New Issue