BLE broadcast Bytes

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

image

How about this, on the runner app?

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.

That's a table lookup problem.

Using multiple TinyDB Namespaces, you can persistently map devices into bib numbers and vice versa.

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 :frowning:
Ive attached my aia file
BLE_Reader.aia (200.2 KB)

Show your blocks for how you save the name and bib no to tinydb.

image

You probably need to add a selection event for savedList ListView, to retrieve the TinyDB value for the bib.

Also, maybe bib should be the value, and device the tag?

Also, don't calll a selection a list.

My take on it, with two TinyDBs for back and forth lookup:
image
BLE_Reader (1).aia (200.6 KB)

Of course, I can't test.

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.

Thanks, yes it is working - but I need the second list (savedlist) to also show the saved bib no. at the moment it only show teh saved name.


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.

The ListView component can be set up to show major and minor element parts in different font sizes.

Alternatively, you could loop through the tinydb tags/value pairs and join them with \n separators for a combined ListView Elements list.

So the first part pretty much do what it needs to do - save the device MAC and Name and Bib no to the TinyDB

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 :frowning:

Attached my AIA
BLE_Reader_1.aia (203.1 KB)

Here is a cleaner way to populate a ListView from a TinyDB (written before I read your last post)
image
BLE_Reader (2).aia (201.6 KB)



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?

This will only show arrivals of new devices, as detected during a race.

Times are logged as HH:MM:SS values, along with bib numbers (if available, otherwise devices)

I copied over from Screen1 the TinyDB instance that stores the bib number values for device tags.

BLE_Reader_1.aia (206.1 KB)

All the action happens in the Device Found event.

I am unable to test this.

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.

I just got a good look at your device list in a prior post.

The devices end in a negative two digit number.

I suspect that is the signal strength of the device in decibels.

That number might change as the device approaches and departs, causing the app to regard it as different devices.

To handle that possibility, split each device at '-' and just take item 1 of the resulting list.

Do that in both screens, where you fill the TinyDBs and where you do the lookups.

I have added signal strength omission to the app, but am unable to download .aia files now.

Windows 10 MS Defender just decided that the aia files have a virus.

So here are block images.


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.

Screen1:







RaceTimer blocks:




(I am awash in technical debt.)