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:
Timm Bogner 2022-10-01 00:19:53 -05:00
parent cbcadb1105
commit 5340965c3a
7 changed files with 15 additions and 22 deletions

View File

@ -142,7 +142,7 @@ void loop() {
}
#endif
while (UART_IF.available()) {
while (UART_IF.available() || Serial.available()) {
getSerial();
}
getLoRa();

View File

@ -154,7 +154,7 @@ void loop() {
}
#endif
while (UART_IF.available()) {
while (UART_IF.available() || Serial.available()) {
getSerial();
}
getLoRa();

View File

@ -142,7 +142,7 @@ void loop() {
}
#endif
while (UART_IF.available()) {
while (UART_IF.available() || Serial.available()) {
getSerial();
}
getLoRa();

View File

@ -142,7 +142,7 @@ void loop() {
}
#endif
while (UART_IF.available()) {
while (UART_IF.available() || Serial.available()) {
getSerial();
}
getLoRa();

View File

@ -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) {

View File

@ -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.

View File

@ -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");