对服务器的第二个请求后,ESP8266重新启动异常9

问题描述

我是这个社区的新手,我期待着您在此问题上的帮助。 我在两个ESP8266模块之间进行通信。其中一个作为服务器/访问点,另一个作为客户端。这两个模块之间的配置和连接令人满意,并且也是通信的一部分。但是,在Client发出第一个请求(Begin和GET)并且server做出响应之后,对于第二个Client/Server请求,客户端将重新启动下一条消息或异常。>

Exception (9):
epc1=0x40207204 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0036006a depc=0x00000000

也就是说,对服务器根目录的第一个请求得到了答复,而对/data的第二个请求则导致在Client上发生了上述重启。

查看了堆栈异常解码器后,我发现代码(9)表示9:LoadStoreAlignmentCause Load or store to an unaligned address.

然后,我为此问题尝试了不同的解决方案

  • 删除所有Flash内容
  • http.end()
  • 将宏delay()更改为delayMicroseconds()
  • 还有一些

但是什么都没有。

请帮我解决这个问题。服务器和客户端的代码为:

客户:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define LED_PIN 2

const char* ssid     = "Mi_Servidor";
const char* password = "";
const char* host = "http://192.168.4.1";
int counter=1,httpCode=0;

HTTPClient http;

void peticion (int httpCode){
  String mensaje;
  if(httpCode == 200) {
    mensaje = http.getString();
    Serial.println(mensaje);
    } 
    else {
      Serial.print("[HTTP] GET... failed,no connection or no HTTP server\n");
    }
}

void setup() {
  pinMode(LED_PIN,OUTPUT);
  Serial.begin(115200);
  delay(10);
  Serial.print("Conectando a ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid,password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 
  Serial.println("WiFi conectada"); 
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  
}

void loop(){
  counter++;
  int modulo=counter%2;

  if(WiFi.status() != WL_CONNECTED){
    WiFi.begin(ssid,password);
    while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    }
  }
  else{
    Serial.print("[HTTP] begin...\n");
  
    if(modulo==0) http.begin("192.168.4.1",80);   //HTTp   
    else http.begin("192.168.4.1",80,"/data");   //HTTp
    
    httpCode = http.GET();
        
    Serial.print("httpCode: ");  //JJ
    Serial.println(httpCode);  //JJ
    
    peticion(httpCode);
    delay(20);     
    }
  Serial.println("End Loop!");
}

和服务器:

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

#define LED_PIN 2

void handle_datos();

const char WiFiClave[] = "";  //Sin clave
const char AP_Nombre[] = "Mi_Servidor";
int val;
String MiMessage = "Message to transmit:\n\r";

ESP8266WebServer server(80);

void handle_data() {
  server.send(200,"text/plain",MiMessage);
  delay(1000);
  }

void handle_root() {
  server.send(200,"Mi_root");
  delay(1000);
  }

void setup() {
  pinMode(LED_PIN,OUTPUT);
  Serial.begin(115200);
  pinMode(LED_PIN,OUTPUT);
  digitalWrite(LED_PIN,LOW);
  WiFi.mode(WIFI_AP);
  WiFi.softAP(AP_Nombre,WiFiClave); 
  server.on("/data",handle_data); 
  server.on("/",handle_root); 
  server.begin();

//  for (int i = 0; i <= 3999; i++) {
//    MiMessage.concat(String(i));
//    MiMessage.concat(";");
//  }
  Serial.println();
  Serial.println(MiMessage); 

  Serial.println("\nServidor ready... ");
}

void loop() {
  server.handleClient();
  delay(100);
}

预先感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...