BLE device name?
-
adv = bt.get_adv() get a ble device
but bt.resolve_adv_data(adv.data, bt.ADV_NAME_CMPL) always returns a 'None'
-
This is what I add into my lopy so they get a name:
bluetooth.set_advertisement(name="lopy", manufacturer_data="lopy_v1")
and when I look for the lopy I do this:
from network import Bluetooth
#import time - Dont need this part for this
bt = Bluetooth()
bt.start_scan(-1)while True:
adv = bt.get_adv()
if adv and bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == 'lopy':
try:
conn = bt.connect(adv.mac)
-
@daniel @Ralph Thank you for your explain,another questin ,when i set my LoPy ble device to scanning state,my iPhone can't search it too.
from network import Bluetooth
bluetooth = Bluetooth()
bluetooth.start_scan(-1)
-
@DongYin BLE advertisements can only carry a certain amount of data (up to 31 bytes) and the device advertising chooses what to send. Many devices do not advertise the name.
-
@DongYin I'm not the bluetooth expert, but I think not all devices return their name. I also get None for most devices I find in our office building, but when I test it with this BLE Peripheral simulator app, I do get the name. Maybe @daniel can confirm.
-
@duffo64 said in BLE device name?:
Hi @DongYin,
What happens if you try to use ADV_NAME_SHORT instead of ADV_NAME_CMPL ?
ADV_NAME_SHORT returns 'None' too.
if i use ADV_MANUFACTURER_DATA returns " b'L\x00\x10\x02\n\x00' "
others Address type all return 'None'
-
Hi @DongYin,
What happens if you try to use ADV_NAME_SHORT instead of ADV_NAME_CMPL ?