Reply To: XML Socket API questions 2017-12-21T22:52:48+00:00

HOME Forums Gateways Raspberry Pi XML Socket API questions Reply To: XML Socket API questions

Anonymous
Post count: 259

Hi,

When requesting information or sending commands you want to use the Node_ClusterCommand API. For getting information from a Zigbee temperature/humidity sensor we just have to fill up the API with the correct Endpoint, Cluster id and Payload value.

You may want to download the Zigbee Cluster Library and understand more about Endpoints, Commands, Clusters, Datatypes, Attribute ID’s etc.

We also have a lower level API called ZBPCID_API for messages between the ZBPServer and the Zigbee Radio

Here’s an example for the ZBHT-2:

//Read Attribute for Humidity
………………………………………..

ZBP_Node
Node_ClusterCommand

130 //u8Mode
16491 //u16DestAdd
10 //u8DestEP
1029 //u16ClusterID. (0x0405 == Relative Humidity Measurement)
0 //u8Command. (Command for Read Atrributes = 0)
[1,0,0] //Payload. [Number of Attributes, Attibute ID byte 1, Attribute ID byte 2]

8922

………………………………………..

//Read Attribute for Temperature
………………………………………..

ZBP_Node
Node_ClusterCommand

146
16491
10
1026 //Cluster ID. (0x0402 == Temperature Measurement)
0
[1,0,0]

45533

………………………………………..

The Gateway will then respond with:
………………………………………..

ZBP_Node
Node_ClusterCommand

0 //Status byte (0=success, message sent to device),(2=Device not found)

39043

………………………………………..

If successful, the sensor will then send a response to the Gateway, which the Gateway formats as the Node_ClusterCmdRsp Signal:
………………………………………..

Node
Node_ClusterCmdRsp

b2 //u8Mode
406b //u16SrcAdd
a //u8SrcEP
402 //Cluster ID. (0x0402 == Temperature Measurement)
1 //u8CmdID. (Read Attributes Response = 0x01)
1 //Number of Attributes in Payload
[00,00,00,29,09,b1] //Payload explained below.

………………………………………..

………………………………………..

Node
Node_ClusterCmdRsp

b2
406b
a
405 //u16ClusterID. (0x0405 == Relative Humidity Measurement)
1
1
[00,00,00,21,11,45]

………………………………………..

Payload received is formatted as follows:
Array (list) of attribute records. Each record consists of:
u16AttribID – Attribute identifier
u8Status – Attribute read status (SUCCESS = 0)
u8DataType – Type of the attribute
AttribData – Attribute data (variable depending on type)
………………………………………..

For Humidity we received: [00,00,00,21,11,45]. Here’s how to derive the actual Humidity %
00,00 = 0x0000 MeasuredValue (Attribute of the Humidity Cluster)
21 = 0x21 DataType (Unsigned 16-bit integer)
11,45 = 0x1145 Data. Convert to Decimal and divide by 100. Humidity = 44.21%
………………………………………..
and for Temperature we received: [00,00,00,29,09,b1]
00,00 = 0x0000 MeasuredValue (Attribute of the Temperature Cluster)
29 = 0x29 DataType (Signed 16-bit integer)
09,b1 = 0x09b1 Data. Convert to Decimal and divide by 100 for Celsius. Temperature = 24.81 °C

Hope this helps. Thanks.