Maybe one day someone will use this;
**When sketch fails second push will work without gateway and it will restart
**
void loop()
{
gw.process();
debouncer.update();
value = debouncer.read();
if (value != oldValue && value==0) {
if (re!="1")
{
int oku=digitalRead(RELAY_PIN);
if(oku==1)
{
digitalWrite(RELAY_PIN,0);
}
else
{
digitalWrite(RELAY_PIN,1);
}
asm volatile (" jmp 0"); //reboot
}
gw.send(msg.set(state?false:true),true); // Send new state and request ack back
re="";
}
oldValue = value;
}
void incomingMessage(const MyMessage &message) {
state = message.getBool();
digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
gw.saveState(CHILD_ID, state);
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
re=String(message.sensor);
}