blue_st_sdk.utils package¶
Submodules¶
blue_st_sdk.utils.ble_node_definitions module¶
ble_node_definitions
The ble_node_definitions module contains definitions related to the Bluetooth and recognized by the BlueSTSDK.
-
class
blue_st_sdk.utils.ble_node_definitions.
BLENodeDefinitions
[source]¶ Bases:
object
This class helps to get the list of services and characteristics available in the BlueST devices.
It defines the UUID and the name of the services and the characteristics available in the BlueST devices.
-
BASE_FEATURE_UUID
= '-0001'¶ Base feature UUID.
-
BLUESTSDK_CHARACTERISTIC_UUID
= '-11e1-ac36-0002a5d5c51b'¶ Characteristic UUIDs handled by this SDK must end with this value.
-
BLUESTSDK_SERVICE_UUID
= '-11e1-9ab4-0002a5d5c51b'¶ Service UUIDs handled by this SDK must end with this value.
-
CONFIG_UUID
= '-000F'¶ Config UUID.
-
DEBUG_UUID
= '-000E'¶ Debug UUID.
-
EXTENDED_FEATURE_UUID
= '-0002'¶ Extended feature UUID.
-
-
class
blue_st_sdk.utils.ble_node_definitions.
Config
[source]¶ Bases:
object
Service that allows to configure device’s parameters or features.
-
CONFIG_BLUESTSDK_SERVICE_UUID
= UUID('00000000-000f-11e1-9ab4-0002a5d5c51b')¶ Control service UUID.
-
CONFIG_COMMAND_BLUESTSDK_SERVICE_UUID
= UUID('00000002-000f-11e1-9ab4-0002a5d5c51b')¶ Control characteristic UUID through which you can send commands to a feature.
-
REGISTERS_ACCESS_UUID
= UUID('00000001-000f-11e1-9ab4-0002a5d5c51b')¶ Control characteristic UUID through which you can manage registers, i.e. to read or write registers.
-
-
class
blue_st_sdk.utils.ble_node_definitions.
Debug
[source]¶ Bases:
object
Class to access stdout/stderr streams.
-
DEBUG_BLUESTSDK_SERVICE_UUID
= UUID('00000000-000e-11e1-9ab4-0002a5d5c51b')¶ Debug service UUID.
-
DEBUG_STDERR_BLUESTSDK_SERVICE_UUID
= UUID('00000002-000e-11e1-ac36-0002a5d5c51b')¶ Debug characteristic UUID where the node writes error messages.
-
DEBUG_STDINOUT_BLUESTSDK_SERVICE_UUID
= UUID('00000001-000e-11e1-ac36-0002a5d5c51b')¶ Debug characteristic UUID where you can read and write messages.
-
-
class
blue_st_sdk.utils.ble_node_definitions.
FeatureCharacteristic
[source]¶ Bases:
object
This class defines the associations characteristic-feature.
A feature’s characteristic has the form ‘XXXXXXXX-0001-11e1-ac36-0002a5d5c51b’.
‘XXXXXXXX’ is a number in which only one bit has value ‘1’. In case multiple bits have value ‘1’ it means that this characteristic sends all the corresponding features’ values at the same time.
-
BASE_MASK_TO_FEATURE_DIC
= {4: <class 'blue_st_sdk.features.feature_proximity_gesture.FeatureProximityGesture'>, 16: <class 'blue_st_sdk.features.feature_activity_recognition.FeatureActivityRecognition'>, 8192: <class 'blue_st_sdk.features.feature_stepper_motor.FeatureStepperMotor'>, 65536: <class 'blue_st_sdk.features.feature_temperature.FeatureTemperature'>, 262144: <class 'blue_st_sdk.features.feature_temperature.FeatureTemperature'>, 524288: <class 'blue_st_sdk.features.feature_humidity.FeatureHumidity'>, 1048576: <class 'blue_st_sdk.features.feature_pressure.FeaturePressure'>, 2097152: <class 'blue_st_sdk.features.feature_magnetometer.FeatureMagnetometer'>, 4194304: <class 'blue_st_sdk.features.feature_gyroscope.FeatureGyroscope'>, 8388608: <class 'blue_st_sdk.features.feature_accelerometer.FeatureAccelerometer'>, 33554432: <class 'blue_st_sdk.features.feature_proximity.FeatureProximity'>, 134217728: <class 'blue_st_sdk.features.audio.adpcm.feature_audio_adpcm.FeatureAudioADPCM'>, 536870912: <class 'blue_st_sdk.features.feature_switch.FeatureSwitch'>, 1073741824: <class 'blue_st_sdk.features.audio.adpcm.feature_audio_adpcm_sync.FeatureAudioADPCMSync'>}¶ Map from base feature’s masks to feature’s classes.
-
BLUESTSDK_BASE_FEATURES_UUID
= '-0001-11e1-ac36-0002a5d5c51b'¶ Base feature UUIDs handled by this SDK must end with this value.
-
BLUESTSDK_EXTENDED_FEATURES_UUID
= '-0002-11e1-ac36-0002a5d5c51b'¶ Extended feature UUIDs handled by this SDK must end with this value.
-
EXTENDED_MASK_TO_FEATURE_DIC
= {3: <class 'blue_st_sdk.features.feature_audio_scene_classification.FeatureAudioSceneClassification'>}¶ Map from extended feature’s masks to feature’s classes.
-
SENSOR_TILE_BOX_MASK_TO_FEATURE_DIC
= {4: <class 'blue_st_sdk.features.feature_proximity_gesture.FeatureProximityGesture'>, 16: <class 'blue_st_sdk.features.feature_activity_recognition.FeatureActivityRecognition'>, 65536: <class 'blue_st_sdk.features.feature_temperature.FeatureTemperature'>, 262144: <class 'blue_st_sdk.features.feature_temperature.FeatureTemperature'>, 524288: <class 'blue_st_sdk.features.feature_humidity.FeatureHumidity'>, 1048576: <class 'blue_st_sdk.features.feature_pressure.FeaturePressure'>, 2097152: <class 'blue_st_sdk.features.feature_magnetometer.FeatureMagnetometer'>, 4194304: <class 'blue_st_sdk.features.feature_gyroscope.FeatureGyroscope'>, 8388608: <class 'blue_st_sdk.features.feature_accelerometer.FeatureAccelerometer'>, 33554432: <class 'blue_st_sdk.features.feature_proximity.FeatureProximity'>, 134217728: <class 'blue_st_sdk.features.audio.adpcm.feature_audio_adpcm.FeatureAudioADPCM'>, 536870912: <class 'blue_st_sdk.features.feature_switch.FeatureSwitch'>, 1073741824: <class 'blue_st_sdk.features.audio.adpcm.feature_audio_adpcm_sync.FeatureAudioADPCMSync'>}¶ Map from SensorTile.box feature’s masks to feature’s classes.
-
classmethod
extract_feature_mask
(uuid)[source]¶ “Extract the fist 32 bits from the characteristic’s UUID.
- Args:
- uuid (UUID): Characteristic’s UUID. Refer to UUID: for more information.
- Returns:
- int: The first 32 bit of the characteristic’s UUID.
-
classmethod
get_extended_feature_class
(uuid)[source]¶ Getting the extended feature class from a UUID.
- Args:
- uuid (UUID): Characteristic’s UUID. Refer to UUID: for more information.
- Returns:
- type: The feature’s class if found, “None” otherwise.
-
-
class
blue_st_sdk.utils.ble_node_definitions.
Services
[source]¶ Bases:
object
This class helps to get list of services available in the BlueST devices.
It defines the UUID and the name of the services available in the BlueST devices.
A valid service UUID has the form ‘00000000-XXXX-11e1-9ab4-0002a5d5c51b’, where ‘XXXX’ is the service identifier.
-
BLUESTSDK_SERVICE_UUID_FORMAT
= '00000000-[0-9a-fA-F]{4}-11e1-9ab4-0002a5d5c51b'¶ Format of the blue_st_sdk’s service UUID.
-
classmethod
is_known_service
(uuid)[source]¶ Checking whether the service is handled by this SDK, i.e. if the uuid has the ‘00000000-YYYY-11e1-9ab4-0002a5d5c51b’ format.
- Args:
- uuid (str): UUID of the service under test.
- Returns:
- bool: True if the UUID ends with
blue_st_sdk.utils.ble_node_definitions.BLENodeDefinitions.BLUESTSDK_SERVICE_UUID
, False otherwise.
-
blue_st_sdk.utils.blue_st_exceptions module¶
blue_st_exceptions
The blue_st_exceptions module defines exceptions raised by the BlueSTSDK.
-
exception
blue_st_sdk.utils.blue_st_exceptions.
BlueSTInvalidAdvertisingDataException
(msg)[source]¶ Bases:
exceptions.Exception
Exception raised whenever an advertising data has a format not recognized by the BlueSTSDK.
-
exception
blue_st_sdk.utils.blue_st_exceptions.
BlueSTInvalidDataException
(msg)[source]¶ Bases:
exceptions.Exception
Exception raised whenever a feature’s data are not complete.
blue_st_sdk.utils.dict_put_single_element module¶
dict_put_single_element
The dict_put_single_element module contains tools to map keys to list of elements.
-
class
blue_st_sdk.utils.dict_put_single_element.
DictPutSingleElement
(*args, **kwargs)[source]¶ Bases:
_abcoll.MutableMapping
Utility class to map keys to list of elements.
It works like a dictionary with an exception: the “put()” method inserts a single element at a time instead of a list of elements.
blue_st_sdk.utils.number_conversion module¶
number_conversion
The number_conversion module contains tools to convert features’ data to numbers.
-
class
blue_st_sdk.utils.number_conversion.
BigEndian
[source]¶ Bases:
object
This class implements the conversion from array of bytes to different formats, and viceversa, in Big Endian base order.
-
classmethod
bytes_to_float
(data, start=0)[source]¶ Return the floating point value of four bytes of the array in Big Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
bytes_to_int16
(data, start=0)[source]¶ Return the signed short value of two bytes of the array in Big Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
bytes_to_int32
(data, start=0)[source]¶ Return the signed integer value of four bytes of the array in Big Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
bytes_to_uint16
(data, start=0)[source]¶ Return the unsigned short value of two bytes of the array in Big Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
bytes_to_uint32
(data, start=0)[source]¶ Return the unsigned integer value of four bytes of the array in Big Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
float_to_bytes
(value)[source]¶ Return the four bytes array corresponding to the floating point value in Big Endian base order.
- Args:
- value (int): Value to convert.
- Returns:
- The corresponding array of bytes.
-
classmethod
int16_to_bytes
(value)[source]¶ Return the two bytes array corresponding to the signed short value in Big Endian base order.
- Args:
- value (int): Value to convert.
- Returns:
- The corresponding array of bytes.
-
classmethod
int32_to_bytes
(value)[source]¶ Return the four bytes array corresponding to the signed integer value in Big Endian base order.
- Args:
- value (int): Value to convert.
- Returns:
- The corresponding array of bytes.
-
classmethod
-
class
blue_st_sdk.utils.number_conversion.
LittleEndian
[source]¶ Bases:
object
This class implements the conversion from array of bytes to different formats, and viceversa, in Little Endian base order.
-
classmethod
bytes_to_float
(data, start=0)[source]¶ Return the floating point value of four bytes of the array in Little Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
bytes_to_int16
(data, start=0)[source]¶ Return the signed short value of two bytes of the array in Little Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
bytes_to_int32
(data, start=0)[source]¶ Return the signed integer value of four bytes of the array in Little Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
bytes_to_uint16
(data, start=0)[source]¶ Return the unsigned short value of two bytes of the array in Little Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
bytes_to_uint32
(data, start=0)[source]¶ Return the unsigned integer value of four bytes of the array in Little Endian base order.
- Args:
- data (str): Input array of bytes that contains the value to convert. start (int): Start index in the array of the value to convert.
- Returns:
- The corresponding numerical value.
-
classmethod
float_to_bytes
(value)[source]¶ Return the four bytes array corresponding to the floating point value in Little Endian base order.
- Args:
- value (float): Value to convert.
- Returns:
- The corresponding array of bytes.
-
classmethod
int16_to_bytes
(value)[source]¶ Return the two bytes array corresponding to the signed short value in Little Endian base order.
- Args:
- value (int): Value to convert.
- Returns:
- The corresponding array of bytes.
-
classmethod
int32_to_bytes
(value)[source]¶ Return the four bytes array corresponding to the signed integer value in Little Endian base order.
- Args:
- value (int): Value to convert.
- Returns:
- The corresponding array of bytes.
-
classmethod
blue_st_sdk.utils.python_utils module¶
python_utils
The python_utils module defines utility functions related to the Python language.
-
blue_st_sdk.utils.python_utils.
get_class
(class_name)[source]¶ Get a class from the class name throuth the ‘reflection’ property.
-
blue_st_sdk.utils.python_utils.
lock
(self)[source]¶ To be used to gain exclusive access to a block of code from different threads.
-
blue_st_sdk.utils.python_utils.
lock_for_object
(obj, locks={})[source]¶ To be used to gain exclusive access to a shared object from different threads.
blue_st_sdk.utils.unwrap_timestamp module¶
unwrap_timestamp
The unwrap_timestamp module contains tools to unwrap timestamp values.
blue_st_sdk.utils.uuid_to_feature_map module¶
uuid_to_feature_map
The uuid_to_feature_map module contains tools to map UUIDs to list of features.
-
class
blue_st_sdk.utils.uuid_to_feature_map.
UUIDToFeatureMap
[source]¶ Bases:
blue_st_sdk.utils.dict_put_single_element.DictPutSingleElement
Utility class to map UUIDs to list of features.
It works like a dictionary with an exception: the “put()” method inserts a single feature at a time instead of a list of features.