#ifndef NR_ANTENNA_CONTROL_H #define NR_ANTENNA_CONTROL_H #include "nr_antenna_state.h" #include #ifdef __cplusplus extern "C" { #endif /// Default port for the test socket server (development mode only) #define NR_ANTENNA_CONTROL_TEST_PORT 9999 /** * @brief Antenna control backend type */ typedef enum { ANTENNA_CTRL_BACKEND_NONE = 0, ///< No external control ANTENNA_CTRL_BACKEND_MPLANE, ///< O-RAN M-Plane NETCONF (production) ANTENNA_CTRL_BACKEND_TEST_SOCKET ///< Test socket interface (development) } nr_antenna_ctrl_backend_t; /** * @brief Initialize antenna control with O-RAN M-Plane NETCONF backend * * This is the O-RAN compliant production interface. It connects the * antenna state to a real NETCONF session to an O-RU. * * When antenna masks are changed via nr_set_tx_antenna_bitmask() or * similar functions, the changes are automatically propagated to the * RU via NETCONF edit-config operations. * * @param ant_state Pointer to the antenna state to control * @param ru_session Active M-Plane NETCONF session (from radio/fhi_72/mplane/) * @return true if initialization successful */ bool nr_antenna_control_init_mplane(nr_antenna_state_t *ant_state, void *ru_session); /** * @brief Start the test socket server (development mode only) * * Creates a simple TCP server for testing antenna control without * NETCONF infrastructure. This is NOT O-RAN compliant. * * Commands supported (for backwards compatibility): * MUTE TX - Mute TX antenna * UNMUTE TX - Unmute TX antenna * MUTE RX - Mute RX antenna * UNMUTE RX - Unmute RX antenna * SET TX MASK - Set TX antenna bitmask * SET RX MASK - Set RX antenna bitmask * STATUS - Get current antenna state * STATS - Get energy saving statistics * RESET STATS - Reset statistics * QUIT - Close connection * * @param ant_state Pointer to the antenna state to control * @param port TCP port to listen on (use 0 for default) * @return true if server started successfully * * @note This function logs a warning that it's not O-RAN compliant */ bool nr_antenna_control_start_test_server(nr_antenna_state_t *ant_state, int port); /** * @brief Legacy function - start antenna control server * * @deprecated Use nr_antenna_control_init_mplane() for O-RAN compliance * or nr_antenna_control_start_test_server() for testing. * * This function starts the test socket server for backwards compatibility. * It logs a deprecation warning. */ bool nr_antenna_control_start(nr_antenna_state_t *ant_state, int port); /** * @brief Stop the antenna control interface * * Stops the test socket server if running. * For M-Plane backend, this disconnects from NETCONF notifications. */ void nr_antenna_control_stop(void); /** * @brief Check if antenna control is active * @return true if control interface is running */ bool nr_antenna_control_is_running(void); /** * @brief Get current antenna control backend type * @return Backend type currently in use */ nr_antenna_ctrl_backend_t nr_antenna_control_get_backend(void); /** * @brief Synchronize local antenna state to RU via M-Plane NETCONF * * Sends the current antenna bitmask configuration to the RU. * Only applicable when using the M-Plane NETCONF backend. * * @param ant_state Pointer to the antenna state * @return true if synchronization successful or not applicable */ bool nr_antenna_control_sync_to_ru(nr_antenna_state_t *ant_state); /** * @brief Synchronize RU antenna state to local via M-Plane NETCONF * * Reads the current antenna bitmask from the RU and updates local state. * Only applicable when using the M-Plane NETCONF backend. * * @param ant_state Pointer to the antenna state * @return true if synchronization successful or not applicable */ bool nr_antenna_control_sync_from_ru(nr_antenna_state_t *ant_state); #ifdef __cplusplus } #endif #endif /* NR_ANTENNA_CONTROL_H */