Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Nodemcu have an exception when change http fingerprint to communication with https #264

Closed
xang555 opened this issue May 18, 2017 · 3 comments
Labels

Comments

@xang555
Copy link

xang555 commented May 18, 2017

Basic Infos

Hardware

Hardware: Nodemcu v0.9

Description

when i using firebase-arduino for get data from firebase database and after that. i'm send data to my api by using ESP8266HTTPClient. nodemcu have an exception, I think this exception maybe happen from i'm change http fingerprint for communication with my api that using https because when i using http. nodemcu don't have any exception.

Settings in IDE

Module: Nodemcu 0.9 (ESP-12 Modulue)
Flash Size: 4MB/3MB
CPU Frequency: 80Mhz
Upload Using: SERIAL

Sketch

some my code

#include <Arduino.h>

void setup() {

Serial.begin(250000);
//set pin mode
pinMode(SETTING_MODE,INPUT);
pinMode(STATE_CONNECTION,OUTPUT);
pinMode(gas_sensor, INPUT); //Set gas sensor as input

}

void loop() {

  static uint8_t state = 0;

  switch(state) {

  case 0 :
    Serial.println("check Mode");
    checkMode(state); //check mode
  break;

  case 1 :
    //auto connect wifi and firebase
    Serial.println("auto connect wifi and firebase");
   state = AutoConnectWifiAndFirebase();


  break;

  case 2 :
  //connect wifi
     Serial.println("connect wifi and firebase");
     state = ConnectwifiAndFirebase();

  break;

  case 3 :
  //handle with firebase
   Serial.println("handle firebase");
   handleFirebaseController(state);

  break;

  default :
  state = 0;

  }

  delay(500);

}


void handleFirebaseController (uint8_t& state) {

while (true) {

  if (isEnterOfflineMode()) {
      state = 0 ;
      return;
  }

  AnswerUplink();  
  handleGasSensor(); // send sensor value to Firebase
  checkConnection(); //check connection
  delay(100);

}

} // handle working in Firebase


void AnswerUplink() {

static uint8_t uplink = 0;
uint8_t state_uplink= Firebase.getInt(uplink_path);

// handle error
if (Firebase.failed()) {
    Serial.print("get status uplink failed:");
    Serial.println(Firebase.error());
    count_connection_lose++;
    return;
}

if (state_uplink != uplink) {
uint8_t ack = state_uplink;
Firebase.setInt(ack_path,ack);
// handle error
if (Firebase.failed()) {
    Serial.print("set status ack failed:");
    Serial.println(Firebase.error());
    count_connection_lose++;
    return;
}

uplink = state_uplink;

}

} // check if have uplink signal


void handleGasSensor() {

  double ppm = getSensorValue();
  Serial.println(ppm);
 static int repeatTime = 0;
 static bool isNotify = false;

  if (ppm > 2000) {

    if (repeatTime > 100) {
      isNotify = false;
    }

    if (!isNotify) {
        AlertNotification(); //send fcm
        isNotify = true;
    }

    repeatTime ++;

  }

} //handle Sensor

void AlertNotification() {

      http.begin(fcm_server,"A3 41 68 37 4D 94 36 8D 01 2C 68 49 05 58 D2 CC 0E 0B DE F4"); // url test server api
      http.addHeader("Content-Type", "application/x-www-form-urlencoded");
      http.addHeader("Authorization", fcm_server_key);
      String payload = "sdid="+DEVICE_ID;
      int httpCode =  http.sendRequest("POST",payload);

  if (httpCode > 0 ) {

  if (httpCode == HTTP_CODE_OK) {
     Serial.println(http.getString());
   }else{
     Serial.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
   }

   http.end();

 }else {
   count_connection_lose++;
 }


} //alert notification


double getSensorValue(){

  float sensor_volt; //Define variable for sensor voltage
  float RS_gas; //Define variable for sensor resistance
  float ratio; //Define variable for ratio
  float sensorValue = analogRead(gas_sensor); //Read analog values of sensor

  sensor_volt = sensorValue * (5.0 / 1024.0); //Convert average to voltage
  RS_gas = ((5.0 * 20.0) / sensor_volt) - 20.0; //Calculate RS in fresh air
  ratio = RS_gas / R0;   // Get ratio RS_gas/RS_air

  double ppm_log = (log10(ratio) - b) / m; //Get ppm value in linear scale according to the the ratio value
  double ppm = pow(10, ppm_log); //Convert ppm value to log scale
  //double percentage = ppm / 10000; //Convert to percentage

  return ppm;

} // get gass sensor

nodemcu have an exception when ran in this statement

......

AlertNotification(); //send fcm

.....

void AlertNotification() {

      http.begin(fcm_server,"A3 89 90 37 4D 94 36 8D 01 2C 68 49 05 58 D2 CC 0E 0B DE F4"); // url test server api
      http.addHeader("Content-Type", "application/x-www-form-urlencoded");
      http.addHeader("Authorization", fcm_server_key);
      String payload = "sdid="+DEVICE_ID;
      int httpCode =  http.sendRequest("POST",payload);

  if (httpCode > 0 ) {

  if (httpCode == HTTP_CODE_OK) {
     Serial.println(http.getString());
   }else{
     Serial.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
   }

   http.end();

 }else {
   count_connection_lose++;
 }

} //alert notification

