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

Public interface for SenderApp — the UDP sender application on Thread 1. More...

#include <stdint.h>
#include "juno/app/app_api.h"
#include "juno/sb/broker_api.h"
#include "udp_api.h"
#include "juno/module.h"
#include "juno/types.h"
Include dependency graph for sender_app.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct SENDER_APP_TAG SENDER_APP_T
 

Functions

struct SENDER_APP_TAG JUNO_MODULE_DERIVE (JUNO_APP_ROOT_T, JUNO_UDP_ROOT_T *ptUdp;JUNO_SB_BROKER_ROOT_T *ptBroker;uint32_t _uSeqNum;)
 Concrete SenderApp instance.
 
JUNO_STATUS_T SenderApp_Init (SENDER_APP_T *ptApp, JUNO_UDP_ROOT_T *ptUdp, JUNO_SB_BROKER_ROOT_T *ptBroker, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, void *pvFailureUserData)
 Initialize a SenderApp instance.
 

Detailed Description

Public interface for SenderApp — the UDP sender application on Thread 1.

SenderApp implements the JUNO_APP_API_T lifecycle interface. On each scheduler cycle it builds a UDP_THREAD_MSG_T with a monotonically incrementing sequence counter, publishes it to Thread 1's software-bus broker (so MonitorApp can observe it locally), and transmits it via the UDP module to the loopback address so UdpBridgeApp on Thread 2 can receive it.

All memory is caller-owned and injected. SenderApp allocates nothing.

Typical usage:

SENDER_APP_T tSender;
SenderApp_Init(&tSender,
&tUdp.tRoot, &tBroker,
MyFailureHandler, NULL);
tSender.tRoot.ptApi->OnStart(&tSender.tRoot);
// ... scheduler loop ...
tSender.tRoot.ptApi->OnProcess(&tSender.tRoot);
// ...
tSender.tRoot.ptApi->OnExit(&tSender.tRoot);
JUNO_STATUS_T SenderApp_Init(SENDER_APP_T *ptApp, JUNO_UDP_ROOT_T *ptUdp, JUNO_SB_BROKER_ROOT_T *ptBroker, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, void *pvFailureUserData)
Initialize a SenderApp instance.
Definition sender_app.cpp:104
struct SENDER_APP_TAG SENDER_APP_T
Definition sender_app.h:90

Typedef Documentation

◆ SENDER_APP_T

typedef struct SENDER_APP_TAG SENDER_APP_T

Function Documentation

◆ JUNO_MODULE_DERIVE()

struct SENDER_APP_TAG JUNO_MODULE_DERIVE ( JUNO_APP_ROOT_T  ,
JUNO_UDP_ROOT_T *ptUdp;JUNO_SB_BROKER_ROOT_T *ptBroker;uint32_t _uSeqNum;   
)

Concrete SenderApp instance.

Embeds JUNO_APP_ROOT_T via JUNO_MODULE_DERIVE, accessible as JUNO_MODULE_SUPER (tRoot), enabling safe up-cast from a JUNO_APP_ROOT_T * to SENDER_APP_T * inside the lifecycle callbacks. The scheduler holds a JUNO_APP_ROOT_T * and dispatches via the vtable; each callback recovers the full struct with:

SENDER_APP_T *ptSender = (SENDER_APP_T *)ptApp;

All fields other than the embedded root are either injected at SenderApp_Init time or are private mutable state (_uSeqNum). The composition root owns this struct; no field is heap-allocated.

◆ SenderApp_Init()

JUNO_STATUS_T SenderApp_Init ( SENDER_APP_T ptApp,
JUNO_UDP_ROOT_T ptUdp,
JUNO_SB_BROKER_ROOT_T ptBroker,
JUNO_FAILURE_HANDLER_T  pfcnFailureHandler,
void *  pvFailureUserData 
)

Initialize a SenderApp instance.

Wires the internal static vtable into ptApp->tRoot.ptApi, stores ptUdp and ptBroker, stores the failure handler and user data into the root, and sets _uSeqNum to zero. Verifies that no required injected pointer is NULL before returning.

Must be called before any lifecycle operation. All caller-allocated storage; this function does not allocate any memory.

Parameters
ptAppCaller-owned SenderApp storage; must be non-NULL.
ptUdpUDP module root configured for sender role; must be non-NULL and outlive ptApp.
ptBrokerThread 1 broker root; must be non-NULL and outlive ptApp.
pfcnFailureHandlerDiagnostic callback invoked before any error return; may be NULL.
pvFailureUserDataOpaque pointer passed to the failure handler; may be NULL.
Returns
JUNO_STATUS_SUCCESS on success; JUNO_STATUS_NULLPTR_ERROR if any required pointer is NULL.