Automate nRF52840 Dongle running pc-nrfconnect-ble

Hello,

 I'm very unexperienced with low-level programming, so I apologize is some of my questions make little sense.

  We have this board that sends telemetry data using a nRF52840 to a Window 10 PC.  Looking for a quick and dirty way to scan for the board, connect to it, and record the RSSI value I found out the nRF52840 dongle.  Running Bluetooth Low Energy app that comes with nRF Connect for Desktop works like a charm, but now I'm looking for a way to replicate this thru LabView. I took a gander at the serial port communications between the app and the dongle and it's mostly HEX commands, so I tried looking around github for a piece of code or example that I could use to duplicate these commands, but I can't figure out where or what to look for..

 I'm hoping someone can point me to a piece of code/example or document that explains how to send and read the commands to a nRF52840 dongle programmed with pc-nrfconnect-ble.

Thanks.

Parents
  • Hello,

    Attached below is a python script for the pc-ble-driver-py I quickly put together which will connect to any BLE device named 'TARGET_DEV_NAME' and start logging the RSSI. You can use it with the same dongle and FW you use with the Bluetooth low energy app.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    #
    # Copyright (c) 2016 Nordic Semiconductor ASA
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without modification,
    # are permitted provided that the following conditions are met:
    #
    # 1. Redistributions of source code must retain the above copyright notice, this
    # list of conditions and the following disclaimer.
    #
    # 2. Redistributions in binary form must reproduce the above copyright notice, this
    # list of conditions and the following disclaimer in the documentation and/or
    # other materials provided with the distribution.
    #
    # 3. Neither the name of Nordic Semiconductor ASA nor the names of other
    # contributors to this software may be used to endorse or promote products
    # derived from this software without specific prior written permission.
    #
    # 4. This software must only be used in or with a processor manufactured by Nordic
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Steps for testing the script:

    1. Install pc-ble-driver-py through PyPi: $ pip install --user pc-ble-driver-py

    2. Change TARGET_DEV_NAME in the script to match your device.

    3. Run script with python: $ python3 rssi_logger.py NRF52 <COM port for nrf52840 dongle>

    After the connection has been established you should start seeing the measured RSSIs from the connection:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    $ python3 rssi_logger.py NRF52 /dev/ttyACM0
    Serial port used: /dev/ttyACM0
    2022-04-11 15:54:27,049 [139762313049856/LogThread] Successfully opened /dev/ttyACM0. Baud rate: 1000000. Flow control: none. Parity: none.
    Received advertisment report, address: 0xC4A1E304973B, device_name: Nordic_UART
    New connection: 0
    Client requesting to update ATT MTU to 247 bytes
    Max rx octets: 251
    Max tx octets: 251
    Max rx time: 2120
    Max tx time: 2120
    RSSI: -39
    RSSI: -37
    RSSI: -37
    RSSI: -37
    RSSI: -40
    RSSI: -42
    RSSI: -38
    RSSI: -39
    RSSI: -39
    RSSI: -39
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I do not have much experience with LabView, but I hope you will be able to parse the log output from it.

    Best regards,

    Vidar

Reply
  • Hello,

    Attached below is a python script for the pc-ble-driver-py I quickly put together which will connect to any BLE device named 'TARGET_DEV_NAME' and start logging the RSSI. You can use it with the same dongle and FW you use with the Bluetooth low energy app.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    #
    # Copyright (c) 2016 Nordic Semiconductor ASA
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without modification,
    # are permitted provided that the following conditions are met:
    #
    # 1. Redistributions of source code must retain the above copyright notice, this
    # list of conditions and the following disclaimer.
    #
    # 2. Redistributions in binary form must reproduce the above copyright notice, this
    # list of conditions and the following disclaimer in the documentation and/or
    # other materials provided with the distribution.
    #
    # 3. Neither the name of Nordic Semiconductor ASA nor the names of other
    # contributors to this software may be used to endorse or promote products
    # derived from this software without specific prior written permission.
    #
    # 4. This software must only be used in or with a processor manufactured by Nordic
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Steps for testing the script:

    1. Install pc-ble-driver-py through PyPi: $ pip install --user pc-ble-driver-py

    2. Change TARGET_DEV_NAME in the script to match your device.

    3. Run script with python: $ python3 rssi_logger.py NRF52 <COM port for nrf52840 dongle>

    After the connection has been established you should start seeing the measured RSSIs from the connection:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    $ python3 rssi_logger.py NRF52 /dev/ttyACM0
    Serial port used: /dev/ttyACM0
    2022-04-11 15:54:27,049 [139762313049856/LogThread] Successfully opened /dev/ttyACM0. Baud rate: 1000000. Flow control: none. Parity: none.
    Received advertisment report, address: 0xC4A1E304973B, device_name: Nordic_UART
    New connection: 0
    Client requesting to update ATT MTU to 247 bytes
    Max rx octets: 251
    Max tx octets: 251
    Max rx time: 2120
    Max tx time: 2120
    RSSI: -39
    RSSI: -37
    RSSI: -37
    RSSI: -37
    RSSI: -40
    RSSI: -42
    RSSI: -38
    RSSI: -39
    RSSI: -39
    RSSI: -39
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I do not have much experience with LabView, but I hope you will be able to parse the log output from it.

    Best regards,

    Vidar

Children
No Data