13#ifndef INFUSE_SDK_INCLUDE_INFUSE_EPACKET_INTERFACE_H_
14#define INFUSE_SDK_INCLUDE_INFUSE_EPACKET_INTERFACE_H_
16#include <zephyr/device.h>
17#include <zephyr/net_buf.h>
30#define EPACKET_INTERFACE_MAX_PACKET(node_id) \
31 (MIN(CONFIG_EPACKET_PACKET_SIZE_MAX, \
32 DT_PROP_OR(node_id, max_packet_size, CONFIG_EPACKET_PACKET_SIZE_MAX)))
34#define EPACKET_INTERFACE_PACKET_OVERHEAD(node_id) \
35 (DT_PROP(node_id, header_size) + DT_PROP(node_id, footer_size))
37#define EPACKET_INTERFACE_PAYLOAD_FROM_PACKET(node_id, packet_size) \
38 (MIN(packet_size, CONFIG_EPACKET_PACKET_SIZE_MAX) - \
39 EPACKET_INTERFACE_PACKET_OVERHEAD(node_id))
41#define EPACKET_INTERFACE_MAX_PAYLOAD(node_id) \
42 (EPACKET_INTERFACE_PAYLOAD_FROM_PACKET(node_id, EPACKET_INTERFACE_MAX_PACKET(node_id)))
52#define EPACKET_INTERFACE_IS_COMPILED_IN(node_id) IS_ENABLED(DT_STRING_TOKEN(node_id, depends_on))
115 void (*
send)(
const struct device *dev,
struct net_buf *buf);
307#define GATEWAY_HANDLER_DEFINE(name, backhaul) \
308 static void name(struct net_buf *buf) \
310 epacket_gateway_receive_handler(backhaul, buf); \
static bool epacket_unregister_callback(const struct device *dev, struct epacket_interface_cb *cb)
Unregister from interface events.
Definition interface.h:268
int epacket_send_key_ids(const struct device *dev, k_timeout_t timeout)
Send a INFUSE_KEY_IDS packet on an interface.
epacket_interface_id
Definition interface.h:55
static void epacket_set_receive_handler(const struct device *dev, epacket_receive_handler handler)
Set the ePacket receive handler for an interface.
Definition interface.h:235
static uint16_t epacket_interface_max_packet_size(const struct device *dev)
Get current maximum packet size.
Definition interface.h:217
void epacket_gateway_receive_handler(const struct device *backhaul, struct net_buf *buf)
Default gateway receive handler.
void epacket_default_receive_handler(struct net_buf *buf)
Default ePacket receive handler.
void epacket_queue(const struct device *dev, struct net_buf *buf)
Queue an ePacket for sending over an interface.
void(* epacket_receive_handler)(struct net_buf *packet)
Callback to run on received packet.
Definition interface.h:153
int epacket_receive(const struct device *dev, k_timeout_t timeout)
Enable receiving on the interface for a duration.
static void epacket_register_callback(const struct device *dev, struct epacket_interface_cb *cb)
Register to be notified of interface events.
Definition interface.h:249
@ EPACKET_INTERFACE_UDP
Definition interface.h:57
@ EPACKET_INTERFACE_HCI
Definition interface.h:61
@ EPACKET_INTERFACE_SERIAL
Definition interface.h:56
@ EPACKET_INTERFACE_BT_ADV
Definition interface.h:58
@ EPACKET_INTERFACE_BT_PERIPHERAL
Definition interface.h:59
@ EPACKET_INTERFACE_BT_CENTRAL
Definition interface.h:60
@ EPACKET_INTERFACE_DUMMY
Definition interface.h:62
Definition interface.h:106
uint16_t(* max_packet_size)(const struct device *dev)
Get current maximum packet size.
Definition interface.h:145
void(* send)(const struct device *dev, struct net_buf *buf)
Send a packet over the interface.
Definition interface.h:115
int(* receive_ctrl)(const struct device *dev, bool enable)
Control receiving on the interface.
Definition interface.h:135
void(* decrypt_result)(const struct device *dev, struct net_buf *buf, int decrypt_result)
Callback for packet decryption result.
Definition interface.h:125
ePacket interface callback structure.
Definition interface.h:66
void(* tx_failure)(const struct net_buf *buf, int reason, void *user_ctx)
A packet failed to transmit on the interface.
Definition interface.h:82
sys_snode_t node
Definition interface.h:103
bool(* packet_received)(struct net_buf *buf, bool decrypted, void *user_ctx)
A packet was received on the interface.
Definition interface.h:98
void(* interface_state)(uint16_t current_max_payload, void *user_ctx)
The interface connection state has changed.
Definition interface.h:73
void * user_ctx
Definition interface.h:101
Common config struct for all interfaces.
Definition interface.h:165
uint16_t max_packet_size
Definition interface.h:166
uint8_t footer_size
Definition interface.h:168
uint8_t header_size
Definition interface.h:167
Common data struct for all interfaces.
Definition interface.h:156
epacket_receive_handler receive_handler
Definition interface.h:157
const struct device * dev
Definition interface.h:161
struct k_work_delayable receive_timeout
Definition interface.h:158
sys_slist_t callback_list
Definition interface.h:160
struct k_spinlock callback_lock
Definition interface.h:159