src.bluetooth_sig.gatt.characteristics.utils.data_parser

Data parsing utilities for basic data types.

Classes

Name

Description

DataParser

Utility class for basic data type parsing and encoding.

Module Contents

class src.bluetooth_sig.gatt.characteristics.utils.data_parser.DataParser

Utility class for basic data type parsing and encoding.

static encode_float32(value: float) bytearray

Encode IEEE-754 32-bit float (little-endian).

static encode_float64(value: float) bytearray

Encode IEEE-754 64-bit double (little-endian).

static encode_int16(value: int, signed: bool = False, endian: Literal['little', 'big'] = 'little') bytearray

Encode 16-bit integer with configurable endianness and signed/unsigned validation.

static encode_int24(value: int, signed: bool = False, endian: Literal['little', 'big'] = 'little') bytearray

Encode 24-bit integer with configurable endianness and signed/unsigned validation.

static encode_int32(value: int, signed: bool = False, endian: Literal['little', 'big'] = 'little') bytearray

Encode 32-bit integer with configurable endianness and signed/unsigned validation.

static encode_int8(value: int, signed: bool = False) bytearray

Encode 8-bit integer with signed/unsigned validation.

static parse_float32(data: bytearray, offset: int = 0) float

Parse IEEE-754 32-bit float (little-endian).

static parse_float64(data: bytearray, offset: int = 0) float

Parse IEEE-754 64-bit double (little-endian).

static parse_int16(data: bytes | bytearray, offset: int = 0, signed: bool = False, endian: Literal['little', 'big'] = 'little') int

Parse 16-bit integer with configurable endianness and signed interpretation.

static parse_int24(data: bytes | bytearray, offset: int = 0, signed: bool = False, endian: Literal['little', 'big'] = 'little') int

Parse 24-bit integer with configurable endianness and signed interpretation.

static parse_int32(data: bytes | bytearray, offset: int = 0, signed: bool = False, endian: Literal['little', 'big'] = 'little') int

Parse 32-bit integer with configurable endianness and signed interpretation.

static parse_int8(data: bytes | bytearray, offset: int = 0, signed: bool = False) int

Parse 8-bit integer with optional signed interpretation.

static parse_utf8_string(data: bytearray) str

Parse UTF-8 string from bytearray with null termination handling.

static parse_variable_length(data: bytes | bytearray, min_length: int, max_length: int) bytes

Parse variable length data with validation.