From 581dc2fb3f534586e5a09ad9bfb98f50962df83e Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 18 Dec 2019 13:22:59 -0800 Subject: [PATCH 1/3] Remove ANCS It now lives here: https://github.com/adafruit/Adafruit_CircuitPython_BLE_Apple_Notification_Center --- adafruit_ble/services/apple.py | 243 ---------------------------- docs/services.rst | 3 - examples/ble_apple_notifications.py | 34 ---- 3 files changed, 280 deletions(-) delete mode 100755 adafruit_ble/services/apple.py delete mode 100644 examples/ble_apple_notifications.py diff --git a/adafruit_ble/services/apple.py b/adafruit_ble/services/apple.py deleted file mode 100755 index 115192e..0000000 --- a/adafruit_ble/services/apple.py +++ /dev/null @@ -1,243 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2019 Scott Shawcroft for Adafruit Industries -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -""" -:py:mod:`~adafruit_ble.services.apple` -==================================================== - -This module provides Services defined by Apple. **Unimplemented.** - -""" - -import struct -import time - -from . import Service -from ..uuid import VendorUUID -from ..characteristics.stream import StreamIn, StreamOut - -__version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE.git" - -class ContinuityService(Service): - """Service used for cross-Apple device functionality like AirDrop. Unimplemented.""" - uuid = VendorUUID("d0611e78-bbb4-4591-a5f8-487910ae4366") - -class UnknownApple1Service(Service): - """Unknown service. Unimplemented.""" - uuid = VendorUUID("9fa480e0-4967-4542-9390-d343dc5d04ae") - -class _NotificationAttribute: - def __init__(self, attribute_id, *, max_length=False): - self._id = attribute_id - self._max_length = max_length - - def __get__(self, notification, cls): - if self._id in notification._attribute_cache: - return notification._attribute_cache[self._id] - - if self._max_length: - command = struct.pack(" 7: # pylint: disable=no-member - buffer = self.notification_source.read(8) # pylint: disable=no-member - event_id, event_flags, category_id, category_count, nid = struct.unpack(" time.monotonic() - start_time: - try: - new_notification = next(self._update()) - except StopIteration: - return - if new_notification: - yield new_notification - - @property - def active_notifications(self): - """A dictionary of active notifications keyed by id.""" - for _ in self._update(): - pass - return self._active_notifications - -class AppleMediaService(Service): - """View and control currently playing media. Unimplemented.""" - uuid = VendorUUID("89D3502B-0F36-433A-8EF4-C502AD55F8DC") diff --git a/docs/services.rst b/docs/services.rst index 2a66ed1..cee8742 100644 --- a/docs/services.rst +++ b/docs/services.rst @@ -9,9 +9,6 @@ standard_services -.. automodule:: adafruit_ble.services.apple - :members: - .. automodule:: adafruit_ble.services.circuitpython :members: diff --git a/examples/ble_apple_notifications.py b/examples/ble_apple_notifications.py deleted file mode 100644 index aa0f243..0000000 --- a/examples/ble_apple_notifications.py +++ /dev/null @@ -1,34 +0,0 @@ -""" -This example solicits that apple devices that provide notifications connect to it, initiates -pairing, prints existing notifications and then prints any new ones as they arrive. -""" - -import time -import adafruit_ble -from adafruit_ble.advertising.standard import SolicitServicesAdvertisement -from adafruit_ble.services.apple import AppleNotificationService - -radio = adafruit_ble.BLERadio() -a = SolicitServicesAdvertisement() -a.solicited_services.append(AppleNotificationService) -radio.start_advertising(a) - -while not radio.connected: - pass - -print("connected") - -known_notifications = set() - -while radio.connected: - for connection in radio.connections: - if not connection.paired: - connection.pair() - print("paired") - - ans = connection[AppleNotificationService] - for notification in ans.wait_for_new_notifications(): - print(notification) - time.sleep(1) - -print("disconnected") From 625cbef2171c5a1666479cc6b87f0588f88372ef Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 18 Dec 2019 13:24:01 -0800 Subject: [PATCH 2/3] Remove debug prints from example --- examples/ble_hid_periph.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/ble_hid_periph.py b/examples/ble_hid_periph.py index 230439b..cef9e21 100644 --- a/examples/ble_hid_periph.py +++ b/examples/ble_hid_periph.py @@ -121,15 +121,12 @@ hid = HIDService(HID_DESCRIPTOR) device_info = DeviceInfoService(software_revision=adafruit_ble.__version__, manufacturer="Adafruit Industries") -print(device_info.manufacturer) advertisement = ProvideServicesAdvertisement(hid) advertisement.appearance = 961 scan_response = Advertisement() scan_response.complete_name = "CircuitPython HID" ble = adafruit_ble.BLERadio() -print(advertisement) -print(to_hex(bytes(advertisement))) if not ble.connected: print("advertising") ble.start_advertising(advertisement, scan_response) From 03431500fd373ba77da07c89fa461da572d740a5 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 18 Dec 2019 13:30:47 -0800 Subject: [PATCH 3/3] Remove to_hex import that was used in debugging --- examples/ble_hid_periph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ble_hid_periph.py b/examples/ble_hid_periph.py index cef9e21..761affd 100644 --- a/examples/ble_hid_periph.py +++ b/examples/ble_hid_periph.py @@ -7,7 +7,7 @@ import time import adafruit_ble -from adafruit_ble.advertising import to_hex, Advertisement +from adafruit_ble.advertising import Advertisement from adafruit_ble.advertising.standard import ProvideServicesAdvertisement from adafruit_ble.services.standard.hid import HIDService from adafruit_ble.services.standard.device_info import DeviceInfoService