How to use the bellows.types.EmberEUI64 function in bellows

To help you get started, we’ve selected a few bellows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zigpy / bellows / tests / test_application.py View on Github external
def ieee(init=0):
    return t.EmberEUI64(map(t.uint8_t, range(init, init + 8)))
github zigpy / bellows / tests / test_appdb.py View on Github external
def ieee(init=0):
    return t.EmberEUI64(map(t.uint8_t, range(init, init + 8)))
github zigpy / bellows / tests / test_zdo.py View on Github external
def zdo_f():
    app = mock.MagicMock()
    app.ieee = t.EmberEUI64(map(t.uint8_t, [8, 9, 10, 11, 12, 13, 14, 15]))
    app.get_sequence = mock.MagicMock(return_value=123)
    ieee = t.EmberEUI64(map(t.uint8_t, [0, 1, 2, 3, 4, 5, 6, 7]))
    dev = bellows.zigbee.device.Device(app, ieee, 65535)
    return zdo.ZDO(dev)
github zigpy / bellows / tests / test_zdo_types.py View on Github external
def test_multi_address_3():
    ma = types.MultiAddress()
    ma.addrmode = 3
    ma.ieee = t.EmberEUI64(map(t.uint8_t, [0, 1, 2, 3, 4, 5, 6, 7]))
    ma.endpoint = 1
    ser = ma.serialize()

    ma2, data = types.MultiAddress.deserialize(ser)
    assert data == b''
    assert ma2.addrmode == ma.addrmode
    assert ma2.ieee == ma.ieee
    assert ma2.endpoint == ma.endpoint
github zigpy / bellows / tests / test_types.py View on Github external
def test_ember_eui64():
    ser = b"\x00\x01\x02\x03\x04\x05\x06\x07"
    eui64, data = t.EmberEUI64.deserialize(ser)
    assert data == b""
    assert eui64.serialize() == ser
github zigpy / bellows / bellows / zigbee / appdb.py View on Github external
def convert_ieee(s):
        ieee = [t.uint8_t(p, base=16) for p in s.split(b':')]
        return t.EmberEUI64(ieee)
    sqlite3.register_converter("ieee", convert_ieee)
github zigpy / bellows / bellows / zigbee / application.py View on Github external
async def form_network(self):
        nwk = self.config[zigpy.config.CONF_NWK]

        pan_id = nwk[zigpy.config.CONF_NWK_PAN_ID]
        if pan_id is None:
            pan_id = int.from_bytes(os.urandom(2), byteorder="little")

        extended_pan_id = nwk[zigpy.config.CONF_NWK_EXTENDED_PAN_ID]
        if extended_pan_id is None:
            extended_pan_id = t.EmberEUI64([t.uint8_t(0)] * 8)

        initial_security_state = bellows.zigbee.util.zha_security(nwk, controller=True)
        v = await self._ezsp.setInitialSecurityState(initial_security_state)
        assert v[0] == t.EmberStatus.SUCCESS  # TODO: Better check
        parameters = t.EmberNetworkParameters()
        parameters.panId = t.EmberPanId(pan_id)
        parameters.extendedPanId = extended_pan_id
        parameters.radioTxPower = t.uint8_t(8)
        parameters.radioChannel = t.uint8_t(nwk[zigpy.config.CONF_NWK_CHANNEL])
        parameters.joinMethod = t.EmberJoinMethod.USE_MAC_ASSOCIATION
        parameters.nwkManagerId = t.EmberNodeId(0)
        parameters.nwkUpdateId = t.uint8_t(nwk[zigpy.config.CONF_NWK_UPDATE_ID])
        parameters.channels = nwk[zigpy.config.CONF_NWK_CHANNELS]

        await self._ezsp.formNetwork(parameters)
        await self._ezsp.setValue(t.EzspValueId.VALUE_STACK_TOKEN_WRITING, 1)
github zigpy / bellows / bellows / zigbee / application.py View on Github external
async def permit_with_key(self, node, code, time_s=60):
        if type(node) is not t.EmberEUI64:
            node = t.EmberEUI64([t.uint8_t(p) for p in node])

        key = zigpy.util.convert_install_code(code)
        if key is None:
            raise Exception("Invalid install code")

        link_key = t.EmberKeyData(key)
        v = await self._ezsp.addTransientLinkKey(node, link_key)

        if v[0] != t.EmberStatus.SUCCESS:
            raise Exception("Failed to set link key")

        v = await self._ezsp.setPolicy(
            t.EzspPolicyId.TC_KEY_REQUEST_POLICY,
            t.EzspDecisionId.GENERATE_NEW_TC_LINK_KEY,
        )
        if v[0] != t.EmberStatus.SUCCESS: