gmag11/WifiLocation

Too many connectios make Soft reset

arturo393 opened this issue · 10 comments

Hi, i am using the library in a ESP8466 and i am getting a soft reset every time the getGeoFromWiFi() is used but not always. I think this is because there are too many wifi ap's and it kind overflow some variable.
it can be possible?

I have the same problem

Hi, It is possible. Using HTTPS in ESP8266 makes free heap to go down to less than 20 kB during the request to Google.
I have quite a lot wifi networks around (around 20) but I've not tested the limit.
Another possibility is that WiFiClient library limit maximum content length, I guess this limit is about 1500 bytes.
Could you enable debug information and paste it here?

A possible work around could be limit the maximum number of networks filtering out less powerful ones.

Thanks

Hi, restart is due to watchdog. It may be because some code on your scketch. May you try plain example?

To enable debug you have to uncomment this line

I've built a new branch that limits number of networks to 20. Please test it:
https://github.com/gmag11/ESPWifiLocation/tree/limit_number_of_wifis

Hi im use a Nodemcu and have this error:
`Status = 3
MAC NodeMCU: 5C:CF:7F:43:83:D6
Connected to API endpoint
2 WiFi networks found
WiFi list :
[
{"macAddress":"A8:D3:F7:0D:81:E3","signalStrength":-76,"channel":1},
{"macAddress":"A4:70:D6:D1:97:60","signalStrength":-32,"channel":3}]
requesting URL: /geolocation/v1/geolocate?key=AIzaSyCJn1P6Dpx4DouCT5H-B9dDr3tplRGrKSo
request:
POST /geolocation/v1/geolocate?key=AIzaSyCJn1P6Dpx4DouCT5H-B9dDr3tplRGrKSo HTTP/1.1
Host: www.googleapis.com
User-Agent: ESP8266
Content-Type:application/json
Content-Length:160
Connection: close

{"wifiAccessPoints":[
{"macAddress":"A8:D3:F7:0D:81:E3","signalStrength":-76,"channel":1},
{"macAddress":"A4:70:D6:D1:97:60","signalStrength":-32,"channel":3}]}
request sent
Free heap: 39528

Soft WDT reset

ctx: cont
sp: 3fff0f10 end: 3fff11b0 offset: 01b0

stack>>>
3fff10c0: 402042a8 3ffeff80 3fff00c8 40204708
3fff10d0: 3ffeff74 3ffeff80 3fff00c8 40203ff2
3fff10e0: 00000000 00000000 00000000 00000000
3fff10f0: 00000000 00000000 00000000 00000000
3fff1100: 00000000 3fff1180 3fff113c 4010068c
3fff1110: 3fff6b84 0000016f 0000016c 3fff401c
3fff1120: 000000af 000000a0 3fff2114 0000000f
3fff1130: 00000000 00000011 3fff00c8 40204531
3fff1140: 3ffe9b98 3ffeff60 3fff00c8 3fff0184
3fff1150: 3ffe8ea4 3ffeff60 3fff00c8 3fff0184
3fff1160: 3fffdad0 00000000 3fff017c 4020254b
3fff1170: 3ffe8ea4 3ffeff60 3fff00c8 40202306
3fff1180: 00000000 00000000 00000000 feefeffe
3fff1190: 3fffdad0 00000000 3fff017c 40204ed8
3fff11a0: feefeffe feefeffe 3fff0190 40100718
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
`

Howdy gmag11! I have been trying to use the 20 wifi network limited branch, but I still get errors as previous posters have mentioned. Here is my debug info that I am getting. I am using an ESP8266 NodeMCU chip. Your help would be greatly appreciated. Thanks!

7 WiFi networks found
WiFi list :
[
{"macAddress":"D0:17:C2:3E:32:00","signalStrength":-46,"channel":9},
{"macAddress":"10:DA:43:0D:DD:4C","signalStrength":-72,"channel":4},
{"macAddress":"60:38:E0:33:2E:9D","signalStrength":-71,"channel":5},
{"macAddress":"FE:3F:DB:B8:78:01","signalStrength":-79,"channel":5},
{"macAddress":"00:71:CC:2B:CD:35","signalStrength":-90,"channel":5},
{"macAddress":"F8:CF:C5:F5:5A:1D","signalStrength":-89,"channel":6},
{"macAddress":"00:22:3F:6D:48:E8","signalStrength":-92,"channel":11}]
requesting URL: /geolocation/v1/geolocate?key=AIzaSyCFlt-8IDiYMgXZdiKAL1mQiqsIG_I7st8
request: 
POST /geolocation/v1/geolocate?key=AIzaSyCFlt-8IDiYMgXZdiKAL1mQiqsIG_I7st8 HTTP/1.1
Host: www.googleapis.com
User-Agent: ESP8266
Content-Type:application/json
Content-Length:506
Connection: close

