Ga naar inhoud

services

Service #

Bases: Enum

Geeft een overzicht van alle services die door de micro:bit kunnen worden aangeboden

Zie ook: https://lancaster-university.github.io/microbit-docs/resources/bluetooth/bluetooth_profile.html

Source code in src/kaspersmicrobit/bluetoothprofile/services.py
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
class Service(Enum):
    """
    Lists all services that could be offered by the micro:bit

    See Also: https://lancaster-university.github.io/microbit-docs/resources/bluetooth/bluetooth_profile.html
    """

    GENERIC_ACCESS = '00001800-0000-1000-8000-00805f9b34fb'
    """
    The generic_access service contains generic information about the device.
    All available Characteristics are readonly.
    """

    GENERIC_ATTRIBUTE = '00001801-0000-1000-8000-00805f9b34fb'
    """
    """

    DEVICE_INFORMATION = '0000180a-0000-1000-8000-00805f9b34fb'
    """
    The Device Information Service exposes manufacturer and/or vendor information about a device.            

    This service exposes manufacturer information about a device.
    The Device Information Service is instantiated as a Primary Service.
    Only one instance of the Device Information Service is exposed on a device.
    """

    ACCELEROMETER = 'e95d0753-251d-470a-a062-fa1922dfa9a8'
    """
    Exposes accelerometer data. An accelerometer is an electromechanical device that will measure acceleration forces. 
    These forces may be static, like the constant force of gravity pulling at your feet, or they could be dynamic 
    - caused by moving or vibrating the accelerometer.

    Value contains fields which represent 3 separate accelerometer measurements for X, Y and Z axes 
    as 3 unsigned 16 bit values in that order and in little endian format. 

    Data can be read on demand or notified periodically.
    """

    MAGNETOMETER = 'e95df2d8-251d-470a-a062-fa1922dfa9a8'
    """
    Exposes magnetometer data.  A magnetometer measures a magnetic field such as the earth's magnetic field in 3 axes.
    """

    BUTTON = 'e95d9882-251d-470a-a062-fa1922dfa9a8'
    """
    Exposes the two Micro Bit buttons and allows 'commands' associated with button state changes to be associated 
    with button states and notified to a connected client.
    """

    IO_PIN = 'e95d127b-251d-470a-a062-fa1922dfa9a8'
    """
    Provides read/write access to I/O pins, individually or collectively. Allows configuration of each pin for 
    input/output and analogue/digital use.
    """

    LED = 'e95dd91d-251d-470a-a062-fa1922dfa9a8'
    """
    Provides access to and control of LED state. 
    Allows the state (ON or OFF) of all 25 LEDs to be set in a single write operation. 
    Allows short text strings to be sent by a client for display on the LED matrix and scrolled across at a speed 
    controlled by the Scrolling Delay characteristic.
    """

    EVENT = 'e95d93af-251d-470a-a062-fa1922dfa9a8'
    """
    A generic, bi-directional event communication service. 

    The Event Service allows events or commands to be notified to the micro:bit by a connected client and it allows 
    micro:bit to notify the connected client of events or commands originating from with the micro:bit. The micro:bit 
    can inform the client of the types of event it is interested in being informed about (e.g. an incoming call) and 
    the client can inform the micro:bit of types of event it wants to be notified about.  

    The term "event" will be used here for both event and command types of data.

    Events may have an associated value.

    Note that specific event ID values including any special values such as those which may represent wild cards are 
    not defined here. The micro:bit run time documentation should be consulted for this information.

    Multiple events of different types may be notified to the client or micro:bit at the same time.
    Event data is encoded as an array of structs each encoding an event of a given type together with an associated 
    value. Event Type and Event Value are both defined as uint16 and therefore the length of this array will always be 
    a multiple of 4.

        struct event {
         uint16 event_type;
         uint16 event_value;
        };

    """

    DFU_CONTROL = 'e95d93b0-251d-470a-a062-fa1922dfa9a8'
    """
    Allows clients to initiate the micro:bit pairing and over the air firmware update procedures.
    """

    TEMPERATURE = 'e95d6100-251d-470a-a062-fa1922dfa9a8'
    """
    Ambient temperature derived from several internal temperature sensors on the micro:bit
    """

    UART = '6e400001-b5a3-f393-e0a9-e50e24dcca9e'
    """
    This is an implementation of Nordic Semiconductor's UART/Serial Port Emulation over Bluetooth low energy. 

    See https://developer.nordicsemi.com/nRF5_SDK/nRF51_SDK_v8.x.x/doc/8.0.0/s110/html/a00072.html for the original 
    Nordic Semiconductor documentation by way of background.
    """

    @staticmethod
    def lookup(uuid: str):
        """
        Looks up the enum corresponding the given uuid

        Returns (Service):
            The enum with the given uuid, None if not found.
        """
        try:
            return Service(uuid)
        except ValueError:
            return None

GENERIC_ACCESS class-attribute instance-attribute #

GENERIC_ACCESS = '00001800-0000-1000-8000-00805f9b34fb'

GENERIC_ATTRIBUTE class-attribute instance-attribute #

GENERIC_ATTRIBUTE = '00001801-0000-1000-8000-00805f9b34fb'

DEVICE_INFORMATION class-attribute instance-attribute #

DEVICE_INFORMATION = '0000180a-0000-1000-8000-00805f9b34fb'

ACCELEROMETER class-attribute instance-attribute #

ACCELEROMETER = 'e95d0753-251d-470a-a062-fa1922dfa9a8'

MAGNETOMETER class-attribute instance-attribute #

MAGNETOMETER = 'e95df2d8-251d-470a-a062-fa1922dfa9a8'

BUTTON class-attribute instance-attribute #

BUTTON = 'e95d9882-251d-470a-a062-fa1922dfa9a8'

IO_PIN class-attribute instance-attribute #

IO_PIN = 'e95d127b-251d-470a-a062-fa1922dfa9a8'

LED class-attribute instance-attribute #

LED = 'e95dd91d-251d-470a-a062-fa1922dfa9a8'

EVENT class-attribute instance-attribute #

EVENT = 'e95d93af-251d-470a-a062-fa1922dfa9a8'

DFU_CONTROL class-attribute instance-attribute #

DFU_CONTROL = 'e95d93b0-251d-470a-a062-fa1922dfa9a8'

TEMPERATURE class-attribute instance-attribute #

TEMPERATURE = 'e95d6100-251d-470a-a062-fa1922dfa9a8'

UART class-attribute instance-attribute #

UART = '6e400001-b5a3-f393-e0a9-e50e24dcca9e'

lookup staticmethod #

lookup(uuid: str)

Looks up the enum corresponding the given uuid

Returns (Service): The enum with the given uuid, None if not found.

Source code in src/kaspersmicrobit/bluetoothprofile/services.py
118
119
120
121
122
123
124
125
126
127
128
129
@staticmethod
def lookup(uuid: str):
    """
    Looks up the enum corresponding the given uuid

    Returns (Service):
        The enum with the given uuid, None if not found.
    """
    try:
        return Service(uuid)
    except ValueError:
        return None