@@ -70,6 +70,7 @@ ZigbeeSwitch zbSwitch = ZigbeeSwitch(SWITCH_ENDPOINT_NUMBER);
70
70
static void onZbButton (SwitchData *button_func_pair) {
71
71
if (button_func_pair->func == SWITCH_ONOFF_TOGGLE_CONTROL) {
72
72
// Send toggle command to the light
73
+ Serial.println (" Toggling light" );
73
74
zbSwitch.lightToggle ();
74
75
}
75
76
}
@@ -93,7 +94,6 @@ static void enableGpioInterrupt(bool enabled) {
93
94
94
95
/* ******************** Arduino functions **************************/
95
96
void setup () {
96
-
97
97
Serial.begin (115200 );
98
98
while (!Serial) {
99
99
delay (10 );
@@ -106,7 +106,7 @@ void setup() {
106
106
zbSwitch.allowMultipleBinding (true );
107
107
108
108
// Add endpoint to Zigbee Core
109
- log_d (" Adding ZigbeeSwitch endpoint to Zigbee Core" );
109
+ Serial. println (" Adding ZigbeeSwitch endpoint to Zigbee Core" );
110
110
Zigbee.addEndpoint (&zbSwitch);
111
111
112
112
// Open network for 180 seconds after boot
@@ -118,19 +118,22 @@ void setup() {
118
118
/* create a queue to handle gpio event from isr */
119
119
gpio_evt_queue = xQueueCreate (10 , sizeof (SwitchData));
120
120
if (gpio_evt_queue == 0 ) {
121
- log_e (" Queue was not created and must not be used " );
122
- while ( 1 );
121
+ Serial. println (" Queue creating failed, rebooting... " );
122
+ ESP. restart ( );
123
123
}
124
124
attachInterruptArg (buttonFunctionPair[i].pin , onGpioInterrupt, (void *)(buttonFunctionPair + i), FALLING);
125
125
}
126
126
127
127
// When all EPs are registered, start Zigbee with ZIGBEE_COORDINATOR mode
128
- log_d (" Calling Zigbee.begin()" );
129
- Zigbee.begin (ZIGBEE_COORDINATOR);
128
+ if (!Zigbee.begin (ZIGBEE_COORDINATOR)) {
129
+ Serial.println (" Zigbee failed to start!" );
130
+ Serial.println (" Rebooting..." );
131
+ ESP.restart ();
132
+ }
130
133
131
134
Serial.println (" Waiting for Light to bound to the switch" );
132
135
// Wait for switch to bound to a light:
133
- while (!zbSwitch.isBound ()) {
136
+ while (!zbSwitch.bound ()) {
134
137
Serial.printf (" ." );
135
138
delay (500 );
136
139
}
0 commit comments