|
LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
|
Public interface for UdpBridgeApp — the UDP-to-broker bridge application. More...


Go to the source code of this file.
Typedefs | |
| typedef struct UDP_BRIDGE_APP_TAG | UDP_BRIDGE_APP_T |
Functions | |
| struct UDP_BRIDGE_APP_TAG | JUNO_MODULE_DERIVE (JUNO_APP_ROOT_T, JUNO_UDP_ROOT_T *ptUdp;JUNO_SB_BROKER_ROOT_T *ptBroker;) |
| Concrete struct for UdpBridgeApp. | |
| JUNO_STATUS_T | UdpBridgeApp_Init (UDP_BRIDGE_APP_T *ptApp, JUNO_UDP_ROOT_T *ptUdp, JUNO_SB_BROKER_ROOT_T *ptBroker, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, void *pvFailureUserData) |
| Initialize a UdpBridgeApp instance with its dependencies. | |
Public interface for UdpBridgeApp — the UDP-to-broker bridge application.
UdpBridgeApp runs on Thread 2. On each scheduler cycle it attempts to receive one datagram from the already-open UDP receiver socket. When a datagram arrives it is published to Thread 2's software-bus broker so that ProcessorApp may consume it. When the receive times out the app returns success immediately without publishing.
This module follows the LibJuno vtable / dependency-injection pattern:
UDP_BRIDGE_APP_T embeds JUNO_APP_ROOT_T as its first member, enabling safe upcast from JUNO_APP_ROOT_T* to the concrete app pointer.JUNO_UDP_ROOT_T, JUNO_SB_BROKER_ROOT_T) are injected at UdpBridgeApp_Init time. The app allocates nothing.static inside udp_bridge_app.cpp and are wired into a static const vtable in that translation unit. Callers never reference the vtable by name.Typical usage:
| typedef struct UDP_BRIDGE_APP_TAG UDP_BRIDGE_APP_T |
| struct UDP_BRIDGE_APP_TAG JUNO_MODULE_DERIVE | ( | JUNO_APP_ROOT_T | , |
| JUNO_UDP_ROOT_T *ptUdp;JUNO_SB_BROKER_ROOT_T *ptBroker; | |||
| ) |
Concrete struct for UdpBridgeApp.
Embeds JUNO_APP_ROOT_T (as JUNO_MODULE_SUPER) via JUNO_MODULE_DERIVE so that the scheduler can hold a JUNO_APP_ROOT_T* and dispatch lifecycle calls through the vtable. The concrete implementation recovers full state by casting:
All instances are stack- or statically-allocated by the composition root. No member of this struct is heap-allocated.
| JUNO_STATUS_T UdpBridgeApp_Init | ( | UDP_BRIDGE_APP_T * | ptApp, |
| JUNO_UDP_ROOT_T * | ptUdp, | ||
| JUNO_SB_BROKER_ROOT_T * | ptBroker, | ||
| JUNO_FAILURE_HANDLER_T | pfcnFailureHandler, | ||
| void * | pvFailureUserData | ||
| ) |
Initialize a UdpBridgeApp instance with its dependencies.
Wires the internal static vtable into ptApp->tRoot.ptApi, stores ptUdp and ptBroker, stores the failure handler and user data into ptApp->tRoot, and verifies that no required pointer is NULL. Must be called before any lifecycle function.
The UDP socket is opened by the composition root (main.cpp) via JunoUdp_LinuxInit before the thread starts; OnStart does not re-open it.
| ptApp | Caller-owned app instance storage; must be non-NULL. |
| ptUdp | UDP module root (receiver role); must be non-NULL and must outlive ptApp. |
| ptBroker | Thread 2's software-bus broker root; must be non-NULL and must outlive ptApp. |
| pfcnFailureHandler | Diagnostic callback invoked before any error return; may be NULL. |
| pvFailureUserData | Opaque pointer threaded to pfcnFailureHandler; may be NULL. |
JUNO_STATUS_SUCCESS on success; JUNO_STATUS_NULLPTR_ERROR if any required pointer is NULL.