Can you compare 2 Firebase tag values for a match?

Hi, I'm currently scanning for ble devices at two different locations and sending the data to firebase. I would like to then get the value of Test1 and Test2 and see if any of the ble Mac addresses match.
I just cant seem to figure it out..
Here is my data I uploaded to Firebase.

firebase
I'm assuming this will not work as the data set contains more then just Mac addresses as I'm sending the DeviceList?


However when I change value to store to component_set_get it does not record all the addresses..

Q1. Is there a trick to only just recording Mac addresses? (even though later on I would still like to record all the other details, mainly the device name if it has one)

Q2. Is it possible to retrieve the Firebase data and look for devices that are the same and display the match?

Any help is always appreciated. Cheers.

Have you tried reversing the hierarchy, and instead storing the devices under the MAC addresses?

Each MAC address would hold a list of the relevant devices.

Sorry, im not sure I understand what you are saying..

Rearranged structure:

MACIDs
   "0A:7B:CF:AF:06:F9": Location1 Location2
   "FA:B7:F7:63:17:C1": Location1 Location2

The problem is I am unable to list my Mac's in that format.
They are currently
LOC1
but what I need is them to be listed like this
LOC2
I just cant work out how to separate the list and add each item as a tag........? its driving me nuts..

Time to show us your blocks, for how you are collecting the data and posting it.

Please download and post each of those event block(s)/procedures here ...
(sample video)


Please export your project and post it here.

Here is some reading for you on how to structure your Firebase data ...
https://firebase.google.com/docs/database/android/structure-data

I've tried a million combos, probably all way off the mark.. The original try is above on the original post. other are;




Try something like this:

Firebase data:

image

Thank you.... It's getting there.... but the device list contains more then 2 devices (MacAdd RSSI Name)
So this works for the first one and then the second Mac contains the rest.


Result
Result

@TIMAI2 @ABG Thanks for your help so far. I have manage to Achieve the first part of listing the Mac's as Tags and the rest of the information as the value. I'll post my blocks in the event that it might help someone else. It was of trial and lots of errors. :slight_smile:

relevant2

I fear I'll get more headaches trying to work out now the original question of trying to work out how I can check if there are any MAC matches in Location1 vs Location2....

I searched this thread, but I was unable to find out where the app gets to know if it is at Location1, Location2, etc.

Does the app user type that in, or is it derived from GPS?

The location is set by the user.

This hand crafted example is the data structure I imagined ...
macIDs
macIDs is the bucket, and its tags are the mac IDs.
Each mac ID has under it subtags (is that a Firebase thing?) for each of the locations that see it in their device list.
Each tag = mac ID / location has the value true.
This enforces uniqueness, so when a location sees a mac ID it only needs to set value true for tag macID/location under bucket "macIDs".

I'm guessing if you request the value for tag 0A:7B:CF:AF:06:F9 you will receive the dictionary {"loc2":true,"loc3":true} or the JSON equivalent.

I have not tested this, since I don't have that many Bluetooth devices.

Further details ...

This assumes you trim the fat off the mac ID before you add it, and you don't care about the fat. If you care about the fat (stuff that appears after the macID in each item if the device list), that changes the tree structure. (example to follow)
enhanced macIDs

This also assumes the extra stuff with the mac ID belongs only to the mac ID, and not to the connection between location and mac ID. That would require moving the auxData subtags to under each macID/location branch.

1 Like

I forgot to mention this ...

If you are thinking of doing mesh networking, and you want a way to see which devices connect to which other devices, you will also need to know what the MACID of a device is, in itself.

You might need an extension to look into this. (I have not looked into this.)

Alternatively, you would have to rig your app to send and receive messages like "What is your name?" and respond to such messages.

Thanks mate. No mesh networking required.
I find navigating the firebase buckets the most dificult.
I have it working ok ish with trimming all the fat off.
But still recording it the fat in a list and might work out a way where at the end I can back fill the fat. Havent really decided yet. I appreciate all the help.