-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ruuvi-friends/better-structure
Iteration on structure and base interface
- Loading branch information
Showing
8 changed files
with
200 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
class BluetoothAdaptor(object): | ||
|
||
def __init__(self, callback, bt_device=''): | ||
''' | ||
Arguments: | ||
callback: Function that receives the data from BLE | ||
device (string): BLE device (default 0) | ||
''' | ||
|
||
self.callback = callback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
import logging | ||
from simple_ruuvitag.adaptors import BluetoothAdaptor | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
class DummyBle(object): | ||
class DummyBle(BluetoothAdaptor): | ||
'''Bluetooth LE communication with Bleson''' | ||
|
||
def mock_datas(self, callback): | ||
|
||
callback(('DU:MM:YD:AT:A9:3D', | ||
'1E0201060303AAFE1616AAFE10EE037275752E76692F23416A7759414D4663CD')) | ||
|
||
callback(('NO:TS:UP:PO:RT:ED', | ||
'1E0201060303AAFE1616AAFE10EE037275752E76692F23416A7759414D4663CD')) | ||
|
||
def __init__(self): | ||
self.observer = None | ||
callback( | ||
{ | ||
"address": 'DU:MM:YD:AT:A9:3D', | ||
"raw_data": '1E0201060303AAFE1616AAFE10EE037275752E76692F23416A7759414D4663CD' | ||
} | ||
) | ||
|
||
def start(self, callback, bt_device=''): | ||
callback( | ||
{ | ||
"address": 'NO:TS:UP:PO:RT:ED', | ||
"raw_data": '1E0201060303AAFE1616AAFE10EE037275752E76692F23416A7759414D4663CD' | ||
} | ||
) | ||
|
||
def start(self): | ||
|
||
# Simulates the call to the callback | ||
self.mock_datas(callback) | ||
self.mock_datas(self.callback) | ||
|
||
return None | ||
|
||
def stop(self): | ||
pass | ||
# dummy BLE cannot stop. | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.