BLE Scan forever stops after 7+ Hours

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
devnull
Posts: 454
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: BLE Scan forever stops after 7+ Hours

Post by devnull » Sat Apr 04, 2020 10:54 am

Yes, bug in my code caused by bad data.

All seems good now, thanks again

:D

User avatar
devnull
Posts: 454
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: BLE Scan forever stops after 7+ Hours

Post by devnull » Sat Apr 04, 2020 11:47 am

Oops, hold your horses, need to test it again !

User avatar
devnull
Posts: 454
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: BLE Scan forever stops after 7+ Hours

Post by devnull » Wed Apr 08, 2020 11:40 am

Still not fixed, timestamp of 11464919 shows that it failed after about 3 hours and stopped discovering.

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: BLE Scan forever stops after 7+ Hours

Post by jimmo » Wed Apr 08, 2020 2:04 pm

Uh oh.

I spoke to another person who was previously seeing this issue frequently and they claim that it's solid now.

If you have any additional information about how to repro this (or if you have a really minimal test case that I can try) then that would be useful.

PM-TPI
Posts: 29
Joined: Fri Jun 28, 2019 3:09 pm

Re: BLE Scan forever stops after 7+ Hours

Post by PM-TPI » Fri May 29, 2020 5:55 pm

Same Issue....
Just scanning every 1min for 10sec duration .2sec interval .18sec window
The main.py uses wifi with email, and a WDT 2.5min see email attachment of reboot logs.
I also have a very striped down version with just bt.gap_scan and faster timings.
Same results except able to run sometimes for 23hr straight. Code below.

Code: Select all

import ubluetooth
import utime
from micropython import const
from machine import Timer

wdt = WDT(timeout=180000)  # timeout 2.5min

_IRQ_SCAN_RESULT = const(1 << 4)
_IRQ_SCAN_COMPLETE = const(1 << 5)

def ble(tm):
	def bt_irq(event, data):
		if event == _IRQ_SCAN_RESULT:
			print(data)
		elif event == _IRQ_SCAN_COMPLETE:
			uData(utime.time())
	bt.gap_scan(5_000, 200_000, 180_000) # 5.0 / .20 / .18 seconds
	print("scan start")
	bt.irq(handler = bt_irq)

def uData(y):
	print("scan complete")
	print("free memory: " + gc.mem_free() +"\n")
	print("complete run time:",y,"sec\n")

bt=ubluetooth.BLE()
bt.active(True)
ble('x')
tm = Timer(-1)
tm.init(period=15000, mode=Timer.PERIODIC, callback=ble)
IS There a known fix or work around?
Attachments
BLE-reboot-log.png
BLE-reboot-log.png (16.66 KiB) Viewed 324 times

PM-TPI
Posts: 29
Joined: Fri Jun 28, 2019 3:09 pm

Re: BLE Scan forever stops after 7+ Hours

Post by PM-TPI » Fri Jun 05, 2020 7:38 pm

jimmo wrote:
Tue Mar 31, 2020 11:47 pm
Oh... they did backport it to v4.0 but they just re-used the same tag. Argh. This cursed chip.

Anyway. To test this out. In your esp-idf repo,

Code: Select all

git fetch origin
git checkout origin/release/v4.0
git reset --hard HEAD
git submodule update --init --recursive
git rev-parse HEAD
The last line should be a3f3c7bdc3e81d88eba076c31cd92bca9fadd02c

Update esp32/Makefile and set ESPIDF_SUPHASH_V4 to that, then "make clean" and "make". This compiles for me, but I haven't had a chance to test it yet.
Tried this repo (a3f3c7bdc3e81d88eba076c31cd92bca9fadd02c) and have many Bizarre issues with ble scan,
if event == _IRQ_SCAN_RESULT: not functioning now.

I tried the new idf 4.0.1 but won't build.
Is there a timeline on when micropython will commit.

PM-TPI
Posts: 29
Joined: Fri Jun 28, 2019 3:09 pm

Re: BLE Scan forever stops after 7+ Hours

Post by PM-TPI » Mon Jun 08, 2020 12:00 pm

Latest build with...
ESP-IDF v4.0.1 4c81978a3e2220674a432a588292a4c860eef27b
micropython 1e6d18c915ccea0b6a19ffec9710d33dd7e5f866
and esp32/Make file updated to fa2c8f1ef8687aa4025f2fbbc7333ae925363585

Has appeared to correct BLE scan unexpectedly stopping issue.
Previous build would not run for more than ~ 3hr.
This latest build is running... and has past 24 hr so far.

also somewhere along the line
_IRQ_SCAN_RESULT = const(1 << 4) changed to cont(5) and
_IRQ_SCAN_COMPLETE = const(1 << 5) changed to cont(6)

corrected... if event == _IRQ_SCAN_RESULT: not passing

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: BLE Scan forever stops after 7+ Hours

Post by jimmo » Wed Jun 10, 2020 5:56 am

PM-TPI wrote:
Mon Jun 08, 2020 12:00 pm
Has appeared to correct BLE scan unexpectedly stopping issue.
Previous build would not run for more than ~ 3hr.
This latest build is running... and has past 24 hr so far.
That's good to hear!! Thanks for the update :)
PM-TPI wrote:
Mon Jun 08, 2020 12:00 pm
also somewhere along the line
_IRQ_SCAN_RESULT = const(1 << 4) changed to cont(5) and
_IRQ_SCAN_COMPLETE = const(1 << 5) changed to cont(6)

corrected... if event == _IRQ_SCAN_RESULT: not passing
https://github.com/micropython/micropython/pull/6033 made some breaking API changes (this is still an in-development API).

The docs are updated, but I also summarised the main differences here https://github.com/micropython/micropyt ... -641057340

Post Reply