I am trying to run the heart_rate_collector.py example in Nordic's pc_ble_driver_py library. When I try to execute the program, I get the following error:
Traceback (most recent call last): File "/Users/elainechesoni/Dev/Nordic/pc-ble-driver-py/pc_ble_driver_py/examples/heart_rate_collector.py", line 234, in <module> main(serial_port) File "/Users/elainechesoni/Dev/Nordic/pc-ble-driver-py/pc_ble_driver_py/examples/heart_rate_collector.py", line 168, in main driver = BLEDriver( NameError: name 'BLEDriver' is not defined
Command used to run example:
python3 heart_rate_collector.py NRF52
(I have also tried running with python instead of python3)
I have modified the code in two places:
- main function starting on Line 166 now reads:
def main(selected_serial_port): print("Serial port used: {}".format(selected_serial_port)) driver = BLEDriver( serial_port=selected_serial_port, auto_flash=False, baud_rate=1000000, log_severity_level="info" ) print("BLEDriver has been established...") adapter = BLEAdapter(driver) print("Adapter has been established...") collector = HRCollector(adapter) print("Collector has been established...") collector.open() print("Open to advertising devices...") # conn = collector.connect_and_discover() conn = None while conn == None: conn = collector.connect_and_discover() print(conn) if conn is not None: # time.sleep(10) # time.sleep(1000) while True: print("Connection not none") print("Closing collector...") collector.close() print("Collector has been closed.")
- Line 216 now reads:
if __name__ == "__main__": serial_port = #hard coded serial port main(serial_port) quit()
Things I have tried to resolve this issue:
- Uninstalling Python3.9, and installing Python3.8.8
- I have tried using different serial ports on my computer
The issue still exists.
Additionally, I am using a Mac, and have followed instructions here to properly disable MSD. I am able to verify that the board connects successfully via the serial port by opening nRF Connect and selecting the device.
My system Information:
OS: macOS Big Sur version 11.2.1
Python version 3.8.8
Connectivity firmware version: 4.2.1
SoftDevice API version 5
What am I unable to execute the pc_ble_driver_py example?
Please let me know if I can offer any additional information to help resolve this issue.