#define BLINKER_WIFI
#define BLINKER_ESP_SMARTCONFIG
#include <Blinker.h>
#include "ESP32_CAM_SERVER.h"
char auth[] = "********";
BlinkerButton Button1("lai");
bool setup_camera = false;
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.printObject("video", "{\"str\":\"mjpg\",\"url\":\"http:"+ String(WiFi.localIP()) + "\"}");
}
void button1_callback(const String & lai) {
BLINKER_LOG("get button state: ",lai);
if (lai=="on") {
digitalWrite(4, HIGH);
// 反馈开关状态
Button1.print("on");
} else if(lai=="off"){
digitalWrite(4,LOW);
// 反馈开关状态
Button1.print("off");
}
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
pinMode(4, OUTPUT);
digitalWrite(4,LOW);
Blinker.begin(auth);//, ssid, pswd
Blinker.attachData(dataRead);
Button1.attach(button1_callback);
}
void loop()
{
Blinker.run();
if (Blinker.connected() && !setup_camera)
{
setupCamera();
setup_camera = true;
Blinker.printObject("video", "{\"str\":\"mjpg\",\"url\":\"http://"+ WiFi.localIP().toString() + "\"}");
}
//此图片的视频是添加在另外一个板块上的
|