/** * @file config.h * @brief Main configuration file for the CRAH Unit (TCP) emulator. * @author Emmanuel Hernandez Cruz * @date 2025-09-02 * * This file contains two important configurations: WiFi network parameters * and the Modbus register map for the device. */ #ifndef CONFIG_H #define CONFIG_H #include "core.h" #include "Equipment/Equipment.h" #if defined(USE_MODBUS_IP) /** * @defgroup ModbusTCPConfig Modbus IP Configuration * @brief Parameters for Modbus TCP communication. * @{ */ #include const char *ssid = "ArduinoWifiB"; /**< @brief The SSID of the WiFi network. */ const char *password = "123abc456"; /**< @brief The password for the WiFi network. */ IPAddress local_IP(172, 17, 32, 88); /**< @brief The static IP address for the device. */ IPAddress gateway(172, 17, 32, 1); /**< @brief The gateway IP address. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ ModbusIP mb; #else /** * @defgroup ModbusRTUConfig Modbus RTU Configuration * @brief Parameters for serial Modbus RTU communication. * @{ */ #include const int BAUDRATE = 19200; /**< @brief The serial communication speed in bits per second. */ const int RX_PIN = 17; /**< @brief The GPIO pin used for receiving data (RX). */ const int TX_PIN = 16; /**< @brief The GPIO pin used for transmitting data (TX). */ const int RST_PIN = 4; /**< @brief The GPIO pin connected to the RS485 driver's DE/RE pins for direction control. */ const int MODBUS_ID = 1; /**< @brief The unique slave ID for this device on the Modbus bus. */ /** @} */ /** @brief Global instance of the Modbus RTU server. */ ModbusRTU mb; #endif /** * @defgroup ModbusMapConfig Modbus Map Configuration * @brief Defines the Modbus register map and related parameters for the emulator. * @{ */ /** * @brief The Modbus map for the Equipment device. * This array defines all the Modbus points available on the emulated device. * The `description` field is crucial as it's used to look up points within the application logic. */ modbusMap mb_map[] = { {HR, 15, 0, "State Control"}, //Internal to control from Modscan {HR, 16, 0, "Fault Code"}, //Internal Fault code from Modscan {HR, 549, 0, "Word 1"}, {HR, 550, 0, "Word 2"}, {HR, 551, 0, "Word 3"}, }; //Size of modbus map used in FOR cycles, automatically calculated. /** * @brief The total number of entries in the `mb_map` array. * This is calculated at compile time and used for iterating over the map. */ const int map_size = sizeof(mb_map) / sizeof(mb_map[0]); /** @brief The main loop update interval in milliseconds. */ int interval = 250; /** @} */ // End of ModbusMapConfig group #endif // CONFIG_H