13#ifndef INFUSE_SDK_INCLUDE_INFUSE_EPACKET_PACKET_H_
14#define INFUSE_SDK_INCLUDE_INFUSE_EPACKET_PACKET_H_
18#include <zephyr/kernel.h>
19#include <zephyr/device.h>
20#include <zephyr/toolchain.h>
21#include <zephyr/net_buf.h>
22#include <zephyr/bluetooth/bluetooth.h>
62#define EPACKET_ADDR_ALL ((union epacket_interface_address){0})
79#ifdef CONFIG_EPACKET_BUFFERS_TX_DELAYABLE_WORK
81 struct k_work_delayable dwork;
155#define EPACKET_KEY_ID_REQ_MAGIC 0x4D
164#define EPACKET_RATE_LIMIT_REQ_MAGIC 0x4E
380 uint32_t key_identifier, uint16_t flags,
409 uint32_t key_id = 0x00;
epacket_interface_id
Identifier for ePacket interface.
Definition interface.h:75
static uint16_t epacket_interface_max_packet_size(const struct device *dev)
Get current maximum packet size.
Definition interface.h:258
epacket_auth
ePacket authentication levels
Definition packet.h:42
struct net_buf * epacket_alloc_tx(k_timeout_t timeout)
Allocate ePacket TX buffer.
int epacket_received_packet_append(struct net_buf *storage_buf, struct net_buf *received_buf)
Append received packet to storage buffer.
struct net_buf * epacket_alloc_rx(k_timeout_t timeout)
Allocate ePacket RX buffer.
void epacket_global_flags_set(uint16_t flags)
Set global flags for all transmitted packets.
void epacket_rate_limit_reset(void)
Reset any active rate limits.
epacket_flags
Global ePacket flags.
Definition packet.h:136
void(* epacket_tx_done_cb)(const struct device *dev, struct net_buf *pkt, int result, void *user_data)
Callback run when packet is transmitted.
Definition packet.h:72
int epacket_num_buffers_free_rx(void)
Query the number of free RX buffers.
int epacket_num_buffers_free_tx(void)
Query the number of free TX buffers.
static void epacket_set_tx_metadata(struct net_buf *buf, enum epacket_auth auth, uint16_t flags, enum infuse_type type, union epacket_interface_address dest)
Set metadata on a packet.
Definition packet.h:405
static void epacket_set_tx_metadata_core(struct net_buf *buf, enum epacket_auth auth, uint32_t key_identifier, uint16_t flags, enum infuse_type type, union epacket_interface_address dest)
Set all metadata on a packet.
Definition packet.h:379
static struct net_buf * epacket_alloc_tx_for_interface(const struct device *dev, k_timeout_t timeout)
Allocate ePacket TX buffer for a specific interface.
Definition packet.h:345
uint16_t epacket_global_flags_get(void)
Get the current global flags value.
static void epacket_set_tx_callback(struct net_buf *buf, epacket_tx_done_cb tx_done, void *user_data)
Set callback to be run after packet sent.
Definition packet.h:427
epacket_forward_auto_conn_flags
Flags for epacket_forward_auto_conn_header::flags.
Definition packet.h:234
void epacket_rate_limit_tx(k_ticks_t *last_call, uint16_t bytes_transmitted)
Limit the transmission rate of bulk data paths.
@ EPACKET_AUTH_NETWORK
Packet is encrypted with a network key.
Definition packet.h:48
@ EPACKET_AUTH_DEVICE
Packet is encrypted with a device key.
Definition packet.h:50
@ EPACKET_AUTH_FAILURE
Packet failed to decrypt.
Definition packet.h:44
@ EPACKET_AUTH_REMOTE_ENCRYPTED
Packet is encrypted for remote device.
Definition packet.h:46
@ EPACKET_FLAGS_ENCRYPTION_NETWORK
Bit 15: Encryption type is network key.
Definition packet.h:140
@ EPACKET_FLAGS_CLOUD_SELF
Bit 12: Device sends its own data to the cloud.
Definition packet.h:146
@ EPACKET_FLAGS_ENCRYPTION_DEVICE
Bit 15: Encryption type is device key.
Definition packet.h:138
@ EPACKET_FLAGS_INTERFACE_MASK
Bits 0-7: Interface specific.
Definition packet.h:149
@ EPACKET_FLAGS_ACK_REQUEST
Bit 14: Transmitting device requests an ACK.
Definition packet.h:142
@ EPACKET_FLAGS_CLOUD_FORWARDING
Bit 13: Device can forward data to the cloud.
Definition packet.h:144
@ EPACKET_FORWARD_AUTO_CONN_DC_NOTIFICATION
Send a INFUSE_EPACKET_CONN_TERMINATED on connection terminated.
Definition packet.h:240
@ EPACKET_FORWARD_AUTO_CONN_SUB_DATA
Subscribe to data while connected.
Definition packet.h:238
@ EPACKET_FORWARD_AUTO_CONN_PRIORITISE_UPLINK
Prioritise uplink throughput to the connection associated with this request.
Definition packet.h:242
@ EPACKET_FORWARD_AUTO_CONN_SINGLE_RPC
Automatically disconnect on the first received INFUSE_RPC_RSP.
Definition packet.h:236
uint32_t infuse_security_network_key_identifier(void)
Get the current network key identifier.
uint32_t infuse_security_device_key_identifier(void)
Get the current device key identifier.
infuse_type
Core Infuse Data Types.
Definition types.h:27
Core Infuse-IoT platform types.
Infuse Platform Security Identifiers.
Packet for INFUSE_EPACKET_CONN_TERMINATED.
Definition packet.h:264
uint8_t interface
Value from epacket_interface_id.
Definition packet.h:266
int16_t reason
Reason that interface disconnected.
Definition packet.h:268
uint8_t address[]
Interface address that disconnected.
Definition packet.h:270
Format of BLE address in INFUSE_RECEIVED_EPACKET and INFUSE_EPACKET_FORWARD.
Definition packet.h:183
uint8_t type
Bluetooth LE address type.
Definition packet.h:185
uint8_t addr[6]
Bluetooth LE address value.
Definition packet.h:187
Common config struct for all interfaces.
Definition interface.h:203
uint8_t footer_size
Size of the interface footer on each packet.
Definition interface.h:209
uint8_t header_size
Size of the interface header on each packet.
Definition interface.h:207
Format of INFUSE_KEY_IDS packet.
Definition packet.h:158
uint8_t device_key_id[3]
24 bit device key identifier
Definition packet.h:160
Magic two byte packet that requests a pause in data transmission.
Definition packet.h:167
uint8_t magic
EPACKET_RATE_LIMIT_REQ_MAGIC
Definition packet.h:169
uint8_t delay_ms
Duration to pause transmission for.
Definition packet.h:171
Magic three byte packet that sets a target data throughput.
Definition packet.h:175
uint16_t target_throughput_kbps
Target data throughput in kilobits/sec.
Definition packet.h:179
uint8_t magic
EPACKET_RATE_LIMIT_REQ_MAGIC
Definition packet.h:177
Interface specific addresses.
Definition packet.h:56
bt_addr_le_t bluetooth
Bluetooth LE address.
Definition packet.h:58