File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change 4343_MANUFACTURING_DATA_ADT = const (0xff )
4444_ADAFRUIT_COMPANY_ID = const (0x0822 )
4545_COLOR_DATA_ID = const (0x0000 )
46+ _RADIO_DATA_ID = const (0x0001 ) # TODO: check this isn't already taken.
47+
4648
4749class AdafruitColor (Advertisement ):
4850 """Broadcast a single RGB color."""
@@ -61,12 +63,17 @@ class AdafruitColor(Advertisement):
6163 color = ManufacturerDataField (_COLOR_DATA_ID , "<I" )
6264 """Color to broadcast as RGB integer."""
6365
64- # TODO: Add radio packets.
65- #
66- # class AdafruitRadio(Advertisement):
67- # prefix = b"\x06\xff\xff\xff\x00\x01"
68- #
69- # channel = Struct()
70- # address =
71- # group =
72- # data =
66+
67+ class AdafruitRadio (Advertisement ):
68+ """Broadcast arbitrary bytes as a radio message."""
69+ prefix = struct .pack ("<BBHH" ,
70+ 0x6 ,
71+ _MANUFACTURING_DATA_ADT ,
72+ _ADAFRUIT_COMPANY_ID ,
73+ _RADIO_DATA_ID )
74+ manufacturer_data = LazyField (ManufacturerData ,
75+ "manufacturer_data" ,
76+ advertising_data_type = _MANUFACTURING_DATA_ADT ,
77+ company_id = _ADAFRUIT_COMPANY_ID ,
78+ key_encoding = "<H" )
79+ msg = ManufacturerDataField (_RADIO_DATA_ID , "<248s" ) # 255 byte ads
You can’t perform that action at this time.
0 commit comments