mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-08 13:10:29 +00:00
input via Serial0
data at the Rx of the USB Serial port (normally used for debugging) will now be entered into the getSerial() function
This commit is contained in:
parent
cbcadb1105
commit
5340965c3a
@ -142,7 +142,7 @@ void loop() {
|
||||
}
|
||||
#endif
|
||||
|
||||
while (UART_IF.available()) {
|
||||
while (UART_IF.available() || Serial.available()) {
|
||||
getSerial();
|
||||
}
|
||||
getLoRa();
|
||||
|
@ -154,7 +154,7 @@ void loop() {
|
||||
}
|
||||
#endif
|
||||
|
||||
while (UART_IF.available()) {
|
||||
while (UART_IF.available() || Serial.available()) {
|
||||
getSerial();
|
||||
}
|
||||
getLoRa();
|
||||
|
@ -142,7 +142,7 @@ void loop() {
|
||||
}
|
||||
#endif
|
||||
|
||||
while (UART_IF.available()) {
|
||||
while (UART_IF.available() || Serial.available()) {
|
||||
getSerial();
|
||||
}
|
||||
getLoRa();
|
||||
|
@ -142,7 +142,7 @@ void loop() {
|
||||
}
|
||||
#endif
|
||||
|
||||
while (UART_IF.available()) {
|
||||
while (UART_IF.available() || Serial.available()) {
|
||||
getSerial();
|
||||
}
|
||||
getLoRa();
|
||||
|
@ -46,13 +46,7 @@ void begin_espnow() {
|
||||
esp_now_set_self_role(ESP_NOW_ROLE_COMBO);
|
||||
esp_now_register_send_cb(OnDataSent);
|
||||
esp_now_register_recv_cb(OnDataRecv);
|
||||
// Register peers
|
||||
//#ifdef ESPNOW1_PEER
|
||||
// esp_now_add_peer(ESPNOW1, ESP_NOW_ROLE_COMBO, 0, NULL, 0);
|
||||
//#endif
|
||||
//#ifdef ESPNOW2_PEER
|
||||
// esp_now_add_peer(ESPNOW2, ESP_NOW_ROLE_COMBO, 0, NULL, 0);
|
||||
//#endif
|
||||
|
||||
#elif defined(ESP32)
|
||||
esp_wifi_set_mac(WIFI_IF_STA, &selfAddress[0]);
|
||||
if (esp_now_init() != ESP_OK) {
|
||||
|
@ -174,16 +174,9 @@ uint8_t broadcast_mac[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
uint8_t selfAddress[] = {MAC_PREFIX, UNIT_MAC};
|
||||
uint8_t incMAC[6];
|
||||
|
||||
#ifdef ESPNOW1_PEER
|
||||
uint8_t ESPNOW1[] = {MAC_PREFIX, ESPNOW_NEIGHBOR_1};
|
||||
#else
|
||||
uint8_t ESPNOW1[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
#endif
|
||||
#ifdef ESPNOW2_PEER
|
||||
uint8_t ESPNOW2[] = {MAC_PREFIX, ESPNOW_NEIGHBOR_2};
|
||||
#else
|
||||
uint8_t ESPNOW2[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_LORA
|
||||
uint16_t LoRa1 = ((mac_prefix[4] << 8) | LORA_NEIGHBOR_1); // Use 2 bytes for LoRa addressing instead of previous 3 bytes
|
||||
@ -303,7 +296,13 @@ static uint16_t crc16_update(uint16_t crc, uint8_t a)
|
||||
#include <fdrs_espnow.h>
|
||||
|
||||
void getSerial() {
|
||||
String incomingString = UART_IF.readStringUntil('\n');
|
||||
String incomingString;
|
||||
if (UART_IF.available()){
|
||||
incomingString = UART_IF.readStringUntil('\n');
|
||||
}
|
||||
else if (Serial.available()){
|
||||
incomingString = Serial.readStringUntil('\n');
|
||||
}
|
||||
DynamicJsonDocument doc(24576);
|
||||
DeserializationError error = deserializeJson(doc, incomingString);
|
||||
if (error) { // Test if parsing succeeds.
|
||||
|
@ -165,7 +165,8 @@ void beginFDRS() {
|
||||
// esp_reset_reason_t resetReason;
|
||||
// resetReason = esp_reset_reason();
|
||||
#endif
|
||||
DBG("FDRS Sensor ID " + String(READING_ID) + " initializing...");
|
||||
DBG("FDRS User Node initializing...");
|
||||
DBG(" Reading ID " + String(READING_ID));
|
||||
DBG(" Gateway: " + String (GTWY_MAC, HEX));
|
||||
#ifdef POWER_CTRL
|
||||
DBG("Powering up the sensor array!");
|
||||
@ -199,7 +200,6 @@ void beginFDRS() {
|
||||
peerInfo.ifidx = WIFI_IF_STA;
|
||||
peerInfo.channel = 0;
|
||||
peerInfo.encrypt = false;
|
||||
// Register first peer
|
||||
memcpy(peerInfo.peer_addr, broadcast_mac, 6);
|
||||
if (esp_now_add_peer(&peerInfo) != ESP_OK) {
|
||||
DBG("Failed to add peer bcast");
|
||||
|
Loading…
Reference in New Issue
Block a user