myriad of arm/adi additions. working on moving past arm7 into adiv5
[goodfet] / client / em260_data.py
1 #############################
2 # Transaction Values
3 #   0 = Request
4 #   1 = Response
5 #############################
6 TRANSACTION = 0
7 #############################
8
9 #############################
10 # SPI Byte Values
11 #############################
12 spi_version_mask = 0xC0
13 spi_pro_stat = (0x0A, 0x0B, 0xC0, 0xC1)
14
15 spi_bytes = (
16     0x00,
17     0x01,
18     0x02,
19     0x03,
20     0x04,
21     0x0A,
22     0x0B,
23     0xC0,
24     0xC1,
25     0xA7,
26     0xFD,
27     0xFE,
28     0xFF
29 )
30
31 spi_values = (
32     'EM260_RESET',
33     'OVERSIZED_EZSP_FRAME',
34     'ABORTED_TRANSACTION',
35     'MISSING_FRAME_TERMINATOR',
36     'RESERVED_ERROR',
37     'SPI_PROTOCOL_VERSION',
38     'SPI_STATUS',
39     'RESP_STAT_SLEEP',
40     'RESP_STAT_READY',
41     'FRAME_TERMINATOR',
42     'BOOTLOADER_FRAME',
43     'EZSP_FRAME',
44     'CONT_BYTE'
45 )
46
47 spi_table = {}
48 spi_table_rev = {}
49 for byte in xrange(len(spi_bytes)):
50     spi_table[spi_bytes[byte]] = spi_values[byte]
51     spi_table_rev[spi_values[byte]] = spi_bytes[byte]
52
53 #############################
54
55 #############################
56 # Command Control Frame
57 #############################
58 cmd_mask = 0x80
59 resp_over_mask = 0x01
60 resp_trun_mask = 0x02
61
62 cmd_control = (
63     'CMDI',       # Master State: Idle
64     'CMDD',       # Master State: Deep Sleep
65     'CMDP',       # Master State: Power Down
66     'Reserved',
67     'Reserved',
68     'Reserved',
69     'Reserved',
70 )
71
72 #resp_overflow = 'Out of Memory'
73 resp_overflow = 'NOMEM'
74 #resp_truncated = 'Truncated Response'
75 resp_truncated = 'TRUNC_RESP'
76 #############################
77
78 #############################
79 # Named Values
80 #############################
81
82 # Ember
83
84 # Boolean
85 boolean = (
86     'FALSE',      # 0x00
87     'TRUE'        # 0x01
88 )
89
90 # Frame IDs
91 frame_error = 'NOT IMPLEMENTED'
92 frame_ids = (
93     'version',                  # 0x00
94     'NOT IMPLEMENTED',          # 0x01
95     'addEndpoint',              # 0x02
96     'NOT IMPLEMENTED',          # 0x03
97     'NOT IMPLEMENTED',          # 0x04
98     'nop',                      # 0x05
99     'callback',                 # 0x06
100     'noCallbacks',              # 0x07
101     'reset',                    # 0x08
102     'setToken',                 # 0x09
103     'getToken',                 # 0x0A
104     'getMfgToken',              # 0x0B
105     'NOT IMPLEMENTED',          # 0x0C
106     'getMillisecondTime',       # 0x0D
107     'setTimer',                 # 0x0E
108     'timerHandler',             # 0x0F
109     'serialWrite',              # 0x10
110     'serialRead',               # 0x11
111     'debugWrite',               # 0x12
112     'debugHandler',             # 0x13
113     'requestLinkKey',           # 0x14
114     'setManufacturerCode',      # 0x15
115     'setPowerDescriptor',       # 0x16
116     'networkInit',              # 0x17
117     'networkState',             # 0x18
118     'stackStatusHandler',       # 0x19
119     'startScan',                # 0x1A
120     'networkFoundHandler',      # 0x1B
121     'scanCompleteHandler',      # 0x1C
122     'stopScan',                 # 0x1D
123     'formNetwork',              # 0x1E
124     'joinNetwork',              # 0x1F
125     'leaveNetwork',             # 0x20
126     'findAndRejoinNetwork',     # 0x21
127     'permitJoining',            # 0x22
128     'childJoinHandler',         # 0x23
129     'trustCenterJoinHandler',   # 0x24
130     'NOT IMPLEMENTED',          # 0x25
131     'getEui64',                 # 0x26
132     'getNodeId',                # 0x27
133     'getNetworkParameters',     # 0x28
134     'getParentChildParameters', # 0x29
135     'clearBindingTable',        # 0x2A
136     'setBinding',               # 0x2B
137     'getBinding',               # 0x2C
138     'deleteBinding',            # 0x2D
139     'bindingIsActive',          # 0x2E
140     'getBindingRemoteNodeId',   # 0x2F
141     'setBindingRemoteNodeId',   # 0x30
142     'remoteSetBindingHandler',  # 0x31
143     'remoteDeleteBindingHandler',   # 0x32
144     'maximumPayloadLength',     # 0x33
145     'sendUnicast',              # 0x34
146     'NOT IMPLEMENTED',          # 0x35
147     'sendBroadcast',            # 0x36
148     'NOT IMPLEMENTED',          # 0x37
149     'sendMulticast',            # 0x38
150     'sendReply',                # 0x39
151     'NOT IMPLEMENTED',          # 0x3A
152     'NOT IMPLEMENTED',          # 0x3B
153     'NOT IMPLEMENTED',          # 0x3C
154     'NOT IMPLEMENTED',          # 0x3D
155     'NOT IMPLEMENTED',          # 0x3E
156     'messageSentHandler',       # 0x3F
157     'cancelMessage',            # 0x40
158     'sendManyToOneRouteRequest',# 0x41
159     'pollForData',              # 0x42
160     'pollCompleteHandler',      # 0x43
161     'pollHandler',              # 0x44
162     'incomingMessageHandler',   # 0x45
163     'setRam',                   # 0x46
164     'getRam',                   # 0x47
165     'energyScanResultHandler',  # 0x48
166     'getRandomNumber',          # 0x49
167     'getChildData',             # 0x4A
168     'NOT IMPLEMENTED',          # 0x4B
169     'NOT IMPLEMENTED',          # 0x4C
170     'NOT IMPLEMENTED',          # 0x4D
171     'getTimer',                 # 0x4E
172     'scanAndFormNetwork',       # 0x4F
173     'scanAndJoinNetwork',       # 0x50
174     'scanErrorHandler',         # 0x51
175     'getConfigurationValue',    # 0x52
176     'setConfigurationValue',    # 0x53
177     'NOT IMPLEMENTED',          # 0x54
178     'setPolicy',                # 0x55
179     'getPolicy',                # 0x56
180     'NOT IMPLEMENTED',          # 0x57
181     'invalidCommand',           # 0x58
182     'incomingRouteRecordHandler',   # 0x59
183     'setSourceRoute',           # 0x5A
184     'addressTableEntryIsActive',# 0x5B
185     'setAddressTableRemoteEui64',   # 0x5C
186     'setAddressTableRemoteNodeId',  # 0x5D
187     'getAddressTableRemoteEui64',   # 0x5E
188     'getAddressTableRemoteNodeId',  # 0x5F
189     'lookupNodeIdByEui64',      # 0x60
190     'lookupEui64ByNodeId',      # 0x61
191     'incomingSenderEui64Handler',   # 0x62
192     'getMulticastTableEntry',   # 0x63
193     'setMulticastTableEntry',   # 0x64
194     'readAndClearCounters',     # 0x65
195     'addOrUpdateKeyTableEntry', # 0x66
196     'NOT IMPLEMENTED',          # 0x67
197     'setInitialSecurityState',  # 0x68
198     'getCurrentSecurityState',  # 0x69
199     'getKey',                   # 0x6A
200     'NOT IMPLEMENTED',          # 0x6B
201     'NOT IMPLEMENTED',          # 0x6C
202     'NOT IMPLEMENTED',          # 0x6D
203     'switchNetworkKeyHandler',  # 0x6E
204     'NOT IMPLEMENTED',          # 0x6F
205     'NOT IMPLEMENTED',          # 0x70
206     'getKeyTableEntry',         # 0x71
207     'setKeyTableEntry',         # 0x72
208     'broadcastNextNetworkKey',  # 0x73
209     'broadcastNetworkKeySwitch',# 0x74
210     'findKeyTableEntry',        # 0x75
211     'eraseKeyTableEntry',       # 0x76
212     'becomeTrustCenter',        # 0x77
213     'NOT IMPLEMENTED',          # 0x78
214     'getNeighbor',              # 0x79
215     'neighborCount',            # 0x7A
216     'getRouteTableEntry',       # 0x7B
217     'idConflictHandler',        # 0x7C
218     'incomingManyToOneRouteRequestHandler', # 0x7D
219     'setExtendedTimeout',       # 0x7E
220     'getExtendedTimeout',       # 0x7F
221     'incomingRouteErrorHandler',# 0x80
222     'echo',                     # 0x81
223     'replaceAddressTableEntry', # 0x82
224     'mfglibStart',              # 0x83
225     'mfglibEnd',                # 0x84
226     'mfglibStartTone',          # 0x85
227     'mfglibStopTone',           # 0x86
228     'mfglibStartStream',        # 0x87
229     'mfglibStopStream',         # 0x88
230     'mfglibSendPacket',         # 0x89
231     'mfglibSetChannel',         # 0x8A
232     'mfglibGetChannel',         # 0x8B
233     'mfglibSetPower',           # 0x8C
234     'mfglibGetPower',           # 0x8D
235     'mfglibRxHandler',          # 0x8E
236     'launchStandaloneBootloader',   # 0x8F
237     'sendBootloadMessage',      # 0x90
238     'getStandaloneBootloaderVersionPlatMicroPhy',   # 0x91
239     'incomingBootloadMessageHandler',   # 0x92
240     'bootloadTransmitCompleteHandler',  # 0x93
241     'aesEncrypt',               # 0x94
242     'overrideCurrentChannel',   # 0x95
243     'sendRawMessage',           # 0x96
244     'macPassthroughMessageHandler', # 0x97
245     'rawTransmitCompleteHandler',   # 0x98
246     'setRadioPower',            # 0x99
247     'setRadioChannel',          # 0x9A
248     'zigbeeKeyEstablishmentHandler',    # 0x9B
249     'energyScanRequest',        # 0x9C
250     'delayTest',                # 0x9D
251     'generateCbkeKeysHandler',  # 0x9E
252     'calculateSmacs',           # 0x9F
253     'calculateSmacsHandler',    # 0xA0
254     'clearTemporaryDataMaybeStoreLinkKey',  # 0xA1
255     'NOT IMPLEMENTED',          # 0xA2
256     'NOT IMPLEMENTED',          # 0xA3
257     'generateCbkeKeys',         # 0xA4
258     'NOT IMPLEMENTED',          # 0xA5
259     'dsaSign',                  # 0xA6
260     'dsaSignHandler',           # 0xA7
261     'scanForJoinableNetwork',   # 0xA8
262     'unusedPanIdFoundHandler',  # 0xA9
263     'getValue',                 # 0xAA
264     'setValue',                 # 0xAB
265     'NOT IMPLEMENTED',          # 0xAC
266     'NOT IMPLEMENTED',          # 0xAD
267     'NOT IMPLEMENTED',          # 0xAE
268     'NOT IMPLEMENTED'           # 0xAF
269 )
270
271 frame_table = {}
272 frame_table_rev = {}
273 for fid in xrange(len(frame_ids)):
274     frame_table[fid] = frame_ids[fid]
275     frame_table[frame_ids[fid]] = fid
276
277 # EzspConfigId
278 EZSP_CONFIG_PACKET_BUFFER_COUNT         = 0x01
279 EZSP_CONFIG_NEIGHBOR_TABLE_SIZE         = 0x02
280 EZSP_CONFIG_APS_UNICAST_MESSAGE_COUNT   = 0x03
281 EZSP_CONFIG_BINDING_TABLE_SIZE          = 0x04
282 EZSP_CONFIG_ADDRESS_TABLE_SIZE          = 0x05
283 EZSP_CONFIG_MULTICAST_TABLE_SIZE        = 0x06
284 EZSP_CONFIG_ROUTE_TABLE_SIZE            = 0x07
285 EZSP_CONFIG_DISCOVERY_TABLE_SIZE        = 0x08
286 EZSP_CONFIG_BROADCAST_ALARM_DATA_SIZE   = 0x09
287 EZSP_CONFIG_UNICAST_ALARM_DATA_SIZE     = 0x0A
288 EZSP_CONFIG_STACK_PROFILE               = 0x0C
289 EZSP_CONFIG_SECURITY_LEVEL              = 0x0D
290 EZSP_CONFIG_MAX_HOPS                    = 0x10
291 EZSP_CONFIG_MAX_END_DEVICE_CHILDREN     = 0x11
292 EZSP_CONFIG_INDIRECT_TRANSMISSION_TIMEOUT = 0x12
293 EZSP_CONFIG_END_DEVICE_POLL_TIMEOUT     = 0x13
294 EZSP_CONFIG_MOBILE_NODE_POLL_TIMEOUT    = 0x14
295 EZSP_CONFIG_RESERVED_MOBILE_CHILD_ENTRIES = 0x15
296 EZSP_CONFIG_HOST_RAM                    = 0x16
297 EZSP_CONFIG_TX_POWER_MODE               = 0x17
298 EZSP_CONFIG_DISABLE_RELAY               = 0x18
299 EZSP_CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE = 0x19
300 EZSP_CONFIG_SOURCE_ROUTE_TABLE_SIZE     = 0x1A
301 EZSP_CONFIG_END_DEVICE_POLL_TIMEOUT_SHIFT = 0x1B
302 EZSP_CONFIG_FRAGMENT_WINDOW_SIZE        = 0x1C
303 EZSP_CONFIG_FRAGMENT_DELAY_MS           = 0x1D
304 EZSP_CONFIG_KEY_TABLE_SIZE              = 0x1E
305 EZSP_CONFIG_APS_ACK_TIMEOUT             = 0x1F
306 EZSP_CONFIG_ACTIVE_SCAN_DURATION        = 0x20
307 EZSP_CONFIG_END_DEVICE_BIND_TIMEOUT     = 0x21
308 EZSP_CONFIG_PAN_ID_CONFLICT_REPORT_THRESHOLD = 0x22
309 EZSP_CONFIG_REQUEST_KEY_TIMEOUT         = 0x24
310 EZSP_CONFIG_ENABLE_DUAL_CHANNEL_SCAN    = 0x25
311
312 ezsp_config_id = {
313         'EZSP_CONFIG_PACKET_BUFFER_COUNT'         : 0x01,\
314         'EZSP_CONFIG_NEIGHBOR_TABLE_SIZE'         : 0x02,\
315         'EZSP_CONFIG_APS_UNICAST_MESSAGE_COUNT'   : 0x03,\
316         'EZSP_CONFIG_BINDING_TABLE_SIZE'          : 0x04,\
317         'EZSP_CONFIG_ADDRESS_TABLE_SIZE'          : 0x05,\
318         'EZSP_CONFIG_MULTICAST_TABLE_SIZE'        : 0x06,\
319         'EZSP_CONFIG_ROUTE_TABLE_SIZE'            : 0x07,\
320         'EZSP_CONFIG_DISCOVERY_TABLE_SIZE'        : 0x08,\
321         'EZSP_CONFIG_BROADCAST_ALARM_DATA_SIZE'   : 0x09,\
322         'EZSP_CONFIG_UNICAST_ALARM_DATA_SIZE'     : 0x0A,\
323         'EZSP_CONFIG_STACK_PROFILE'               : 0x0C,\
324         'EZSP_CONFIG_SECURITY_LEVEL'              : 0x0D,\
325         'EZSP_CONFIG_MAX_HOPS'                    : 0x10,\
326         'EZSP_CONFIG_MAX_END_DEVICE_CHILDREN'     : 0x11,\
327         'EZSP_CONFIG_INDIRECT_TRANSMISSION_TIMEOUT' : 0x12,\
328         'EZSP_CONFIG_END_DEVICE_POLL_TIMEOUT'     : 0x13,\
329         'EZSP_CONFIG_MOBILE_NODE_POLL_TIMEOUT'    : 0x14,\
330         'EZSP_CONFIG_RESERVED_MOBILE_CHILD_ENTRIES' : 0x15,\
331         'EZSP_CONFIG_HOST_RAM'                    : 0x16,\
332         'EZSP_CONFIG_TX_POWER_MODE'               : 0x17,\
333         'EZSP_CONFIG_DISABLE_RELAY'               : 0x18,\
334         'EZSP_CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE' : 0x19,\
335         'EZSP_CONFIG_SOURCE_ROUTE_TABLE_SIZE'     : 0x1A,\
336         'EZSP_CONFIG_END_DEVICE_POLL_TIMEOUT_SHIFT' : 0x1B,\
337         'EZSP_CONFIG_FRAGMENT_WINDOW_SIZE'        : 0x1C,\
338         'EZSP_CONFIG_FRAGMENT_DELAY_MS'           : 0x1D,\
339         'EZSP_CONFIG_KEY_TABLE_SIZE'              : 0x1E,\
340         'EZSP_CONFIG_APS_ACK_TIMEOUT'             : 0x1F,\
341         'EZSP_CONFIG_ACTIVE_SCAN_DURATION'        : 0x20,\
342         'EZSP_CONFIG_END_DEVICE_BIND_TIMEOUT'     : 0x21,\
343         'EZSP_CONFIG_PAN_ID_CONFLICT_REPORT_THRESHOLD' : 0x22,\
344         'EZSP_CONFIG_REQUEST_KEY_TIMEOUT'         : 0x24,\
345         'EZSP_CONFIG_ENABLE_DUAL_CHANNEL_SCAN'    : 0x25,\
346     }
347 ezsp_config_id_rev = {}
348 for cid,num in ezsp_config_id.items():
349     ezsp_config_id_rev[num] = cid
350
351 # EzspValueId
352 EZSP_VALUE_TOKEN_STACK_NODE_DATA        = 0x00
353 EZSP_VALUE_MAC_PASSTHROUGH_FLAGS        = 0x01
354 EZSP_VALUE_EMBERNET_PASSTHROUGH_SOURCE_ADDRESS = 0x02
355 ezsp_value_id = {\
356     'EZSP_VALUE_TOKEN_STACK_NODE_DATA'        : 0x00,\
357     'EZSP_VALUE_MAC_PASSTHROUGH_FLAGS'        : 0x01,\
358     'EZSP_VALUE_EMBERNET_PASSTHROUGH_SOURCE_ADDRESS' : 0x02,\
359 }
360 ezsp_value_id_rev = {}
361 for vid,num in ezsp_value_id.items():
362     ezsp_value_id_rev[num] = vid
363
364 # EmberConfigTxPowerMode
365 EMBER_TX_POWER_MODE_DEFAULT             = 0x00
366 EMBER_TX_POWER_MODE_BOOST               = 0x01
367 EMBER_TX_POWER_MODE_ALTERNATE           = 0x02
368 EMBER_TX_POWER_MODE_BOOST_AND_ALTERNATE = 0x03
369
370 ember_config_tx_power_mode = {\
371     'EMBER_TX_POWER_MODE_DEFAULT'             : 0x00,\
372     'EMBER_TX_POWER_MODE_BOOST'               : 0x01,\
373     'EMBER_TX_POWER_MODE_ALTERNATE'           : 0x02,\
374     'EMBER_TX_POWER_MODE_BOOST_AND_ALTERNATE' : 0x03,\
375 }
376 ember_config_tx_power_mode_rev = {}
377 for mode,num in ember_config_tx_power_mode.items():
378     ember_config_tx_power_mode_rev[num] = mode
379
380
381 # EzspPolicyId
382 EZSP_TRUST_CENTER_POLICY                = 0x00
383 EZSP_BINDING_MODIFICATION_POLICY        = 0x01
384 EZSP_UNICAST_REPLIES_POLICY             = 0x02
385 EZSP_POLL_HANDLER_POLICY                = 0x03
386 EZSP_MESSAGE_CONTENTS_IN_CALLBACK_POLICY = 0x04
387 EZSP_TC_KEY_REQUEST_POLICY              = 0x05
388 EZSP_APP_KEY_REQUEST_POLICY             = 0x06
389 ezsp_policy_id = {\
390     'EZSP_TRUST_CENTER_POLICY'                : 0x00,\
391     'EZSP_BINDING_MODIFICATION_POLICY'        : 0x01,\
392     'EZSP_UNICAST_REPLIES_POLICY'             : 0x02,\
393     'EZSP_POLL_HANDLER_POLICY'                : 0x03,\
394     'EZSP_MESSAGE_CONTENTS_IN_CALLBACK_POLICY' : 0x04,\
395     'EZSP_TC_KEY_REQUEST_POLICY'              : 0x05,\
396     'EZSP_APP_KEY_REQUEST_POLICY'             : 0x06,\
397 }
398 ezsp_policy_id_rev = {}
399 for pid,num in ezsp_policy_id.items():
400     ezsp_policy_id_rev[num] = pid
401
402
403 # EzspDecisionid
404 EZSP_ALLOW_JOINS                        = 0x00
405 EZSP_ALLOW_JOINS_REJOINS_HAVE_LINK_KEY  = 0x04
406 EZSP_ALLOW_PRECONFIGURED_KEY_JOINS      = 0x01
407 EZSP_ALLOW_REJOINS_ONLY                 = 0x02
408 EZSP_DISALLOW_ALL_JOINS_AND_REJOINS     = 0x03
409 EZSP_DISALLOW_BINDING_MODIFICATION      = 0x10
410 EZSP_ALLOW_BINDING_MODIFICATION         = 0x11
411 EZSP_HOST_WILL_NOT_SUPPLY_REPLY         = 0x20
412 EZSP_HOST_WILL_SUPPLY_REPLY             = 0x21
413 EZSP_POLL_HANDLER_IGNORE                = 0x30
414 EZSP_POLL_HANDLER_CALLBACK              = 0x31
415 EZSP_MESSAGE_TAG_ONLY_IN_CALLBACK       = 0x40
416 EZSP_MESSAGE_TAG_AND_CONTENTS_IN_CALLBACK = 0x41
417 EZSP_DENY_TC_KEY_REQUESTS               = 0x50
418 EZSP_ALLOW_TC_KEY_REQUESTS              = 0x51
419 EZSP_DENY_APP_KEY_REQUESTS              = 0x60
420 EZSP_ALLOW_APP_KEY_REQUESTS             = 0x61
421 ezsp_decision_id = {
422     'EZSP_ALLOW_JOINS'                        : 0x00,\
423     'EZSP_ALLOW_JOINS_REJOINS_HAVE_LINK_KEY'  : 0x04,\
424     'EZSP_ALLOW_PRECONFIGURED_KEY_JOINS'      : 0x01,\
425     'EZSP_ALLOW_REJOINS_ONLY'                 : 0x02,\
426     'EZSP_DISALLOW_ALL_JOINS_AND_REJOINS'     : 0x03,\
427     'EZSP_DISALLOW_BINDING_MODIFICATION'      : 0x10,\
428     'EZSP_ALLOW_BINDING_MODIFICATION'         : 0x11,\
429     'EZSP_HOST_WILL_NOT_SUPPLY_REPLY'         : 0x20,\
430     'EZSP_HOST_WILL_SUPPLY_REPLY'             : 0x21,\
431     'EZSP_POLL_HANDLER_IGNORE'                : 0x30,\
432     'EZSP_POLL_HANDLER_CALLBACK'              : 0x31,\
433     'EZSP_MESSAGE_TAG_ONLY_IN_CALLBACK'       : 0x40,\
434     'EZSP_MESSAGE_TAG_AND_CONTENTS_IN_CALLBACK' : 0x41,\
435     'EZSP_DENY_TC_KEY_REQUESTS'               : 0x50,\
436     'EZSP_ALLOW_TC_KEY_REQUESTS'              : 0x51,\
437     'EZSP_DENY_APP_KEY_REQUESTS'              : 0x60,\
438     'EZSP_ALLOW_APP_KEY_REQUESTS'             : 0x61,\
439 }
440 ezsp_decision_id_rev = {}
441 for did,num in ezsp_decision_id.items():
442     ezsp_decision_id_rev[num] = did
443
444
445 # EzspMfgTokenId
446 EZSP_MFG_CUSTOM_VERSION                 = 0x00
447 EZSP_MFG_STRING                         = 0x01
448 EZSP_MFG_BOARD_NAME                     = 0x02
449 EZSP_MFG_MANUF_ID                       = 0x03
450 EZSP_MFG_PHY_CONFIG                     = 0x04
451 EZSP_MFG_BOOTLOAD_AES_KEY               = 0x05
452 EZSP_MFG_ASH_CONFIG                     = 0x06
453 EZSP_MFG_EZSP_STORAGE                   = 0x07
454 EZSP_STACK_CAL_DATA                     = 0x08
455 EZSP_MFG_CBKE_DATA                      = 0x09
456 EZSP_MFG_INSTALLATION_CODE              = 0x0A
457 ezsp_mfg_token_id = {
458     'EZSP_MFG_CUSTOM_VERSION'                 : 0x00,\
459     'EZSP_MFG_STRING'                         : 0x01,\
460     'EZSP_MFG_BOARD_NAME'                     : 0x02,\
461     'EZSP_MFG_MANUF_ID'                       : 0x03,\
462     'EZSP_MFG_PHY_CONFIG'                     : 0x04,\
463     'EZSP_MFG_BOOTLOAD_AES_KEY'               : 0x05,\
464     'EZSP_MFG_ASH_CONFIG'                     : 0x06,\
465     'EZSP_MFG_EZSP_STORAGE'                   : 0x07,\
466     'EZSP_STACK_CAL_DATA'                     : 0x08,\
467     'EZSP_MFG_CBKE_DATA'                      : 0x09,\
468     'EZSP_MFG_INSTALLATION_CODE'              : 0x0A,\
469 }
470 ezsp_mfg_token_id_rev = {}
471 for tid,num in ezsp_mfg_token_id.items():
472     ezsp_mfg_token_id_rev[num] = tid
473
474
475 # EzspStatus
476 EZSP_SUCCESS                            = 0x00
477 EZSP_SPI_ERR_FATAL                      = 0x10
478 EZSP_SPI_ERR_EM260_RESET                = 0x11
479 EZSP_SPI_ERR_OVERSIZED_EZSP_FRAME       = 0x12
480 EZSP_SPI_ERR_ABORTED_TRANSACTION        = 0x13
481 EZSP_SPI_ERR_MISSING_FRAME_TERMINATOR   = 0x14
482 EZSP_SPI_ERR_WAIT_SECTION_TIMEOUT       = 0x15
483 EZSP_SPI_ERR_NO_FRAME_TERMINATOR        = 0x16
484 EZSP_SPI_ERR_EZSP_COMMAND_OVERSIZED     = 0x17
485 EZSP_SPI_ERR_EZSP_RESPONSE_OVERSIZED    = 0x18
486 EZSP_SPI_WAITING_FOR_RESPONSE           = 0x19
487 EZSP_SPI_ERR_HANDSHAKE_TIMEOUT          = 0x1A
488 EZSP_SPI_ERR_STARTUP_TIMEOUT            = 0x1B
489 EZSP_SPI_ERR_STARTUP_FAIL               = 0x1C
490 EZSP_SPI_ERR_UNSUPPORTED_SPI_COMMAND    = 0x1D
491 EZSP_ASH_IN_PROGRESS                    = 0x20
492 EZSP_ASH_HOST_FATAL_ERROR               = 0x21
493 EZSP_ASH_NCP_FATAL_ERROR                = 0x22
494 EZSP_ASH_DATA_FRAME_TOO_LONG            = 0x23
495 EZSP_ASH_DATA_FRAME_TOO_SHORT           = 0x24
496 EZSP_ASH_NO_TX_SPACE                    = 0x25
497 EZSP_ASH_NO_RX_SPACE                    = 0x26
498 EZSP_ASH_NO_RX_DATA                     = 0x27
499 EZSP_ASH_NOT_CONNECTED                  = 0x28
500 EZSP_ERROR_VERSION_NOT_SET              = 0x30
501 EZSP_ERROR_INVALID_FRAME_ID             = 0x31
502 EZSP_ERROR_WRONG_DIRECTION              = 0x32
503 EZSP_ERROR_TRUNCATED                    = 0x33
504 EZSP_ERROR_OVERFLOW                     = 0x34
505 EZSP_ERROR_OUT_OF_MEMORY                = 0x35
506 EZSP_ERROR_INVALID_VALUE                = 0x36
507 EZSP_ERROR_INVALID_ID                   = 0x37
508 EZSP_ERROR_INVALID_CALL                 = 0x38
509 EZSP_ERROR_NO_RESPONSE                  = 0x39
510 EZSP_ERROR_COMMAND_TOO_LONG             = 0x40
511 EZSP_ERROR_QUEUE_FULL                   = 0x41
512 EZSP_ASH_ERROR_VERSION                  = 0x50
513 EZSP_ASH_ERROR_TIMEOUTS                 = 0x51
514 EZSP_ASH_ERROR_RESET_FAIL               = 0x52
515 EZSP_ASH_ERROR_NCP_RESET                = 0x53
516 EZSP_ASH_ERROR_SERIAL_INIT              = 0x54
517 EZSP_ASH_ERROR_NCP_TYPE                 = 0x55
518 EZSP_ASH_ERROR_RESET_METHOD             = 0x56
519 EZSP_ASH_ERROR_XON_XOFF                 = 0x57
520 EZSP_ASH_STARTED                        = 0x70
521 EZSP_ASH_CONNECTED                      = 0x71
522 EZSP_ASH_DISCONNECTED                   = 0x72
523 EZSP_ASH_ACK_TIMEOUT                    = 0x73
524 EZSP_ASH_CANCELLED                      = 0x74
525 EZSP_ASH_OUT_OF_SEQUENCE                = 0x75
526 EZSP_ASH_BAD_CRC                        = 0x76
527 EZSP_ASH_COMM_ERROR                     = 0x77
528 EZSP_ASH_BAD_ACKNUM                     = 0x78
529 EZSP_ASH_TOO_SHORT                      = 0x79
530 EZSP_ASH_TOO_LONG                       = 0x7A
531 EZSP_ASH_BAD_CONTROL                    = 0x7B
532 EZSP_ASH_BAD_LENGTH                     = 0x7C
533 EZSP_ASH_NO_ERROR                       = 0xFF
534 ezsp_status = {\
535     'EZSP_SUCCESS'                            : 0x00,\
536     'EZSP_SPI_ERR_FATAL'                      : 0x10,\
537     'EZSP_SPI_ERR_EM260_RESET'                : 0x11,\
538     'EZSP_SPI_ERR_OVERSIZED_EZSP_FRAME'       : 0x12,\
539     'EZSP_SPI_ERR_ABORTED_TRANSACTION'        : 0x13,\
540     'EZSP_SPI_ERR_MISSING_FRAME_TERMINATOR'   : 0x14,\
541     'EZSP_SPI_ERR_WAIT_SECTION_TIMEOUT'       : 0x15,\
542     'EZSP_SPI_ERR_NO_FRAME_TERMINATOR'        : 0x16,\
543     'EZSP_SPI_ERR_EZSP_COMMAND_OVERSIZED'     : 0x17,\
544     'EZSP_SPI_ERR_EZSP_RESPONSE_OVERSIZED'    : 0x18,\
545     'EZSP_SPI_WAITING_FOR_RESPONSE'           : 0x19,\
546     'EZSP_SPI_ERR_HANDSHAKE_TIMEOUT'          : 0x1A,\
547     'EZSP_SPI_ERR_STARTUP_TIMEOUT'            : 0x1B,\
548     'EZSP_SPI_ERR_STARTUP_FAIL'               : 0x1C,\
549     'EZSP_SPI_ERR_UNSUPPORTED_SPI_COMMAND'    : 0x1D,\
550     'EZSP_ASH_IN_PROGRESS'                    : 0x20,\
551     'EZSP_ASH_HOST_FATAL_ERROR'               : 0x21,\
552     'EZSP_ASH_NCP_FATAL_ERROR'                : 0x22,\
553     'EZSP_ASH_DATA_FRAME_TOO_LONG'            : 0x23,\
554     'EZSP_ASH_DATA_FRAME_TOO_SHORT'           : 0x24,\
555     'EZSP_ASH_NO_TX_SPACE'                    : 0x25,\
556     'EZSP_ASH_NO_RX_SPACE'                    : 0x26,\
557     'EZSP_ASH_NO_RX_DATA'                     : 0x27,\
558     'EZSP_ASH_NOT_CONNECTED'                  : 0x28,\
559     'EZSP_ERROR_VERSION_NOT_SET'              : 0x30,\
560     'EZSP_ERROR_INVALID_FRAME_ID'             : 0x31,\
561     'EZSP_ERROR_WRONG_DIRECTION'              : 0x32,\
562     'EZSP_ERROR_TRUNCATED'                    : 0x33,\
563     'EZSP_ERROR_OVERFLOW'                     : 0x34,\
564     'EZSP_ERROR_OUT_OF_MEMORY'                : 0x35,\
565     'EZSP_ERROR_INVALID_VALUE'                : 0x36,\
566     'EZSP_ERROR_INVALID_ID'                   : 0x37,\
567     'EZSP_ERROR_INVALID_CALL'                 : 0x38,\
568     'EZSP_ERROR_NO_RESPONSE'                  : 0x39,\
569     'EZSP_ERROR_COMMAND_TOO_LONG'             : 0x40,\
570     'EZSP_ERROR_QUEUE_FULL'                   : 0x41,\
571     'EZSP_ASH_ERROR_VERSION'                  : 0x50,\
572     'EZSP_ASH_ERROR_TIMEOUTS'                 : 0x51,\
573     'EZSP_ASH_ERROR_RESET_FAIL'               : 0x52,\
574     'EZSP_ASH_ERROR_NCP_RESET'                : 0x53,\
575     'EZSP_ASH_ERROR_SERIAL_INIT'              : 0x54,\
576     'EZSP_ASH_ERROR_NCP_TYPE'                 : 0x55,\
577     'EZSP_ASH_ERROR_RESET_METHOD'             : 0x56,\
578     'EZSP_ASH_ERROR_XON_XOFF'                 : 0x57,\
579     'EZSP_ASH_STARTED'                        : 0x70,\
580     'EZSP_ASH_CONNECTED'                      : 0x71,\
581     'EZSP_ASH_DISCONNECTED'                   : 0x72,\
582     'EZSP_ASH_ACK_TIMEOUT'                    : 0x73,\
583     'EZSP_ASH_CANCELLED'                      : 0x74,\
584     'EZSP_ASH_OUT_OF_SEQUENCE'                : 0x75,\
585     'EZSP_ASH_BAD_CRC'                        : 0x76,\
586     'EZSP_ASH_COMM_ERROR'                     : 0x77,\
587     'EZSP_ASH_BAD_ACKNUM'                     : 0x78,\
588     'EZSP_ASH_TOO_SHORT'                      : 0x79,\
589     'EZSP_ASH_TOO_LONG'                       : 0x7A,\
590     'EZSP_ASH_BAD_CONTROL'                    : 0x7B,\
591     'EZSP_ASH_BAD_LENGTH'                     : 0x7C,\
592     'EZSP_ASH_NO_ERROR'                       : 0xFF,\
593 }
594 ezsp_status_rev = {}
595 for tid,num in ezsp_status.items():
596     ezsp_status_rev[num] = tid
597
598
599 # EmberStatus
600 EMBER_SUCCESS                           = 0x00
601 EMBER_ERR_FATAL                         = 0x01
602 EMBER_EEPROM_MFG_STACK_VERSION_MISMATCH = 0x04
603 EMBER_INCOMPATIBLE_STATIC_MEMORY_DEFINITIONS = 0x05
604 EMBER_EEPROM_MFG_VERSION_MISMATCH       = 0x06
605 EMBER_EEPROM_STACK_VERSION_MISMATCH     = 0x07
606 EMBER_NO_BUFFERS                        = 0x18
607 EMBER_SERIAL_INVALID_BAUD_RATE          = 0x20
608 EMBER_SERIAL_INVALID_PORT               = 0x21
609 EMBER_SERIAL_TX_OVERFLOW                = 0x22
610 EMBER_SERIAL_RX_OVERFLOW                = 0x23
611 EMBER_SERIAL_RX_FRAME_ERROR             = 0x24
612 EMBER_SERIAL_RX_PARITY_ERROR            = 0x25
613 EMBER_SERIAL_RX_EMPTY                   = 0x26
614 EMBER_SERIAL_RX_OVERRUN_ERROR           = 0x27
615 EMBER_MAC_TRANSMIT_QUEUE_FULL           = 0x39
616 EMBER_MAC_UNKNOWN_HEADER_TYPE           = 0x3A
617 EMBER_MAC_SCANNING                      = 0x3D
618 EMBER_MAC_NO_DATA                       = 0x31
619 EMBER_MAC_JOINED_NETWORK                = 0x32
620 EMBER_MAC_BAD_SCAN_DURATION             = 0x33
621 EMBER_MAC_INCORRECT_SCAN_TYPE           = 0x34
622 EMBER_MAC_INVALID_CHANNEL_MASK          = 0x35
623 EMBER_MAC_COMMAND_TRANSMIT_FAILURE      = 0x36
624 EMBER_MAC_NO_ACK_RECEIVED               = 0x40
625 EMBER_MAC_INDIRECT_TIMEOUT              = 0x42
626 EMBER_SIM_EEPROM_ERASE_PAGE_GREEN       = 0x43
627 EMBER_SIM_EEPROM_ERASE_PAGE_RED         = 0x44
628 EMBER_SIM_EEPROM_FULL                   = 0x45
629 EMBER_ERR_FLASH_WRITE_INHIBITED         = 0x46
630 EMBER_ERR_FLASH_VERIFY_FAILED           = 0x47
631 EMBER_SIM_EEPROM_INIT_1_FAILED          = 0x48
632 EMBER_SIM_EEPROM_INIT_2_FAILED          = 0x49
633 EMBER_SIM_EEPROM_INIT_3_FAILED          = 0x4A
634 EMBER_ERR_TOKEN_UNKNOWN                 = 0x4B
635 EMBER_ERR_TOKEN_EXISTS                  = 0x4C
636 EMBER_ERR_TOKEN_INVALID_SIZE            = 0x4D
637 EMBER_ERR_TOKEN_READ_ONLY               = 0x4E
638 EMBER_ERR_BOOTLOADER_TRAP_TABLE_BAD     = 0x58
639 EMBER_ERR_BOOTLOADER_TRAP_UNKNOWN       = 0x59
640 EMBER_ERR_BOOTLOADER_NO_IMAGE           = 0x5A
641 EMBER_DELIVERY_FAILED                   = 0x66
642 EMBER_BINDING_INDEX_OUT_OF_RANGE        = 0x69
643 EMBER_ADDRESS_TABLE_INDEX_OUT_OF_RANGE  = 0x6A
644 EMBER_INVALID_BINDING_INDEX             = 0x6C
645 EMBER_INVALID_CALL                      = 0x70
646 EMBER_COST_NOT_KNOWN                    = 0x71
647 EMBER_MAX_MESSAGE_LIMIT_REACHED         = 0x72
648 EMBER_MESSAGE_TOO_LONG                  = 0x74
649 EMBER_BINDING_IS_ACTIVE                 = 0x75
650 EMBER_ADDRESS_TABLE_ENTRY_IS_ACTIVE     = 0x76
651 EMBER_ADC_CONVERSION_DONE               = 0x80
652 EMBER_ADC_CONVERSION_BUSY               = 0x81
653 EMBER_ADC_CONVERSION_DEFERRED           = 0x82
654 EMBER_ADC_NO_CONVERSION_PENDING         = 0x84
655 EMBER_SLEEP_INTERRUPTED                 = 0x85
656 EMBER_PHY_TX_UNDERFLOW                  = 0x88
657 EMBER_PHY_TX_INCOMPLETE                 = 0x89
658 EMBER_PHY_INVALID_CHANNEL               = 0x8A
659 EMBER_PHY_INVALID_POWER                 = 0x8B
660 EMBER_PHY_TX_BUSY                       = 0x8C
661 EMBER_PHY_UNKNOWN_RADIO_TYPE            = 0x8D
662 EMBER_PHY_OSCILLATOR_CHECK_FAILED       = 0x8E
663 EMBER_PHY_PARTIAL_PACKET                = 0x8F
664 EMBER_NETWORK_UP                        = 0x90
665 EMBER_NETWORK_DOWN                      = 0x91
666 EMBER_JOIN_FAILED                       = 0x94
667 EMBER_MOVE_FAILED                       = 0x96
668 EMBER_CANNOT_JOIN_AS_ROUTER             = 0x98
669 EMBER_NODE_ID_CHANGED                   = 0x99
670 EMBER_PAN_ID_CHANGED                    = 0x9A
671 EMBER_NO_BEACONS                        = 0xAB
672 EMBER_RECEIVED_KEY_IN_THE_CLEAR         = 0xAC
673 EMBER_NO_NETWORK_KEY_RECEIVED           = 0xAD
674 EMBER_NO_LINK_KEY_RECEIVED              = 0xAE
675 EMBER_PRECONFIGURED_KEY_REQUIRED        = 0xAF
676 EMBER_NOT_JOINED                        = 0x93
677 EMBER_INVALID_SECURITY_LEVEL            = 0x95
678 EMBER_NETWORK_BUSY                      = 0xA1
679 EMBER_INVALID_ENDPOINT                  = 0xA3
680 EMBER_BINDING_HAS_CHANGED               = 0xA4
681 EMBER_INSUFFICIENT_RANDOM_DATA          = 0xA5
682 EMBER_APS_ENCRYPTION_ERROR              = 0xA6
683 EMBER_TRUST_CENTER_MASTER_KEY_NOT_SET   = 0xA7
684 EMBER_SECURITY_STATE_NOT_SET            = 0xA8
685 EMBER_KEY_TABLE_INVALID_ADDRESS         = 0xB3
686 EMBER_SECURITY_CONFIGURATION_INVALID    = 0xB7
687 EMBER_TOO_SOON_FOR_SWITCH_KEY           = 0xB8
688 EMBER_KEY_NOT_AUTHORIZED                = 0xBB
689 EMBER_SOURCE_ROUTE_FAILURE              = 0xA9
690 EMBER_MANY_TO_ONE_ROUTE_FAILURE         = 0xAA
691 EMBER_STACK_AND_HARDWARE_MISMATCH       = 0xB0
692 EMBER_APPLICATION_ERROR_0               = 0xF0
693 EMBER_APPLICATION_ERROR_1               = 0xF1
694 EMBER_APPLICATION_ERROR_2               = 0xF2
695 EMBER_APPLICATION_ERROR_3               = 0xF3
696 EMBER_APPLICATION_ERROR_4               = 0xF4
697 EMBER_APPLICATION_ERROR_5               = 0xF5
698 EMBER_APPLICATION_ERROR_6               = 0xF6
699 EMBER_APPLICATION_ERROR_7               = 0xF7
700 EMBER_APPLICATION_ERROR_8               = 0xF8
701 EMBER_APPLICATION_ERROR_9               = 0xF9
702 EMBER_APPLICATION_ERROR_10              = 0xFA
703 EMBER_APPLICATION_ERROR_11              = 0xFB
704 EMBER_APPLICATION_ERROR_12              = 0xFC
705 EMBER_APPLICATION_ERROR_13              = 0xFD
706 EMBER_APPLICATION_ERROR_14              = 0xFE
707 EMBER_APPLICATION_ERROR_15              = 0xFF
708 ember_status = {\
709     'EMBER_SUCCESS'                           : 0x00,\
710     'EMBER_ERR_FATAL'                         : 0x01,\
711     'EMBER_EEPROM_MFG_STACK_VERSION_MISMATCH' : 0x04,\
712     'EMBER_INCOMPATIBLE_STATIC_MEMORY_DEFINITIONS' : 0x05,\
713     'EMBER_EEPROM_MFG_VERSION_MISMATCH'       : 0x06,\
714     'EMBER_EEPROM_STACK_VERSION_MISMATCH'     : 0x07,\
715     'EMBER_NO_BUFFERS'                        : 0x18,\
716     'EMBER_SERIAL_INVALID_BAUD_RATE'          : 0x20,\
717     'EMBER_SERIAL_INVALID_PORT'               : 0x21,\
718     'EMBER_SERIAL_TX_OVERFLOW'                : 0x22,\
719     'EMBER_SERIAL_RX_OVERFLOW'                : 0x23,\
720     'EMBER_SERIAL_RX_FRAME_ERROR'             : 0x24,\
721     'EMBER_SERIAL_RX_PARITY_ERROR'            : 0x25,\
722     'EMBER_SERIAL_RX_EMPTY'                   : 0x26,\
723     'EMBER_SERIAL_RX_OVERRUN_ERROR'           : 0x27,\
724     'EMBER_MAC_TRANSMIT_QUEUE_FULL'           : 0x39,\
725     'EMBER_MAC_UNKNOWN_HEADER_TYPE'           : 0x3A,\
726     'EMBER_MAC_SCANNING'                      : 0x3D,\
727     'EMBER_MAC_NO_DATA'                       : 0x31,\
728     'EMBER_MAC_JOINED_NETWORK'                : 0x32,\
729     'EMBER_MAC_BAD_SCAN_DURATION'             : 0x33,\
730     'EMBER_MAC_INCORRECT_SCAN_TYPE'           : 0x34,\
731     'EMBER_MAC_INVALID_CHANNEL_MASK'          : 0x35,\
732     'EMBER_MAC_COMMAND_TRANSMIT_FAILURE'      : 0x36,\
733     'EMBER_MAC_NO_ACK_RECEIVED'               : 0x40,\
734     'EMBER_MAC_INDIRECT_TIMEOUT'              : 0x42,\
735     'EMBER_SIM_EEPROM_ERASE_PAGE_GREEN'       : 0x43,\
736     'EMBER_SIM_EEPROM_ERASE_PAGE_RED'         : 0x44,\
737     'EMBER_SIM_EEPROM_FULL'                   : 0x45,\
738     'EMBER_ERR_FLASH_WRITE_INHIBITED'         : 0x46,\
739     'EMBER_ERR_FLASH_VERIFY_FAILED'           : 0x47,\
740     EMBER_SIM_EEPROM_INIT_1_FAILED          : 0x48,\
741     EMBER_SIM_EEPROM_INIT_2_FAILED          : 0x49,\
742     EMBER_SIM_EEPROM_INIT_3_FAILED          : 0x4A,\
743     'EMBER_ERR_TOKEN_UNKNOWN'                 : 0x4B,\
744     'EMBER_ERR_TOKEN_EXISTS'                  : 0x4C,\
745     'EMBER_ERR_TOKEN_INVALID_SIZE'            : 0x4D,\
746     'EMBER_ERR_TOKEN_READ_ONLY'               : 0x4E,\
747     'EMBER_ERR_BOOTLOADER_TRAP_TABLE_BAD'     : 0x58,\
748     'EMBER_ERR_BOOTLOADER_TRAP_UNKNOWN'       : 0x59,\
749     'EMBER_ERR_BOOTLOADER_NO_IMAGE'           : 0x5A,\
750     'EMBER_DELIVERY_FAILED'                   : 0x66,\
751     'EMBER_BINDING_INDEX_OUT_OF_RANGE'        : 0x69,\
752     'EMBER_ADDRESS_TABLE_INDEX_OUT_OF_RANGE'  : 0x6A,\
753     'EMBER_INVALID_BINDING_INDEX'             : 0x6C,\
754     'EMBER_INVALID_CALL'                      : 0x70,\
755     'EMBER_COST_NOT_KNOWN'                    : 0x71,\
756     'EMBER_MAX_MESSAGE_LIMIT_REACHED'         : 0x72,\
757     'EMBER_MESSAGE_TOO_LONG'                  : 0x74,\
758     'EMBER_BINDING_IS_ACTIVE'                 : 0x75,\
759     'EMBER_ADDRESS_TABLE_ENTRY_IS_ACTIVE'     : 0x76,\
760     'EMBER_ADC_CONVERSION_DONE'               : 0x80,\
761     'EMBER_ADC_CONVERSION_BUSY'               : 0x81,\
762     'EMBER_ADC_CONVERSION_DEFERRED'           : 0x82,\
763     'EMBER_ADC_NO_CONVERSION_PENDING'         : 0x84,\
764     'EMBER_SLEEP_INTERRUPTED'                 : 0x85,\
765     'EMBER_PHY_TX_UNDERFLOW'                  : 0x88,\
766     'EMBER_PHY_TX_INCOMPLETE'                 : 0x89,\
767     'EMBER_PHY_INVALID_CHANNEL'               : 0x8A,\
768     'EMBER_PHY_INVALID_POWER'                 : 0x8B,\
769     'EMBER_PHY_TX_BUSY'                       : 0x8C,\
770     'EMBER_PHY_UNKNOWN_RADIO_TYPE'            : 0x8D,\
771     'EMBER_PHY_OSCILLATOR_CHECK_FAILED'       : 0x8E,\
772     'EMBER_PHY_PARTIAL_PACKET'                : 0x8F,\
773     'EMBER_NETWORK_UP'                        : 0x90,\
774     'EMBER_NETWORK_DOWN'                      : 0x91,\
775     'EMBER_JOIN_FAILED'                       : 0x94,\
776     'EMBER_MOVE_FAILED'                       : 0x96,\
777     'EMBER_CANNOT_JOIN_AS_ROUTER'             : 0x98,\
778     'EMBER_NODE_ID_CHANGED'                   : 0x99,\
779     'EMBER_PAN_ID_CHANGED'                    : 0x9A,\
780     'EMBER_NO_BEACONS'                        : 0xAB,\
781     'EMBER_RECEIVED_KEY_IN_THE_CLEAR'         : 0xAC,\
782     'EMBER_NO_NETWORK_KEY_RECEIVED'           : 0xAD,\
783     'EMBER_NO_LINK_KEY_RECEIVED'              : 0xAE,\
784     'EMBER_PRECONFIGURED_KEY_REQUIRED'        : 0xAF,\
785     'EMBER_NOT_JOINED'                        : 0x93,\
786     'EMBER_INVALID_SECURITY_LEVEL'            : 0x95,\
787     'EMBER_NETWORK_BUSY'                      : 0xA1,\
788     'EMBER_INVALID_ENDPOINT'                  : 0xA3,\
789     'EMBER_BINDING_HAS_CHANGED'               : 0xA4,\
790     'EMBER_INSUFFICIENT_RANDOM_DATA'          : 0xA5,\
791     'EMBER_APS_ENCRYPTION_ERROR'              : 0xA6,\
792     'EMBER_TRUST_CENTER_MASTER_KEY_NOT_SET'   : 0xA7,\
793     'EMBER_SECURITY_STATE_NOT_SET'            : 0xA8,\
794     'EMBER_KEY_TABLE_INVALID_ADDRESS'         : 0xB3,\
795     'EMBER_SECURITY_CONFIGURATION_INVALID'    : 0xB7,\
796     'EMBER_TOO_SOON_FOR_SWITCH_KEY'           : 0xB8,\
797     'EMBER_KEY_NOT_AUTHORIZED'                : 0xBB,\
798     'EMBER_SOURCE_ROUTE_FAILURE'              : 0xA9,\
799     'EMBER_MANY_TO_ONE_ROUTE_FAILURE'         : 0xAA,\
800     'EMBER_STACK_AND_HARDWARE_MISMATCH'       : 0xB0,\
801     'EMBER_APPLICATION_ERROR_0'               : 0xF0,\
802     'EMBER_APPLICATION_ERROR_1'               : 0xF1,\
803     'EMBER_APPLICATION_ERROR_2'               : 0xF2,\
804     'EMBER_APPLICATION_ERROR_3'               : 0xF3,\
805     'EMBER_APPLICATION_ERROR_4'               : 0xF4,\
806     'EMBER_APPLICATION_ERROR_5'               : 0xF5,\
807     'EMBER_APPLICATION_ERROR_6'               : 0xF6,\
808     'EMBER_APPLICATION_ERROR_7'               : 0xF7,\
809     'EMBER_APPLICATION_ERROR_8'               : 0xF8,\
810     'EMBER_APPLICATION_ERROR_9'               : 0xF9,\
811     'EMBER_APPLICATION_ERROR_10'              : 0xFA,\
812     'EMBER_APPLICATION_ERROR_11'              : 0xFB,\
813     'EMBER_APPLICATION_ERROR_12'              : 0xFC,\
814     'EMBER_APPLICATION_ERROR_13'              : 0xFD,\
815     'EMBER_APPLICATION_ERROR_14'              : 0xFE,\
816     'EMBER_APPLICATION_ERROR_15'              : 0xFF,\
817 }
818 ember_status_rev = {}
819 for tid,num in ember_status.items():
820     ember_status_rev[num] = tid
821
822
823 # EmberEventUnits
824 EMBER_EVENT_INACTIVE                    = 0x00
825 EMBER_EVENT_MS_TIME                     = 0x01
826 EMBER_EVENT_QS_TIME                     = 0x02
827 EMBER_EVENT_MINUTE_TIME                 = 0x03
828 ember_event_units = {\
829     'EMBER_EVENT_INACTIVE'                    : 0x00,\
830     'EMBER_EVENT_MS_TIME'                     : 0x01,\
831     'EMBER_EVENT_QS_TIME'                     : 0x02,\
832     'EMBER_EVENT_MINUTE_TIME'                 : 0x03,\
833 }
834 ember_event_units_rev = {}
835 for tid,num in ember_event_units.items():
836     ember_event_units_rev[num] = tid
837
838
839 # EmberNodeType
840 EMBER_UNKNOWN_DEVICE                    = 0x00
841 EMBER_COORDINATOR                       = 0x01
842 EMBER_ROUTER                            = 0x02
843 EMBER_END_DEVICE                        = 0x03
844 EMBER_SLEEPY_END_DEVICE                 = 0x04
845 EMBER_MOBILE_END_DEVICE                 = 0x05 
846 ember_node_type = {\
847     'EMBER_UNKNOWN_DEVICE'                    : 0x00,\
848     'EMBER_COORDINATOR'                       : 0x01,\
849     'EMBER_ROUTER'                            : 0x02,\
850     'EMBER_END_DEVICE'                        : 0x03,\
851     'EMBER_SLEEPY_END_DEVICE'                 : 0x04,\
852     'EMBER_MOBILE_END_DEVICE'                 : 0x05 ,\
853 }
854 ember_node_type_rev = {}
855 for tid,num in ember_node_type.items():
856     ember_node_type_rev[num] = tid
857
858
859 # EmberNetworkStatus
860 EMBER_NO_NETWORK                        = 0x00
861 EMBER_JOINING_NETWORK                   = 0x01
862 EMBER_JOINED_NETWORK                    = 0x02
863 EMBER_JOINED_NETWORK_NO_PARENT          = 0x03
864 EMBER_LEAVING_NETWORK                   = 0x04 
865 ember_network_status = {\
866     'EMBER_NO_NETWORK'                        : 0x00,\
867     'EMBER_JOINING_NETWORK'                   : 0x01,\
868     'EMBER_JOINED_NETWORK'                    : 0x02,\
869     'EMBER_JOINED_NETWORK_NO_PARENT'          : 0x03,\
870     'EMBER_LEAVING_NETWORK'                   : 0x04 ,\
871 }
872 ember_network_status_rev = {}
873 for tid,num in ember_network_status.items():
874     ember_network_status_rev[num] = tid
875
876
877 # EmberIncomingMessageType
878 EMBER_INCOMING_UNICAST                  = 0x00
879 EMBER_INCOMING_UNICAST_REPLY            = 0x01
880 EMBER_INCOMING_MULTICAST                = 0x02
881 EMBER_INCOMING_MULTICAST_LOOPBACK       = 0x03
882 EMBER_INCOMING_BROADCAST                = 0x04
883 EMBER_INCOMING_BROADCAST_LOOPBACK       = 0x05
884 EMBER_INCOMING_MANY_TO_ONE_ROUTE_REQUEST = 0x06
885 ember_incoming_message_type = {\
886     'EMBER_INCOMING_UNICAST'                  : 0x00,\
887     'EMBER_INCOMING_UNICAST_REPLY'            : 0x01,\
888     'EMBER_INCOMING_MULTICAST'                : 0x02,\
889     'EMBER_INCOMING_MULTICAST_LOOPBACK'       : 0x03,\
890     'EMBER_INCOMING_BROADCAST'                : 0x04,\
891     'EMBER_INCOMING_BROADCAST_LOOPBACK'       : 0x05,\
892     'EMBER_INCOMING_MANY_TO_ONE_ROUTE_REQUEST' : 0x06,\
893 }
894 ember_incoming_message_type_rev = {}
895 for tid,num in ember_incoming_message_type.items():
896     ember_incoming_message_type_rev[num] = tid
897
898
899 # EmberOutgoingMessageType
900 EMBER_OUTGOING_DIRECT                   = 0x00
901 EMBER_OUTGOING_VIA_ADDRESS_TABLE        = 0x01
902 EMBER_OUTGOING_VIA_BINDING              = 0x02
903 EMBER_OUTGOING_MULTICAST                = 0x03
904 EMBER_OUTGOING_BROADCAST                = 0x04
905 ember_outgoing_message_type = {\
906     'EMBER_OUTGOING_DIRECT'                   : 0x00,\
907     'EMBER_OUTGOING_VIA_ADDRESS_TABLE'        : 0x01,\
908     'EMBER_OUTGOING_VIA_BINDING'              : 0x02,\
909     'EMBER_OUTGOING_MULTICAST'                : 0x03,\
910     'EMBER_OUTGOING_BROADCAST'                : 0x04,\
911 }
912 ember_outgoing_message_type_rev = {}
913 for tid,num in ember_outgoing_message_type.items():
914     ember_outgoing_message_type_rev[num] = tid
915
916
917 # EmberMacPassthroughType
918 EMBER_MAC_PASSTHROUGH_NONE              = 0x00
919 EMBER_MAC_PASSTHROUGH_SE_INTERPAN       = 0x01
920 EMBER_MAC_PASSTHROUGH_EMBERNET          = 0x02
921 EMBER_MAC_PASSTHROUGH_EMBERNET_SOURCE   = 0x04
922 ember_mac_passthrough_type = {\
923     'EMBER_MAC_PASSTHROUGH_NONE'              : 0x00,\
924     'EMBER_MAC_PASSTHROUGH_SE_INTERPAN'       : 0x01,\
925     'EMBER_MAC_PASSTHROUGH_EMBERNET'          : 0x02,\
926     'EMBER_MAC_PASSTHROUGH_EMBERNET_SOURCE'   : 0x04,\
927 }
928 ember_mac_passthrough_type_rev = {}
929 for tid,num in ember_mac_passthrough_type.items():
930     ember_mac_passthrough_type_rev[num] = tid
931
932
933 # EmberBindingType
934 EMBER_UNUSED_BINDING                    = 0x00
935 EMBER_UNICAST_BINDING                   = 0x01
936 EMBER_MANY_TO_ONE_BINDING               = 0x02
937 EMBER_MULTICAST_BINDING                 = 0x03
938 ember_binding_type = {\
939     'EMBER_UNUSED_BINDING'                    : 0x00,\
940     'EMBER_UNICAST_BINDING'                   : 0x01,\
941     'EMBER_MANY_TO_ONE_BINDING'               : 0x02,\
942     'EMBER_MULTICAST_BINDING'                 : 0x03,\
943 }
944 ember_binding_type_rev = {}
945 for tid,num in ember_binding_type.items():
946     ember_binding_type_rev[num] = tid
947
948
949 # EmberApsOption
950 EMBER_APS_OPTION_NONE                   = 0x0000
951 EMBER_APS_OPTION_ENCRYPTION             = 0x0020
952 EMBER_APS_OPTION_RETRY                  = 0x0040
953 EMBER_APS_OPTION_ENABLE_ROUTE_DISCOVERY = 0x0100
954 EMBER_APS_OPTION_FORCE_ROUTE_DISCOVERY  = 0x0200
955 EMBER_APS_OPTION_SOURCE_EUI64           = 0x0400
956 EMBER_APS_OPTION_DESTINATION_EUI64      = 0x0800
957 EMBER_APS_OPTION_ENABLE_ADDRESS_DISCOVERY = 0x1000
958 EMBER_APS_OPTION_POLL_RESPONSE          = 0x2000
959 EMBER_APS_OPTION_FRAGMENT               = 0x8000
960 ember_aps_options = {\
961     'EMBER_APS_OPTION_NONE'                   : 0x0000,\
962     'EMBER_APS_OPTION_ENCRYPTION'             : 0x0020,\
963     'EMBER_APS_OPTION_RETRY'                  : 0x0040,\
964     'EMBER_APS_OPTION_ENABLE_ROUTE_DISCOVERY' : 0x0100,\
965     'EMBER_APS_OPTION_FORCE_ROUTE_DISCOVERY'  : 0x0200,\
966     'EMBER_APS_OPTION_SOURCE_EUI64'           : 0x0400,\
967     'EMBER_APS_OPTION_DESTINATION_EUI64'      : 0x0800,\
968     'EMBER_APS_OPTION_ENABLE_ADDRESS_DISCOVERY' : 0x1000,\
969     'EMBER_APS_OPTION_POLL_RESPONSE'          : 0x2000,\
970     'EMBER_APS_OPTION_FRAGMENT'               : 0x8000,\
971 }
972 ember_aps_options_rev = {}
973 for tid,num in ember_aps_options.items():
974     ember_aps_options_rev[num] = tid
975
976
977 # EzspNetworkScanType
978 EZSP_ENERGY_SCAN                        = 0x00
979 EZSP_ACTIVE_SCAN                        = 0x01
980 EZSP_UNUSED_PAN_ID_SCAN                 = 0x02
981 EZSP_NEXT_JOINABLE_NETWORK_SCAN         = 0x03
982 ezsp_network_scan_type = {\
983     'EZSP_ENERGY_SCAN'                        : 0x00,\
984     'EZSP_ACTIVE_SCAN'                        : 0x01,\
985     'EZSP_UNUSED_PAN_ID_SCAN'                 : 0x02,\
986     'EZSP_NEXT_JOINABLE_NETWORK_SCAN'         : 0x03,\
987 }
988 ezsp_network_scan_type_rev = {}
989 for tid,num in ezsp_network_scan_type.items():
990     ezsp_network_scan_type_rev[num] = tid
991
992
993 # EmberJoinDecision
994 EMBER_USE_PRECONFIGURED_KEY             = 0x00
995 EMBER_SEND_KEY_IN_THE_CLEAR             = 0x01
996 EMBER_DENY_JOIN                         = 0x02
997 EMBER_NO_ACTION                         = 0x03
998 ember_join_decision = {\
999     'EMBER_USE_PRECONFIGURED_KEY'             : 0x00,\
1000     'EMBER_SEND_KEY_IN_THE_CLEAR'             : 0x01,\
1001     'EMBER_DENY_JOIN'                         : 0x02,\
1002     'EMBER_NO_ACTION'                         : 0x03,\
1003 }
1004 ember_join_decision_rev = {}
1005 for tid,num in ember_join_decision.items():
1006     ember_join_decision_rev[num] = tid
1007
1008
1009 # EmberInitialSecurityBitmask
1010 EMBER_STANDARD_SECURITY_MODE            = 0x0000
1011 EMBER_HIGH_SECURITY_MODE                = 0x0001
1012 EMBER_DISTRIBUTED_TRUST_CENTER_MODE     = 0x0002
1013 EMBER_GLOBAL_LINK_KEY                   = 0x0004
1014 EMBER_PRECONFIGURED_NETWORK_KEY_MODE    = 0x0008
1015 EMBER_TRUST_CENTER_USES_HASHED_LINK_KEY = 0x0084
1016 EMBER_HAVE_PRECONFIGURED_KEY            = 0x0100
1017 EMBER_HAVE_NETWORK_KEY                  = 0x0200
1018 EMBER_GET_LINK_KEY_WHEN_JOINING         = 0x0400
1019 EMBER_REQUIRE_ENCRYPTED_KEY             = 0x0800
1020 ember_initial_security_bitmask = {\
1021     'EMBER_STANDARD_SECURITY_MODE'            : 0x0000,\
1022     'EMBER_HIGH_SECURITY_MODE'                : 0x0001,\
1023     'EMBER_DISTRIBUTED_TRUST_CENTER_MODE'     : 0x0002,\
1024     'EMBER_GLOBAL_LINK_KEY'                   : 0x0004,\
1025     'EMBER_PRECONFIGURED_NETWORK_KEY_MODE'    : 0x0008,\
1026     'EMBER_TRUST_CENTER_USES_HASHED_LINK_KEY' : 0x0084,\
1027     'EMBER_HAVE_PRECONFIGURED_KEY'            : 0x0100,\
1028     'EMBER_HAVE_NETWORK_KEY'                  : 0x0200,\
1029     'EMBER_GET_LINK_KEY_WHEN_JOINING'         : 0x0400,\
1030     'EMBER_REQUIRE_ENCRYPTED_KEY'             : 0x0800,\
1031 }
1032 ember_initial_security_bitmask_rev = {}
1033 for tid,num in ember_initial_security_bitmask.items():
1034     ember_initial_security_bitmask_rev[num] = tid
1035
1036
1037 # EmberCurrentSecurityBitmask
1038 EMBER_STANDARD_SECURITY_MODE            = 0x0000
1039 EMBER_HIGH_SECURITY_MODE                = 0x0001
1040 EMBER_DISTRIBUTED_TRUST_CENTER_MODE     = 0x0002
1041 EMBER_GLOBAL_LINK_KEY                   = 0x0004
1042 EMBER_HAVE_TRUST_CENTER_LINK_KEY        = 0x0010
1043 EMBER_TRUST_CENTER_USES_HASHED_LINK_KEY = 0x0084
1044 ember_current_security_bitmask = {\
1045     'EMBER_STANDARD_SECURITY_MODE'            : 0x0000,\
1046     'EMBER_HIGH_SECURITY_MODE'                : 0x0001,\
1047     'EMBER_DISTRIBUTED_TRUST_CENTER_MODE'     : 0x0002,\
1048     'EMBER_GLOBAL_LINK_KEY'                   : 0x0004,\
1049     'EMBER_HAVE_TRUST_CENTER_LINK_KEY'        : 0x0010,\
1050     'EMBER_TRUST_CENTER_USES_HASHED_LINK_KEY' : 0x0084,\
1051 }
1052 ember_current_security_bitmask_rev = {}
1053 for tid,num in ember_current_security_bitmask.items():
1054     ember_current_security_bitmask_rev[num] = tid
1055
1056
1057 # EmberKeyType
1058 EMBER_TRUST_CENTER_LINK_KEY             = 0x01
1059 EMBER_TRUST_CENTER_MASTER_KEY           = 0x02
1060 EMBER_CURRENT_NETWORK_KEY               = 0x03
1061 EMBER_NEXT_NETWORK_KEY                  = 0x04
1062 EMBER_APPLICATION_LINK_KEY              = 0x05
1063 EMBER_APPLICATION_MASTER_KEY            = 0x06
1064 ember_key_type = {\
1065     'EMBER_TRUST_CENTER_LINK_KEY'             : 0x01,\
1066     'EMBER_TRUST_CENTER_MASTER_KEY'           : 0x02,\
1067     'EMBER_CURRENT_NETWORK_KEY'               : 0x03,\
1068     'EMBER_NEXT_NETWORK_KEY'                  : 0x04,\
1069     'EMBER_APPLICATION_LINK_KEY'              : 0x05,\
1070     'EMBER_APPLICATION_MASTER_KEY'            : 0x06,\
1071 }
1072 ember_key_type_rev = {}
1073 for tid,num in ember_key_type.items():
1074     ember_key_type_rev[num] = tid
1075
1076
1077 # EmberKeyStructBitmask
1078 EMBER_KEY_HAS_SEQUENCE_NUMBER           = 0x0001
1079 EMBER_KEY_HAS_OUTGOING_FRAME_COUNTER    = 0x0002
1080 EMBER_KEY_HAS_INCOMING_FRAME_COUNTER    = 0x0004
1081 EMBER_KEY_HAS_PARTNER_EUI64             = 0x0008
1082 ember_key_structure_bitmask = {\
1083     'EMBER_KEY_HAS_SEQUENCE_NUMBER'           : 0x0001,\
1084     'EMBER_KEY_HAS_OUTGOING_FRAME_COUNTER'    : 0x0002,\
1085     'EMBER_KEY_HAS_INCOMING_FRAME_COUNTER'    : 0x0004,\
1086     'EMBER_KEY_HAS_PARTNER_EUI64'             : 0x0008,\
1087 }
1088 ember_key_structure_bitmask_rev = {}
1089 for tid,num in ember_key_structure_bitmask.items():
1090     ember_key_structure_bitmask_rev[num] = tid
1091
1092
1093 # EmberDeviceUpdate
1094 EMBER_STANDARD_SECURITY_SECURED_REJOIN  = 0x0
1095 EMBER_STANDARD_SECURITY_UNSECURED_JOIN  = 0x1
1096 EMBER_DEVICE_LEFT                       = 0x2
1097 EMBER_STANDARD_SECURITY_UNSECURED_REJOIN = 0x3
1098 EMBER_HIGH_SECURITY_SECURED_REJOIN      = 0x4
1099 EMBER_HIGH_SECURITY_UNSECURED_JOIN      = 0x5
1100 EMBER_HIGH_SECURITY_UNSECURED_REJOIN    = 0x7
1101 ember_device_update = {\
1102     'EMBER_STANDARD_SECURITY_SECURED_REJOIN'  : 0x0,\
1103     'EMBER_STANDARD_SECURITY_UNSECURED_JOIN'  : 0x1,\
1104     'EMBER_DEVICE_LEFT'                       : 0x2,\
1105     'EMBER_STANDARD_SECURITY_UNSECURED_REJOIN' : 0x3,\
1106     'EMBER_HIGH_SECURITY_SECURED_REJOIN'      : 0x4,\
1107     'EMBER_HIGH_SECURITY_UNSECURED_JOIN'      : 0x5,\
1108     'EMBER_HIGH_SECURITY_UNSECURED_REJOIN'    : 0x7,\
1109 }
1110 ember_device_update_rev = {}
1111 for tid,num in ember_device_update.items():
1112     ember_device_update_rev[num] = tid
1113
1114
1115 # EmberKeyStatus
1116 EMBER_APP_LINK_KEY_ESTABLISHED          = 0x01
1117 EMBER_APP_MASTER_KEY_ESTABLISHED        = 0x02
1118 EMBER_TRUST_CENTER_LINK_KEY_ESTABLISHED = 0x03
1119 EMBER_KEY_ESTABLISHMENT_TIMEOUT         = 0x04
1120 EMBER_KEY_TABLE_FULL                    = 0x05
1121 EMBER_TC_RESPONDED_TO_KEY_REQUEST       = 0x06
1122 EMBER_TC_APP_KEY_SENT_TO_REQUESTER      = 0x07
1123 EMBER_TC_RESPONSE_TO_KEY_REQUEST_FAILED = 0x08
1124 EMBER_TC_REQUEST_KEY_TYPE_NOT_SUPPORTED = 0x09
1125 EMBER_TC_NO_LINK_KEY_FOR_REQUESTER      = 0x0A
1126 EMBER_TC_REQUESTER_EUI64_UNKNOWN        = 0x0B
1127 EMBER_TC_RECEIVED_FIRST_APP_KEY_REQUEST = 0x0C
1128 EMBER_TC_TIMEOUT_WAITING_FOR_SECOND_APP_KEY_REQUEST = 0x0D
1129 EMBER_TC_NON_MATCHING_APP_KEY_REQUEST_RECEIVED = 0x0E
1130 EMBER_TC_FAILED_TO_SEND_APP_KEYS        = 0x0F
1131 EMBER_TC_FAILED_TO_STORE_APP_KEY_REQUEST = 0x10
1132 EMBER_TC_REJECTED_APP_KEY_REQUEST       = 0x11
1133 ember_key_status = {\
1134     'EMBER_APP_LINK_KEY_ESTABLISHED'          : 0x01,\
1135     'EMBER_APP_MASTER_KEY_ESTABLISHED'        : 0x02,\
1136     'EMBER_TRUST_CENTER_LINK_KEY_ESTABLISHED' : 0x03,\
1137     'EMBER_KEY_ESTABLISHMENT_TIMEOUT'         : 0x04,\
1138     'EMBER_KEY_TABLE_FULL'                    : 0x05,\
1139     'EMBER_TC_RESPONDED_TO_KEY_REQUEST'       : 0x06,\
1140     'EMBER_TC_APP_KEY_SENT_TO_REQUESTER'      : 0x07,\
1141     'EMBER_TC_RESPONSE_TO_KEY_REQUEST_FAILED' : 0x08,\
1142     'EMBER_TC_REQUEST_KEY_TYPE_NOT_SUPPORTED' : 0x09,\
1143     'EMBER_TC_NO_LINK_KEY_FOR_REQUESTER'      : 0x0A,\
1144     'EMBER_TC_REQUESTER_EUI64_UNKNOWN'        : 0x0B,\
1145     'EMBER_TC_RECEIVED_FIRST_APP_KEY_REQUEST' : 0x0C,\
1146     'EMBER_TC_TIMEOUT_WAITING_FOR_SECOND_APP_KEY_REQUEST' : 0x0D,\
1147     'EMBER_TC_NON_MATCHING_APP_KEY_REQUEST_RECEIVED' : 0x0E,\
1148     'EMBER_TC_FAILED_TO_SEND_APP_KEYS'        : 0x0F,\
1149     'EMBER_TC_FAILED_TO_STORE_APP_KEY_REQUEST' : 0x10,\
1150     'EMBER_TC_REJECTED_APP_KEY_REQUEST'       : 0x11,\
1151 }
1152 ember_key_status_rev = {}
1153 for tid,num in ember_key_status.items():
1154     ember_key_status_rev[num] = tid
1155
1156 #############################
1157