def hdl_wid_92(desc): bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() # This pattern is matching Notification handle pattern = re.compile("(handle)\s?=\s?'([0-9a-fA-F]+)'") params = pattern.findall(desc) if not params: logging.error("parsing error") return False params = dict(params) handle = int(params.get('handle'), 16) att_rsp, value_len, value = btp.gatts_get_attr_val(bd_addr_type, bd_addr, handle) if att_rsp: logging.debug("cannot read chrc value") return False # delay to let the PTS subscribe for notifications sleep(2) btp.gatts_set_val(handle, hexlify(value)), return True
def hdl_wid_136(_: WIDParams): btp.gatts_add_svc(0, UUID.VND16_1) btp.gatts_add_char(0, Prop.read | Prop.auth_swrite, Perm.read | Perm.write_authn, UUID.VND16_2) btp.gatts_set_val(0, '01') btp.gatts_start_server() return True
def hdl_wid_136(desc): btp.core_reg_svc_gatt() btp.gatts_add_svc(0, UUID.VND16_1) btp.gatts_add_char(0, Prop.read | Prop.auth_swrite, Perm.read | Perm.write_authn, UUID.VND16_2) btp.gatts_set_val(0, '01') btp.gatts_start_server() return True
def handle_wid_136_sec_csign_bi_04(): """ project_name: GAP wid: 136 description: Please prepare a characteristic that is sign writable which requires also requires authentication. (Security mode 2 level 2) Press OK to continue. style: MMI_Style_Ok_Cancel1 0x11041 response: 8238800 <type 'int'> 93825543207024 response_size: 2048 response_is_present: 0 <type 'int'> """ btp.core_reg_svc_gatt() btp.gatts_add_svc(0, UUID.VND16_1) btp.gatts_add_char(0, Prop.read | Prop.auth_swrite, Perm.read | Perm.write_authn, UUID.VND16_2) btp.gatts_set_val(0, '01') btp.gatts_start_server() return True
def hdl_wid_98(desc): MMI.reset() MMI.parse_description(desc) if not MMI.args: logging.error("parsing error") return False handle = int(MMI.args[0], 16) att_rsp, value_len, value = btp.gatts_get_attr_val(handle) if att_rsp: logging.debug("cannot read chrc value") return False # delay to let the PTS subscribe for notifications sleep(2) btp.gatts_set_val(handle, hexlify(value)), return True
def hdl_wid_98(params: WIDParams): MMI.reset() MMI.parse_description(params.description) if not MMI.args: logging.error("parsing error") return False handle = int(MMI.args[0], 16) bd_addr = btp.pts_addr_get() bd_addr_type = btp.pts_addr_type_get() att_rsp, value_len, value = btp.gatts_get_attr_val(bd_addr_type, bd_addr, handle) if att_rsp: logging.debug("cannot read chrc value") return False # delay, to let the PTS subscribe for notifications sleep(2) btp.gatts_set_val(handle, hexlify(value)) return True