{"wifiAccessPoints":[
{"macAddress":"D0:17:C2:3E:32:00","signalStrength":-46,"channel":9},
{"macAddress":"10:DA:43:0D:DD:4C","signalStrength":-72,"channel":4},
{"macAddress":"60:38:E0:33:2E:9D","signalStrength":-71,"channel":5},
{"macAddress":"FE:3F:DB:B8:78:01","signalStrength":-79,"channel":5},
{"macAddress":"00:71:CC:2B:CD:35","signalStrength":-90,"channel":5},
{"macAddress":"F8:CF:C5:F5:5A:1D","signalStrength":-89,"channel":6},
{"macAddress":"00:22:3F:6D:48:E8","signalStrength":-92,"channel":11}]}
request sent
Free heap: 39264

Soft WDT reset

ctx: cont 
sp: 3fff0cc0 end: 3fff0f70 offset: 01b0

>>>stack>>>
3fff0e70:  402041a0 3ffefe14 3fff0fb4 40204580  
3fff0e80:  3ffefe08 3ffefe14 3fff0fb4 40203c7a  
3fff0e90:  00000000 00000000 00000000 00000000  
3fff0ea0:  00000000 00000000 00000000 00000000  
3fff0eb0:  00000000 feefeffe 3fff1fac 40201f29  
3fff0ec0:  3fff69d4 000002cf 000002c6 3fff6f9c  
3fff0ed0:  000001ff 000001fa 3fff1a0c 0000000f  
3fff0ee0:  00000000 3fff0fb4 3ffefe30 3fffdad0  
3fff0ef0:  4021d987 3ffeff40 40204010 3ffeff50  
3fff0f00:  3fff1a64 402027d8 3fff0fb4 3ffeff40  
3fff0f10:  3fffdad0 3ffefe30 3fff0fb4 40202224  
3fff0f20:  feefeffe feefeffe feefeffe feefeffe  
3fff0f30:  feefeffe feefeffe feefeffe feefeffe  
3fff0f40:  feefeffe feefeffe feefeffe feefeffe  
3fff0f50:  feefeffe 00000000 3ffeff38 40204054  
3fff0f60:  feefeffe feefeffe 3ffeff50 40100718  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 
hosek commented

I hit same issue, its ESP8266 watchdog - waiting for response takes too long and you need to return control back to wifi stack.
Adding yield(); into waiting loop works for me:
// Wait for response while (millis() - timer < MAX_CONNECTION_TIMEOUT) { if (_client.available()){ break; } yield(); }

after putting yield(); the Watchdog reset stops but I am not getting lat long ... here is the debug output

⸮Attempting to connect to WPA SSID: AS_AGRI
Status = 6
Attempting to connect to WPA SSID: AS_AGRI
Status = 6
Attempting to connect to WPA SSID: AS_AGRI
Status = 6
Attempting to connect to WPA SSID: AS_AGRI
Status = 6
Attempting to connect to WPA SSID: AS_AGRI
Status = 6
Attempting to connect to WPA SSID: AS_AGRI
Status = 6
Attempting to connect to WPA SSID: AS_AGRI
Status = 6
Connected to API endpoint
14 WiFi networks found
WiFi list :
[
{"macAddress":"B8:C1:A2:4F:EC:8C","signalStrength":-91,"channel":1},
{"macAddress":"10:6F:3F:6B:D3:60","signalStrength":-93,"channel":1},
{"macAddress":"B8:C1:A2:37:91:84","signalStrength":-92,"channel":1},
{"macAddress":"50:09:59:83:2A:ED","signalStrength":-92,"channel":1},
{"macAddress":"B8:C1:A2:60:70:7C","signalStrength":-81,"channel":2},
{"macAddress":"B8:C1:A2:41:3F:04","signalStrength":-88,"channel":2},
{"macAddress":"C8:D7:79:CB:09:38","signalStrength":-41,"channel":7},
{"macAddress":"0C:D2:B5:86:F8:9B","signalStrength":-90,"channel":6},
{"macAddress":"74:DA:DA:25:1B:A7","signalStrength":-89,"channel":7},
{"macAddress":"78:11:DC:35:5D:4E","signalStrength":-93,"channel":9},
{"macAddress":"A0:AB:1B:27:B7:54","signalStrength":-79,"channel":9},
{"macAddress":"A0:AB:1B:27:B7:4C","signalStrength":-83,"channel":9},
{"macAddress":"0C:D2:B5:6A:A8:B4","signalStrength":-93,"channel":10},
{"macAddress":"70:62:B8:8B:22:F0","signalStrength":-84,"channel":11}]
requesting URL: /geolocation/v1/geolocate?key=AIzaSyCFlt-8IDiYMgXZdiKAL1mQiqsIG_I7st8
request:
POST /geolocation/v1/geolocate?key=AIzaSyCFlt-8IDiYMgXZdiKAL1mQiqsIG_I7st8 HTTP/1.1
Host: www.googleapis.com
User-Agent: ESP8266
Content-Type:application/json
Content-Length:990
Connection: close

