File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 39
39
40
40
#define uS_TO_S_FACTOR 1000000ULL /* Conversion factor for micro seconds to seconds */
41
41
#define TIME_TO_SLEEP 55 /* Sleep for 55s will + 5s delay for establishing connection => data reported every 1 minute */
42
- #define REPORT_TIMEOUT 30000 /* Timeout for reporting data in ms */
42
+ #define REPORT_TIMEOUT 1000 /* Timeout for response from coordinator in ms */
43
43
44
44
uint8_t button = BOOT_PIN;
45
45
@@ -93,17 +93,22 @@ static void meausureAndSleep(void *arg) {
93
93
const unsigned long timeout = REPORT_TIMEOUT;
94
94
95
95
Serial.printf (" Waiting for data report to be confirmed \r\n " );
96
- // Wait until data was succesfully sent
97
- while (dataToSend != 0 ) {
96
+ // Wait until data was successfully sent
97
+ int tries = 0 ;
98
+ const int maxTries = 3 ;
99
+ while (dataToSend != 0 && tries < maxTries) {
98
100
if (resend) {
99
101
Serial.println (" Resending data on failure!" );
100
102
resend = false ;
101
103
dataToSend = 2 ;
102
104
zbTempSensor.report (); // report again
103
105
}
104
106
if (millis () - startTime >= timeout) {
105
- Serial.println (" Report timeout!" );
106
- break ;
107
+ Serial.println (" \n Report timeout! Report Again" );
108
+ dataToSend = 2 ;
109
+ zbTempSensor.report (); // report again
110
+ startTime = millis ();
111
+ tries++;
107
112
}
108
113
Serial.printf (" ." );
109
114
delay (50 ); // 50ms delay to avoid busy-waiting
You can’t perform that action at this time.
0 commit comments