Paired by Bluetooth the Lopy with a Android mobile

  • Hello everyone,

    I begin on the bluetooth and the lopy.

    I made a Android application using bluetooth, for now it's just giving order to change the led color for testing and see if the connection bewteen the lopy and the smartphone working, but the goal is to read some data (for example sensor connected on the lopy) or give order.

    I need first be paired, then I launch the application which list all devices paired, then I can choose the device for read/write data.

    So, my problem is when I try to pair my smartphone on the Lopy, the Lopy seems to connect (the consol print "connected") on the mobile, but the mobile cannot pair. I use example code on the documentation (link below) but I'm lost.

    Here, the code I use :

    from network import Bluetooth
    bluetooth = Bluetooth()
    bluetooth.set_advertisement(name='LoPy', service_uuid=b'1234567890123456')
    def conn_cb (bt_o):
        events =   # this method returns the flags and clears the internal registry
        if events & Bluetooth.CLIENT_CONNECTED:
            print("Client connected")
        elif events & Bluetooth.CLIENT_DISCONNECTED:
            print("Client disconnected")
    bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)

    I have 2 mobiles phone, one is 4.1.2, the other is 5.1

    If someone can give me some help, it would be nice.

    Thanks, and sorry for my english.

  • Have you solved this problem?

  • Hey xallano,

    I know it is a one-year-old post. However, I am trying to connect an Android device to a Lopy, to eventually send data from my android device to the Lopy.
    What have you done so far? Can you provide me with the source code for both the Android App and the Lopy?

    Thank you.

  • @panos29
    Well you can send as much data as you want over Bluetooth - but it'll be slow

  • @jmarcelino so it's possible to send big amounts of data from like a sensor on the wipy to my android device via BT?

  • The LoPy cannot currently pair (at least in the Bluetooth pairing sense) however you can just scan for it and connect from your Android app without pairing.

    For that you'll also need to create some services and characteristics in your Python code, see the GATTSCharacterist example

  • I have the lastest so 1.6.12.b1

  • @xallano Hi, I had the same problem with WiPy 2.0 with an old firmware. In these days I try with the latest firmware which has made many changes on BT.

    Anyway, what is your LoPy firmware? Try:

    import os

Pycom on Twitter