本帖最后由 skygz 于 2020-6-11 17:19 编辑
//使用这句就会出现异常
Blinker.begin(auth, WiFi.SSID().c_str(),WiFi.psk().c_str());
//直接指定WIFI参数, 则使用正常
Blinker.begin(auth, ssid, pswd);
//---------------------------------------------------------------------------------------
#define BLINKER_WIFI
#include <Blinker.h>
#include <WiFiManager.h>
//for LED status
#include <Ticker.h>
char auth[] = "*********";
//char ssid[] = "SKY";
//char pswd[] = "12345678";
// 新建组件对象
BlinkerButton Button1("btn-switch");
bool oState = false;
int Pin = 0; //定义控制引脚
Ticker ticker;
void tick();
// 按下按键即会执行该函数
void button1_callback(const String & state)
{
BLINKER_LOG("get button state: ", state);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
digitalWrite(Pin, !digitalRead(Pin));
}
// 如果未绑定的组件被触发,则会执行其中内容
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
}
void setup()
{
// 初始化串口
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
// 初始化有LED的IO
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
pinMode(Pin, OUTPUT); //定义io口为输出
digitalWrite(Pin, HIGH); //定义io默认电平
//闪烁
ticker.attach(0.6, tick);
Serial.println("Connecting...");
WiFiManager wifiManager;
WiFi.mode(WIFI_STA);
wifiManager.setDebugOutput(true);
// 重置保存的修改 目标是为了每次进来都是去掉配置页面
wifiManager.resetSettings();
if(!wifiManager.autoConnect("ESP_AP","12345678")) {
Serial.println(F("Failed to connect. Reset and try again. . ."));
delay(3000);
ESP.restart();;
delay(5000);
}
Serial.println(F("Connected to Wifi."));
Serial.print(F("My IP:"));
Serial.println(WiFi.localIP());
ticker.detach(); //取消闪烁
digitalWrite(BUILTIN_LED, HIGH);
// 初始化blinker
Blinker.begin(auth, WiFi.SSID().c_str(),WiFi.psk().c_str()); //使用这句就会出现异常
//Blinker.begin(auth, ssid, pswd); //直接指定WIFI参数, 则使用正常
Blinker.attachData(dataRead);
Button1.attach(button1_callback);
}
void loop() {
Blinker.run();
}
/**
* 功能描述:设置LED灯闪烁,提示用户进入配置模式
*/
void tick(){
int state = digitalRead(LED_BUILTIN);
digitalWrite(LED_BUILTIN, !state);
}
//-----------------------------------------------------------------------------------
Connecting...
*WM: [1] getCoreVersion(): 2_7_1
*WM: [1] system_get_sdk_version(): 2.2.2-dev(38a443e)
*WM: [1] system_get_boot_version(): 31
*WM: [1] getFreeHeap(): 34112
*WM: [1] resetSettings
*WM: [3] WiFi station enable
*WM: [3] enableSTA PERSISTENT ON
*WM: [1] SETTINGS ERASED
*WM: [1] AutoConnect
*WM: [1] No Credentials are Saved, skipping connect
*WM: [2] Starting Config Portal
*WM: [2] AccessPoint set password is VALID
*WM: [1] 12345678
*WM: [3] WiFi station enable
*WM: [2] Disabling STA
*WM: [2] Enabling AP
*WM: [1] StartAP with SSID: ESP_AP
*WM: [1] SoftAP Configuration
*WM: [1] --------------------
*WM: [1] ssid: ESP_AP
*WM: [1] password: 12345678
*WM: [1] ssid_len: 6
*WM: [1] channel: 1
*WM: [1] authmode: 3
*WM: [1] ssid_hidden:
*WM: [1] max_connection: 4
*WM: [1] country: CN
*WM: [1] beacon_interval: 100(ms)
*WM: [1] --------------------
*WM: [1] AP IP address: 192.168.4.1
*WM: [3] setupConfigPortal
*WM: [1] Starting Web Portal
*WM: [3] dns server started with ip: 192.168.4.1
*WM: [2] HTTP server started
*WM: [2] WiFi Scan completed in 2187 ms
*WM: [2] Config Portal Running, blocking, waiting for clients...
*WM: [3] lastconxresult: WL_IDLE_STATUS
*WM: [3] Sent config page
*WM: [2] <- HTTP Root
*WM: [3] -> 192.168.4.1
*WM: [3] lastconxresult: WL_IDLE_STATUS
*WM: [2] Scan is cached 5425 ms ago
*WM: [3] -> connect.rom.miui.com
*WM: [2] <- Request redirected to captive portal
*WM: [3] -> connect.rom.miui.com
*WM: [2] <- Request redirected to captive portal
*WM: [2] <- HTTP WiFi save
*WM: [3] Method: POST
*WM: [3] Sent wifi save page
*WM: [2] processing save
*WM: [2] Connecting as wifi client...
*WM: [3] STA static IP:
*WM: [2] setSTAConfig static ip not set, skipping
*WM: [1] CONNECTED:
*WM: [1] Connecting to NEW AP: SKY
*WM: [3] Using Password: 12345678
*WM: [3] WiFi station enable
*WM: [3] enableSTA PERSISTENT ON
*WM: [1] connectTimeout not set, ESP waitForConnectResult...
*WM: [2] Connection result: WL_CONNECTED
*WM: [3] lastconxresult: WL_CONNECTED
*WM: [1] Connect to new AP [SUCCESS]
*WM: [1] Got IP Address:
*WM: [1] 192.168.100.173
*WM: [2] disconnect configportal
*WM: [2] restoring usermode STA
*WM: [2] wifi status: WL_CONNECTED
*WM: [2] wifi mode: STA
*WM: [1] config portal exiting
Connected to Wifi.
My IP:192.168.100.173
SSID: SKY
PASS: 12345678
[171712]
[171713]
__ __ __
/\ \ /\ \ __ /\ \ v0.3.4
\ \ \___ \ \ \ /\_\ ___\ \ \/'\ __ _ __
\ \ '__`\\ \ \ \/\ \ /' _ `\ \ , < /'__`\/\`'__\
\ \ \L\ \\ \ \_\ \ \/\ \/\ \ \ \\`\ /\ __/\ \ \./
\ \_,__/ \ \__\\ \_\ \_\ \_\ \_\ \_\ \____\\ \_\
\/___/ \/__/ \/_/\/_/\/_/\/_/\/_/\/____/ \/_/
To better use blinker with your IoT project!
Download latest blinker library here!
=> https://github.com/blinker-iot/blinker-library
[171757] Connecting to SKY
[172167] ESP8266_MQTT initialized...
[172167]
===========================================================
================== Blinker Timer loaded! ==================
Warning!EEPROM address 1536-2431 is used for Blinker Timer!
============= DON'T USE THESE EEPROM ADDRESS! =============
===========================================================
*WM: [3] unloading
[174231] WiFi Connected.
[174231] IP Address:
[174231] 192.168.100.173
Exception (29):
epc1=0x40212201 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffbc0 end: 3fffffc0 offset: 0190
3ffffd50: 3fff0bf8 3fff0c08 3fff0c04 4020ab7d
3ffffd60: 00000000 00000000 3fff3a94 3fff3e0c
3ffffd70: 0011001f 00ff05bc 3f0101bb 40001388
3ffffd80: 3fff3e34 004e004f 00ff00c8 70747468
3ffffd90: 3fff0073 85ff05bc 3fff52ec 0000001f
3ffffda0: 00000000 3fff6bdc 0011001f 00ff3abf
3ffffdb0: 3fff3a00 3fff3a94 80ff3aa4 00000000
3ffffdc0: 00000000 00000000 ffffffff 4022cc01
3ffffdd0: 00000000 0000000a 33373100 4022a63d
3ffffde0: 80fffe50 00000000 00000000 3fffbe00
3ffffdf0: 3fff1a74 3fff1b7f 3fff1dd4 3fff1e74
3ffffe00: 3fff1e64 3fff1dd4 3ffffe20 3fffbe00
3ffffe10: 0037003f 80ff115c 3fff1f00 0027002f
3ffffe20: 80000031 0000000a 3ffffe4c 40227589
3ffffe30: 3fffbde4 0020002f 00fffe7a 79696c61
3ffffe40: 40006e75 86ff115c 3fff3eb4 000b000f
3ffffe50: 00000000 3fffbdac 0020002f 00227589
3ffffe60: 3fff5314 001a001f 00000a0d 3fff3e8c
3ffffe70: 0018001f 00000002 3fff3c5c 0149014f
3ffffe80: 00000000 3fff633c 0067006f 00000000
3ffffe90: 3fff6b44 003b003f 00c6a7f0 3fff6c9c
3ffffea0: 0011001f 00ff115c 40100498 0002a8a1
3ffffeb0: 3ffffe00 3ffffdf0 00000000 3fff3a94
3ffffec0: 3fffbe8c 00000000 3fff0c0c 4020fc59
3ffffed0: 40218c78 3fffff00 3fffff00 3fff12b8
3ffffee0: 3fffdad0 00000000 3fff05bc 4020ad61
3ffffef0: 007a1200 00000000 3fff05bc 4020af19
3fffff00: 40105461 033e99fd 3fff1318 00000000
3fffff10: 3ffef890 3fff1318 0000000a 3fff12b8
3fffff20: 3fffdad0 3fff1318 0000000a 402292ac
3fffff30: 3fffdad0 00000000 3fff05bc 4020af5a
3fffff40: 3fffdad0 00000000 3fff00c8 4020f69c
3fffff50: 0000203a 80efeffe 3fff5100 000e000f
3fffff60: 007a1200 359c59bf 000f0000 80efeffe
3fffff70: 00000000 feefeffe 80efeffe 3fff5100
3fffff80: 00000000 00000000 00000001 3fff12b8
3fffff90: 3fffdad0 00000000 3fff1278 4020fa68
3fffffa0: 3fffdad0 00000000 3fff1278 402293c4
3fffffb0: feefeffe feefeffe 3ffe85b0 40100ee5
<<<stack<<<
last failed alloc call: 4020AB7D(2280)
ets Jan 8 2013,rst cause:2, boot mode3,6)
load 0x4010f000, len 3456, room 16
tail 0
chksum 0x84
csum 0x84
va5432625
~ld
|