Ga naar inhoud

device_information

DeviceInformationService #

Source code in src/kaspersmicrobit/services/device_information.py
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
class DeviceInformationService:
    def __init__(self, device: BluetoothDevice):
        self._device = device

    def is_available(self) -> bool:
        """
        Checks whether the device information Bluetooth service is found on the connected micro:bit.

        Returns:
            true if the device information service was found, false if not.
        """
        return self._device.is_service_available(Service.DEVICE_INFORMATION)

    def read_model_number(self) -> str:
        """
        Reads the model number of the micro:bit.

        Returns:
            the model number of the micro:bit

        Raises:
            errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
            errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
                to read the model number (normally not present)
        """
        return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.MODEL_NUMBER_STRING), "utf-8")

    def read_serial_number(self) -> str:
        """
        Reads the serial number of the micro:bit.

        Returns:
            the serial number of the micro:bit

        Raises:
            errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
            errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
                to read the serial number (normally does not occur)
        """
        return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.SERIAL_NUMBER_STRING), "utf-8")

    def read_firmware_revision(self) -> str:
        """
        Reads the firmware version string from the micro:bit.

        Returns:
            the firmware version string of the micro:bit

        Raises:
            errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
            errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
                to read the firmware version (normally not present)
        """
        return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.FIRMWARE_REVISION_STRING), "utf-8")

    def read_hardware_revision(self) -> str:
        """
        Reads the hardware version string from the micro:bit.

        Attention:
            Although reading the hardware revision is mentioned in the bluetooth profile of the micro:bit, I was not
            successful in doing this on the micro:bits I had available for testing

        Returns:
            the hardware version string of the micro:bit

        Raises:
            errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
            errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
                to read the hardware version (normally not present)
        """
        return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.HARDWARE_REVISION_STRING), "utf-8")

    def read_manufacturer_name(self) -> str:
        """
        Reads the name of the manufacturer of the micro:bit.

        Attention:
            Although reading the manufacturer's name is listed in the micro:bit's Bluetooth profile,I was not
            successful in doing this on the micro:bits I had available for testing

        Returns:
            the name of the manufacturer of the micro:bit

        Raises:
            errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
            errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
                to read the manufacturer's name (normally not found)
        """
        return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.MANUFACTURER_NAME_STRING), "utf-8")

is_available #

is_available() -> bool

Kijkt na of de device information bluetooth service gevonden wordt op de geconnecteerde micro:bit.

Returns:

  • bool

    true als de device information service gevonden werd, false indien niet.

Source code in src/kaspersmicrobit/services/device_information.py
14
15
16
17
18
19
20
21
def is_available(self) -> bool:
    """
    Checks whether the device information Bluetooth service is found on the connected micro:bit.

    Returns:
        true if the device information service was found, false if not.
    """
    return self._device.is_service_available(Service.DEVICE_INFORMATION)

read_model_number #

read_model_number() -> str

Leest het modelnummer van de micro:bit.

Returns:

  • str

    het modelnummer van de micro:bit

Raises:

Source code in src/kaspersmicrobit/services/device_information.py
23
24
25
26
27
28
29
30
31
32
33
34
35
def read_model_number(self) -> str:
    """
    Reads the model number of the micro:bit.

    Returns:
        the model number of the micro:bit

    Raises:
        errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
        errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
            to read the model number (normally not present)
    """
    return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.MODEL_NUMBER_STRING), "utf-8")

read_serial_number #

read_serial_number() -> str

Leest het serienummer van de micro:bit.

Returns:

  • str

    het serienummer van de micro:bit

Raises:

Source code in src/kaspersmicrobit/services/device_information.py
37
38
39
40
41
42
43
44
45
46
47
48
49
def read_serial_number(self) -> str:
    """
    Reads the serial number of the micro:bit.

    Returns:
        the serial number of the micro:bit

    Raises:
        errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
        errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
            to read the serial number (normally does not occur)
    """
    return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.SERIAL_NUMBER_STRING), "utf-8")

read_firmware_revision #

read_firmware_revision() -> str

Leest de firmware versie string van de micro:bit.

Returns:

  • str

    de firmware versie string van de micro:bit

Raises:

Source code in src/kaspersmicrobit/services/device_information.py
51
52
53
54
55
56
57
58
59
60
61
62
63
def read_firmware_revision(self) -> str:
    """
    Reads the firmware version string from the micro:bit.

    Returns:
        the firmware version string of the micro:bit

    Raises:
        errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
        errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
            to read the firmware version (normally not present)
    """
    return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.FIRMWARE_REVISION_STRING), "utf-8")

read_hardware_revision #

read_hardware_revision() -> str

Leest de hardware versie string van de micro:bit.

Opgelet

Hoewel het lezen van de harware revisie vermeld wordt in het bluetooth profiel van de micro:bit, kon ik deze niet opvragen op de microbits die ik heb kunnen testen.

Returns:

  • str

    de hardware versie string van de micro:bit

Raises:

Source code in src/kaspersmicrobit/services/device_information.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
def read_hardware_revision(self) -> str:
    """
    Reads the hardware version string from the micro:bit.

    Attention:
        Although reading the hardware revision is mentioned in the bluetooth profile of the micro:bit, I was not
        successful in doing this on the micro:bits I had available for testing

    Returns:
        the hardware version string of the micro:bit

    Raises:
        errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
        errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
            to read the hardware version (normally not present)
    """
    return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.HARDWARE_REVISION_STRING), "utf-8")

read_manufacturer_name #

read_manufacturer_name() -> str

Leest de naam van de fabrikant van de micro:bit.

Opgelet

Hoewel het lezen van de naam van de fabrikant vermeld wordt in het bluetooth profiel van de micro:bit, kon ik deze niet opvragen op de microbits die ik heb kunnen testen.

Returns:

  • str

    de naam van de fabrikant van de micro:bit

Raises:

  • BluetoothServiceNotFound

    Wanneer de device information service niet actief is op de micro:bit

  • BluetoothCharacteristicNotFound

    Wanneer de button device information actief is, maar er geen manier was om de naam van de fabrikant te lezen (komt normaal gezien niet voor)

Source code in src/kaspersmicrobit/services/device_information.py
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
def read_manufacturer_name(self) -> str:
    """
    Reads the name of the manufacturer of the micro:bit.

    Attention:
        Although reading the manufacturer's name is listed in the micro:bit's Bluetooth profile,I was not
        successful in doing this on the micro:bits I had available for testing

    Returns:
        the name of the manufacturer of the micro:bit

    Raises:
        errors.BluetoothServiceNotFound: When the device information service is not active on the micro:bit
        errors.BluetoothCharacteristicNotFound: When the device information button is active, but there was no way
            to read the manufacturer's name (normally not found)
    """
    return str(self._device.read(Service.DEVICE_INFORMATION, Characteristic.MANUFACTURER_NAME_STRING), "utf-8")