def send_unencrypted(self, message, wait_for_response=True): self.rx_unencrypted = [] self.rx_unencr_seg = '' if ((False == self.connected) or (None == self.ps_gdio_handle)): log.debug('BLE adapter error: not connected') else: message = utils.add_crc(message) log.debug('send unencrypted: ' + hexlify(message)) message = self._format_tx(message) self.device.char_write_handle_long(self.ps_gdio_handle, message, self.chunk_size, True)
def _inject_error_encrypted(self, error_id, cmd_id=0xFFFF, auth_id=0xFFFFFFFF): error = error_id cmd_id = cmd_id message = cmd.error_bridge(error, cmd_id) decrypted = utils.pack_u32(auth_id) + message decrypted = utils.add_crc(decrypted) return auth_id, message, decrypted
def encrypt_tx(auth_id, message, key, nonce=''): auth_id = utils.pack_u32(auth_id) pdata = auth_id + message pdata = utils.add_crc(pdata) encrypted = encrypt(pdata, key, nonce) nonce = encrypted[:24] pdata = encrypted[24:] length = len(pdata) length = utils.pack_u16(length) message = nonce + auth_id + length + pdata return message
def _inject_error_unencrypted(self, error_id, cmd_id=0xFFFF): error = error_id message = cmd.error_bridge(error, cmd_id) message = utils.add_crc(message) return message
def pdata(cmd_id, message): message = cmd_id + message message = utils.add_crc(message) return message