Exemple #1
0
 def ble_gatt_wait_for_write_request(self, session_id, handle, timeout=5):
     """Function defined in GattInterface. """
     regex = r"\+SRBLEWRITE_(REQ|IND): %d,%d,(\d+),(\d+),\"(.+)\"" % (
         session_id, handle)
     response = self._serial.serial_search_regex(regex, timeout)
     if response:
         offset = int(response[1])
         value = Eddington._convert_escaped_string_to_data(response[3])
         need_rsp = True if response[0] == 'REQ' else False
         return BleInterface.GattWriteReq(session_id, handle, offset, value,
                                          need_rsp)
     return None
Exemple #2
0
 def ble_gatt_wait_for_write_request(self, session_id, handle, timeout=5):
     """Function defined in GattInterface. """
     regex = r"\+SRBLEWRITE: %d,%d,\"(.+)\"" % (session_id, handle)
     response = self._serial.serial_search_regex(regex, timeout)
     if response:
         value = Euler._convert_escaped_string_to_data(response[0])
         warnings.warn('offset not supported - ignored.')
         warnings.warn(
             'need_rsp automatically handled (accepted) by Euler. \
             Write requests cannot be rejected.')
         return BleInterface.GattWriteReq(session_id, handle, 0, value,
                                          False)
     return None
Exemple #3
0
 def ble_gatt_wait_for_write_request(self, session_id, handle, timeout=5):
     """Function defined in GattInterface."""
     link_id = self._ble_sessions_get_link_id_from_session_id(session_id)
     if link_id is not None:
         regex = r"BLE_WRITE {:X} {:04X} (\d+) (\d+)".format(
             link_id, handle) + BC127_EOL
         response = self._serial.serial_search_regex(regex, timeout)
         if response:
             data_iter = iter(response[1])
             value = [int(a + b, 16) for a, b in zip(data_iter, data_iter)]
             return BleInterface.GattWriteReq(session_id, handle, 0, value,
                                              False)
     return None