예제 #1
0
파일: multicast.py 프로젝트: nk3750/bellows
    async def subscribe(self, group_id) -> t.EmberStatus:
        if group_id in self._multicast:
            LOGGER.debug("%s is already subscribed",
                         t.EmberMulticastId(group_id))
            return t.EmberStatus.SUCCESS

        try:
            idx = self._available.pop()
        except KeyError:
            LOGGER.error("No more available slots MulticastId subscription")
            return t.EmberStatus.INDEX_OUT_OF_RANGE
        entry = t.EmberMulticastTableEntry()
        entry.endpoint = t.uint8_t(1)
        entry.multicastId = t.EmberMulticastId(group_id)
        entry.networkIndex = t.uint8_t(0)
        status = await self._ezsp.setMulticastTableEntry(idx, entry)
        if status[0] != t.EmberStatus.SUCCESS:
            LOGGER.warning(
                "Set MulticastTableEntry #%s for %s multicast id: %s", idx,
                entry.multicastId, status)
            self._available.add(idx)
            return status[0]

        self._multicast[entry.multicastId] = (entry, idx)
        LOGGER.debug("Set MulticastTableEntry #%s for %s multicast id: %s",
                     idx, entry.multicastId, status)
        return status[0]
예제 #2
0
 async def mock_get(*args):
     nonlocal group_id
     entry = t.EmberMulticastTableEntry()
     entry.endpoint = t.uint8_t(group_id % 3 + 1)
     entry.multicastId = t.EmberMulticastId(group_id)
     entry.networkIndex = t.uint8_t(0)
     group_id += 1
     return [t.EmberStatus.ERR_FATAL, entry]
예제 #3
0
 async def mock_get(*args):
     nonlocal group_id, mct
     entry = t.EmberMulticastTableEntry()
     if mct > 0:
         entry.endpoint = t.uint8_t(group_id % 3 + 1)
     else:
         entry.endpoint = t.uint8_t(0)
     entry.multicastId = t.EmberMulticastId(group_id)
     entry.networkIndex = t.uint8_t(0)
     group_id += 1
     mct -= 1
     return [t.EmberStatus.SUCCESS, entry]