Source code for brainaccess.core.ble_device
import ctypes
class _BaBleDevice(ctypes.Structure):
"""One entry of the library's scan result (internal).
The strings are only valid until the next scan; :func:`brainaccess.core.scan`
copies them into :class:`ScannedDevice` objects.
"""
_fields_ = [
("_name", ctypes.c_char_p),
("_mac_address", ctypes.c_char_p),
]
@property
def name(self) -> str:
"""The advertised device name."""
return self._name.decode("utf-8", errors="replace")
@property
def mac_address(self) -> str:
"""The device address."""
return self._mac_address.decode("utf-8", errors="replace")
[docs]
class ScannedDevice:
"""A headset found by :func:`brainaccess.core.scan`.
Attributes
----------
name : str
The advertised name, for example ``"BA HALO 042"``. Pass it to
:meth:`~brainaccess.core.eeg_manager.EEGManager.connect`.
mac_address : str
The device address. On Linux and Windows this is the MAC address; macOS
does not reveal MAC addresses, so there it is the 36-character
CoreBluetooth UUID.
"""
__slots__ = ("name", "mac_address")
def __init__(self, name: str, mac_address: str) -> None:
[docs]
self.mac_address = mac_address
def __repr__(self) -> str:
return (
f"{type(self).__name__}(name={self.name!r}, "
f"mac_address={self.mac_address!r})"
)