Lopy4 to Lopy4 with BLE get_adv() always none [Solved]



  • Hello everyone!
    I was trying to connect two Lopy4 with BLE, but bluetooth.get_adv() is always returning none. Just in a few cases it and using the same code work but then stopped.

    import ubinascii
    from network import Bluetooth
    from time import sleep
    
    bt = Bluetooth()
    bt.init()
    
    bt.set_advertisement(name="lopy", manufacturer_data="lopy_v1")
    if bt.isscanning():
        bt.stop_scan()
    
    bt.start_scan(-1)
    while bt.isscanning():
        adv = bt.get_adv()
        if adv:
            print(adv)
    
    

    Both with the same code, and different names (I also try it with the same name)

    Thank you



  • @eric73
    Thank you so much!
    It worked! Also, it can scan and advertise at the same time.



  • @amarulp Hello, I think you cannot, at same time, advertise and scan for device with a lopy but you can test it in case, with some luck it can work.
    I suggest you to have on one lopy to advertise (btw you must add in your code bt.advertise(true) after your bt.set_advertisement according to documentation) and the other lopy do bluetooth scanning.


Log in to reply
 

Pycom on Twitter