-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed broken examples, added unit tests. (#123)
* Fixed broken examples, added unit tests. * Linting * More fixes * Fixed PyTest execution * Fixed PyTest execution * Fixed PyTest execution * Fixed uninitialized memory
- Loading branch information
Showing
17 changed files
with
161 additions
and
29 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 |
---|---|---|
|
@@ -6,6 +6,7 @@ _doxygen | |
|
||
/build_* | ||
simplepyble/build | ||
simplepyble/dist | ||
|
||
__pycache__ | ||
*.egg-info | ||
|
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
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
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
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
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
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,3 +1,7 @@ | ||
twine | ||
wheel | ||
ninja | ||
pytest | ||
pybind11 | ||
setuptools | ||
cibuildwheel==2.9 |
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,62 @@ | ||
# Note: This test suite is only evaluating the Python bindings, not the C++ library. | ||
# The SimpleBLE implementation to test this on is the PLAIN version. | ||
import simplepyble | ||
|
||
|
||
def test_get_adapters(): | ||
assert simplepyble.Adapter.bluetooth_enabled() == True | ||
|
||
adapters = simplepyble.Adapter.get_adapters() | ||
assert len(adapters) == 1 | ||
|
||
adapter = adapters[0] | ||
assert adapter.identifier() == "Plain Adapter" | ||
assert adapter.address() == "AA:BB:CC:DD:EE:FF" | ||
|
||
|
||
def test_scan_blocking(): | ||
adapter = simplepyble.Adapter.get_adapters()[0] | ||
|
||
adapter.scan_for(1) | ||
peripherals = adapter.scan_get_results() | ||
assert len(peripherals) == 1 | ||
|
||
peripheral = peripherals[0] | ||
assert peripheral.identifier() == "Plain Peripheral" | ||
assert peripheral.address() == "11:22:33:44:55:66" | ||
assert peripheral.rssi() == -60 | ||
assert peripheral.is_connected() == False | ||
assert peripheral.is_paired() == False | ||
|
||
|
||
def test_scan_async(): | ||
# TODO: Implement once we have proper callback and advertising emulation. | ||
pass | ||
|
||
|
||
def test_connect(): | ||
adapter = simplepyble.Adapter.get_adapters()[0] | ||
|
||
adapter.scan_for(1) | ||
peripherals = adapter.scan_get_results() | ||
peripheral = peripherals[0] | ||
|
||
peripheral.connect() | ||
assert peripheral.is_connected() == True | ||
assert peripheral.is_paired() == True | ||
|
||
services = peripheral.services() | ||
assert len(services) == 1 | ||
|
||
service = services[0] | ||
assert service.uuid() == "0000180f-0000-1000-8000-00805f9b34fb" | ||
|
||
characteristics = service.characteristics() | ||
assert len(characteristics) == 1 | ||
|
||
characteristic = characteristics[0] | ||
assert characteristic.uuid() == "00002a19-0000-1000-8000-00805f9b34fb" | ||
|
||
peripheral.disconnect() | ||
assert peripheral.is_connected() == False | ||
assert peripheral.is_paired() == True |
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