Skip to content

Commit 926b491

Browse files
committed
add a non-empty bluefruit_connect_simpletest.py
1 parent 3f4f160 commit 926b491

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
# To be supplied
1+
# Print out the color data from a ColorPacket.
2+
3+
from adafruit_ble.uart import UARTServer
4+
from adafruit_bluefruit_connect.packet import Packet
5+
# Only the packet classes that are imported will be known to Packet.
6+
from adafruit_bluefruit_connect.color_packet import ColorPacket
7+
8+
uart_server = UARTServer()
9+
10+
advertising_now = False
11+
12+
while True:
13+
if not uart_server.connected:
14+
if not advertising_now:
15+
uart_server.start_advertising()
16+
advertising_now = True
17+
continue
18+
19+
# Connected, so no longer advertising
20+
advertising_now = False
21+
22+
packet = Packet.from_stream(uart_server)
23+
if isinstance(packet, ColorPacket):
24+
print(packet.color)

0 commit comments

Comments
 (0)