device.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:python-miio 作者: rytilahti 项目源码 文件源码
def do_discover(self) -> Message:
        """Send a handshake to the device,
        which can be used to the device type and serial.
        The handshake must also be done regularly to enable communication
        with the device.

        :rtype: Message

        :raises DeviceException: if the device could not be discovered."""
        m = Device.discover(self.ip)
        if m is not None:
            self._device_id = m.header.value.device_id
            self._device_ts = m.header.value.ts
            if self.debug > 1:
                _LOGGER.debug(m)
            _LOGGER.debug("Discovered %s with ts: %s, token: %s",
                          self._device_id,
                          self._device_ts,
                          codecs.encode(m.checksum, 'hex'))
        else:
            _LOGGER.error("Unable to discover a device at address %s", self.ip)
            raise DeviceException("Unable to discover the device %s" % self.ip)

        return m
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号