Start work on types
Bring in typings folder for adafruit_ble and micropython
This commit is contained in:
173
typings/adafruit_ble/advertising/__init__.pyi
Normal file
173
typings/adafruit_ble/advertising/__init__.pyi
Normal file
@@ -0,0 +1,173 @@
|
||||
"""
|
||||
This type stub file was generated by pyright.
|
||||
"""
|
||||
|
||||
import struct
|
||||
|
||||
"""
|
||||
Advertising is the first phase of BLE where devices can broadcast
|
||||
"""
|
||||
def to_hex(seq): # -> str:
|
||||
"""Pretty prints a byte sequence as hex values."""
|
||||
...
|
||||
|
||||
def to_bytes_literal(seq): # -> str:
|
||||
"""Prints a byte sequence as a Python bytes literal that only uses hex encoding."""
|
||||
...
|
||||
|
||||
def decode_data(data, *, key_encoding=...): # -> dict[Unknown, Unknown]:
|
||||
"""Helper which decodes length encoded structures into a dictionary with the given key
|
||||
encoding."""
|
||||
...
|
||||
|
||||
def compute_length(data_dict, *, key_encoding=...): # -> int:
|
||||
"""Computes the length of the encoded data dictionary."""
|
||||
...
|
||||
|
||||
def encode_data(data_dict, *, key_encoding=...): # -> bytes:
|
||||
"""Helper which encodes dictionaries into length encoded structures with the given key
|
||||
encoding."""
|
||||
...
|
||||
|
||||
class AdvertisingDataField:
|
||||
"""Top level class for any descriptor classes that live in Advertisement or its subclasses."""
|
||||
...
|
||||
|
||||
|
||||
class AdvertisingFlag:
|
||||
"""A single bit flag within an AdvertisingFlags object."""
|
||||
def __init__(self, bit_position) -> None:
|
||||
...
|
||||
|
||||
def __get__(self, obj, cls): # -> AdvertisingFlag:
|
||||
...
|
||||
|
||||
def __set__(self, obj, value): # -> None:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class AdvertisingFlags(AdvertisingDataField):
|
||||
"""Standard advertising flags"""
|
||||
limited_discovery = ...
|
||||
general_discovery = ...
|
||||
le_only = ...
|
||||
def __init__(self, advertisement, advertising_data_type) -> None:
|
||||
...
|
||||
|
||||
def __len__(self): # -> Literal[1]:
|
||||
...
|
||||
|
||||
def __bytes__(self): # -> bytes:
|
||||
...
|
||||
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class String(AdvertisingDataField):
|
||||
"""UTF-8 encoded string in an Advertisement.
|
||||
|
||||
Not null terminated once encoded because length is always transmitted."""
|
||||
def __init__(self, *, advertising_data_type) -> None:
|
||||
...
|
||||
|
||||
def __get__(self, obj, cls): # -> String | str | None:
|
||||
...
|
||||
|
||||
def __set__(self, obj, value): # -> None:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class Struct(AdvertisingDataField):
|
||||
"""`struct` encoded data in an Advertisement."""
|
||||
def __init__(self, struct_format, *, advertising_data_type) -> None:
|
||||
...
|
||||
|
||||
def __get__(self, obj, cls): # -> Struct | Any | None:
|
||||
...
|
||||
|
||||
def __set__(self, obj, value): # -> None:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class LazyObjectField(AdvertisingDataField):
|
||||
"""Non-data descriptor useful for lazily binding a complex object to an advertisement object."""
|
||||
def __init__(self, cls, attribute_name, *, advertising_data_type, **kwargs) -> None:
|
||||
...
|
||||
|
||||
def __get__(self, obj, cls): # -> LazyObjectField | None:
|
||||
...
|
||||
|
||||
@property
|
||||
def advertising_data_type(self):
|
||||
"""Return the data type value used to indicate this field."""
|
||||
...
|
||||
|
||||
|
||||
|
||||
class Advertisement:
|
||||
"""Core Advertisement type.
|
||||
|
||||
The class attribute ``match_prefixes``, if not ``None``, is a tuple of
|
||||
bytestring prefixes to match against the multiple data structures in the advertisement.
|
||||
"""
|
||||
match_prefixes = ...
|
||||
_prefix_bytes = ...
|
||||
flags = ...
|
||||
short_name = ...
|
||||
complete_name = ...
|
||||
tx_power = ...
|
||||
appearance = ...
|
||||
def __init__(self, *, entry=...) -> None:
|
||||
"""Create an empty advertising packet or one from a ScanEntry."""
|
||||
...
|
||||
|
||||
@property
|
||||
def rssi(self): # -> None:
|
||||
"""Signal strength of the scanned advertisement. Only available on Advertisements returned
|
||||
from `BLERadio.start_scan()`. (read-only)"""
|
||||
...
|
||||
|
||||
@classmethod
|
||||
def get_prefix_bytes(cls): # -> bytes | Any:
|
||||
"""Return a merged version of match_prefixes as a single bytes object,
|
||||
with length headers.
|
||||
"""
|
||||
...
|
||||
|
||||
@classmethod
|
||||
def matches(cls, entry):
|
||||
"""Returns ``True`` if the given `_bleio.ScanEntry` advertisement fields
|
||||
matches all of the given prefixes in the `match_prefixes` tuple attribute.
|
||||
Subclasses may override this to match any instead of all.
|
||||
"""
|
||||
...
|
||||
|
||||
@classmethod
|
||||
def matches_prefixes(cls, entry, *, all_):
|
||||
"""Returns ``True`` if the given `_bleio.ScanEntry` advertisement fields
|
||||
match any or all of the given prefixes in the `match_prefixes` tuple attribute.
|
||||
If ``all_`` is ``True``, all the prefixes must match. If ``all_`` is ``False``,
|
||||
returns ``True`` if at least one of the prefixes match.
|
||||
"""
|
||||
...
|
||||
|
||||
def __bytes__(self): # -> bytes:
|
||||
"""The raw packet bytes."""
|
||||
...
|
||||
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
|
||||
def __len__(self): # -> int:
|
||||
...
|
||||
|
||||
def __repr__(self): # -> str:
|
||||
...
|
||||
|
||||
|
||||
|
122
typings/adafruit_ble/advertising/standard.pyi
Normal file
122
typings/adafruit_ble/advertising/standard.pyi
Normal file
@@ -0,0 +1,122 @@
|
||||
"""
|
||||
This type stub file was generated by pyright.
|
||||
"""
|
||||
|
||||
from . import Advertisement, AdvertisingDataField
|
||||
|
||||
"""
|
||||
:py:mod:`~adafruit_ble.advertising.standard`
|
||||
====================================================
|
||||
|
||||
This module provides BLE standard defined advertisements. The Advertisements are single purpose
|
||||
even though multiple purposes may actually be present in a single packet.
|
||||
|
||||
"""
|
||||
__version__ = ...
|
||||
__repo__ = ...
|
||||
class BoundServiceList:
|
||||
"""Sequence-like object of Service UUID objects. It stores both standard and vendor UUIDs."""
|
||||
def __init__(self, advertisement, *, standard_services, vendor_services) -> None:
|
||||
...
|
||||
|
||||
def __contains__(self, key): # -> bool:
|
||||
...
|
||||
|
||||
def __iter__(self): # -> Iterator[Unknown]:
|
||||
...
|
||||
|
||||
def append(self, service): # -> None:
|
||||
"""Append a service to the list."""
|
||||
...
|
||||
|
||||
def extend(self, services): # -> None:
|
||||
"""Appends all services in the iterable to the list."""
|
||||
...
|
||||
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class ServiceList(AdvertisingDataField):
|
||||
"""Descriptor for a list of Service UUIDs that lazily binds a corresponding BoundServiceList."""
|
||||
def __init__(self, *, standard_services, vendor_services) -> None:
|
||||
...
|
||||
|
||||
def __get__(self, obj, cls): # -> ServiceList | tuple[()]:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class ProvideServicesAdvertisement(Advertisement):
|
||||
"""Advertise what services that the device makes available upon connection."""
|
||||
match_prefixes = ...
|
||||
services = ...
|
||||
def __init__(self, *services, entry=...) -> None:
|
||||
...
|
||||
|
||||
@classmethod
|
||||
def matches(cls, entry):
|
||||
"""Only one kind of service list need be present in a ProvideServicesAdvertisement,
|
||||
so override the default behavior and match any prefix, not all.
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
|
||||
class SolicitServicesAdvertisement(Advertisement):
|
||||
"""Advertise what services the device would like to use over a connection."""
|
||||
match_prefixes = ...
|
||||
solicited_services = ...
|
||||
def __init__(self, *services, entry=...) -> None:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class ManufacturerData(AdvertisingDataField):
|
||||
"""Encapsulates manufacturer specific keyed data bytes. The manufacturer is identified by the
|
||||
company_id and the data is structured like an advertisement with a configurable key
|
||||
format. The order of the serialized data is determined by the order that the
|
||||
`ManufacturerDataField` attributes are set in - this can be useful for
|
||||
`match_prefixes` in an `Advertisement` sub-class."""
|
||||
def __init__(self, obj, *, advertising_data_type=..., company_id, key_encoding=...) -> None:
|
||||
...
|
||||
|
||||
def __len__(self): # -> int:
|
||||
...
|
||||
|
||||
def __bytes__(self): # -> bytes:
|
||||
...
|
||||
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class ManufacturerDataField:
|
||||
"""A single piece of data within the manufacturer specific data. The format can be repeated."""
|
||||
def __init__(self, key, value_format, field_names=...) -> None:
|
||||
...
|
||||
|
||||
def __get__(self, obj, cls): # -> ManufacturerDataField | mdf_tuple | Any | Tuple[Any, ...] | tuple[None, ...] | None:
|
||||
...
|
||||
|
||||
def __set__(self, obj, value): # -> None:
|
||||
...
|
||||
|
||||
|
||||
|
||||
class ServiceData(AdvertisingDataField):
|
||||
"""Encapsulates service data. It is read as a memoryview which can be manipulated or set as a
|
||||
bytearray to change the size."""
|
||||
def __init__(self, service) -> None:
|
||||
...
|
||||
|
||||
def __get__(self, obj, cls): # -> ServiceData | memoryview | None:
|
||||
...
|
||||
|
||||
def __set__(self, obj, value): # -> None:
|
||||
...
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user