LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
udp_bridge_app.h File Reference

Public interface for UdpBridgeApp — the UDP-to-broker bridge application. More...

#include "juno/app/app_api.h"
#include "juno/sb/broker_api.h"
#include "udp_api.h"
Include dependency graph for udp_bridge_app.h:
This graph shows which files directly or indirectly include this file:

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.
 

Detailed Description

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.
  • All dependencies (JUNO_UDP_ROOT_T, JUNO_SB_BROKER_ROOT_T) are injected at UdpBridgeApp_Init time. The app allocates nothing.
  • The concrete lifecycle functions are 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:

UDP_BRIDGE_APP_T tBridgeApp;
&tBridgeApp,
&tUdpReceiver.tRoot,
&tBroker2.tRoot,
NULL, NULL
);
JUNO_APP_ROOT_T *ptApp = &tBridgeApp.tRoot;
ptApp->ptApi->OnStart(ptApp);
// ... scheduler loop ...
ptApp->ptApi->OnProcess(ptApp);
// ...
ptApp->ptApi->OnExit(ptApp);
struct JUNO_APP_ROOT_TAG JUNO_APP_ROOT_T
The application module.
Definition app_api.h:50
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.
Definition udp_bridge_app.cpp:46
struct UDP_BRIDGE_APP_TAG UDP_BRIDGE_APP_T
Definition udp_bridge_app.h:93

Typedef Documentation

◆ UDP_BRIDGE_APP_T

typedef struct UDP_BRIDGE_APP_TAG UDP_BRIDGE_APP_T

Function Documentation

◆ JUNO_MODULE_DERIVE()

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:

UDP_BRIDGE_APP_T *ptBridge = (UDP_BRIDGE_APP_T *)ptApp;

All instances are stack- or statically-allocated by the composition root. No member of this struct is heap-allocated.

◆ UdpBridgeApp_Init()

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.

Parameters
ptAppCaller-owned app instance storage; must be non-NULL.
ptUdpUDP module root (receiver role); must be non-NULL and must outlive ptApp.
ptBrokerThread 2's software-bus broker root; must be non-NULL and must outlive ptApp.
pfcnFailureHandlerDiagnostic callback invoked before any error return; may be NULL.
pvFailureUserDataOpaque pointer threaded to pfcnFailureHandler; may be NULL.
Returns
JUNO_STATUS_SUCCESS on success; JUNO_STATUS_NULLPTR_ERROR if any required pointer is NULL.