Skip to content

Commit 42e871d

Browse files
committed
rename bleio to _bleio
1 parent a643591 commit 42e871d

File tree

12 files changed

+77
-74
lines changed

12 files changed

+77
-74
lines changed

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Introduction
1313
:target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_ble
1414
:alt: Build Status
1515

16-
This module provides higher-level BLE (Bluetooth Low Energy) functionality, building on the native `bleio` module.
16+
This module provides higher-level BLE (Bluetooth Low Energy) functionality,
17+
building on the native `_bleio` module.
1718

1819
Dependencies
1920
=============

adafruit_ble/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
====================================================
2525
2626
This module provides higher-level BLE (Bluetooth Low Energy) functionality,
27-
building on the native `bleio` module.
27+
building on the native `_bleio` module.
2828
2929
* Author(s): Dan Halbert for Adafruit Industries
3030

adafruit_ble/beacon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"""
3131

3232
import struct
33-
import bleio
33+
from _bleio import Peripheral
3434

3535
from .advertising import AdvertisingPacket
3636

@@ -41,7 +41,7 @@ def __init__(self, advertising_packet):
4141
4242
:param AdvertisingPacket advertising_packet
4343
"""
44-
self._broadcaster = bleio.Peripheral()
44+
self._broadcaster = Peripheral()
4545
self._advertising_packet = advertising_packet
4646

4747
def start(self, interval=1.0):
@@ -76,7 +76,7 @@ def __init__(self, company_id, uuid, major, minor, rssi):
7676
Example::
7777
7878
from adafruit_ble.beacon import LocationBeacon
79-
from bleio import UUID
79+
from adafruit_ble.uuid import UUID
8080
test_uuid = UUID('12345678-1234-1234-1234-123456789abc')
8181
test_company = 0xFFFF
8282
b = LocationBeacon(test_company, test_uuid, 123, 234, -54)

adafruit_ble/current_time_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import struct
3232
import time
3333

34-
from bleio import Peripheral, UUID
34+
from _bleio import Peripheral, UUID
3535
from .advertising import SolicitationAdvertisement
3636

3737
class CurrentTimeClient:

