If you are going to have the runners have a client app running when they reach the finish line, have their apps scan for devices continually, and note when they encounter a pre-programmed device ID (your finish line device) for the first time.
The pre-programmed device ID would be detectable at the gate.
Have the runner app upload their bib ID and time somewhere.
Yes that is the principle. Thats the whole issue - how do I broadcast and recieve a pre programmed ID? Coupled to a bib no, or preferebly the bib no itself?
There are blocks in the BLE extension that send advertisements, and a block that scan advertisements, but none that VIEW or extract it
could work, but that require all devices to have an active internet connection, and also the timestamps could not be accurate. But will try it, it might work
So, here is the workaround I am thinking of:
1)The Athlete broadcasting app will still advertise as initially planned.
2) The Reader app already catch the MAC Adress and Bluetooth name, in a list.
The Idea is at registration before start, to select each entry's device on the bluetooth list, and assign the bib number manually. this way I can control the entries, and also check that each participant's app DOES broadcast.
Now the challenge is how do I "substitute" all selected devices with the assigned bib no.
I have a List that populate nearby BLE devices, and once selected, I want to save the name and a bib no to a Tinydb.
Once its saved I want it to display it in my savelist. Now it show the saved bib no, but not the saved name. Any help perhaps? Its been a while since Ive done this and Im old and rusty
Ive attached my aia file BLE_Reader.aia (200.2 KB)
P.S. I left out convenience factors for the bib number assignment phase, tracking high water mark for bib numbers and omitting already assigned devices for new device entry.
Ive replaced the get Tags with Get Entries?
So this screen will be a athelte registration screen.
The next step is to create a second screen where the actual timing will be done with a start/stop timer, and once started it will scan for saved suernames, and once detected, it will write to a list again, with the bib no abd timestamp.
NOw, I have a second screen, that start scan again, this time it should check the recieved device (could be the MAC or name or both?) against the DB, and if found, then add to the list, with a timestamp.
I have no clue how to do that
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.