Hello everyone,
So I have a Xbee S2 as a coordinator for working out messages and a digi gateway where all the work will end up. I can send basic messages and get Successful replies on both devices (xbee s2 and Digi Gateway) for example Network address request, Node Descriptor request, Simple descriptor request, Active Endpoints Request, however I am stuck on the Match Descriptor Response.
I want to receive state messages from a IAS zone device (Occupancy Sensor, Samsung).
The device periodically sends out a 0x0006 -> Match Descriptor Request.
7E 00 1B 91 28 6D 97 00 01 0A 02 3B DD A1 00 00 00 06 00 00 42 67 FD FF 04 01 01 19 00 00 B2
67 = Transaction Number
FDFF = Coordinator Address
0401 = 0x0104 - Home Automation Profile
01 = The number of input clusters in the In Cluster List for matching. = 1
1900 = 0x0019 Cluster ID
00 = number of output clusters, Zero.
I need to respond correctly to this however I am not sure how to do it correctly.
How do I respond correctly to this?
I am not a ZDO expert but what I can tell you is that generally you need to obtain a copy of the Zigbee spec for the device or standard you are working on. Then you should be able to look up the match descriptor function and see what your response needs to be.
I am using the Zigbee Spec.
TransNum|NWKAddrOfInterest|ProfileID|NumInClusters|InClusterList| NumOutClusters|OutClusterList
67|FDFF|04 01|01|1900|00
Which I read as TransNum = 0x67, Broadcast to non sleep device = FFFD, Profile = Home Automation (0x0104), Number of in clusters = 1, incluster list = 0x0019.
So the reply should be
TransNumber|Status|NWKAddrOfInterest|MatchLen|MtchEndPnt
08| 00| A1DD| 01 |01
However sensor sends back another 0x8006 - Match Desc Response.
TransNumber|Status|NWKAddrOfInterest|Match|LengthMatch
0C| 00| A1DD|0B | 0183
This I read as 11 matches (0x0B) however there are not 11 matches there is only 2 -> 01,83.
Thus, I feel this is a failed message because I can’t see where the ZDO Spec relates to this.
However the document states:
On receipt of the Match_Desc_rsp command, the recipient is either notified of the results of its match criterion query indicated in the original Match_Desc_req command or notified of an error. If the Match_Desc_rsp command is received with a Status of SUCCESS, the MatchList field shall contain the list of endpoints containing simple descriptors that matched the criterion. Otherwise, the Status field indicates the error and the MatchList field shall not be included."
Status = 0x00 -> SUCCESS!
0B | 0183 = What?
I am also new, possibly my understanding of the response is wrong, therefore I ask for help from those who know.
Ok so as it turns out it was the xbee s2 module.
I started python coding on my gateway. Using my gateway I only have to send a 0x0500 cluster command and the zone is connected and sending data when it detects motion or I open the door/window sensor (I brought one today). At the moment I think it is just sending an enrol request every time they detect a state change. However I am relieved to be off the ground.
Here is some basic code for anyone who stumbled across this and has an xbee/zigbee gateway.
It has no error handling but will give you an idea for IAS.
import sys, os
from zigbee import *
from socket import *
from time import sleep
counter = 0
maxcounter = 100
time = 0
maxtime = 5
def sendIt(destination, DestEndpoint, message, bufferLength, cluster):
if cluster == 0x0001: #Cluster 0x0001 response 0x8001 gets sent 2 times from the end device.
x = 2#2 #So we have to clear the buffer twice. May only be Motion sensor.
else: # Yes Only Motion sensor
x = 1
sd = socket(AF_ZIGBEE, SOCK_DGRAM, XBS_PROT_TRANSPORT)
sd.bind(("", DestEndpoint, 0, 0))
print "Sending"
sd.sendto(message, 0, destination)
for x in range(x):
payload, src_addr = sd.recvfrom(bufferLength)
print "Received"
print "src_addr: ", src_addr
print "len(payload): %d" % len(payload)
if ord(payload[1]) == 0:
print "SUCCESS!"
for index, byte in enumerate(payload):
print "payload[%d] = %s (%d)" % (index, hex(ord(byte)), ord(byte))
#sd.close()
sleep(2)
#Hang out here and listen for messages.
while True:
for x in range(1):
payload, src_addr = sd.recvfrom(bufferLength)
print "Received"
print "src_addr: ", src_addr
print "len(payload): %d" % len(payload)
if ord(payload[1]) == 0:
print "SUCCESS!"
for index, byte in enumerate(payload):
print "payload[%d] = %s (%d)" % (index, hex(ord(byte)), ord(byte))
#sd.close()
sleep(2)
print "
\rZoneIAScrap - "
Destination = ("28:6d:97:00:01:0a:02:3b!", 0x01, 0x0104, 0x0500)
sendIt(Destination, 0x01, "\x00"+"\x01"+"\x02"+"\x10\x00"+"\xf0"+"\x45\x73\x81\x41\x00\xa2\x13\x00", 100, 0x0500)