Esempio n. 1
0
def test_api_frame(api):
    ieee = t.EUI64([t.uint8_t(a) for a in range(0, 8)])
    for cmd_name, cmd_opts in xbee_api.COMMANDS.items():
        cmd_id, schema, repl = cmd_opts
        if schema:
            args = [ieee if isinstance(a(), t.EUI64) else a() for a in schema]
            frame, repl = api._api_frame(cmd_name, *args)
        else:
            frame, repl = api._api_frame(cmd_name)
Esempio n. 2
0
def test_deserialize():
    extra = b"\xBE\xEF"
    data = b"\xff\xff\xfe01234567"
    schema = (t.uint8_t, t.int16s, t.EUI64)
    result, rest = t.deserialize(data + extra, schema)

    assert rest == extra
    assert result[0] == 0xFF
    assert result[1] == -2
    assert result[2] == t.EUI64((0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30))
def test_handle_many_to_one_rri(api):
    ieee = t.EUI64([t.uint8_t(a) for a in range(0, 8)])
    nwk = 0x1234
    api._handle_many_to_one_rri(ieee, nwk, 0)
Esempio n. 4
0
def test_serialize():
    data = [0xFF, -2, t.EUI64([t.uint8_t(i) for i in range(0x30, 0x38)])]
    schema = (t.uint8_t, t.int16s, t.EUI64)
    result = t.serialize(data, schema)

    assert result == b"\xff\xff\xfe01234567"