def ATTReadByTypeRspHandler(self, dictionary): ''' Limitation: 1. cuurently only consider one key-value pair to return, it is becuase most of cases only one key should be found 2. no permission restriction, all data are readable ''' def _sendATTReadByTypeRsp(conn_handle, value, data_length): print("COMMAND: ATT_ReadByTypeRsp") print(utils.printOutput(self.ble_builder.send("fd09", conn_handle = conn_handle, data_length = data_length, value = value))) def _get_pdu(data): handle = utils.stringToSByteInHex(data[0][0])[::-1] value = utils.stringToSByteInHex(data[0][1], ":") pdu = handle + value return pdu conn_handle = dictionary['conn_handle'] start_handle = dictionary['start_handle'] end_handle = dictionary['end_handle'] _type = dictionary['type'] conn_handle = conn_handle[0] start = start_handle[1] end = end_handle[1] uuid = _type[1] #get data from gatt table sql = sqls.sql_select_handles_in_range % (uuid, start, end) data = self._execute_sql(sql) pdu = _get_pdu(data) data_length = utils.getByteDataLengh(pdu) _sendATTReadByTypeRsp(conn_handle, pdu, data_length)
def DoUpdateAdvertisingData(self, data, ad_type=adType.ADVERTISEMENT_DATA): print("COMMAND: Set advertising data as %s " % data) data_length = utils.getByteDataLengh(data) print( utils.printOutput( self.ble_builder.send("fe07", advert_data=data, data_length=data_length, ad_type=ad_type)))
def DoUpdateAdvertisingData(self, data, ad_type = adType.ADVERTISEMENT_DATA): print("COMMAND: Set advertising data as %s " % data) data_length = utils.getByteDataLengh(data) print(utils.printOutput(self.ble_builder.send("fe07", advert_data = data, data_length = data_length, ad_type= ad_type)))