Regarding timestamp collection, you need yet another TinyDB instance and NameSpace, with bib number as tag and timestamp as value. You would need to capture the time of the start of the race too, to translate arrival timestamps into minutes and seconds.
Pull in the Clock component from Sensors and use SystemTime (milliseconds from 1970) for your stored values. They are database friendly numbers and math-friendly too. The Clock component has lots of formatting blocks.
Before I jump into your new code, there is something nagging at me I would like you to resolve with actual experiment.
The Device List - Does it shrink and grow as devices leave and return, or is it cached, available to speed up connection attempts?
Also, where will be the user of the app when the race starts?
At the finish line, away from all the racers, or
In their midst, awash in Devices?
Might need a bit of record keeping to detect runners falling off the Device list at the start of the race, then reappearing later for the finish? Perhaps count how many reappearances on the Device list, for laps around the track, if circular?
P.S. I used the device address as the default for the TinyDB bib number lookup, just to prove I was capturing new arrivals.
You might want to restrict logging to the Elements only to devices that return a bib number, using a different (not found) default and an enclosing if/then test on the TinyDB value.
Otherwise, the app would record arrivals of random people in the finish line crowd.
P.P.S. You could also add yet another TinyDB Namespace, mapping bib numbers to people names. That's more user friendly.
To work around Microsoft Defender's sudden allergy to the BLE extension, here are draggable png downloads of my latest changes, thanks to the AI2Helper browser addon.
Good morning, Thanks, this is realy really helpfull. Will work through this today.
I am really grateful!
I dont have the AI2Helper, so will just redo all
The changes make sense, end does help. SOmehow the timer dont run. (Fixed - just add Timer enabled)
So when tested, screen 2 should list should only show the devices saved in the TinyDB saved in screen 1
Also, by using the MAC adress, it might not work - and have to use only the Advertiser names. Everytime a participant stop and start his brodcast, the MAC adress change. But the Device bluetooth name stays the same. SO ive changed the Devicelist to AdvertiserNames
Tested quickly, but am at a race currently. working good. The next challenge for me is to now on page 2 to scan all the time when started, and not just a scan period. Also monitor the selected devices, and if they are not in the list anymore, it should be available to log their time again once they are in range. This is basically to be able to scan bibs doing laps.
The Bluetooth name can be the Bib number. That will reduce the amount of interaction required between apps. If there was only one athlete BLE might be good enough for the task
Another issue you have to solve is keeping the Apps on for a prolonged time (not to mention potential weather issues).
I think ultimately you are going to have to ditch the smartphones and apps and look into a sensors + mini computer solution. Sorry for the doom and gloom.
Here are changes to record lap times by bib.
(I leave it to you to figure out how to keep those Device Found events triggering with incoming advertiser names, probably by adding a Clock Timer for that)
BLE_Reader_3.aia (207.9 KB)
(Changes made in the RaceTimer Screen)
Yet another TinyDB instance, mapping bib numbers into lists of arrival times
Good morning, thanks for all the help!
I did not had any luck with teh testing - somehow when I stop scanning on Page 1 after assigning the bib no's, and switch to Page 2 for timekeeping, the assigned bib no's dont pick up. Only when I keep scanning on page 1, then page 2 work. and dont know how the Page 2 read the Page 1 DB?
Also, when on page 2, the timing page, when on I simulate the race, when the bluetooth is out of range and within range again, it does not log the new time.
Ok, So, I have played around with teh ESP32 version, and it might be a better reader solution. (some tests worked great)
however, the broadcasting app sometimes loose focus (or stop and start) broadcasting when screen is off. is there a way to keep it broadcasting in the background even when screen is off?