Skip to content

Commit c9d2b4d

Browse files
committed
Add support for a TextPacket, as sent using the UART module in the AdaFruit BlueTooth app
1 parent c9eca4b commit c9d2b4d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

adafruit_bluefruit_connect/packet.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,24 @@ def from_stream(cls, stream):
9494
if not start:
9595
# Timeout: nothing read.
9696
return None
97+
9798
if start == b"!":
9899
# Found start of packet.
99100
packet_type = stream.read(1)
100101
if not packet_type:
101102
# Timeout: nothing more read.
102103
return None
103104
break
105+
104106
# Didn't find a packet start.
105-
else:
106-
text_packet_cls = cls._type_to_class.get(b"TX", None)
107-
# Is TextPacket registered?
108-
# If so, read an entire line and pass that to TextPacket.
109-
if text_packet_cls:
110-
ln = stream.readline()
111-
packet = bytes(start + ln)
112-
return text_packet_cls(packet)
113-
114-
# else loop and try again.
107+
text_packet_cls = cls._type_to_class.get(b"TX", None)
108+
# Is TextPacket registered?
109+
# If so, read an entire line and pass that to TextPacket.
110+
if text_packet_cls:
111+
packet = bytes(start + stream.readline())
112+
return text_packet_cls(packet)
113+
114+
# else loop and try again.
115115

116116
header = bytes(start + packet_type)
117117
packet_class = cls._type_to_class.get(header, None)

0 commit comments

Comments
 (0)