Beispiel #1
0
 def parseSingleDeviceAnnounce(self, stream: BytesIO):
     deviceType = DeviceType(Uint32LE.unpack(stream))
     deviceId = Uint32LE.unpack(stream)
     preferredDosName = stream.read(8)
     deviceDataLength = Uint32LE.unpack(stream)
     deviceData = stream.read(deviceDataLength)
     return DeviceAnnounce(deviceType, deviceId, preferredDosName, deviceData)
Beispiel #2
0
 def parseDeviceMapping(self, stream: BytesIO,
                        timestamp: int) -> PlayerDeviceMappingPDU:
     deviceID = Uint32LE.unpack(stream)
     deviceType = DeviceType(Uint32LE.unpack(stream))
     nameLength = Uint32LE.unpack(stream)
     name = stream.read(nameLength).decode()
     return PlayerDeviceMappingPDU(timestamp, deviceID, deviceType, name)
Beispiel #3
0
    def handleDeviceListAnnounceRequest(self, pdu: DeviceListAnnounceRequest):
        """
        Log mapped devices.
        :param pdu: the device list announce request.
        """

        for device in pdu.deviceList:
            self.log.info(
                "%(deviceName)s mapped with ID %(deviceID)d: %(deviceData)s", {
                    "deviceName": DeviceType.getPrettyName(device.deviceType),
                    "deviceID": device.deviceID,
                    "deviceData":
                    device.preferredDosName.rstrip(b"\x00").decode()
                })
    def handleDeviceListAnnounceRequest(self, pdu: DeviceListAnnounceRequest):
        """
        Log mapped devices.
        :param pdu: the device list announce request.
        """

        for device in pdu.deviceList:
            self.log.info("%(deviceType)s mapped with ID %(deviceID)d: %(deviceName)s", {
                "deviceType": DeviceType.getPrettyName(device.deviceType),
                "deviceID": device.deviceID,
                "deviceName": device.preferredDOSName
            })

            self.observer.onDeviceAnnounce(device)
    def parseDeviceAnnounce(self, stream: BytesIO) -> DeviceAnnounce:
        deviceType = DeviceType(Uint32LE.unpack(stream))
        deviceID = Uint32LE.unpack(stream)
        preferredDOSName = stream.read(8)
        deviceDataLength = Uint32LE.unpack(stream)
        deviceData = stream.read(deviceDataLength)

        preferredDOSName = preferredDOSName.decode(errors="ignore")[:7]
        endIndex = preferredDOSName.index("\x00")

        if endIndex >= 0:
            preferredDOSName = preferredDOSName[:endIndex]

        return DeviceAnnounce(deviceType, deviceID, preferredDOSName,
                              deviceData)