ESP8266 WiFiClientSecure 异常 9
ESP8266 WiFiClientSecure Exception 9
我在尝试将我的 ESP8266 连接到我的网络服务器时遇到了一些问题。
我想连接到 Web 服务器,然后通过 REST-API 将信息发送到服务器。
不幸的是,我的程序在连接到服务器时崩溃了。
这是我的代码:
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#ifndef STASSID
#define STASSID "SSID" //SSID
#define STAPSK NULL //Password
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "IP-Adress"; //Load Balancer IP
const uint16_t httpsPort = 443; //Load Balancer Port
// Use web browser to view and copy SHA1 fingerprint of the certificate
const char fingerprint[] PROGMEM = "FI NG ER PR IN T0";
void setup() {
Serial.begin(115200);
Serial.println("[INFO]\t\tStarting GPS Service");
Serial.printf("[INFO] LAN:\tConnecting to WiFi '%s'", ssid);
WiFi.mode(WIFI_STA); //Setting WiFi Client Mode
WiFi.begin(ssid, password); //Connecting to WiFi
while (WiFi.status() != WL_CONNECTED) {
delay(250); Serial.print("."); //Waiting for WiFi Connection
}
Serial.print("\n");
Serial.printf("[INFO] LAN:\tSuccessfully Connected to WiFi '%s'\n", ssid);
Serial.print("[INFO] LAN:\tLocal IP-Address '");
Serial.print(WiFi.localIP());
Serial.print("'\n");
Serial.printf("[INFO] WAN:\tConnecting to %s:%d\n" ,host, httpsPort);
WiFiClientSecure client; // Use WiFiClientSecure class to create TLS connection
Serial.printf("[INFO] WAN:\tUsing fingerprint '%s'\n", fingerprint);
client.setFingerprint(fingerprint); //Set Fingerprint for WiFiClientSecure
if (client.connect(host, httpsPort)) { //Here my Programm is Crashing
Serial.printf("[INFO] WAN:\tSuccessfully Connected to WAN-IP '%s'\n", host);
} else {
Serial.println("[ERROR] WAN:\tConnection failed!");
return;
}
Serial.println("[INFO] WAN:\tClosing connection");
}
void loop() {
}
此时程序崩溃if (client.connect(host, httpsPort)) {
这是输出:
[INFO] Starting GPS Service
[INFO] LAN: Connecting to WiFi 'SSID'.
[INFO] LAN: Successfully Connected to WiFi 'SSID'
[INFO] LAN: Local IP address '192.168.178.*'
[INFO] WAN: Connecting to Server-Adress
[INFO] WAN: Using fingerprint 'FI NG ER PR IN T0'
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (9):
epc1=0x40207874 epc2=0x00000000 epc3=0x00000000 excvaddr=0xfeefeffe depc=0x00000000
>>>stack>>>
...
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
当我解码堆栈时,我得到以下信息:
Decoding 12 results
0x40203aab: BearSSL::WiFiClientSecure::_connectSSL(char const*) at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.cpp line 1093
0x40205878: esp_yield at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\cores\esp8266/core_esp8266_main.cpp line 119
0x40205e72: __delay at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\cores\esp8266/core_esp8266_wiring.cpp line 54
0x402026c0: WiFiClient::connect(IPAddress, unsigned short) at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\libraries\ESP8266WiFi\src/include/ClientContext.h line 144
: (inlined by) WiFiClient::connect(IPAddress, unsigned short) at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\libraries\ESP8266WiFi\src/WiFiClient.cpp line 170
0x40203c81: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.cpp line 229
0x40207e20: precache at ?? line ?
0x40207e20: precache at ?? line ?
0x40250e56: sleep_reset_analog_rtcreg_8266 at ?? line ?
0x40201138: setup at C:\Users\Username\Desktop\Beispiele\WiFi/WiFi.ino line 58
0x40207cc0: precache at ?? line ?
0x40205988: loop_wrapper() at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\cores\esp8266/core_esp8266_main.cpp line 194
0x40100bd5: cont_wrapper at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\cores\esp8266/cont.S line 81
有人知道如何解决这个问题吗?
提前致谢,
帕特里克
我能够解决这个问题,完全重新安装 Arduino Portable IDE 对我有用。
我在尝试将我的 ESP8266 连接到我的网络服务器时遇到了一些问题。 我想连接到 Web 服务器,然后通过 REST-API 将信息发送到服务器。
不幸的是,我的程序在连接到服务器时崩溃了。
这是我的代码:
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#ifndef STASSID
#define STASSID "SSID" //SSID
#define STAPSK NULL //Password
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "IP-Adress"; //Load Balancer IP
const uint16_t httpsPort = 443; //Load Balancer Port
// Use web browser to view and copy SHA1 fingerprint of the certificate
const char fingerprint[] PROGMEM = "FI NG ER PR IN T0";
void setup() {
Serial.begin(115200);
Serial.println("[INFO]\t\tStarting GPS Service");
Serial.printf("[INFO] LAN:\tConnecting to WiFi '%s'", ssid);
WiFi.mode(WIFI_STA); //Setting WiFi Client Mode
WiFi.begin(ssid, password); //Connecting to WiFi
while (WiFi.status() != WL_CONNECTED) {
delay(250); Serial.print("."); //Waiting for WiFi Connection
}
Serial.print("\n");
Serial.printf("[INFO] LAN:\tSuccessfully Connected to WiFi '%s'\n", ssid);
Serial.print("[INFO] LAN:\tLocal IP-Address '");
Serial.print(WiFi.localIP());
Serial.print("'\n");
Serial.printf("[INFO] WAN:\tConnecting to %s:%d\n" ,host, httpsPort);
WiFiClientSecure client; // Use WiFiClientSecure class to create TLS connection
Serial.printf("[INFO] WAN:\tUsing fingerprint '%s'\n", fingerprint);
client.setFingerprint(fingerprint); //Set Fingerprint for WiFiClientSecure
if (client.connect(host, httpsPort)) { //Here my Programm is Crashing
Serial.printf("[INFO] WAN:\tSuccessfully Connected to WAN-IP '%s'\n", host);
} else {
Serial.println("[ERROR] WAN:\tConnection failed!");
return;
}
Serial.println("[INFO] WAN:\tClosing connection");
}
void loop() {
}
此时程序崩溃if (client.connect(host, httpsPort)) {
这是输出:
[INFO] Starting GPS Service
[INFO] LAN: Connecting to WiFi 'SSID'.
[INFO] LAN: Successfully Connected to WiFi 'SSID'
[INFO] LAN: Local IP address '192.168.178.*'
[INFO] WAN: Connecting to Server-Adress
[INFO] WAN: Using fingerprint 'FI NG ER PR IN T0'
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (9):
epc1=0x40207874 epc2=0x00000000 epc3=0x00000000 excvaddr=0xfeefeffe depc=0x00000000
>>>stack>>>
...
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
当我解码堆栈时,我得到以下信息:
Decoding 12 results
0x40203aab: BearSSL::WiFiClientSecure::_connectSSL(char const*) at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.cpp line 1093
0x40205878: esp_yield at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\cores\esp8266/core_esp8266_main.cpp line 119
0x40205e72: __delay at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\cores\esp8266/core_esp8266_wiring.cpp line 54
0x402026c0: WiFiClient::connect(IPAddress, unsigned short) at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\libraries\ESP8266WiFi\src/include/ClientContext.h line 144
: (inlined by) WiFiClient::connect(IPAddress, unsigned short) at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\libraries\ESP8266WiFi\src/WiFiClient.cpp line 170
0x40203c81: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.cpp line 229
0x40207e20: precache at ?? line ?
0x40207e20: precache at ?? line ?
0x40250e56: sleep_reset_analog_rtcreg_8266 at ?? line ?
0x40201138: setup at C:\Users\Username\Desktop\Beispiele\WiFi/WiFi.ino line 58
0x40207cc0: precache at ?? line ?
0x40205988: loop_wrapper() at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\cores\esp8266/core_esp8266_main.cpp line 194
0x40100bd5: cont_wrapper at C:\Users\Username\Desktop\ArduinoPortable\App\arduino\portable\packages\esp8266\hardware\esp8266.7.3\cores\esp8266/cont.S line 81
有人知道如何解决这个问题吗? 提前致谢, 帕特里克
我能够解决这个问题,完全重新安装 Arduino Portable IDE 对我有用。