updating gen file for generic app functions

pull/1/head
nathan wagner 3 years ago
parent 00d835d673
commit 5724969696

@ -0,0 +1,38 @@
def attribute_result(kwargs):
attr_list = kwargs['attributes']
return_array=''
for i in attr_list:
if i == 0: #zcl version default 0x2
return_array = b'\x00\x00'
return_array = return_array+b'\x00\x20\x03'
if i == 1: #Application Version, gonna be \x01 didn't make it 0 didn't make it
return_array = b'\x01\x00'
return_array = return_array+b'\x00\x20\x01'
if i == 2: #stack version
return_array = b'\x02\x00'
return_array = return_array+b'\x00\x20\x03'
if i == 3: #hardware version
return_array = b'\x03\x00'
return_array = return_array+b'\x00\x20\x01'
if i == 4: #manufacturer name
return_array = b'\x04\x00'
return_array = return_array+b'\x00\x42\x0B\x44\x69\x67\x69\x20\x4e\x61\x74\x68\x61\x6e'
if i == 5: #model identifier this is used for z2m tie
return_array = b'\x05\x00'
return_array = return_array+b'\x00\x42\x0F\x44\x69\x67\x69\x20\x47\x61\x72\x61\x67\x65\x44\x6f\x6f\x72'
if i == 6: # dateCode
return_array = b'\x06\x00'
return_array = return_array + b'\x00\x42\x08\x32\x30\x32\x31\x30\x36\x31\x35'
if i == 7: #power source did make it
return_array=b'\x07\x00'
return_array = return_array + b'\x00\x30\x04'
if i == 17: #physical environment
return_array=b'\x11\x00'
return_array = return_array + b'\x00\x30\x19'
if i == 16384: #swbuildID , gonna be E didn't make it 24 didn't make it
return_array = b'\x00\x40'
return_array = return_array+b'\x00\x42\x01\x45'
return return_array

@ -7,7 +7,7 @@ import spec
import ubinascii
from machine import I2C
from machine import Pin
from machine import Timer
import gen
import struct
# print(" +-------------------------------------+")
@ -62,7 +62,6 @@ lame = 0
# send=1
send=0
time.sleep(1)
def fancy_transmit(payload, source_ep, dest_ep, cluster,profile):
send = 0
while send==0:
@ -81,7 +80,7 @@ fancy_transmit( payload=initial_payload, source_ep=0, dest_ep=0, cluster=19,prof
print("receiving")
diff = 3600000
first_report = False
timestamp = time.tick_ms()
timestamp = time.ticks_ms()
while 1 != 0:
blorp = xbee.receive()
if blorp is not None:
@ -89,6 +88,9 @@ while 1 != 0:
if blorp['cluster'] == 6: #genOnOffCluster in HA Profile
if blorp['profile'] == 260: #HA profile
cluster_name, seq, CommandType, command_name, disable_default_response, kwargs = spec.decode_zcl(blorp['cluster'], blorp['payload'])
print(CommandType)
print(command_name)
print(kwargs)
if 'command' in kwargs:
if kwargs['commands'][0] == 0:
ad4.value(1)
@ -124,7 +126,7 @@ while 1 != 0:
print(command_name)
print(kwargs)
if 'attributes' in kwargs:
attr_bytes=spec.attribute_result(kwargs)
attr_bytes=gen.attribute_result(kwargs)
#payload: control byte, code bytes(2), seq copy, command identifier(read_attributes_response,
#payload = bytes([4, 30, 16, seq, 1, attr_bytes, 0, 8, 0])
payload = bytes([12, 30, 16, seq, 1])
@ -151,12 +153,12 @@ while 1 != 0:
print("Node descriptor response integer payload discard")
#for key, value in blorp.items():
#1 print (key, ' : ', value)
if (diff < time.diff(time.ticks_ms() - timestamp)) or ( not first_report ) :
if (diff < time.ticks_diff(time.ticks_ms(), timestamp)) or ( not first_report ) :
timestamp = time.ticks_ms()
first_report = True
zcl_head = bytes([12, 30, 16, 171, 10])
payload = zcl_head + bytes([0,0,10,0]) #for now only return off for state report
fancy_transmit(payload=payload, source_ep=blorp[8], dest_ep=blorp[1], cluster=6, profile=260)
fancy_transmit(payload=payload, source_ep=8, dest_ep=1, cluster=6, profile=260)
#print(xbee.receive())

@ -797,39 +797,3 @@ def get_cluster_rx_command(cluster_name, command_name):
# }
def attribute_result(kwargs):
attr_list = kwargs['attributes']
return_array=''
for i in attr_list:
if i == 0: #zcl version default 0x2
return_array = b'\x00\x00'
return_array = return_array+b'\x00\x20\x03'
if i == 1: #Application Version, gonna be \x01 didn't make it 0 didn't make it
return_array = b'\x01\x00'
return_array = return_array+b'\x00\x20\x01'
if i == 2: #stack version
return_array = b'\x02\x00'
return_array = return_array+b'\x00\x20\x03'
if i == 3: #hardware version
return_array = b'\x03\x00'
return_array = return_array+b'\x00\x20\x01'
if i == 4: #manufacturer name
return_array = b'\x04\x00'
return_array = return_array+b'\x00\x42\x0B\x44\x69\x67\x69\x20\x4e\x61\x74\x68\x61\x46'
if i == 5: #model identifier this is used for z2m tie
return_array = b'\x05\x00'
return_array = return_array+b'\x00\x42\x0F\x44\x69\x67\x69\x20\x47\x61\x72\x61\x67\x65\x44\x6f\x6f\x72'
if i == 6: # dateCode
return_array = b'\x06\x00'
return_array = return_array + b'\x00\x42\x08\x32\x30\x32\x31\x30\x36\x31\x35'
if i == 7: #power source did make it
return_array=b'\x07\x00'
return_array = return_array + b'\x00\x30\x04'
if i == 17: #physical environment
return_array=b'\x11\x00'
return_array = return_array + b'\x00\x30\x19'
if i == 16384: #swbuildID , gonna be E didn't make it 24 didn't make it
return_array = b'\x00\x40'
return_array = return_array+b'\x00\x42\x01\x45'
return return_array
Loading…
Cancel
Save