code: def write_handle(self, handle: int, value: bytes):
          # noqa: C901
          # pylint: disable=arguments-differ
  
          
  
          if not self.is_connected():
              raise BluetoothBackendException('Not connected to any device.')
  
          attempt = 0
          delay = 10
          _LOGGER.debug("Enter write_ble (%s)", current_thread())
  
          while attempt <= self.retries:
              cmd = "gatttool --device={} --addr-type={} --char-write-req -a {} -n {} --adapter={}".format(
                  self._mac, self.address_type, self.byte_to_handle(handle), self.bytes_to_string(value), self.adapter)
              _LOGGER.debug("Running gatttool with a timeout of %d: %s",
                            self.timeout, cmd)
  
              with Popen(cmd,
                         shell=True,
                         stdout=PIPE,
                         stderr=PIPE,
                         preexec_fn=os.setsid) as process:
                  try:
                      result = process.communicate(timeout=self.timeout)[0]
                      _LOGGER.debug("Finished gatttool")
                  except TimeoutExpired:
                      # send signal to the process group
                      os.killpg(process.pid, signal.SIGINT)
                      result = process.communicate()[0]
                      _LOGGER.debug("Killed hanging gatttool")
  
              result = result.decode("utf-8").strip(' \n\t')
              if "Write Request failed" in result:
                  raise BluetoothBackendException('Error writing handle to sensor: {}'.format(result))
              _LOGGER.debug("Got %s from gatttool", result)
              # Parse the output
              if "successfully" in result:
                  _LOGGER.debug(
                      "Exit write_ble with result (%s)", current_thread())
                  return True
  
              attempt += 1
              _LOGGER.debug("Waiting for %s seconds before retrying", delay)
              if attempt < self.retries:
                  time.sleep(delay)
                  delay *= 2
  
          raise BluetoothBackendException("Exit write_ble, no data ({})".format(current_thread()))
docs: Read from a BLE address.
  
          @param: mac - MAC address in format XX:XX:XX:XX:XX:XX
          @param: handle - BLE characteristics handle in format 0xXX
          @param: value - value to write to the given handle