Debug Messages

Exception (29):
epc1=0x4000df64 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3fff1fc0 end: 3fff2470 offset: 01a0

>>>stack>>>
3fff2160:  00000080 3fff5914 3fffb15c 4022c1c4  
3fff2170:  3fffba6c 3fff5914 3fffb15c 4022cbb1  
3fff2180:  3fff7004 19c41f67 f00f3c34 00000020  
3fff2190:  3fffa19c 3fff5914 3fff9d9c 00000020  
3fff21a0:  3fffa19c 3fff5914 00000010 4022ceb0  
3fff21b0:  3fff36ac 3fff7034 3fff9d9c 00000001  
3fff21c0:  00000001 3fff9d9c 3fff790d 4022bc88  
3fff21d0:  00000200 3fff6fd4 3fff7787 00000000  
3fff21e0:  00000200 3fff6fd4 3fff7787 4022deb1  
3fff21f0:  3fff2220 00000000 000001d0 00000030  
3fff2200:  eeff0328 07859941 1a3d6898 00000004  
3fff2210:  00000004 3fff76c4 3fff7781 40229fbc  
3fff2220:  7c2e0203 ad010691 41178fbf 3bc9d677  
3fff2230:  cda0a69f 34d97fb7 eb7324bd 87740707  
3fff2240:  65fbed34 96646a5b fa433f60 0328ff58  
3fff2250:  00000004 3fff7781 3fff76c4 4022a3bd  
3fff2260:  e7d8ad06 081f1987 87f287cc 3fff3664  
3fff2270:  00000000 00000004 00000004 40203edb  
3fff2280:  3fff7785 3fff7781 3fff926c 00000a40  
3fff2290:  00000abb 3fff8224 00000017 00000004  
3fff22a0:  3fff76c4 3fff7781 00000004 00000004  
3fff22b0:  00000004 3fff7781 3fff76c4 40229db4  
3fff22c0:  00000000 3fff7781 3fff76c4 4022a15c  
3fff22d0:  00000018 3fff3c34 00000019 401004d8  
3fff22e0:  3fff2330 0000000e 00000010 00000000  
3fff22f0:  3fff39c4 3fff3c34 3fff76c4 01000000  
3fff2300:  3fff2330 3fff3b44 3fff76c4 40229f0c  
3fff2310:  40203cec 000008d0 3fff1450 00001387  
3fff2320:  00002ad0 3fff3b44 3fff35cc 4020437d  
3fff2330:  000001bb 3fff583c 3fff3b44 40203712  
3fff2340:  1c19d067 00000000 3fff2380 3fff62dc  
3fff2350:  000001bb 3fff3b44 3fff3c34 402046d1  
3fff2360:  3ffe9ee8 1c19d067 3ffe9ee8 1c19d067  
3fff2370:  3fffdad0 00000000 3fff0884 40209358  
3fff2380:  00000000 00000b40 00000168 00000168  
3fff2390:  00000000 00000012 3fff0884 40209b28  
3fff23a0:  00000020 3fff2400 3fff2400 4020a7fc  
3fff23b0:  3fff3b1c 00000012 3fff2400 4020a84b  
3fff23c0:  3ffe91dc 000006a9 3fff2400 4020a87d  
3fff23d0:  3fffdad0 3fff087c 3fff2400 3fff1448  
3fff23e0:  3fffdad0 3fff087c 3fff0884 40209bd6  
3fff23f0:  3fffdad0 3fff087c 3fff0884 402028f3  
3fff2400:  3fff62dc 0000001f 00000012 3fff3b1c  
3fff2410:  0000001f 00000012 3fff1448 4020a5d0  
3fff2420:  3fffdad0 3fff087c 3fff0878 40202aa1  
3fff2430:  3fffdad0 00000000 3fff0881 40202aff  
3fff2440:  00000000 00000000 3fff0881 40202b82  
3fff2450:  3fffdad0 00000000 3fff1441 4020b3f4  
3fff2460:  feefeffe feefeffe 3fff1450 40100718  
<<<stack<<<

decode this Exception

