adafruit / adafruit/Adafruit_CircuitPython_BLE

Does advertising.standard.ManufacturerDataField.field_names currently serve a purpose?

Open
#114 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
138
Forks
58
PR merge metrics
No merged PRs in 30d

Description

Correct me where I'm wrong:

The two possible ways to pack multiple bits of (manufacturer) data into an advertisement are

1) create multiple ManufacturerDataField() items in your ad class.
Pro: you get to access that data with `AlexsAd.firstdataitem` syntax, and you get to include-or-not items as you see fit per-broadcast.
Con: Costs a few bytes to include the data type ID before the data item in the ad.
2) create a single ManufacturerDataField() item, with a format that includes however many fields, all of which must be populated for any given ad.
Pro: Saves having to spend a couple bytes per field
Con: Have to access with `AlexsAd.data[index]` where you simply have to know the relevance of data at a given index, and data must have some rational "null" value that indicates "I never set that" like 0 for battery voltage, or -1 for "firefighters on scene"

Assuming I understand that architecture right, what purpose does the `self.field_names` object serve in advertising.standard.ManufacturerDataField on https://github.com/adafruit/Adafruit_CircuitPython_BLE/blob/8bb1210eebed4846dae7e76ff1db86a010b132bc/adafruit_ble/advertising/standard.py#L270?

It seems to add some structure and convenience about what the different indices in a `ManufacturerDataField` tuple mean, but also there doesn't seem to be any actual way to use that. The `field_names` must be defined at the class level for the class to function right, but then the values passed serve no purpose from that point on other than to consume memory (do they even?).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at adafruit_ble/advertising/standard.py around ManufacturerDataField and its field_names definition. Trace where field_names is read, including the two packing approaches described in the issue, and check related advertising classes or tests. Done means establishing whether it has a runtime purpose and identifying the resulting change or documentation needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.