Enable Remote Calibration
This commit is contained in:
parent
36963daac6
commit
ac60546eab
2 changed files with 27 additions and 10 deletions
|
@ -52,7 +52,7 @@ uint8_t SENSAIRS8::getSensorData(char *payload, uint8_t startbyte) {
|
||||||
void SENSAIRS8::calibrate(void) {
|
void SENSAIRS8::calibrate(void) {
|
||||||
pinMode(calpin, OUTPUT);
|
pinMode(calpin, OUTPUT);
|
||||||
digitalWrite(calpin, LOW);
|
digitalWrite(calpin, LOW);
|
||||||
delay(5000);
|
delay(6000);
|
||||||
digitalWrite(calpin, HIGH);
|
digitalWrite(calpin, HIGH);
|
||||||
pinMode(calpin, INPUT_PULLUP);
|
pinMode(calpin, INPUT_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
35
src/main.cpp
35
src/main.cpp
|
@ -157,15 +157,32 @@ void onEvent(ev_t ev) {
|
||||||
// Check for Downlink
|
// Check for Downlink
|
||||||
DEBUG_PRINTLN("LoRa Packet Sent");
|
DEBUG_PRINTLN("LoRa Packet Sent");
|
||||||
WS2812B_BLINK(1,0,127,0,1000);
|
WS2812B_BLINK(1,0,127,0,1000);
|
||||||
if ((int)LMIC.dataLen == 2) {
|
if ((int)LMIC.dataLen > 0) {
|
||||||
// We got a Packet with the right size - lets assemble it into a uint16_t
|
// Check for Downlinks
|
||||||
DEBUG_PRINTLN("Received Downlink")
|
// Function based in Ports:
|
||||||
uint16_t tmpslp = (LMIC.frame[LMIC.dataBeg] << 8) | LMIC.frame[LMIC.dataBeg+1];
|
// Port 1
|
||||||
DEBUG_PRINT("Setting Sleep Time to: ");
|
// Set Sending Interval
|
||||||
DEBUG_PRINTLN(tmpslp);
|
// Port 2
|
||||||
sleep_time = tmpslp;
|
// Do Calibration
|
||||||
EEPROM.put(ADDR_SLP, tmpslp);
|
switch((uint8_t)LMIC.frame[LMIC.dataBeg-1]) {
|
||||||
WS2812B_BLINK(1,0,0,127,250);
|
case 1:
|
||||||
|
if ((int)LMIC.dataLen == 2) {
|
||||||
|
// We got a Packet with the right size - lets assemble it into a uint16_t
|
||||||
|
DEBUG_PRINTLN("Received Downlink")
|
||||||
|
uint16_t tmpslp = (LMIC.frame[LMIC.dataBeg] << 8) | LMIC.frame[LMIC.dataBeg+1];
|
||||||
|
DEBUG_PRINT("Setting Sleep Time to: ");
|
||||||
|
DEBUG_PRINTLN(tmpslp);
|
||||||
|
sleep_time = tmpslp;
|
||||||
|
EEPROM.put(ADDR_SLP, tmpslp);
|
||||||
|
WS2812B_BLINK(1,0,0,127,250);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
for (uint8_t i=0; i<NUM_SENSORS; i++)
|
||||||
|
sensors[i]->calibrate();
|
||||||
|
BLINK_LED(3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Got to sleep for specified Time
|
// Got to sleep for specified Time
|
||||||
|
|
Loading…
Reference in a new issue