-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_sapi_areq.py
executable file
·106 lines (78 loc) · 2.65 KB
/
test_sapi_areq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#! /usr/bin/env python3
# test_sapi_areq.py
#
# Unit tests for MT SAPI announcements
#
# Author: Rhodri James ([email protected])
# Date: 15 July 2016
#
# Copyright 2016 Kynesim Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import base_test
import unittest
class BaseSapiAReq(base_test.BaseTest):
SUBSYSTEM = "SAPI"
TYPE = "AREQ"
class TestZbSystemReset(BaseSapiAReq):
COMMAND = 0x09
COMMAND_NAME = "ZB_SYSTEM_RESET"
def test_reset(self):
self.run_test()
class TestZbStartConfirm(BaseSapiAReq):
COMMAND = 0x80
COMMAND_NAME = "ZB_START_CONFIRM"
def test_start(self):
self.add_byte("Status", "Success", 0)
self.run_test()
class TestZbBindConfirm(BaseSapiAReq):
COMMAND = 0x81
COMMAND_NAME = "ZB_BIND_CONFIRM"
def test_bind(self):
self.add_hword("CommandId", "0754", 0x0754)
self.add_byte("Status", "Failed", 1)
self.run_test()
class TestZbAllowBindConfirm(BaseSapiAReq):
COMMAND = 0x82
COMMAND_NAME = "ZB_ALLOW_BIND_CONFIRM"
def test_allow_bind(self):
self.add_hword("SrcAddr", "7d2a", 0x7d2a)
self.run_test()
class TestZbSendDataConfirm(BaseSapiAReq):
COMMAND = 0x83
COMMAND_NAME = "ZB_SEND_DATA_CONFIRM"
def test_send_data(self):
self.add_byte("Handle", "0x01")
self.add_byte("Status", "Success", 0)
self.run_test()
class TestZbReceiveDataIndication(BaseSapiAReq):
COMMAND = 0x87
COMMAND_NAME = "ZB_RECEIVE_DATA_INDICATION"
def test_rx_data(self):
self.add_hword("SrcAddr", "0631", 0x0631)
self.add_hword("CommandId", "1359", 0x1359)
self.add_hword("Len", "3")
self.add_bytes("Data", (0x41, 0x42, 0x43))
self.run_test()
class TestZbFindDeviceConfirm(BaseSapiAReq):
COMMAND = 0x85
COMMAND_NAME = "ZB_FIND_DEVICE_CONFIRM"
def test_find(self):
self.add_byte("SearchType", "0x01")
self.add_hword("SearchKey", "2345", 0x2345)
self.add_bytes("Result", (0x67, 0x89, 0xab, 0xcd,
0xef, 0x10, 0x20, 0x40),
leading_0x=True)
self.run_test()
if __name__ == "__main__":
unittest.main()