Decoding 29 results
0x4022c1c4: bi_clone at /Users/igrokhotkov/e/axtls/e1/crypto/bigint.c line 265
0x4022cbb1: bi_barrett at /Users/igrokhotkov/e/axtls/e1/crypto/bigint.c line 1285
0x4022ceb0: precompute_slide_window at /Users/igrokhotkov/e/axtls/e1/crypto/bigint.c line 1323
:  (inlined by) bi_mod_power at /Users/igrokhotkov/e/axtls/e1/crypto/bigint.c line 1372
0x4022bc88: trim at /Users/igrokhotkov/e/axtls/e1/crypto/bigint.c line 1197
0x4022deb1: RSA_public at /Users/igrokhotkov/e/axtls/e1/crypto/rsa.c line 242
:  (inlined by) RSA_encrypt at /Users/igrokhotkov/e/axtls/e1/crypto/rsa.c line 276
0x40229fbc: send_client_key_xchg at /Users/igrokhotkov/e/axtls/e1/ssl/tls1_clnt.c line 352
0x4022a3bd: do_clnt_handshake at /Users/igrokhotkov/e/axtls/e1/ssl/tls1_clnt.c line 109
0x40203edb: ClientContext::_consume(unsigned int) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClientSecure.cpp line 517
:  (inlined by) ClientContext::read(char*, unsigned int) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src\include/ClientContext.h line 175
0x40229db4: do_handshake at /Users/igrokhotkov/e/axtls/e1/ssl/tls1.c line 1481
:  (inlined by) basic_read at /Users/igrokhotkov/e/axtls/e1/ssl/tls1.c line 1357
0x4022a15c: do_client_connect at /Users/igrokhotkov/e/axtls/e1/ssl/tls1_clnt.c line 154
0x401004d8: malloc at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266\umm_malloc/umm_malloc.c line 1664
0x40229f0c: ssl_read at /Users/igrokhotkov/e/axtls/e1/ssl/tls1.c line 265
0x40203cec: WiFiClient::_s_connected(void*, void*, signed char) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClient.cpp line 149
0x4020437d: SSLContext::connect(ClientContext*, char const*, unsigned int) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClientSecure.cpp line 517
:  (inlined by) WiFiClientSecure::_connectSSL(char const*) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClientSecure.cpp line 279
0x40203712: WiFiClient::connect(IPAddress, unsigned short) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClient.cpp line 149
0x402046d1: WiFiClientSecure::connect(char const*, unsigned short) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClientSecure.cpp line 269
0x40209358: HTTPClient::connect() at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.cpp line 197
0x40209b28: HTTPClient::sendRequest(char const*, unsigned char*, unsigned int) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.cpp line 197
0x4020a7fc: String::changeBuffer(unsigned int) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/WString.cpp line 720
0x4020a84b: String::reserve(unsigned int) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/WString.cpp line 720
0x4020a87d: String::copy(char const*, unsigned int) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/WString.cpp line 720
0x40209bd6: HTTPClient::sendRequest(char const*, String) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.cpp line 197
0x402028f3: AlertNotification() at C:\Users\xang\Desktop\GassSensor/GassSensor.ino line 355
0x4020a5d0: Print::println(double, int) at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Print.cpp line 76
0x40202aa1: handleGasSensor() at C:\Users\xang\Desktop\GassSensor/GassSensor.ino line 340
0x40202aff: handleFirebaseController(unsigned char&) at C:\Users\xang\Desktop\GassSensor/GassSensor.ino line 286
0x40202b82: loop at C:\Users\xang\Desktop\GassSensor/GassSensor.ino line 87
0x4020b3f4: loop_wrapper at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/core_esp8266_main.cpp line 56
0x40100718: cont_norm at C:\Users\xang\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/cont.S line 109

i wish you have sufficient information about my problem, and understand my post

@proppy proppy added the question label Sep 8, 2017
@proppy
Copy link
Contributor

proppy commented Sep 8, 2017

Do you still have the issue after updating to #277 ?

@proppy
Copy link
Contributor

proppy commented Jun 15, 2018

Filed #347 to update the FCM fingerprint.

@proppy proppy closed this as completed Jun 15, 2018
@agha96
Copy link

agha96 commented Jun 22, 2018

My node mcu is not updating values from firebase. Do i have to add exception in firebase?
my code is

#include <FirebaseArduino.h>
#include <stdint.h>

#include <ESP8266WiFi.h>
#define FIREBASE_HOST "wheelchairremote.firebaseio.com" //Your Firebase Project URL goes here without "http:" , "" and "/"
#define FIREBASE_AUTH "QihgCV8Dwoq96h7xviAfEY1drPwOZU9LZV4nskTU" //Your Firebase Database Secret goes here
#define WIFI_SSID "Roman Ganssters" //your WiFi SSID for which yout NodeMCU connects
#define WIFI_PASSWORD "skrt1339"//Password of your wifi network
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //baud rate ,if you want to see the process in the serial monitor ,same baud rate should be set.
WiFi.begin(WIFI_SSID,WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status()!=WL_CONNECTED){
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected:");
Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
Firebase.stream("Forward");
Firebase.set("Forward",0);
}
void firebasereconnect()
{
Serial.println("Trying to reconnect");
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

}
int l;
void loop() {

if (Firebase.failed()) {
Serial.print("setting number failed:");
Serial.println(Firebase.error());
firebasereconnect();
return;
}
l=Firebase.getInt("Forward");//The value read from the firebase is read in the form of String and is converted into Integer
Serial.println(l);
if(l==1){

  Serial.println("lightON");
}
else if(l==0){
  
  Serial.println("lightOFF");
}

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants