Last active
January 7, 2020 21:00
-
-
Save erikbuild/de1c732bada174e7be92e1a14f436886 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN]; // receive buffer | |
uint8_t data[] = " OK"; // I don't know what this is used for. | |
uint8_t len; | |
uint8_t from; | |
char equipmentoff[20] = F("AIRCOMPRESSOR:OFF"); | |
char equipmenton[20] = F("AIRCOMPRESSOR:ON"); | |
void loop() { | |
state = digitalRead(sensor); | |
if (state == HIGH) { | |
if (rf69_manager.sendtoWait((uint8_t *)equipmentoff, strlen(equipmentoff), DEST_ADDRESS)) { | |
// Now wait for a reply from the server | |
len = sizeof(buf); | |
if (rf69_manager.recvfromAckTimeout(buf, &len, 2000, &from)) { | |
buf[len] = 0; // zero out remaining string | |
Blink(LED, 40, 3); //blink LED 3 times, 40ms between blinks | |
} | |
} | |
} else { | |
if (rf69_manager.sendtoWait((uint8_t *)equipmenton, strlen(equipmenton), DEST_ADDRESS)) { | |
// Now wait for a reply from the server | |
len = sizeof(buf); | |
if (rf69_manager.recvfromAckTimeout(buf, &len, 2000, &from)) { | |
buf[len] = 0; // zero out remaining string | |
Blink(LED, 40, 3); //blink LED 3 times, 40ms between blinks | |
} | |
} | |
} | |
// Wait a second... | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment