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 Reply Children
  • 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  

  • 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  

Related