{"wifiAccessPoints":[
{"macAddress":"B8:C1:A2:4F:EC:8C","signalStrength":-91,"channel":1},
{"macAddress":"10:6F:3F:6B:D3:60","signalStrength":-93,"channel":1},
{"macAddress":"B8:C1:A2:37:91:84","signalStrength":-92,"channel":1},
{"macAddress":"50:09:59:83:2A:ED","signalStrength":-92,"channel":1},
{"macAddress":"B8:C1:A2:60:70:7C","signalStrength":-81,"channel":2},
{"macAddress":"B8:C1:A2:41:3F:04","signalStrength":-88,"channel":2},
{"macAddress":"C8:D7:79:CB:09:38","signalStrength":-41,"channel":7},
{"macAddress":"0C:D2:B5:86:F8:9B","signalStrength":-90,"channel":6},
{"macAddress":"74:DA:DA:25:1B:A7","signalStrength":-89,"channel":7},
{"macAddress":"78:11:DC:35:5D:4E","signalStrength":-93,"channel":9},
{"macAddress":"A0:AB:1B:27:B7:54","signalStrength":-79,"channel":9},
{"macAddress":"A0:AB:1B:27:B7:4C","signalStrength":-83,"channel":9},
{"macAddress":"0C:D2:B5:6A:A8:B4","signalStrength":-93,"channel":10},
{"macAddress":"70:62:B8:8B:22:F0","signalStrength":-84,"channel":11}]}
request sent
Free heap: 38264

Location request data
16 WiFi networks found
WiFi list :
[
{"macAddress":"10:6F:3F:6B:D3:60","signalStrength":-96,"channel":1},
{"macAddress":"50:09:59:83:2A:ED","signalStrength":-94,"channel":1},
{"macAddress":"B8:C1:A2:4F:EC:8C","signalStrength":-90,"channel":1},
{"macAddress":"B8:C1:A2:4E:EA:7C","signalStrength":-91,"channel":1},
{"macAddress":"B8:C1:A2:37:91:84","signalStrength":-91,"channel":1},
{"macAddress":"74:DA:DA:25:1B:A7","signalStrength":-92,"channel":7},
{"macAddress":"C8:D7:79:CB:09:38","signalStrength":-41,"channel":7},
{"macAddress":"B8:C1:A2:60:70:7C","signalStrength":-87,"channel":2},
{"macAddress":"B8:C1:A2:41:3F:04","signalStrength":-84,"channel":2},
{"macAddress":"78:11:DC:35:5D:4E","signalStrength":-91,"channel":9},
{"macAddress":"A0:AB:1B:27:B7:4C","signalStrength":-84,"channel":9},
{"macAddress":"A0:AB:1B:27:B7:54","signalStrength":-78,"channel":9},
{"macAddress":"0C:D2:B5:6A:A8:B4","signalStrength":-92,"channel":10},
{"macAddress":"48:00:33:99:AA:A8","signalStrength":-91,"channel":11},
{"macAddress":"70:62:B8:8B:22:F0","signalStrength":-84,"channel":11},
{"macAddress":"00:22:6B:5D:A9:56","signalStrength":-92,"channel":11}]
[
{"macAddress":"10:6F:3F:6B:D3:60","signalStrength":-96,"channel":1},
{"macAddress":"50:09:59:83:2A:ED","signalStrength":-94,"channel":1},
{"macAddress":"B8:C1:A2:4F:EC:8C","signalStrength":-90,"channel":1},
{"macAddress":"B8:C1:A2:4E:EA:7C","signalStrength":-91,"channel":1},
{"macAddress":"B8:C1:A2:37:91:84","signalStrength":-91,"channel":1},
{"macAddress":"74:DA:DA:25:1B:A7","signalStrength":-92,"channel":7},
{"macAddress":"C8:D7:79:CB:09:38","signalStrength":-41,"channel":7},
{"macAddress":"B8:C1:A2:60:70:7C","signalStrength":-87,"channel":2},
{"macAddress":"B8:C1:A2:41:3F:04","signalStrength":-84,"channel":2},
{"macAddress":"78:11:DC:35:5D:4E","signalStrength":-91,"channel":9},
{"macAddress":"A0:AB:1B:27:B7:4C","signalStrength":-84,"channel":9},
{"macAddress":"A0:AB:1B:27:B7:54","signalStrength":-78,"channel":9},
{"macAddress":"0C:D2:B5:6A:A8:B4","signalStrength":-92,"channel":10},
{"macAddress":"48:00:33:99:AA:A8","signalStrength":-91,"channel":11},
{"macAddress":"70:62:B8:8B:22:F0","signalStrength":-84,"channel":11},
{"macAddress":"00:22:6B:5D:A9:56","signalStrength":-92,"channel":11}]
Latitude: 0.0000000
Longitude: 0.0000000
Accuracy: 40000

Hi, I've added a couple yield() as of your comments. It is included on master branch on 90c9489
Thank you @hosek