class QuaternionService(AdafruitService): # pylint: disable=too-few-public-methods """Quaternion values.""" uuid = AdafruitService.adafruit_service_uuid(0xD00) quaternion = StructCharacteristic( "<ffff", uuid=AdafruitService.adafruit_service_uuid(0xD01), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Tuple (qw, qx, qy, qz) of float quaternion values.""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms.""" calibration_in = StructCharacteristic( "<fffffffff", uuid=AdafruitService.adafruit_service_uuid(0xD02), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """ 9-tuple of floats sent to client for calibration calculation: acceleration x, y, z, # in m/s^2 gyro x, y, z, # in rad/s magnetic x, y, z, # in microteslas """ calibration_out = StructCharacteristic( "<fffffffffffffffffff", uuid=AdafruitService.adafruit_service_uuid(0xD03), properties=(Characteristic.WRITE), read_perm=Attribute.NO_ACCESS, ) """
class GestureService(AdafruitService): # pylint: disable=too-few-public-methods """Gesture sensor.""" UP = 1 # pylint: disable=invalid-name """swipe up""" DOWN = 2 """swipe down""" LEFT = 3 """swipe left""" RIGHT = 4 """swipe right""" uuid = AdafruitService.adafruit_service_uuid(0xF00) gesture = Uint8Characteristic( uuid=AdafruitService.adafruit_service_uuid(0xF01), properties=(Characteristic.READ | Characteristic.NOTIFY), read_perm=Attribute.OPEN, write_perm=Attribute.NO_ACCESS, ) """ 0: no gesture 1: swipe up (`UP`) 2: swipe down (`DOWN`) 3: swipe left (`LEFT`) 4: swipe right (`RIGHT`) """ measurement_period = AdafruitService.measurement_period_charac(0) """Initially 0: send notification only on changes. -1 means stop reading."""
class MicrophoneService(AdafruitService): # pylint: disable=too-few-public-methods """Digital microphone data.""" uuid = AdafruitService.adafruit_service_uuid(0xB00) sound_samples = Characteristic( uuid=AdafruitService.adafruit_service_uuid(0xB01), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, max_length=512, ) """ Array of 16-bit sound samples, varying based on period. If num_channel == 2, the samples alternate left and right channels. """ number_of_channels = Uint8Characteristic( uuid=AdafruitService.adafruit_service_uuid(0xB02), properties=Characteristic.READ, write_perm=Attribute.NO_ACCESS, ) """1 for mono, 2 for stereo (left and right)""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class LightSensorService(AdafruitService): # pylint: disable=too-few-public-methods """Light sensor value.""" uuid = AdafruitService.adafruit_service_uuid(0x300) light_level = FloatCharacteristic( uuid=AdafruitService.adafruit_service_uuid(0x301), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Uncalibrated light level (float)""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class HumidityService(AdafruitService): # pylint: disable=too-few-public-methods """Humidity sensor value.""" uuid = AdafruitService.adafruit_service_uuid(0x700) humidity = FloatCharacteristic( uuid=AdafruitService.adafruit_service_uuid(0x701), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Relative humidity as a percentage, 0.0% - 100.0% (float)""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class TemperatureService(AdafruitService): # pylint: disable=too-few-public-methods """Temperature sensor.""" uuid = AdafruitService.adafruit_service_uuid(0x100) temperature = FloatCharacteristic( uuid=AdafruitService.adafruit_service_uuid(0x101), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Temperature in degrees Celsius (float).""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class BarometricPressureService(AdafruitService): # pylint: disable=too-few-public-methods """Barometric pressure value.""" uuid = AdafruitService.adafruit_service_uuid(0x800) pressure = FloatCharacteristic( uuid=AdafruitService.adafruit_service_uuid(0x801), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Barometric pressure in hectoPascals (hPa) (float)""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class GyroscopeService(AdafruitService): # pylint: disable=too-few-public-methods """Gyroscope values.""" uuid = AdafruitService.adafruit_service_uuid(0x400) gyro = StructCharacteristic( "<fff", uuid=AdafruitService.adafruit_service_uuid(0x401), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Tuple (x, y, z) float gyroscope values, in rad/s""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class MagnetometerService(AdafruitService): # pylint: disable=too-few-public-methods """Magnetometer values.""" uuid = AdafruitService.adafruit_service_uuid(0x500) magnetic = StructCharacteristic( "<fff", uuid=AdafruitService.adafruit_service_uuid(0x501), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Tuple (x, y, z) float magnetometer values, in micro-Teslas (uT)""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class ColorSensorService(AdafruitService): # pylint: disable=too-few-public-methods """Color sensor value.""" uuid = AdafruitService.adafruit_service_uuid(0xA00) acceleration = StructCharacteristic( "<HHH", uuid=AdafruitService.adafruit_service_uuid(0xA01), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Tuple (r, g, b) red/green/blue color values, each in range 0-65535 (16 bits)""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class AccelerometerService(AdafruitService): # pylint: disable=too-few-public-methods """Accelerometer values.""" uuid = AdafruitService.adafruit_service_uuid(0x200) acceleration = StructCharacteristic( "<fff", uuid=AdafruitService.adafruit_service_uuid(0x201), properties=(Characteristic.READ | Characteristic.NOTIFY), write_perm=Attribute.NO_ACCESS, ) """Tuple (x, y, z) float acceleration values, in m/s^2""" measurement_period = AdafruitService.measurement_period_charac() """Initially 1000ms."""
class ProximityService(AdafruitService): # pylint: disable=too-few-public-methods """Status of buttons and switches on the board.""" uuid = AdafruitService.adafruit_service_uuid(0xE00) proximity = Uint16Characteristic( uuid=AdafruitService.adafruit_service_uuid(0xE01), properties=(Characteristic.READ | Characteristic.NOTIFY), read_perm=Attribute.OPEN, write_perm=Attribute.NO_ACCESS, ) """ A higher number indicates a closer distance to the sensor. The value is unit-less. """ measurement_period = AdafruitService.measurement_period_charac(0) """Initially 0: send notification only on changes. -1 means stop reading."""
class ButtonService(AdafruitService): """Status of buttons and switches on the board.""" uuid = AdafruitService.adafruit_service_uuid(0x600) pressed = Uint32Characteristic( uuid=AdafruitService.adafruit_service_uuid(0x601), properties=(Characteristic.READ | Characteristic.NOTIFY), read_perm=Attribute.OPEN, write_perm=Attribute.NO_ACCESS, ) """ bit 0: slide switch: 1 for left; 0 for right bit 1: 1 if button A is pressed bit 2: 1 if button B is pressed other bits are available for future buttons and switches """ measurement_period = AdafruitService.measurement_period_charac(0) """Initially 0: send notification only on changes. -1 means stop reading.""" def set_pressed(self, switch, button_a, button_b): """Update the pressed value all at once.""" pressed = 0 if switch: pressed |= 0x1 if button_a: pressed |= 0x2 if button_b: pressed |= 0x4 if pressed != self.pressed: self.pressed = pressed @property def switch(self): """``True`` when the slide switch is set to the left; ``False`` when to the right.""" return bool(self.pressed & 0x1) @property def button_a(self): """``True`` when Button A is pressed.""" return bool(self.pressed & 0x2) @property def button_b(self): """``True`` when Button B is pressed.""" return bool(self.pressed & 0x4)