Comments (7)
Please post your sketch here that I will try and investigate the problem.
from firebase-esp8266.
Here it is:
`#include "FirebaseESP8266.h"
#include <ESP8266WiFi.h>
#define FIREBASE_HOST "XXXXXX.firebaseio.com"
#define FIREBASE_AUTH "YYYYYYYYY"
#define FIREBASE_FCM_SERVER_KEY "ZZZZZZZZZZZZZZZZ"
#define FIREBASE_FCM_DEVICE_TOKEN_1 "XXXXXXXXXXXXXXX"
#define WIFI_SSID "RRRRRRRRRRRRRRR"
#define WIFI_PASSWORD "PPPPPPPPPPPPP"
//Define FirebaseESP8266 data object
FirebaseData firebaseData;
unsigned long sendDataPrevMillis = 0;
unsigned long sendMSGPrevMillis = 0;
String path = "/Devices";
uint16_t count = 0;
void setup()
{
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(300);
}
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.reconnectWiFi(true);
firebaseData.fcm.begin(FIREBASE_FCM_SERVER_KEY);
firebaseData.fcm.addDeviceToken(FIREBASE_FCM_DEVICE_TOKEN_1);
//firebaseData.fcm.addDeviceToken(FIREBASE_FCM_DEVICE_TOKEN_2);
firebaseData.fcm.setPriority("high");
firebaseData.fcm.setTimeToLive(1000);
if (!Firebase.beginStream(firebaseData, path))
{
Serial.println("------------------------------------");
Serial.println("Can't begin stream connection...");
Serial.println("REASON: " + firebaseData.errorReason());
Serial.println("------------------------------------");
Serial.println();
}
}
void loop()
{
//This example uses the same Firebase Data object to read/store data (get, set, update, push and delete) and stream.
//This causes some delay (for start new SSL connection) for swiching between read/store and stream operation.
//For no delay, see Different_objects_stream.ino example which uses different Firebase Data object for read/store and stream data.
if (millis() - sendMSGPrevMillis > 10000){
sendMSGPrevMillis = millis();
firebaseData.fcm.setNotifyMessage("Notification"+String(random(0xffff)), "Hello World! " + String(random(0xffff)));
if (Firebase.sendMessage(firebaseData, 0))//send message to recipient index 0
{
Serial.println("PASSED");
Serial.println(firebaseData.fcm.getSendResult());
Serial.println("------------------------------------");
Serial.println();
}
else
{
Serial.println("FAILED");
Serial.println("REASON: " + firebaseData.errorReason());
Serial.println("------------------------------------");
Serial.println();
}
}
if (millis() - sendDataPrevMillis > 15000)
{
sendDataPrevMillis = millis();
count++;
Serial.println("------------------------------------");
Serial.println("Set string...");
if (Firebase.setString(firebaseData, path + "/String", "Hello World! " + String(count)))
{
Serial.println("PASSED");
Serial.println("PATH: " + firebaseData.dataPath());
Serial.println("TYPE: " + firebaseData.dataType());
Serial.print("VALUE: ");
if (firebaseData.dataType() == "int")
Serial.println(firebaseData.intData());
else if (firebaseData.dataType() == "float")
Serial.println(firebaseData.floatData(), 5);
else if (firebaseData.dataType() == "double")
Serial.println(firebaseData.doubleData(), 9);
else if (firebaseData.dataType() == "boolean")
Serial.println(firebaseData.boolData() == 1 ? "true" : "false");
else if (firebaseData.dataType() == "string")
Serial.println(firebaseData.stringData());
else if (firebaseData.dataType() == "json")
Serial.println(firebaseData.jsonData());
Serial.println("------------------------------------");
Serial.println();
}
else
{
Serial.println("FAILED");
Serial.println("REASON: " + firebaseData.errorReason());
Serial.println("------------------------------------");
Serial.println();
}
//Pause WiFi client from all Firebase calls and use shared SSL WiFi client
if (firebaseData.pauseFirebase(true))
{
WiFiClientSecure client = firebaseData.getWiFiClient();
//Use the client to make your own http connection...
}
else
{
Serial.println("------------------------------------");
Serial.println("Can't pause the WiFi client...");
Serial.println("------------------------------------");
Serial.println();
}
//Unpause WiFi client from Firebase task
firebaseData.pauseFirebase(false);
}
if (!Firebase.readStream(firebaseData))
{
Serial.println("------------------------------------");
Serial.println("Can't read stream data...");
Serial.println("REASON: " + firebaseData.errorReason());
Serial.println("------------------------------------");
Serial.println();
}
if (firebaseData.streamTimeout())
{
Serial.println("Stream timeout, resume streaming...");
Serial.println();
}
if (firebaseData.streamAvailable())
{
Serial.println("------------------------------------");
Serial.println("Stream Data available...");
Serial.println("STREAM PATH: " + firebaseData.streamPath());
Serial.println("EVENT PATH: " + firebaseData.dataPath());
Serial.println("DATA TYPE: " + firebaseData.dataType());
Serial.println("EVENT TYPE: " + firebaseData.eventType());
Serial.print("VALUE: ");
if (firebaseData.dataType() == "int")
Serial.println(firebaseData.intData());
else if (firebaseData.dataType() == "float")
Serial.println(firebaseData.floatData());
else if (firebaseData.dataType() == "boolean")
Serial.println(firebaseData.boolData() == 1 ? "true" : "false");
else if (firebaseData.dataType() == "string")
Serial.println(firebaseData.stringData());
else if (firebaseData.dataType() == "json")
Serial.println(firebaseData.jsonData());
Serial.println("------------------------------------");
Serial.println();
}
}`
After first call Firebase.sendMessage(firebaseData, 0) I got this errors:
Can't read stream data...
Fatal exception 3(LoadStoreErrorCause):
epc1=0x4021edc0, epc2=0x00000000, epc3=0x00000000, excvaddr=0x402604a3, depc=0x00000000
Exception (3):
epc1=0x4021edc0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x402604a3 depc=0x00000000
stack>>>
ctx: cont
sp: 3ffffd30 end: 3fffffc0 offset: 01a0
3ffffed0: 3ffe895f 3ffeed30 ffffffff 3ffeee38
3ffffee0: 3ffe895f 3ffeed30 ffffffff 40202294
3ffffef0: 3fffff10 3ffeedc8 3fffff30 40210658
3fffff00: 3ffe8765 3fffff50 3ffeec00 40204a2a
3fffff10: 3ffef38c 3ffeed30 3ffeedc8 4020ffbc
3fffff20: 3ffe8765 3ffeedc8 3ffeec00 40201885
3fffff30: 53414552 203a4e4f 00203a00 402255e2
3fffff40: 3fffff64 3ffeec00 3fffff80 3ffeee38
3fffff50: 00000000 00000000 fffeec00 00000000
3fffff60: 00000000 fffeec00 00000000 00000000
3fffff70: fffeed30 3ffeec00 3ffeedc8 402011cd
3fffff80: 00000000 00000000 ffefef00 00000000
3fffff90: 00000000 00000000 00000001 3ffeee38
3fffffa0: 3fffdad0 00000000 3ffeee04 40210cd4
3fffffb0: feefeffe feefeffe 3ffe854c 401004e9
<<<stack<<<
Decoding stack results
0x40202294: FirebaseESP8266::errorToString(int, std::string&) at D:\Profile\User\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 3612
0x40210658: String::copy(char const*, unsigned int) at C:\Users\Ultimat\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.1\cores\esp8266\WString.cpp line 211
0x40204a2a: FirebaseData::errorReason() at D:\Profile\User\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 4847
0x4020ffbc: Print::println(char const*) at C:\Users\Ultimat\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.1\cores\esp8266\Print.cpp line 190
0x40201885: loop() at D:\Profile\User\Documents\Arduino\Tests\Stream_FCM/Stream_FCM.ino line 167
0x402255e2: std::basic_string , std::allocator >::~basic_string() at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 541
0x402011cd: setup() at D:\Profile\User\Documents\Arduino\Tests\Stream_FCM/Stream_FCM.ino line 61
0x40210cd4: loop_wrapper() at C:\Users\Ultimat\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.1\cores\esp8266\core_esp8266_main.cpp line 125
from firebase-esp8266.
If two issues you open are the same can be close one?
from firebase-esp8266.
Really, I think issues are similar. You can close one of them.
UPDATE:
I determinate, if I copy all my sketch parts from many tabs in Arduino IDE to 1 big sketch tab - all working VERY GOOD. But If I split my sketck by many tabs - then I get ERRORS. Any Ideas? It is IDE BUG?
from firebase-esp8266.
Multiple .ino files may lead to problems.
Try to declare global variables in one header file (.h file on any tab).
Then include this header file at the top of main sketch but not sure it help or not.
For big project and library developt I switch to Platformio on VS Code.
from firebase-esp8266.
Thank you for advice.
from firebase-esp8266.
As I test your posted sketch. No error for stack.
For stream, when FCM need to send new message, it will stop the stream connection and start new http connection to different uri due to they use the same WiFi client in Firebase Data object, and the FCM response from server is a bit slower than RTDB connection. During this time stream can't be connected and after FCM message complete it work, stream will be resumed and use time to re-connected to the stream path, you may miss stream data during this as normal behavior of multi-tasking with only one WiFi client.
from firebase-esp8266.
Related Issues (20)
- help me, error compiling/uploading HOT 3
- Sending PushJSON syntax to log data always failed while streaming. HOT 3
- error: 'SDFSConfig' does not name a type HOT 1
- getJSON returns unknown error HOT 1
- BUG id token (GITKit token), status = error HOT 3
- Can i use RTDB stream Callback when using ESPNOW? HOT 5
- ESP8266 is crashing while writing to firebase realtime database HOT 6
- ESP8266 is crashing while writing to firebase realtime database HOT 5
- soft wdt reset issue in esp8266 HOT 1
- I'm trying to read this data HOT 2
- WiFiClientSecure issue HOT 6
- Get Token status HOT 1
- issuse HOT 14
- BUG Token info: type = id token (GITKit token), status = on request HOT 1
- PLEASE HELP HOT 3
- [HELP] Cannot connect esp8266 and firebase. Compilation error: invalid conversion from 'int' to 'FirebaseConfig*' {aka 'firebase_cfg_t*'} [-fpermissive] HOT 1
- I've been getting a connection refused after a few seconds
- I've been getting a connection refused after a few seconds after connection to firebase HOT 1
- HELP : Executed HTTPS and connection Firebase HOT 2
- HELP :: captivePortal and firebase connection HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebase-esp8266.