Ejemplo n.º 1
0
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,
    )
    """
Ejemplo n.º 2
0
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."""
Ejemplo n.º 3
0
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."""
Ejemplo n.º 4
0
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."""
Ejemplo n.º 5
0
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."""
Ejemplo n.º 6
0
class CoreService(PhysBrykService):
    """Core, 'on-board' charactistics for the physbryk."""

    #the bryk 0000
    uuid = PhysBrykService.physbryk_service_uuid(0x0000)

    # Default period set by MEASUREMENT_PERIOD.
    measurement_period = Int32Characteristic(
        uuid=PhysBrykService.physbryk_service_uuid(0x0001),
        properties=(Characteristic.READ | Characteristic.WRITE),
        initial_value=MEASUREMENT_PERIOD,
    )

    battery = Uint16Characteristic(
        uuid=PhysBrykService.physbryk_service_uuid(0x0002),
        properties=(Characteristic.READ | Characteristic.NOTIFY),
        write_perm=Attribute.NO_ACCESS,
    )

    # motion sensor 0100
    motion_enabled = Uint8Characteristic(
        uuid=PhysBrykService.physbryk_service_uuid(0x0100),
        initial_value=1,
    )
    # Tuple (x, y, z) float acceleration values, in m/s/s
    acceleration = StructCharacteristic(
        "<fff",
        uuid=PhysBrykService.physbryk_service_uuid(0x101),
        properties=(Characteristic.READ | Characteristic.NOTIFY),
        write_perm=Attribute.NO_ACCESS,
    )

    # Tuple (x, y, z) float gyroscope values, in rad/s
    gyro = StructCharacteristic(
        "<fff",
        uuid=PhysBrykService.physbryk_service_uuid(0x102),
        properties=(Characteristic.READ | Characteristic.NOTIFY),
        write_perm=Attribute.NO_ACCESS,
    )

    # magnetometer 0200
    magnetic_enabled = Uint8Characteristic(
        uuid=PhysBrykService.physbryk_service_uuid(0x200),
        initial_value=1,
    )

    # Tuple (x, y, z) float magnetometer values, in micro-Teslas (uT)
    magnetic = StructCharacteristic(
        "<fff",
        uuid=PhysBrykService.physbryk_service_uuid(0x201),
        properties=(Characteristic.READ | Characteristic.NOTIFY),
        write_perm=Attribute.NO_ACCESS,
    )

    # light 0300
    light_enabled = Uint8Characteristic(
        uuid=PhysBrykService.physbryk_service_uuid(0x300),
        initial_value=1,
    )

    # Tuple (r, g, b, c) red/green/blue/clear color values, each in range 0-65535 (16 bits)
    spectrum = StructCharacteristic(
        "<ffff",
        uuid=PhysBrykService.physbryk_service_uuid(0x301),
        properties=(Characteristic.READ | Characteristic.NOTIFY),
        write_perm=Attribute.NO_ACCESS,
        initial_value=(0, 0, 0, 0))

    # A higher number indicates a closer distance to the sensor. The value is unit-less.
    proximity = Uint16Characteristic(
        # "<H",
        uuid=PhysBrykService.physbryk_service_uuid(0x302),
        properties=(Characteristic.READ | Characteristic.NOTIFY),
        write_perm=Attribute.NO_ACCESS,
    )

    # sound
    sound_enabled = Uint8Characteristic(
        uuid=PhysBrykService.physbryk_service_uuid(0x400),
        initial_value=1,
    )

    loudness = Uint16Characteristic(
        # "<H",
        uuid=PhysBrykService.physbryk_service_uuid(0x402),
        properties=(Characteristic.READ | Characteristic.NOTIFY),
        write_perm=Attribute.NO_ACCESS,
    )