diff --git a/adafruit_ble/advertising/standard.py b/adafruit_ble/advertising/standard.py index 4259be0..0d1b5f7 100644 --- a/adafruit_ble/advertising/standard.py +++ b/adafruit_ble/advertising/standard.py @@ -29,6 +29,7 @@ """ import struct +from collections import OrderedDict from . import ( Advertisement, @@ -211,7 +212,9 @@ def __init__(self, *services): class ManufacturerData(AdvertisingDataField): """Encapsulates manufacturer specific keyed data bytes. The manufacturer is identified by the company_id and the data is structured like an advertisement with a configurable key - format.""" + format. The order of the serialized data is determined by the order that the + `ManufacturerDataField` attributes are set in - this can be useful for + `match_prefixes` in an `Advertisement` sub-class.""" def __init__( self, obj, *, advertising_data_type=0xFF, company_id, key_encoding="B" @@ -220,7 +223,7 @@ def __init__( self._company_id = company_id self._adt = advertising_data_type - self.data = {} + self.data = OrderedDict() # makes field order match order they are set in self.company_id = company_id encoded_company = struct.pack("