Bluetooth.connect( adv.mac ) hangs



  • What am I doing wrong here? This code hangs when it comes to "bt.connect( adv.mac )"

    Does anyone have working code to read services data values?

    Thanks, in advance?

    from network import Bluetooth
    import time
    
    bt = Bluetooth()
    bt.init()
    
    while( True ):
        if( not bt.isscanning() ):
            bt.start_scan(-1)
    
        print("Scan")
        adv = bt.get_adv()
        if( adv ):
            bt.stop_scan()
            print( adv.mac )
            try:
                conn = bt.connect( adv.mac )
                if( conn ):
                    if( conn.isconnected()):
                        print(len(conn.services))
                        conn.disconnect()
                    else:
                        print("Not Connected")
                else:
                    print("Conn not available")
            except Exception as e:
                print( e.message )
    
        time.sleep( 1 )


  • Hmm ok I've flagged this internally and will investigate! Thanks for your patience!



  • @bnjroos

    Honestly, I don;t know what fixed. I had already upgrade the firmware and verified the version number and the code I had would not work.

    The next day. I re-flashed the firmware again to be sure. And tried some other code that essentially did the same thing and it works.

    I really don;t know what was the magic solution but I am able to get Bt.Connect() to work now. Although actually reading values is not reliable for me. But, that could be the Beacon or the LOPY and I have not figured out which yet.

    Good Luck with yours.

    thrag



  • @bucknall I think so:

    os.uname()                                                                                                          
    (sysname='LoPy', nodename='LoPy', release='1.7.1.b2', version='v1.8.6-642-g84447452 on 2017-06-03', machine='LoPy with E
    SP32', lorawan='1.0.0')

    I'm trying to connect to this device for the first time: http://www.transducersdirect.com/product-category/pressure-transducers/wireless-pressure-transducers/

    However I was connected with the LoPy to my phone using the 'nrf connect' android app with success 2 days ago and it is not working anymore either.



  • @bnjroos Are you up to date, regarding the firmware?



  • I have the same issue here, it was working but not anymore and it hangs everytime i try to connect with my LoPy. Then I have to power cycle the board.

    Did you do anything ?



  • Actually, I have to correct myself. This is actually working now.. at least better than before. It does not seem to find all advertisements that are available but that could be an issue with the beacon.

    Not sure why it works tonight when it definitely did not yesterday. But anyway, Thanks. It work.



  • Thanks for the reply.

    Yes, the very latest. '1.7.2.b1'

    Garth



  • Are you using the latest firmware?

    os.uname() should tell you


Log in to reply
 

Pycom on Twitter