forked from YoyodyneMonkeyWorks/DuinoZigBeeAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZigBee.h
165 lines (123 loc) · 5.06 KB
/
ZigBee.h
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef ZigBee_h
#define ZigBee_h
#include <Arduino.h>
#include <ZigBeeAPI.h>
#include <SoftwareSerial.h>
#define cluster_Basic 0x0000
#define cluster_PowerConfiguration 0x0001
#define cluster_DeviceTemperature 0x0002
#define cluster_Identity 0x0003
#define cluster_Groups 0x0004
#define cluster_Scenes 0x0005
#define cluster_OnOff 0x0006
#define cluster_OnOffConfiguration 0x0007
#define cluster_LevelControl 0x0008
#define cluster_Alarms 0x0009
#define cluster_Time 0x000a
#define cluster_RSSI 0x000b
#define cluster_IOValue 0x000c
#define cluster_PowerProfile 0x001a
#define cluster_PollControl 0x0020
#define cluster_ShadeConfiguration 0x0100
#define cluster_DoorLock 0x0101
#define cluster_WindowCovering 0x0102
#define cluster_ColorControl 0x0300
#define cluster_BallastConfiguration 0x0301
#define cluster_IlluminanceMeasurement 0x0400
#define cluster_IlluminanceLevelSensing 0x0401
#define cluster_Temperature 0x0402
#define cluster_Pressure 0x0403
#define cluster_FlowMeasurement 0x0404
#define cluster_RelativeHumidity 0x0405
#define cluster_OccupancySensing 0x0406
#define cluster_IASZone 0x0500
#define cluster_IASACE 0x0501
#define cluster_IASWD 0x0502
#define cluster_ElectricalMeasurement 0x0b04
#define cluster_Diagnostics 0x0b05
extern uint16_t Light_Update_Interval;
extern volatile byte clstr_LevelControl_Command;
extern volatile float clstr_LevelControl_CurrentLevel;
extern volatile byte clstr_LevelControl_Level;
extern volatile unsigned int clstr_LevelControl_RemainingTime;
extern volatile float clstr_LevelControl_Gradient;
extern volatile byte clstr_ColorControl_ColourMode;
extern volatile uint16_t clstr_ColorControl_A_RemainingTime;
extern volatile float clstr_ColorControl_A_Current;
extern volatile uint16_t clstr_ColorControl_A;
extern volatile float clstr_ColorControl_A_Gradient;
extern volatile uint16_t clstr_ColorControl_B_RemainingTime;
extern volatile float clstr_ColorControl_B_Current;
extern volatile uint16_t clstr_ColorControl_B;
extern volatile float clstr_ColorControl_B_Gradient;
//extern float clstr_ColorControl_B_Current;
struct EndpointCluster {
byte endpoint;
unsigned int cluster;
};
extern const char Model[] PROGMEM;
extern const char Manufacturer[] PROGMEM;
extern const char SWVersion[] PROGMEM;
const byte ClusterListSize = 40;
const byte BufferSize = 75;
extern byte Buffer[BufferSize];
extern word LclNet;
extern unsigned long LclIeeeLo, LclIeeeHi;
extern unsigned long now;
// Utility functions
bool pinState(byte pin);
void printByteData(uint8_t Byte);
//void PrintHex(int data, int length);
void formatDate(char const *date, char const *tm, char *buff);
// XBee, Network and Reset management
void setup_ZigBee(Stream& port, byte _endpointClusterCount, bool _BatteryPowered);
void loop_ZigBee();
void ConfigureXBee(Stream& port);
void XBeeAwakeChange();
void sleepNow();
void ResetNetwork();
void LeaveNetwork();
void resetXB();
void Tx_Device_annce();
byte GetJoinStatus();
void JoinNetwork();
void SetupAddresses();
void WakeXBee(bool force);
float Get_XBeeTemp();
// Inbound packet processing
int CheckInboundPackets(bool extendedTimeout);
void ProcessInboundPacket(int rxResult);
// ZigBee Device Objects commands
void ZDOpkt();
void Simple_Desc_req();
void Active_EP_req();
int get_EndPointList(char *list);
int get_ClustersForEndPoint(byte endPoint, unsigned int *list);
// Zigbee Cluster Library commands
void ZCLpkt();
void clstr_DeviceTemperature(byte endPoint, byte frmType, byte seqNum, byte cmdID, uint16_t attributeID) __attribute__((weak));
bool get_OnOff(byte endPoint) __attribute__((weak));
void set_OnOff(byte endPoint, bool On) __attribute__((weak));
bool toggle_OnOff(byte endPoint) __attribute__((weak));
void clstr_ColorControl(byte endPoint, byte frmType, byte seqNum, byte cmdID, word attributeID);
float get_Temperature(byte endPoint) __attribute__((weak));
float get_Pressure(byte endPoint) __attribute__((weak));
float get_Humidity(byte endPoint) __attribute__((weak));
void Send10Response(bool Value, int attribute, byte seqNum);
void Send19Response(unsigned int Value, int attribute, byte seqNum);
void Send20Response(byte Value, int attribute, byte seqNum);
void Send21Response(unsigned int Value, int attribute, byte seqNum);
void Send29Response(int Value, int attribute, byte seqNum);
void Send30Response(int Value, int attribute, byte seqNum);
void Send42Response(char * Value, int attribute, byte seqNum);
void sendDefaultResponse(byte CmdID, byte Status, byte EndPoint);
void SendOnOffReport(byte endPoint, boolean Value);
void SendTemperatureReport(byte endPoint, float Value);
void SendPressureReport(byte endPoint, float Value);
void SendHumidityReport(byte endPoint, float Value);
void Send10Report(byte endPoint, int Value, int cluster, int attribute);
void Send21Report(byte endPoint, unsigned int Value, int cluster, int attribute);
void Send29Report(byte endPoint, int Value, int cluster, int attribute);
void clstr_ColorControlSetColour(byte endPoint, byte ColourMode, float hue, float saturation, float level) __attribute__((weak));
int PollSensors();
#endif