adafruit_ble/device_information_service.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Author(s): Dan Halbert for Adafruit Industries
2929
3030
"""
31-
from bleio import Attribute, Characteristic, UUID
31+
from _bleio import Attribute, Characteristic, Service, UUID
3232

3333
class DeviceInformationService:
3434
"""This is a factory class only, and has no instances."""
@@ -67,7 +67,7 @@ def add_to_peripheral(peripheral, *, model_number=None, serial_number=None,
6767
# Software Revision UUID = 0x2A28
6868
# Manufacturer Name UUID = 0x2A29
6969

70-
service = peripheral.add_service(UUID(0x180A))
70+
service = Service.add_to_peripheral(peripheral, UUID(0x180A))
7171

7272
if model_number is None:
7373
import sys
@@ -88,9 +88,10 @@ def add_to_peripheral(peripheral, *, model_number=None, serial_number=None,
8888
firmware_revision, hardware_revision, software_revision,
8989
manufacturer)):
9090

91-
service.add_characteristic(UUID(uuid_num), properties=Characteristic.READ,
92-
read_perm=Attribute.OPEN, write_perm=Attribute.NO_ACCESS,
93-
fixed_length=True, max_length=len(value),
94-
initial_value=value)
91+
Characteristic.add_to_service(
92+
service, UUID(uuid_num), properties=Characteristic.READ,
93+
read_perm=Attribute.OPEN, write_perm=Attribute.NO_ACCESS,
94+
fixed_length=True, max_length=len(value),
95+
initial_value=value)
9596

9697
return service

adafruit_ble/hid_server.py

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# for __version__
3636
import adafruit_ble
3737

38-
from bleio import Attribute, Characteristic, Descriptor, Peripheral, Service, UUID
38+
from _bleio import Attribute, Characteristic, Descriptor, Peripheral, Service, UUID
3939
from .advertising import ServerAdvertisement
4040
from .device_information_service import DeviceInformationService
4141

@@ -116,52 +116,52 @@ class HIDServer:
116116
b'\x95\x03' # Report Count (3)
117117
b'\x91\x01' # Output (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
118118
b'\xC0' # End Collection
119-
# b'\x05\x01' # Usage Page (Generic Desktop Ctrls)
120-
# b'\x09\x02' # Usage (Mouse)
121-
# b'\xA1\x01' # Collection (Application)
122-
# b'\x09\x01' # Usage (Pointer)
123-
# b'\xA1\x00' # Collection (Physical)
124-
# b'\x85\x02' # Report ID (2)
125-
# b'\x05\x09' # Usage Page (Button)
126-
# b'\x19\x01' # Usage Minimum (\x01)
127-
# b'\x29\x05' # Usage Maximum (\x05)
128-
# b'\x15\x00' # Logical Minimum (0)
129-
# b'\x25\x01' # Logical Maximum (1)
130-
# b'\x95\x05' # Report Count (5)
131-
# b'\x75\x01' # Report Size (1)
132-
# b'\x81\x02' # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
133-
# b'\x95\x01' # Report Count (1)
134-
# b'\x75\x03' # Report Size (3)
135-
# b'\x81\x01' # Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
136-
# b'\x05\x01' # Usage Page (Generic Desktop Ctrls)
137-
# b'\x09\x30' # Usage (X)
138-
# b'\x09\x31' # Usage (Y)
139-
# b'\x15\x81' # Logical Minimum (-127)
140-
# b'\x25\x7F' # Logical Maximum (127)
141-
# b'\x75\x08' # Report Size (8)
142-
# b'\x95\x02' # Report Count (2)
143-
# b'\x81\x06' # Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position)
144-
# b'\x09\x38' # Usage (Wheel)
145-
# b'\x15\x81' # Logical Minimum (-127)
146-
# b'\x25\x7F' # Logical Maximum (127)
147-
# b'\x75\x08' # Report Size (8)
148-
# b'\x95\x01' # Report Count (1)
149-
# b'\x81\x06' # Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position)
150-
# b'\xC0' # End Collection
151-
# b'\xC0' # End Collection
152-
# b'\x05\x0C' # Usage Page (Consumer)
153-
# b'\x09\x01' # Usage (Consumer Control)
154-
# b'\xA1\x01' # Collection (Application)
155-
# b'\x85\x03' # Report ID (3)
156-
# b'\x75\x10' # Report Size (16)
157-
# b'\x95\x01' # Report Count (1)
158-
# b'\x15\x01' # Logical Minimum (1)
159-
# b'\x26\x8C\x02' # Logical Maximum (652)
160-
# b'\x19\x01' # Usage Minimum (Consumer Control)
161-
# b'\x2A\x8C\x02' # Usage Maximum (AC Send)
162-
# b'\x81\x00' # Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
163-
# b'\xC0' # End Collection
164-
# b'\x05\x01' # Usage Page (Generic Desktop Ctrls)
119+
b'\x05\x01' # Usage Page (Generic Desktop Ctrls)
120+
b'\x09\x02' # Usage (Mouse)
121+
b'\xA1\x01' # Collection (Application)
122+
b'\x09\x01' # Usage (Pointer)
123+
b'\xA1\x00' # Collection (Physical)
124+
b'\x85\x02' # Report ID (2)
125+
b'\x05\x09' # Usage Page (Button)
126+
b'\x19\x01' # Usage Minimum (\x01)
127+
b'\x29\x05' # Usage Maximum (\x05)
128+
b'\x15\x00' # Logical Minimum (0)
129+
b'\x25\x01' # Logical Maximum (1)
130+
b'\x95\x05' # Report Count (5)
131+
b'\x75\x01' # Report Size (1)
132+
b'\x81\x02' # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
133+
b'\x95\x01' # Report Count (1)
134+
b'\x75\x03' # Report Size (3)
135+
b'\x81\x01' # Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
136+
b'\x05\x01' # Usage Page (Generic Desktop Ctrls)
137+
b'\x09\x30' # Usage (X)
138+
b'\x09\x31' # Usage (Y)
139+
b'\x15\x81' # Logical Minimum (-127)
140+
b'\x25\x7F' # Logical Maximum (127)
141+
b'\x75\x08' # Report Size (8)
142+
b'\x95\x02' # Report Count (2)
143+
b'\x81\x06' # Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position)
144+
b'\x09\x38' # Usage (Wheel)
145+
b'\x15\x81' # Logical Minimum (-127)
146+
b'\x25\x7F' # Logical Maximum (127)
147+
b'\x75\x08' # Report Size (8)
148+
b'\x95\x01' # Report Count (1)
149+
b'\x81\x06' # Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position)
150+
b'\xC0' # End Collection
151+
b'\xC0' # End Collection
152+
b'\x05\x0C' # Usage Page (Consumer)
153+
b'\x09\x01' # Usage (Consumer Control)
154+
b'\xA1\x01' # Collection (Application)
155+
b'\x85\x03' # Report ID (3)
156+
b'\x75\x10' # Report Size (16)
157+
b'\x95\x01' # Report Count (1)
158+
b'\x15\x01' # Logical Minimum (1)
159+
b'\x26\x8C\x02' # Logical Maximum (652)
160+
b'\x19\x01' # Usage Minimum (Consumer Control)
161+
b'\x2A\x8C\x02' # Usage Maximum (AC Send)
162+
b'\x81\x00' # Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
163+
b'\xC0' # End Collection
164+
b'\x05\x01' # Usage Page (Generic Desktop Ctrls)
165165
# b'\x09\x05' # Usage (Game Pad)
166166
# b'\xA1\x01' # Collection (Application)
167167
# b'\x85\x05' # Report ID (5)
@@ -198,8 +198,8 @@ class HIDServer:
198198

199199
_INPUT_REPORT_SIZES = {
200200
REPORT_ID_KEYBOARD : 8,
201-
# REPORT_ID_MOUSE : 4,
202-
# REPORT_ID_CONSUMER_CONTROL : 2,
201+
REPORT_ID_MOUSE : 4,
202+
REPORT_ID_CONSUMER_CONTROL : 2,
203203
# REPORT_ID_GAMEPAD : 6,
204204
}
205205

@@ -215,7 +215,7 @@ def __init__(self, name=None, tx_power=0):
215215
self._periph, software_revision=adafruit_ble.__version__,
216216
manufacturer="Adafruit Industries")
217217

218-
hid_service = Service.add_to_peripheral(UUID(_HID_SERVICE_UUID_NUM))
218+
hid_service = Service.add_to_peripheral(self._periph, UUID(_HID_SERVICE_UUID_NUM))
219219

220220
self._input_chars = {}
221221
for report_id in sorted(self._INPUT_REPORT_SIZES.keys()):

adafruit_ble/scanner.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"""
3131
import struct
3232

