async def _probe(self) -> None: """Open port and try sending a command""" await self.connect() try: # Ensure we have escaped commands await self._at_command("AP", 2) except asyncio.TimeoutError: if not await self.init_api_mode(): raise APIException("Failed to configure XBee for API mode") finally: self.close()
def _command(self, name, *args, mask_frame_id=False): LOGGER.debug("Command %s %s", name, args) if self._uart is None: raise APIException("API is not running") frame_id = 0 if mask_frame_id else self._seq data, needs_response = self._api_frame(name, frame_id, *args) self._uart.send(data) future = None if needs_response and frame_id: future = asyncio.Future() self._awaiting[frame_id] = (future, ) self._seq = (self._seq % 255) + 1 return future