in smart-mirror-full/extracted/device/script/src/agt/ble/adapter.py [0:0]
def get_scan_resp_data(name):
name_bytes = name.encode()
namehex = codecs.encode(name_bytes, 'hex')
str_hex_name = str(namehex, 'ascii')
name_byte_list = ['0x' + str_hex_name[i:i+2] for i in range(0, len(str_hex_name), 2)]
space_sep_name_hex = " ".join(name_byte_list)
len_name = len(name_byte_list)
len_with_flag = 1 + len_name # additional 1 for the type flag
scan_resp_len = 1 + len_with_flag
zeros = [0] * (31 - scan_resp_len)
zero_list_str = " ".join(['0x{:02x}'.format(zeros[i]) for i in range(0, len(zeros), 1)])
scan_resp = 'sudo hcitool -i hci0 cmd 0x08 0x0009 ' + '0x{:02x}'.format(scan_resp_len) + ' ' + '0x{:02x}'.format(len_with_flag) + ' 0x09 ' + space_sep_name_hex + ' ' + zero_list_str
return scan_resp