This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE APP UART

Hello,

This example I got it working with nrf toolbox app, but I was wondering if this should work also with a win7 PC.
https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/usbd_cdc_acm_example.html
I got this window:

But it never asked for a pairing code.

Best regards,
Karel.

Parents
  • In fact the nRF Toolbox / UART only can sent something to the nRF52, it never replies.
    I added one line of code as I don't know how the toolbox is sending a \r or \n, such that it ends with a 0, it also echo the received string. So sending "test0" should trigger the nRF52 to send "test0" back to the toolbox-app, but it doesn't.

  • Sorry, I was too quick; the example is a little more complex. It deals with 2 UARTs. Now I can receive info from nRF52 to toolbox app.

  • Hello Bjorn,

    Yes, understood!
    Any idea if I can interface this BLE-UART from this demo from within a python program?

    Thanks,
    Karel.

  • Hi Karel,

    we do have the pc-ble-driver-py which is a serialization library over serial port that provides Python bindings for our nrf-ble-driver library.

    Best regards

    Bjørn

  • Hello Bjorn,

    I installed this driver, but my python3 installation complains:
    ModuleNotFoundError: No module named 'Queue'

    So installed using python2.7, it installs well, but it seems not to be able to import  pc_ble_driver_py.

    (can be due to my "abandoned" python2 installation...)

    On top I found this issue: 
    https://github.com/NordicSemiconductor/pc-ble-driver-py/issues/64#issuecomment-477932904

    So probably it won't work with my nrf52840 dongle anyways...

    Best regards,
    Karel.

  • Hello Bjorn,


    I wrote a little python script, it uses pygatt, which I believe does not work on windows...
    In linux it worked.
    Can you comment if this is the way to go?

    Best regards,
    Karel.



    #!/usr/bin/env python
    
    import binascii
    import pygatt
    
    from time import sleep
    
    YOUR_DEVICE_ADDRESS = "11:22:33:44:55:66"
    # Many devices, e.g. Fitbit, use random addressing - this is required to connect.
    ADDRESS_TYPE = pygatt.BLEAddressType.random
    
    adapter = pygatt.GATTToolBackend()
    adapter.start()
    device = adapter.connect(YOUR_DEVICE_ADDRESS, address_type=ADDRESS_TYPE)
    
    uuid_write = None
    uuid_notify = None
    
    print("scanning {}:".format(YOUR_DEVICE_ADDRESS))
    for uuid in device.discover_characteristics().keys():
      if str(uuid) == "6e400002-b5a3-f393-e0a9-e50e24dcca9e": # write PC to BLE-UART...
        device.char_write(uuid, bytearray([0x33, 0x33, 0x30]))
        uuid_write = uuid
        continue
    
      if str(uuid) == "6e400003-b5a3-f393-e0a9-e50e24dcca9e": # notify PC from BLE-UART...
        uuid_notify = uuid
        continue
    
      print("Read UUID %s: " % (uuid))
      print("%s" % (binascii.hexlify(device.char_read(uuid))))
    
    print("notification mode..")
    
    
    def cb_ble_uart(handle, data):
      print("cb_ble_uart", data)
    
    
    device.subscribe(uuid_notify, cb_ble_uart)
    
    for i in range(10):
      device.char_write(uuid_write, bytearray([0x33, 0x33]))
      sleep(1)
    
    

  • Hi Karelv, 

    Just to reply to your previous comment on pc-ble-drive-py installation. 

    I have not used the python bindings of the pc-ble-driver, but conflicting python installations could be an issue. 

    As for the nRF52840 dongle support, I know that its lagging a bit behind the pc-ble-driver thats written in C, which supports the nRF52840 dongle so if you're not locked to python, then you could use that instead. 

    karelv said:

    I wrote a little python script, it uses pygatt, which I believe does not work on windows...
    In linux it worked.
    Can you comment if this is the way to go?

    Which Windows version are you using? Could be that there isnt proper support for BLE in your particular version or that pygatt has not been updated to support the windows driver. On linux I would guess that its using Bluez which usually works like a charm.

    I am not very experienced with pygatt so  might not be the right person to ask. I have a javascript library called noble and a c library called gattool on a Raspberry Pi. 

    Best regards

    Bjørn  

Reply
  • Hi Karelv, 

    Just to reply to your previous comment on pc-ble-drive-py installation. 

    I have not used the python bindings of the pc-ble-driver, but conflicting python installations could be an issue. 

    As for the nRF52840 dongle support, I know that its lagging a bit behind the pc-ble-driver thats written in C, which supports the nRF52840 dongle so if you're not locked to python, then you could use that instead. 

    karelv said:

    I wrote a little python script, it uses pygatt, which I believe does not work on windows...
    In linux it worked.
    Can you comment if this is the way to go?

    Which Windows version are you using? Could be that there isnt proper support for BLE in your particular version or that pygatt has not been updated to support the windows driver. On linux I would guess that its using Bluez which usually works like a charm.

    I am not very experienced with pygatt so  might not be the right person to ask. I have a javascript library called noble and a c library called gattool on a Raspberry Pi. 

    Best regards

    Bjørn  

Children
No Data
Related