示例#1
0
    def handle_poller_response(self, message):
        """Handle an incoming poller response message.
        Args:
            message, a poller response message
        Returns:
            None
        """

        if message.poller_id not in self.modules:
            return

        wtp_addr = EtherAddress(message.wtp)

        if wtp_addr not in RUNTIME.wtps:
            return

        wtp = RUNTIME.wtps[wtp_addr]
        hwaddr = EtherAddress(message.hwaddr)
        incoming = ResourcePool()
        incoming.add(ResourceBlock(wtp, hwaddr, message.channel, message.band))

        matching = (wtp.supports & incoming).pop()

        LOG.info("Received %s response from %s (id=%u)",
                 self.MODULE_NAME,
                 matching,
                 message.poller_id)

        # find poller object
        poller = self.modules[message.poller_id]

        # handle the message
        map_type = self.MODULE_NAME
        setattr(poller.block, map_type, CQM())
        map_entry = getattr(poller.block, map_type)

        for entry in message.img_entries:

            addr = EtherAddress(entry[0])

            if not addr.match(poller.addrs):
                continue

            value = {'addr': addr,
                     'last_rssi_std': entry[1] / 1000.0,
                     'last_rssi_avg': entry[2] / 1000.0,
                     'last_packets': entry[3],
                     'hist_packets': entry[4],
                     'ewma_rssi': entry[5] / 1000.0,
                     'sma_rssi': entry[6] / 1000.0}

            map_entry[addr] = value

        # call callback
        handle_callback(poller, poller)
示例#2
0
    def handle_response(self, response):
        """Handle an incoming poller response message.
        Args:
            message, a poller response message
        Returns:
            None
        """

        wtp_addr = EtherAddress(response.wtp)

        if wtp_addr not in RUNTIME.wtps:
            return

        wtp = RUNTIME.wtps[wtp_addr]

        hwaddr = EtherAddress(response.hwaddr)
        block = ResourceBlock(wtp, hwaddr, response.channel, response.band)
        incoming = ResourcePool()
        incoming.add(block)

        matching = (wtp.supports & incoming).pop()

        if not matching:
            return

        # handle the message
        setattr(self.block, self.MODULE_NAME, CQM())
        map_entry = getattr(self.block, self.MODULE_NAME)

        for entry in response.img_entries:

            addr = EtherAddress(entry[0])

            if not addr.match(self.addrs):
                continue

            value = {'addr': addr,
                     'last_rssi_std': entry[1] / 1000.0,
                     'last_rssi_avg': entry[2] / 1000.0,
                     'last_packets': entry[3],
                     'hist_packets': entry[4],
                     'ewma_rssi': entry[5] / 1000.0,
                     'sma_rssi': entry[6] / 1000.0}

            map_entry[addr] = value

        # call callback
        self.handle_callback(self)