Skip to content

Commit 1bd6906

Browse files
committed
Renamed trigger_based flag
1 parent e0748a5 commit 1bd6906

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ a hint to the receiver that the device might not be sending advertisements for
6868
a long time:
6969

7070
```
71-
beacon = BTHome("myBeacon", interval_advertising=False)
71+
beacon = BTHome("myBeacon", trigger_based=True)
7272
```
7373

7474
## Will it run on Microcontroller X?

src/bthome.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class BTHome:
3030
_local_name = ""
3131

3232
# Whether the device sends updates at regular intervals or on a trigger like a button.
33-
_interval_advertising = True
34-
_INTERVAL_ADVERTISING_FLAG = 0x4
33+
_trigger_based = False
34+
_TRIGGER_BASED_FLAG = 0x4
3535

3636
# For most sensors defined below, the naming convention is:
3737
# <const_name> ::= <property> "_" <data-type> "_x" <inverse of factor>
@@ -314,11 +314,11 @@ class BTHome:
314314
button = 0
315315
dimmer = 0
316316

317-
def __init__(self, local_name="BTHome", interval_advertising=True, debug=False):
317+
def __init__(self, local_name="BTHome", trigger_based=False, debug=False):
318318
local_name = local_name[:10] # Truncate to fit [^4]
319319
self._local_name = local_name
320320
self._packet_id = 0
321-
self._interval_advertising = interval_advertising
321+
self._trigger_based = trigger_based
322322
self.debug = debug
323323

324324
@property
@@ -493,10 +493,10 @@ def _pack_service_data(self, *args):
493493
) # indicates a 16-bit service UUID follows
494494
service_data_bytes += pack("<H", BTHome._SERVICE_UUID16)
495495
flags = BTHome._DEVICE_INFO_FLAGS
496-
if self._interval_advertising:
497-
flags &= ~self._INTERVAL_ADVERTISING_FLAG
496+
if self._trigger_based:
497+
flags |= self._TRIGGER_BASED_FLAG
498498
else:
499-
flags |= self._INTERVAL_ADVERTISING_FLAG
499+
flags &= ~self._TRIGGER_BASED_FLAG
500500
service_data_bytes += pack("B", flags)
501501
args = sorted(args, key = lambda x: x if isinstance(x, int) else x[0])
502502
for object_id in args:

0 commit comments

Comments
 (0)