Skip to content

Commit 78e3a12

Browse files
committed
appease pre-commit gods
1 parent 37c6765 commit 78e3a12

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

adafruit_ble_apple_notification_center.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,18 @@ def __init__(
143143

144144
def send_positive_action(self):
145145
"""Sends positive action on this notification. For example, to accept an IncomingCall."""
146-
cmd = 2 # ANCS_CMD_PERFORM_NOTIFICATION_ACTION,
146+
cmd = 2 # ANCS_CMD_PERFORM_NOTIFICATION_ACTION,
147147
uid = self.id
148-
action_id = 0 # ANCS_ACTION_POSITIVE
149-
buffer = struct.pack( "<BIB", cmd, uid, action_id )
148+
action_id = 0 # ANCS_ACTION_POSITIVE
149+
buffer = struct.pack("<BIB", cmd, uid, action_id)
150150
self.control_point.write(buffer)
151151

152152
def send_negative_action(self):
153153
"""Sends negative action on this notification. For example, to decline an IncomingCall."""
154-
cmd = 2 # ANCS_CMD_PERFORM_NOTIFICATION_ACTION,
154+
cmd = 2 # ANCS_CMD_PERFORM_NOTIFICATION_ACTION,
155155
uid = self.id
156-
action_id = 1 # ANCS_ACTION_NEGATIVE
157-
buffer = struct.pack( "<BIB", cmd, uid, action_id )
156+
action_id = 1 # ANCS_ACTION_NEGATIVE
157+
buffer = struct.pack("<BIB", cmd, uid, action_id)
158158
self.control_point.write(buffer)
159159

160160
def update(self, event_flags, category_id, category_count):

examples/ble_apple_notification_center_callhandler.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
# Circuit Playground Bluefruit buttons and LED setup
2121
butA = digitalio.DigitalInOut(board.D4) # CPB "A" button
2222
butB = digitalio.DigitalInOut(board.D5) # CPB "B" button
23-
butA.switch_to_input(digitalio.Pull.DOWN) # buttons are active HIGH
23+
butA.switch_to_input(digitalio.Pull.DOWN) # buttons are active HIGH
2424
butB.switch_to_input(digitalio.Pull.DOWN)
2525

2626
leds = neopixel.NeoPixel(board.D8, 10, brightness=0.1)
2727

28-
(coff, cred, cgrn, cblu, cgra) = (0x000000, 0xff0000, 0x00ff00, 0x0000ff, 0x111111 )
29-
leds_off = ( coff,coff,coff,coff,coff, coff,coff,coff,coff,coff )
30-
leds_idle = ( cgra,cgra,cgra,cgra,cgra, cgra,cgra,cgra,cgra,cgra )
31-
leds_incoming_call = ( coff,cgrn,cgrn,cgrn,coff, coff,cred,cred,cred,coff )
32-
leds_active_call = ( cgrn,coff,coff,coff,cgrn, cgrn,cred,cred,cred,cgrn )
28+
(coff, cred, cgrn, cblu, cgra) = (0x000000, 0xFF0000, 0x00FF00, 0x0000FF, 0x111111)
29+
leds_off = (coff, coff, coff, coff, coff, coff, coff, coff, coff, coff)
30+
leds_idle = (cgra, cgra, cgra, cgra, cgra, cgra, cgra, cgra, cgra, cgra)
31+
leds_incoming_call = (coff, cgrn, cgrn, cgrn, coff, coff, cred, cred, cred, coff)
32+
leds_active_call = (cgrn, coff, coff, coff, cgrn, cgrn, cred, cred, cred, cgrn)
3333

3434
print("starting...")
3535
radio = adafruit_ble.BLERadio() # pylint: disable=no-member
3636
a = SolicitServicesAdvertisement()
37-
#a.complete_name = "CIRPYCALLHANDLER" # this crashes things?
37+
# a.complete_name = "CIRPYCALLHANDLER" # this crashes things?
3838
a.solicited_services.append(ancs.AppleNotificationCenterService)
3939
radio.start_advertising(a)
4040

@@ -64,21 +64,34 @@
6464
if butA.value:
6565
print("Action: accepting call")
6666
notification.send_positive_action()
67-
time.sleep(1) # simple debounce
67+
time.sleep(1) # simple debounce
6868
if butB.value:
6969
print("Action: declining call")
7070
notification.send_negative_action()
71-
time.sleep(1) # simple debounce
71+
time.sleep(1) # simple debounce
7272
# active call category, only has negative action
7373
if notification.category_id == 12:
7474
leds[:] = leds_active_call
7575
if butB.value:
7676
print("Action: hanging up call")
7777
notification.send_negative_action()
78-
time.sleep(1) # simple debounce
78+
time.sleep(1) # simple debounce
7979

8080
if time.monotonic() - last_display_time > 3.0:
8181
last_display_time = time.monotonic()
82-
print("Current Notifications:", len(ans.active_notifications), time.monotonic())
82+
print(
83+
"Current Notifications:",
84+
len(ans.active_notifications),
85+
time.monotonic(),
86+
)
8387
for nid, n in ans.active_notifications.items():
84-
print("- uid:",n.id, "catid:", n.category_id, "title:", n.title, "msg:", n.message)
88+
print(
89+
"- uid:",
90+
n.id,
91+
"catid:",
92+
n.category_id,
93+
"title:",
94+
n.title,
95+
"msg:",
96+
n.message,
97+
)

0 commit comments

Comments
 (0)