def send_characteristic_notification(connection, characteristic, value): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT_SERVER.value MSG_ID = 0x05 payload = pack('<BHB', connection, characteristic, len(value)) + bytes(value) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def set_parameters(connection, min_interval, max_interval, latency, timeout): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.LE_CONNECTION.value MSG_ID = 0x00 payload = pack('<BHHHH', connection, min_interval, max_interval, latency, timeout) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def connect(address, address_type, initiating_phy): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.LE_GAP.value MSG_ID = 0x1a payload = address_to_bytes(address) + pack('<BB', address_type, initiating_phy) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def read_characteristic_value_from_offset(connection, characteristic, offset, maxlen): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT.value MSG_ID = 0x12 payload = pack('<BHHH', connection, characteristic, offset, maxlen) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def write_characteristic_value_without_response(connection, characteristic, value): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT.value MSG_ID = 0x0a payload = pack('<BHB', connection, characteristic, len(value)) + bytes(value) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def read_multiple_characteristic_values(connection, characteristic_list): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT.value MSG_ID = 0x11 payload = pack( '<B', connection) + characteristic_list_to_bytes(characteristic_list) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def send_user_read_response(connection, characteristic, att_errorcode, value): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT_SERVER.value MSG_ID = 0x03 payload = pack('<BHBB', connection, characteristic, att_errorcode, len(value)) + bytes(value) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def prepare_characteristic_value_write(connection, characteristic, offset, value): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT.value MSG_ID = 0x0b payload = pack('<BHHB', connection, characteristic, offset, len(value)) + bytes(value) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def set_advertise_timing(handle, interval_min, interval_max, duration, maxevents): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.LE_GAP.value MSG_ID = 0x0e payload = pack('<BIIHB', handle, interval_min, interval_max, duration, maxevents) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def ps_save(key, value): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.FLASH.value MSG_ID = 0x02 payload = pack('<HB', key, len(value)) + bytes(value) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def ps_erase(key): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.FLASH.value MSG_ID = 0x04 payload = pack('<H', key) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def dtm_end(data): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.TEST.value MSG_ID = 0x02 payload = b'' return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def ps_erase_all(): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.FLASH.value MSG_ID = 0x01 payload = b'' return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def dtm_rx(channel, phy): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.TEST.value MSG_ID = 0x01 payload = pack('<BB', channel, phy) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def dtm_tx(packet_type, length, channel, phy): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.TEST.value MSG_ID = 0x00 payload = pack('<BBBB', packet_type, length, channel, phy) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def set_options(mask, options): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.COEX.value MSG_ID = 0x00 payload = pack('<II', mask, options) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def delete_bonding(bonding): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x06 payload = pack('<B', bonding) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def enter_passkey(connection, passkey): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x08 payload = pack('<Bi', connection, passkey) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def read_attribute_value(attribute, offset): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT_SERVER.value MSG_ID = 0x00 payload = pack('<HH', attribute, offset) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def passkey_confirm(connection, confirm): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x09 payload = pack('<BB', connection, confirm) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def list_all_bondings(): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x0b payload = b'' return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def increase_security(connection): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x04 payload = pack('<B', connection) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def set_bondable_mode(bondable): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x00 payload = pack('<B', bondable) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def find_attribute(start, type_data): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT_SERVER.value MSG_ID = 0x06 payload = pack('<HB', start, len(type_data)) + bytes(type_data) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def set_capabilities(caps): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT_SERVER.value MSG_ID = 0x08 payload = pack('<Ixxxx', caps) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def set_debug_mode(): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x0f payload = b'' return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def write_attribute_value(attribute, offset, value): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.GATT_SERVER.value MSG_ID = 0x02 payload = pack('<HHB', attribute, offset, len(value)) + bytes(value) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def set_oob_data(oob_data): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x0a payload = pack('<B', len(oob_data)) + bytes(oob_data) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def get_counters(reset): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.COEX.value MSG_ID = 0x01 payload = pack('<B', reset) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
def set_passkey(passkey): MSG_TYPE = MessageType.COMMAND_RESPONSE.value MSG_CLASS = MessageClass.SM.value MSG_ID = 0x10 payload = pack('<i', passkey) return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)