Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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)
Пример #5
0
def send(port, confirmed, data_value):
    MSG_TYPE = MessageType.LORA_COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.DATA.value
    MSG_ID = MessageId.SEND.value
    payload = pack('<BBB', port, confirmed,
                   len(data_value)) + bytes(data_value)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #6
0
def write_characteristic_value(connection, characteristic, value):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.GATT.value
    MSG_ID = 0x09
    payload = pack('<BHB', connection, characteristic,
                   len(value)) + bytes(value)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #7
0
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)
Пример #8
0
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)
Пример #9
0
def prepare_characteristic_value_reliable_write(connection, characteristic,
                                                offset, value):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.GATT.value
    MSG_ID = 0x13
    payload = pack('<BHHB', connection, characteristic, offset,
                   len(value)) + bytes(value)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #10
0
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)
Пример #11
0
def join_mode(mode):
    MSG_TYPE = MessageType.LORA_COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.DATA.value
    MSG_ID = MessageId.JOIN_MODE.value
    payload = pack('<B', mode)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #12
0
def confirm_status():
    MSG_TYPE = MessageType.LORA_COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.DATA.value
    MSG_ID = MessageId.CONFIRM_STATUS.value
    payload = b''
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #13
0
def read():
    MSG_TYPE = MessageType.LORA_COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.DATA.value
    MSG_ID = MessageId.READ.value
    payload = b''
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #14
0
def message_to_target(data):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.USER.value
    MSG_ID = 0x00
    payload = pack('<B', len(data)) + bytes(data)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #15
0
def find_included_services(connection, service):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.GATT.value
    MSG_ID = 0x10
    payload = pack('<BI', connection, service)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #16
0
def read_characteristic_value(connection, characteristic):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.GATT.value
    MSG_ID = 0x07
    payload = pack('<BH', connection, characteristic)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #17
0
def set_tx_power(power):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x0a
    payload = pack('<H', power)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #18
0
def set_bt_address(address):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x04
    payload = address_to_bytes(address)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #19
0
def set_device_name(type, name):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x0d
    payload = pack('<BB', type, len(name)) + bytes(name)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #20
0
def discover_characteristics(connection, service):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.GATT.value
    MSG_ID = 0x03
    payload = pack('<BI', connection, service)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #21
0
def reset(dfu):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x01
    payload = pack('<B', dfu)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #22
0
def set_phy(connection, phy):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.LE_CONNECTION.value
    MSG_ID = 0x03
    payload = pack('<BB', connection, phy)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #23
0
def get_random_data(length):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x0b
    payload = pack('<B', length)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #24
0
def get_counters(reset):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x0f
    payload = pack('<B', reset)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #25
0
def disable_slave_latency(connection, disable):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.LE_CONNECTION.value
    MSG_ID = 0x02
    payload = pack('<BB', connection, disable)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #26
0
def get_bt_address():
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x03
    payload = b''
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #27
0
def halt(halt):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x0c
    payload = pack('<B', halt)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #28
0
def read_characteristic_value_by_uuid(connection, service, uuid):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.GATT.value
    MSG_ID = 0x08
    payload = pack('<BI', connection, service) + uuid_to_bytes(uuid)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #29
0
def close(connection):
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.LE_CONNECTION.value
    MSG_ID = 0x04
    payload = pack('<B', connection)
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)
Пример #30
0
def hello():
    MSG_TYPE = MessageType.COMMAND_RESPONSE.value
    MSG_CLASS = MessageClass.SYSTEM.value
    MSG_ID = 0x00
    payload = b''
    return command(MSG_TYPE, MSG_CLASS, MSG_ID, payload)