Update README.md

This commit is contained in:
Timm Bogner 2022-06-08 20:48:20 -05:00 committed by GitHub
parent 20b81e0bae
commit b973264bc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,26 +1,36 @@
# Gateway 2.000 # Gateway 2.000
The FDRS Gateway listens for packets over ESP-NOW, UART, LoRa, and/or MQTT, then retransmits the packets over these interfaces using rules defined in the "Actions" section of the configuration file.
This is the FDRS Multiprotocol Gateway sketch. The device listens for packets over ESP-NOW, UART, LoRa, and/or MQTT, then retransmits the packets over these interfaces using rules defined in the "Actions" section of the configuration file. ## Actions
Actions define how the gateway reacts to a packet recieved via each data source. An action may be comprised of one or multiple commands separated by (and terminated with) semicolons.
## Options
### ```#define UNIT_MAC (0xNN)```
The UNIT_MAC is the ESP-NOW and LoRa address of the gateway. This is the address that nodes or other gateways will use to pass data to this device.
### ```#define DEBUG```
This definition enables debug messages to be sent over the serial port. If disabled, the USB serial port is still used to echo data being sent via the sendSerial() command.
### ```#define RXD2 (pin)``` and ```TXD2 (pin)```
These are the pins for inter-device serial communication. The single ESP8266 serial interface is not configurable, and thus these options only apply to ESP32 boards.
### ```#define USE_LORA```
Enables LoRa. Make sure that you set the LoRa module configuration parameters in the lines below.
BAND and SF (spreading factor) can also be configured in 'fdrs_globals.h' if enabled.
### ```#define USE_WIFI```
Enables WiFi. Used only on the MQTT gateway.
SSID, password, and MQTT credentials are also configurable in 'fdrs_globals.h'.
### #define USE_LED
This option initializes FastLED! I haven't developed this very much, perhaps you have ideas?
## Peers
### Routing
In addition to reacting to packets from general (unknown) ESP-NOW and LoRa devices, the gateway can also listen for traffic from a specific peer's device address (MAC) and react differently than it would to general traffic. This can be used to 'propel' packets upstream or downstream and allows the user to define different paths for data originating from either direction. The user can define up to two peer addresses each for the ESP-NOW and LoRa interfaces (ESPNOW1 & ESPNOW2 and LORA1 & LORA2).
### Buffers
Each peer also has a send buffer associated with it. Buffers are enabled by uncommenting their cooresponding DELAY macro (ex: ```#define LORAG_DELAY 1000```). When enabled, the gateway will automatically send the buffer contents at the interval specified. Buffers can hold a maximum of 256 DataReadings.
While ESP-NOW is quick enough to handle a lot of traffic in real-time, LoRa is much slower. For this reason, you must send LoRa data to a buffer and transmit it at standard intervals. Since buffers are mandatory, a LoRa repeater always needs to be configured using a LoRa peer.
The most commonly used configuration tells the device to take any ESP-NOW packet it receives and output the data over the serial port (UART):
```
#define UNIT_MAC 0x00
#define ESPNOWG_ACT sendSerial();
```
The companion for this device, connected via serial, takes any data it receives from the serial port and sends it via MQTT:
```
#define USE_WIFI
#define SERIAL_ACT sendMQTT();
```
Splitting the gateway into two devices allows you to use ESP-NOW and WiFi simultaneously without channel conflicts. You can also connect the first device to a computer with a USB-UART adapter and get the data that way, eliminating WiFi altogether.
If you have sensors that are out of range of your first gateway, you can use a gateway as a repeater. First set the UNIT_MAC to 0x01, then send general ESP-NOW traffic to the address of the first gateway:
```
#define UNIT_MAC 0x01
#define ESPNOWG_ACT sendESPNOW(0x00);
```
### LoRa
You can also use LoRa to expand the distances between hops. While ESP-NOW is quick enough to handle a lot of traffic in real-time, LoRa is much slower. For this reason, you must send LoRa data to a buffer and transmit it at standard intervals.