Skip to content

Commit

Permalink
Refactor to use backend-specific device subclasses.
Browse files Browse the repository at this point in the history
  • Loading branch information
peplin committed Oct 5, 2015
1 parent ddc78d2 commit 0d81180
Show file tree
Hide file tree
Showing 14 changed files with 542 additions and 430 deletions.
5 changes: 2 additions & 3 deletions pygatt/adapter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .constants import DEFAULT_CONNECT_TIMEOUT_S
from .classes import BLEDevice


# TODO is this really neccessary?
class BLEAdapter(object):

def __init__(self, backend):
Expand All @@ -12,8 +12,7 @@ def stop(self):
self.backend.stop()

def connect(self, address, timeout=DEFAULT_CONNECT_TIMEOUT_S):
handle = self.backend.connect(address, timeout=timeout)
return BLEDevice(address, handle, self.backend)
return self.backend.connect(address, timeout=timeout)

def scan(self, name_filter="", *args, **kwargs):
"""
Expand Down
20 changes: 2 additions & 18 deletions pygatt/backends/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def supports_unbonded(self):
return True

def connect(self, address, **kwargs):
"""Return a handle for the connection if connected, otherwise raise an
expception.
"""Return a BLEDevice for the connection if connected, otherwise raise
an exception.
"""
raise NotImplementedError()

Expand All @@ -33,22 +33,6 @@ def scan(self, *args, **kwargs):
"""
raise NotImplementedError()

def bond(self, connection_handle):
raise NotImplementedError()

def char_read(self, connection_handle, handle):
raise NotImplementedError()

def char_write(self, connection_handle, handle, value,
wait_for_response=False):
raise NotImplementedError()

def measure_rssi(self, connection_handle):
raise NotImplementedError()

def disconnect(self, connection_handle):
raise NotImplementedError()


class Characteristic(object):
"""
Expand Down
Loading

0 comments on commit 0d81180

Please sign in to comment.