mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-08 13:10:29 +00:00
housekeeping
This commit is contained in:
parent
8349097bdf
commit
2dbbdbbf8e
@ -3,8 +3,8 @@
|
||||
// GATEWAY 2.000 Configuration
|
||||
|
||||
#include <fdrs_globals.h>
|
||||
#define FDRS_DEBUG //Enable USB-Serial debugging
|
||||
#define DEBUG_CONFIG // Displays full config info on startup
|
||||
//#define FDRS_DEBUG //Enable USB-Serial debugging
|
||||
//#define DEBUG_CONFIG // Displays full config info on startup
|
||||
|
||||
#define UNIT_MAC 0x01 // The address of this gateway
|
||||
|
||||
|
@ -8,15 +8,15 @@
|
||||
#include "fdrs_sensor_config.h"
|
||||
#include <fdrs_node.h>
|
||||
|
||||
#define CONTROL_1 133 //Address for controller 1
|
||||
#define CONTROL_2 134 //Address for controller 2
|
||||
#define CONTROL_3 135 //Address for controller 3
|
||||
#define CONTROL_4 136 //Address for controller 4
|
||||
#define CONTROL_1 101 //Address for controller 1
|
||||
#define CONTROL_2 102 //Address for controller 2
|
||||
#define CONTROL_3 103 //Address for controller 3
|
||||
#define CONTROL_4 104 //Address for controller 4
|
||||
|
||||
#define COIL_1 5 //Coil Pin 1
|
||||
#define COIL_2 4 //Coil Pin 2
|
||||
#define COIL_3 4 //Coil Pin 3
|
||||
#define COIL_4 4 //Coil Pin 4
|
||||
#define COIL_1 12 //Coil Pin 1
|
||||
#define COIL_2 13 //Coil Pin 2
|
||||
#define COIL_3 14 //Coil Pin 3
|
||||
#define COIL_4 5 //Coil Pin 4
|
||||
|
||||
int status_1 = 0;
|
||||
int status_2 = 0;
|
||||
@ -26,6 +26,7 @@ int status_4 = 0;
|
||||
bool newData = false;
|
||||
|
||||
void fdrs_recv_cb(DataReading theData) {
|
||||
DBG(String(theData.id));
|
||||
switch (theData.id) {
|
||||
case CONTROL_1:
|
||||
status_1 = (int)theData.d;
|
||||
@ -47,24 +48,24 @@ void fdrs_recv_cb(DataReading theData) {
|
||||
}
|
||||
void updateCoils() {
|
||||
if (status_1) {
|
||||
digitalWrite(COIL_1, HIGH);
|
||||
} else {
|
||||
digitalWrite(COIL_1, LOW);
|
||||
} else {
|
||||
digitalWrite(COIL_1, HIGH);
|
||||
}
|
||||
if (status_2) {
|
||||
digitalWrite(COIL_2, HIGH);
|
||||
} else {
|
||||
digitalWrite(COIL_2, LOW);
|
||||
} else {
|
||||
digitalWrite(COIL_2, HIGH);
|
||||
}
|
||||
if (status_3) {
|
||||
digitalWrite(COIL_3, HIGH);
|
||||
} else {
|
||||
digitalWrite(COIL_3, LOW);
|
||||
} else {
|
||||
digitalWrite(COIL_3, HIGH);
|
||||
}
|
||||
if (status_4) {
|
||||
digitalWrite(COIL_4, HIGH);
|
||||
} else {
|
||||
digitalWrite(COIL_4, LOW);
|
||||
} else {
|
||||
digitalWrite(COIL_4, HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,13 +80,13 @@ void setup() {
|
||||
DBG("Not Connected");
|
||||
}
|
||||
pinMode(COIL_1, OUTPUT);
|
||||
digitalWrite(COIL_1, LOW);
|
||||
digitalWrite(COIL_1, HIGH);
|
||||
pinMode(COIL_2, OUTPUT);
|
||||
digitalWrite(COIL_2, LOW);
|
||||
digitalWrite(COIL_2, HIGH);
|
||||
pinMode(COIL_3, OUTPUT);
|
||||
digitalWrite(COIL_3, LOW);
|
||||
digitalWrite(COIL_3, HIGH);
|
||||
pinMode(COIL_4, OUTPUT);
|
||||
digitalWrite(COIL_4, LOW);
|
||||
digitalWrite(COIL_4, HIGH);
|
||||
|
||||
DBG("FARM DATA RELAY SYSTEM :: Irrigation Module");
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// "fdrs_sensor.h"
|
||||
// "fdrs_node.h"
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA.
|
||||
//
|
||||
@ -363,10 +363,11 @@ bool transmitLoRa(uint16_t* destMAC, DataReading * packet, uint8_t len) {
|
||||
#ifdef LORA_ACK // Wait for ACK
|
||||
int retries = LORA_RETRIES + 1;
|
||||
while (retries != 0) {
|
||||
if (transmitLoRaMsg != 0)
|
||||
if (transmitLoRaMsg != 0){
|
||||
DBG("Transmitting LoRa message of size " + String(sizeof(pkt)) + " bytes with CRC 0x" + String(calcCRC, 16) + " to gateway 0x" + String(*destMAC, 16) + ". Retries remaining: " + String(retries - 1) + ", CRC OK " + String((float)msgOkLoRa / transmitLoRaMsg * 100) + "%");
|
||||
else
|
||||
}else{
|
||||
DBG("Transmitting LoRa message of size " + String(sizeof(pkt)) + " bytes with CRC 0x" + String(calcCRC, 16) + " to gateway 0x" + String(*destMAC, 16) + ". Retries remaining: " + String(retries - 1));
|
||||
}
|
||||
//printLoraPacket(pkt,sizeof(pkt));
|
||||
LoRa.beginPacket();
|
||||
LoRa.write((uint8_t*)&pkt, sizeof(pkt));
|
||||
|
Loading…
Reference in New Issue
Block a user