max_ble_hci.utils
utils.py
Description: Basic utilities to help withe BLE-HCI
- address_int2list(addr: int)[source]
- Address converted from int to list of ints - Parameters:
- addr (int) – _description_ 
- Returns:
- _description_ 
- Return type:
- _type_ 
 
- address_int2str(addr: int) str[source]
- Convert address as int to str - Parameters:
- addr (int) – Address. Ex: 0x001122334455 
- Returns:
- Address converted to str (ex : 00:11:22:33:44:55) 
- Return type:
- str 
 
- address_str2int(addr: str) int[source]
- Convert address as string to integer usable by HCI - Parameters:
- addr (str) – Address. Ex: 00:11:22:33:44:55 
- Returns:
- Address converted to integer value 
- Return type:
- int 
 
- byte_length(data: int) int[source]
- Get number of bytes needed to represent an integer value - Parameters:
- data (int) – Number to get bytes needed 
- Returns:
- Bytes needed to represent nearest value 
- Return type:
- int 
 
- can_represent_as_bytes(data: List[int]) bool[source]
- Check whether all data can be represented by 1 byte - Parameters:
- data (list) – data to check 
- Returns:
- True if all data is 1 byte or less 
- Return type:
- bool 
 
- get_serial_ports() List[str][source]
- Lists serial port names - Raises:
- EnvironmentError – On unsupported or unknown platforms 
- Returns:
- A list of the serial ports available on the system 
 
- le_list_to_int(nums: List[int]) int[source]
- Create an integer from a little-endian list. - Converts a little-endian list of single byte values to a single multi-byte integer. - Parameters:
- nums (List[int]) – List containing single-byte values in little endian byte order. 
- Returns:
- The multi-byte value created from the given list. 
- Return type:
- int 
 
- to_le_nbyte_list(value: int, n_bytes: int) List[int][source]
- Create a list of little-endian bytes. - Converts a multi-byte number into a list of single-byte values. The list is little endian. - Parameters:
- value (int) – The multi-byte value that should be converted. 
- n_bytes (int) – The expected byte length of the given value 
 
- Returns:
- The given value represented as a little endian list of single-byte values. The length is equivalent to the n_bytes parameter. 
- Return type:
- List[int]