File syn_heartbeat.c¶
FileList > net > syn_heartbeat.c
Go to the source code of this file
Heartbeat / keep-alive implementation.
#include "../util/syn_assert.h"#include "syn_heartbeat.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| bool | syn_heartbeat_add_peer (SYN_Heartbeat * hb, uint8_t node_id) Add a peer to monitor. |
| void | syn_heartbeat_init (SYN_Heartbeat * hb, SYN_Router * router, SYN_HB_Peer * peers, uint8_t peer_cap, uint32_t interval_ms, uint32_t timeout_ms) Initialize heartbeat system. |
| void | syn_heartbeat_on_peer_found (SYN_Heartbeat * hb, SYN_HB_Callback cb, void * ctx) Register peer-found callback. |
| void | syn_heartbeat_on_peer_lost (SYN_Heartbeat * hb, SYN_HB_Callback cb, void * ctx) Register peer-lost callback. |
| bool | syn_heartbeat_peer_alive (const SYN_Heartbeat * hb, uint8_t node_id) Check if a specific peer is alive. |
| void | syn_heartbeat_set_errlog (SYN_Heartbeat * hb, SYN_ErrLog * errlog) Attach error log for peer-lost/found events. |
| void | syn_heartbeat_update (SYN_Heartbeat * hb) Update — send heartbeat + check peers. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | hb_rx_handler (const SYN_Packet * pkt, void * ctx) Router callback for incoming heartbeat packets. |
Public Functions Documentation¶
function syn_heartbeat_add_peer¶
Add a peer to monitor.
Parameters:
hbHeartbeat instance.node_idPeer node ID.
Returns:
true if added, false if peer table is full.
function syn_heartbeat_init¶
Initialize heartbeat system.
void syn_heartbeat_init (
SYN_Heartbeat * hb,
SYN_Router * router,
SYN_HB_Peer * peers,
uint8_t peer_cap,
uint32_t interval_ms,
uint32_t timeout_ms
)
Automatically registers a handler for SYN_MSG_HEARTBEAT on the router.
Parameters:
hbHeartbeat instance.routerPacket router.peersCaller-owned peer array.peer_capArray capacity.interval_msHow often to send our heartbeat.timeout_msHow long before a peer is "dead".
function syn_heartbeat_on_peer_found¶
Register peer-found callback.
Parameters:
hbHeartbeat instance.cbCallback function.ctxUser context.
function syn_heartbeat_on_peer_lost¶
Register peer-lost callback.
Parameters:
hbHeartbeat instance.cbCallback function.ctxUser context.
function syn_heartbeat_peer_alive¶
Check if a specific peer is alive.
Parameters:
hbHeartbeat instance.node_idPeer node ID.
Returns:
true if the peer is alive.
function syn_heartbeat_set_errlog¶
Attach error log for peer-lost/found events.
Parameters:
hbHeartbeat instance.errlogError log instance.
function syn_heartbeat_update¶
Update — send heartbeat + check peers.
Call from your main loop.
Parameters:
hbHeartbeat instance.
Public Static Functions Documentation¶
function hb_rx_handler¶
Router callback for incoming heartbeat packets.
Parameters:
pktReceived packet.ctxHeartbeat context (SYN_Heartbeat *).
The documentation for this class was generated from the following file src/syntropic/net/syn_heartbeat.c