Skip to content

Instantly share code, notes, and snippets.

@akshmakov
Last active March 24, 2020 21:33
Show Gist options
  • Save akshmakov/fe6d0360a6d46dbbb3340fe5fa27b40b to your computer and use it in GitHub Desktop.
Save akshmakov/fe6d0360a6d46dbbb3340fe5fa27b40b to your computer and use it in GitHub Desktop.
pygatt debug snippet
#!/usr/bin/env python3
import pygatt
import logging
logging.basicConfig()
logging.getLogger('pygatt').setLevel(logging.DEBUG)
b = pygatt.BGAPIBackend()
b.start()
#b.scan()
@calroc
Copy link

calroc commented Mar 24, 2020

(venv) sforman@bock:~/Desktop/muse$ python
Python 2.7.12 (default, Oct  8 2019, 14:14:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygatt
>>> import logging
>>> logging.basicConfig()
>>> logging.getLogger('pygatt').setLevel(logging.DEBUG)
>>> b = pygatt.BGAPIBackend()
INFO:pygatt.backends.bgapi.bgapi:Initialized new BGAPI backend
>>> b.start()
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 2 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyS0 - ttyS0
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyACM0 - Low Energy Dongle - CDC control
DEBUG:pygatt.backends.bgapi.util:USB device: Low Energy Dongle - CDC control VID=0x2458 PID=0x0001 on /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Resetting and reconnecting to device for a clean environment
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 1)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 2 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyS0 - ttyS0
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyACM0 - Low Energy Dongle - CDC control
DEBUG:pygatt.backends.bgapi.util:USB device: Low Energy Dongle - CDC control VID=0x2458 PID=0x0001 on /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/ttyACM0
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 1)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 1 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyS0 - ttyS0
DEBUG:pygatt.backends.bgapi.bgapi:Failed to open serial port
Traceback (most recent call last):
  File "/home/sforman/Desktop/muse/venv/local/lib/python2.7/site-packages/pygatt/backends/bgapi/bgapi.py", line 171, in _open_serial_port
    serial_port = self._serial_port or self._detect_device_port()
  File "/home/sforman/Desktop/muse/venv/local/lib/python2.7/site-packages/pygatt/backends/bgapi/bgapi.py", line 147, in _detect_device_port
    raise BGAPIError("Unable to auto-detect BLED112 serial port")
BGAPIError: Unable to auto-detect BLED112 serial port
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 2)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 1 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyS0 - ttyS0
DEBUG:pygatt.backends.bgapi.bgapi:Failed to open serial port
Traceback (most recent call last):
  File "/home/sforman/Desktop/muse/venv/local/lib/python2.7/site-packages/pygatt/backends/bgapi/bgapi.py", line 171, in _open_serial_port
    serial_port = self._serial_port or self._detect_device_port()
  File "/home/sforman/Desktop/muse/venv/local/lib/python2.7/site-packages/pygatt/backends/bgapi/bgapi.py", line 147, in _detect_device_port
    raise BGAPIError("Unable to auto-detect BLED112 serial port")
BGAPIError: Unable to auto-detect BLED112 serial port
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 3)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 2 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyS0 - ttyS0
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/ttyACM0 - Low Energy Dongle - CDC control
DEBUG:pygatt.backends.bgapi.util:USB device: Low Energy Dongle - CDC control VID=0x2458 PID=0x0001 on /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Running receiver
INFO:pygatt.backends.bgapi.bgapi:Disabling advertising
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.gap_set_mode: 58>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.gap_set_mode packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.sm_set_bondable_mode: 51>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.sm_set_bondable_mode packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Stopping any outstanding GAP procedure
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.gap_end_procedure: 61>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.gap_end_procedure packet: Device in wrong state
>>> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment