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 "Routing" section of the configuration file.
**Events** occur when data arrives at the gateway via its various interfaces. When an event occurs it triggers one or more **actions**, which are functions that re-send the incoming data over the same or different interfaces.
**Example:** In the following configuration, a packet that arrives at the serial port will be sent to the gateway's neighbor #2, and then to all ESP-NOW nodes that are connected:
On each gateway, the user can configure the addresses of two ESP-NOW neighbors and two LoRa neighbors. When data arrives from one of these addresses, it will trigger `ESPNOW1_ACT`, `ESPNOW2_ACT`, `LORA1_ACT`, or `LORA2_ACT`. A neighboring gateway should be placed just at the edge of another gateway's range. It acts as a repeater to broaden the reach of the system. A repeater's routing options should be defined so that messages coming away from the front-end (controller messages) are coming from neighbor #1, and data heading towards the front-end are coming from #2.
Check out the configurations for the [ESP-NOW](https://github.com/timmbogner/Farm-Data-Relay-System/blob/main/examples/2_ESPNOW_Repeater/fdrs_gateway_config.h#L8) and [LoRa](https://github.com/timmbogner/Farm-Data-Relay-System/blob/main/examples/3_LoRa_Repeater/fdrs_gateway_config.h#L10) repeater examples to see this in action.
**LoRa radio parameters are generally configured in the 'src/fdrs_globals.h' file.** The following values may be set in the gateway configuration file if the user wishes to override the global value:
WiFi and MQTT parameters are generally configured in the 'src/fdrs_globals.h' file. Be sure to use the correct topic when sending MQTT commands. The following values may be set in the gateway configuration file if the user wishes to override the global value:
Sets the level of verbosity in debug messages. '0' (default) shows only the most important system messages, '1' will show additional debug messages for troubleshooting, and '2' will show all messages, including those used in development. Much gratitude to [Jeff Lehman](https://github.com/aviateur17) for this feature!
Within this function, the user may utilize the same `loadFDRS()` and `sendFDRS()` commands used by sensors. After the data is sent, it triggers `INTERNAL_ACT` where it can be routed to the front-end.