Skip to content

Commit a4b6429

Browse files
committed
add examples
1 parent 64aac3f commit a4b6429

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

adafruit_ble/uart.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ def connected(self):
6262
return self._periph.connected
6363

6464
def read(self):
65-
"""Read the next available byte from the buffered input. Return None if nothing is available."""
65+
"""Read the next available byte from the buffered input.
66+
Return None if nothing is available.
67+
"""
6668
return self._rx_buffer.read()
6769

68-
def write(self, char):
69-
"""TEMP"""
70-
self._nus_tx_char.value = char
70+
def write(self, bytes_to_write):
71+
"""Write a buffer of bytes."""
72+
self._nus_tx_char.value = bytes_to_write

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Uncomment the below if you use native CircuitPython modules such as
2121
# digitalio, micropython and busio. List the modules you use. Without it, the
2222
# autodoc module docs will fail to generate with a warning.
23-
# autodoc_mock_imports = ["digitalio", "busio"]
23+
autodoc_mock_imports = ["bleio"]
2424

2525

2626
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

examples/ble_eddystone_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from adafruit_ble.beacon import EddystoneURLBeacon
2+
3+
beacon = EddystoneURLBeacon('https://adafru.it/4062')
4+
beacon.start()

examples/ble_uart_echo_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from adafruit_ble.uart import UARTService
2+
3+
# Starts advertising automatically. That may change in later versions.
4+
uart = UARTService()
5+
6+
while True:
7+
# Returns one if nothing was read.
8+
one_byte = uart.read()
9+
if one_byte:
10+
uart.write(bytes([one_byte]))

0 commit comments

Comments
 (0)