Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
f4329a85eThis file is pinned to the selected release. Download the original to open it in your design tool.
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2025 Jibril Sharafi
#pragma once
#include <ModbusServerTCPasync.h>
#include <AdvancedLogger.h>
#include "ade7953.h"
#include "customtime.h"
#include "constants.h"
#include "globals.h"
#define MODBUS_TCP_SERVER_ID 1 // The Modbus TCP server ID
#define MODBUS_TCP_MAX_CLIENTS 3 // The maximum number of clients that can connect to the Modbus TCP server
#define MODBUS_TCP_TIMEOUT (10 * 1000) // The timeout for the Modbus TCP server
// Register address mapping
#define START_REGISTERS_METER_VALUES 100 // Before this, data that is not related to energy values (like time)
#define LOWER_LIMIT_CHANNEL_REGISTERS 1000
#define STEP_CHANNEL_REGISTERS 100
#define UPPER_LIMIT_CHANNEL_REGISTERS (LOWER_LIMIT_CHANNEL_REGISTERS + (MAX_CHANNEL_COUNT) * STEP_CHANNEL_REGISTERS)
namespace ModbusTcp
{
void begin();
void stop();
// Start or stop the server to follow the station link. Modbus TCP is unauthenticated and
// binds every interface, so it must not be listening while a SoftAP is broadcasting -
// that includes GRACE, where STA is already connected but the AP is deliberately held up
// for a few more minutes. Idempotent; safe to call repeatedly.
void syncWithNetwork(bool staConnected, bool apServing);
}