I need to Show the BLE names and connect to their addreesses

I need to have a list with the BLE devices names only and when i select the name from the list picket it connect to the address related.

I tried to do it as per the screenshot attached. But once the app starts it's giving me the error attached.


You can't use a list as a key in a dictionary.

Maybe pick better variable names than 'Name' and 'Value' to tell us

  • their purpose
  • whether or not they are lists, numbers, pieces of text, rtc,
  • parts of other things
  • related to other things.

Hello Talent Tech

Are the Device Names being included with the Address when the BLE Extension Scans them - your code suggests in your case this is so. A device doesn't necessarily have a name. A group of identical devices from a manufacturer may have identical names.

So your code is on the right lines - just populate the List Picker with the Name List. When the User picks a Name, use the Selection Index to pick the related address from the Address List.

Hi Chris the devices are having different names as also i can change it,

I am sorry but i didn't understood well how to avoid the error share and what's the problem with my code

Drop the dictionary.

Your code is nearly there. Like this:

Hi there thanks for your support

The fact is by removing the dictionaries following the steps shared.
i found 3 Bluetooth devices even if i am using just 2 devices, the third is duplicated with no mac address

how to avoid that

That has nothing to do with dictionaries.....

The problem is that BLE will find any devices it can, including the ones that do not belong to your Project. However, since you have named each device, you can filter the addresses to just the devices with the predefined names.

If you can post a representative list, I can show you how to filter it.