BLE not getting connected



  • Hello Folks,
    I have been trying to implement the BLE communication on lopy4 and my laptop. I am referring to the code attached at the bottom for reference and the lopy4 release version is '1.20.2.r3' . The code always gets stuck at bluetooth.connect(adv.mac) for which I have no reason why. Some post suggest that it might be a firmware issue but the latest firmware for lopy4 just stops it from getting connected to comport and then I have to revert back to the older firmware revision. Any guidance or help will be much appreciated.

    Regards
    Subham

    from network import Bluetooth
    import ubinascii
    bluetooth = Bluetooth()
    
    
    bluetooth.start_scan(-1)
    adv = None
    while True:
        adv = bluetooth.get_adv()
        if adv:
            try:
                bluetooth.connect(adv.mac)
            except:
                # start scanning again
                bluetooth.start_scan(-1)
                continue
            break
    print("Connected to device with addr = {}".format(ubinascii.hexlify(adv.mac)))
    


  • Hello @jcaron ,
    Sorry for the inconvenience caused. As a a new user it is not letting me edit it and then submit it again. I have tried multiple times now. I will keep on trying until it lets me do that but in the meantime do you have any idea as in what might stopping me from getting the BLE device connected.
    Regards
    Subham



  • @subham-Joshi Please edit your post, select your code and click on the </> code formatting button in the toolbar, so spacing is respected (which is vital in Python).


Log in to reply
 

Pycom on Twitter