@@ -31,9 +31,9 @@ extern "C" {
31
31
#define DEBUG_PRINT 0
32
32
33
33
// ****************
34
+ time_t getNtpTime ();
34
35
void callback (char * intopic, byte* inpayload, unsigned int length);
35
36
String macToStr (const uint8_t * mac);
36
- time_t getNtpTime ();
37
37
void run_lightcmd ();
38
38
void changelight ();
39
39
void sendmqttMsg (char * topictosend, String payload);
@@ -42,7 +42,6 @@ void getdalastemp();
42
42
void getdht22temp ();
43
43
void sendNTPpacket (IPAddress & address);
44
44
45
-
46
45
// ****************
47
46
const char * ssid = WIFI_SSID;
48
47
const char * password = WIFI_PASSWORD;
@@ -132,9 +131,10 @@ int pirSent ;
132
131
int oldpirValue ;
133
132
134
133
/*
135
- volatile int relaystatus = LOW;
136
- volatile int oldrelaystatus = LOW;
134
+ volatile int relaystatus = LOW;
135
+ volatile int oldrelaystatus = LOW;
137
136
*/
137
+
138
138
volatile int relaystatus = LOW;
139
139
int oldrelaystatus = LOW;
140
140
@@ -369,7 +369,6 @@ void setup()
369
369
// Hostname defaults to esp8266-[ChipID]
370
370
ArduinoOTA.setHostname (" esp-swtemp" );
371
371
372
-
373
372
// No authentication by default
374
373
ArduinoOTA.setPassword (otapassword);
375
374
@@ -384,12 +383,12 @@ void setup()
384
383
});
385
384
ArduinoOTA.onError ([](ota_error_t error) {
386
385
// ESP.restart();
387
- if (error == OTA_AUTH_ERROR) abort ();
388
- else if (error == OTA_BEGIN_ERROR) abort ();
389
- else if (error == OTA_CONNECT_ERROR) abort ();
390
- else if (error == OTA_RECEIVE_ERROR) abort ();
391
- else if (error == OTA_END_ERROR) abort ();
392
-
386
+ if (error == OTA_AUTH_ERROR) abort ();
387
+ else if (error == OTA_BEGIN_ERROR) abort ();
388
+ else if (error == OTA_CONNECT_ERROR) abort ();
389
+ else if (error == OTA_RECEIVE_ERROR) abort ();
390
+ else if (error == OTA_END_ERROR) abort ();
391
+
393
392
});
394
393
395
394
ArduinoOTA.begin ();
@@ -544,7 +543,6 @@ void loop()
544
543
Serial.println (sensor_data.devid );
545
544
}
546
545
547
-
548
546
String radiopayload = " {\" _salt\" :" ;
549
547
radiopayload += sensor_data._salt ;
550
548
radiopayload += " ,\" volt\" :" ;
@@ -557,7 +555,7 @@ void loop()
557
555
radiopayload += sensor_data.devid ;
558
556
radiopayload += " }" ;
559
557
560
- if ( (sensor_data.devid > 0 ) && (sensor_data.devid < 255 ) )
558
+ if ( (sensor_data.devid > 0 ) && (sensor_data.devid < 255 ) )
561
559
{
562
560
String newRadiotopic = radiotopic;
563
561
newRadiotopic += " /" ;
@@ -595,7 +593,6 @@ void runTimerDoLightOff()
595
593
596
594
void changelight ()
597
595
{
598
-
599
596
if (DEBUG_PRINT) {
600
597
Serial.print (" => " );
601
598
Serial.print (" checking relay status changelight --> " );
@@ -682,29 +679,30 @@ void sendmqttMsg(char* topictosend, String payload)
682
679
683
680
void run_lightcmd ()
684
681
{
685
- int topbuttonstatus = ! digitalRead (TOPBUTTONPIN);
682
+ // int topbuttonstatus = ! digitalRead(TOPBUTTONPIN);
686
683
if ( relayIsReady == HIGH ) {
687
- relaystatus = topbuttonstatus ;
684
+ // relaystatus = topbuttonstatus ;
685
+ relaystatus = !relaystatus;
688
686
}
689
687
if (DEBUG_PRINT && ( relayIsReady == HIGH )) {
690
- Serial.print (" run_lightcmd => topbuttonstatus => " );
691
- Serial.print (topbuttonstatus);
688
+ // Serial.print("run_lightcmd => topbuttonstatus => ");
689
+ // Serial.print(topbuttonstatus);
692
690
Serial.print (" => relaystatus => " );
693
691
Serial.println (relaystatus);
694
692
}
695
693
}
696
694
697
695
// pin 16 can't be used for Interrupts
698
696
/*
699
- void motion_detection()
700
- {
697
+ void motion_detection()
698
+ {
701
699
if (DEBUG_PRINT) {
702
700
Serial.println("motion_detection called");
703
701
}
704
702
//pirValue =
705
703
pirValue = digitalRead(pir);
706
704
pirSent = HIGH ;
707
- }
705
+ }
708
706
*/
709
707
710
708
String macToStr (const uint8_t * mac)
0 commit comments