32
32
33
33
#include " Zigbee.h"
34
34
35
- /* Zigbee OTA configuration */
36
-
37
- #define OTA_UPGRADE_RUNNING_FILE_VERSION 0x01010100 // Increment this value when the running image is updated
38
- #define OTA_UPGRADE_DOWNLOADED_FILE_VERSION 0x01010101 // Increment this value when the downloaded image is updated
39
- #define OTA_UPGRADE_HW_VERSION 0x0101 // The hardware version, this can be used to differentiate between different hardware versions
40
-
41
35
#define USE_GLOBAL_ON_RESPONSE_CALLBACK 1 // Set to 0 to use local callback specified directly for the endpoint.
42
36
43
37
/* Zigbee temperature + humidity sensor configuration */
@@ -51,7 +45,6 @@ uint8_t button = BOOT_PIN;
51
45
52
46
ZigbeeTempSensor zbTempSensor = ZigbeeTempSensor(TEMP_SENSOR_ENDPOINT_NUMBER);
53
47
54
- volatile bool otaInhibitSleep = false ;
55
48
uint8_t dataToSend = 2 ; // Temperature and humidity values are reported in same endpoint, so 2 values are reported
56
49
bool resend = false ;
57
50
@@ -80,15 +73,6 @@ void onResponse(zb_cmd_type_t command, esp_zb_zcl_status_t status) {
80
73
}
81
74
#endif
82
75
83
- void otaSleepInhibitCallback (bool otaActive) {
84
- otaInhibitSleep = otaActive;
85
- if (otaActive) {
86
- Serial.println (" OTA started: inhibiting sleep" );
87
- } else {
88
- Serial.println (" OTA finished: sleep allowed" );
89
- }
90
- }
91
-
92
76
/* *********************** Temp sensor *****************************/
93
77
static void meausureAndSleep (void *arg) {
94
78
// Measure temperature sensor value
@@ -131,10 +115,8 @@ static void meausureAndSleep(void *arg) {
131
115
}
132
116
133
117
// Put device to deep sleep after data was sent successfully or timeout
134
- if (!otaInhibitSleep) {
135
- Serial.println (" Going to sleep now" );
136
- esp_deep_sleep_start ();
137
- }
118
+ Serial.println (" Going to sleep now" );
119
+ esp_deep_sleep_start ();
138
120
}
139
121
140
122
/* ******************** Arduino functions **************************/
@@ -150,12 +132,6 @@ void setup() {
150
132
// Optional: set Zigbee device name and model
151
133
zbTempSensor.setManufacturerAndModel (" Espressif" , " SleepyZigbeeTempSensor" );
152
134
153
- // Optional: set ota
154
- zbTempSensor.addOTAClient (OTA_UPGRADE_RUNNING_FILE_VERSION, OTA_UPGRADE_DOWNLOADED_FILE_VERSION, OTA_UPGRADE_HW_VERSION);
155
-
156
- // Optional: Register callback for OTA state change (inhibit sleep during OTA)
157
- zbTempSensor.onOTAStateChange (otaSleepInhibitCallback);
158
-
159
135
// Set minimum and maximum temperature measurement value (10-50°C is default range for chip temperature measurement)
160
136
zbTempSensor.setMinMaxValue (10 , 50 );
161
137
@@ -204,9 +180,6 @@ void setup() {
204
180
Serial.println ();
205
181
Serial.println (" Successfully connected to Zigbee network" );
206
182
207
- // Start Zigbee OTA client query, first request is within a minute and the next requests are sent every hour automatically
208
- zbTempSensor.requestOTAUpdate ();
209
-
210
183
// Start Temperature sensor reading task
211
184
xTaskCreate (meausureAndSleep, " temp_sensor_update" , 2048 , NULL , 10 , NULL );
212
185
}
@@ -220,10 +193,6 @@ void loop() {
220
193
while (digitalRead (button) == LOW) {
221
194
delay (50 );
222
195
if ((millis () - startTime) > 10000 ) {
223
- if (otaInhibitSleep) {
224
- Serial.println (" OTA in progress, cannot reset now" );
225
- break ;
226
- }
227
196
// If key pressed for more than 10secs, factory reset Zigbee and reboot
228
197
Serial.println (" Resetting Zigbee to factory and rebooting in 1s." );
229
198
delay (1000 );
0 commit comments