33-
import bleio
33+
from _bleio import Scanner as _BLEIOScanner
34+
from _bleio import UUID
3435

3536
from .advertising import AdvertisingPacket
3637

@@ -46,7 +47,7 @@ class Scanner:
4647
"""
4748

4849
def __init__(self):
49-
self._scanner = bleio.Scanner()
50+
self._scanner = _BLEIOScanner()
5051

5152
def scan(self, timeout, *, interval=0.1, window=0.1):
5253
"""Scan for advertisements from BLE devices. Suppress duplicates
@@ -82,7 +83,7 @@ class ScanEntry:
8283
"""
8384
Information about an advertising packet from a BLE device received by a `Scanner`.
8485
85-
:param bleio.ScanEntry scan_entry: lower-level ScanEntry returned from `bleio.Scanner`.
86+
:param _bleio.ScanEntry scan_entry: lower-level ScanEntry returned from `_bleio.Scanner`.
8687
This constructor is normally used only by `Scanner`.
8788
"""
8889

@@ -133,7 +134,7 @@ def service_uuids(self):
133134
for i in range(0, len(concat_uuids), 16):
134135
uuid_values.append(concat_uuids[i:i+16])
135136

136-
return [bleio.UUID(value) for value in uuid_values]
137+
return [UUID(value) for value in uuid_values]
137138

138139
@property
139140
def manufacturer_specific_data(self):

adafruit_ble/uart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Author(s): Dan Halbert for Adafruit Industries
2929
3030
"""
31-
from bleio import UUID
31+
from _bleio import UUID
3232

3333
NUS_SERVICE_UUID = UUID("6E400001-B5A3-F393-E0A9-E50E24DCCA9E")
3434
"""Nordic UART Service UUID"""

adafruit_ble/uart_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Author(s): Dan Halbert for Adafruit Industries
2929
3030
"""
31-
from bleio import Central, CharacteristicBuffer
31+
from _bleio import Central, CharacteristicBuffer
3232
from .uart import NUS_SERVICE_UUID, NUS_RX_CHAR_UUID, NUS_TX_CHAR_UUID
3333
from .scanner import Scanner, ScanEntry
3434

@@ -65,7 +65,7 @@ def __init__(self, *, timeout=1.0, buffer_size=64):
6565
def connect(self, address, timeout):
6666
"""Try to connect to the peripheral at the given address.
6767
68-
:param bleio.Address address: The address of the peripheral to connect to
68+
:param Address address: The address of the peripheral to connect to
6969
:param float/int timeout: Try to connect for ``timeout`` seconds.
7070
Not related to the timeout passed to ``UARTClient()``.
7171
"""

adafruit_ble/uart_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Author(s): Dan Halbert for Adafruit Industries
2929
3030
"""
31-
from bleio import Attribute, Characteristic, CharacteristicBuffer, Peripheral, Service
31+
from _bleio import Attribute, Characteristic, CharacteristicBuffer, Peripheral, Service
3232
from .advertising import ServerAdvertisement
3333
from .uart import NUS_SERVICE_UUID, NUS_RX_CHAR_UUID, NUS_TX_CHAR_UUID
3434

adafruit_ble/uuid.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
3030
"""
3131

32-
from bleio import UUID as bleio_UUID
32+
from _bleio import UUID as _bleio_UUID
3333

34-
UUID = bleio_UUID
35-
"""`adafruit_ble.UUID` is the same as `bleio.UUID`"""
34+
UUID = _bleio_UUID
35+
"""`adafruit_ble.UUID` is the same as `_bleio.UUID`"""

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Uncomment the below if you use native CircuitPython modules such as
2121
# digitalio, micropython and busio. List the modules you use. Without it, the
2222
# autodoc module docs will fail to generate with a warning.
23-
autodoc_mock_imports = ["bleio"]
23+
autodoc_mock_imports = ["_bleio"]
2424

2525

2626
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

0 commit comments

Comments
 (0)