4#ifndef PROTOCORE_LORA_H
5#define PROTOCORE_LORA_H
105 const uint8_t **payload, uint16_t *payload_len);
117 uint16_t len, uint8_t *out, uint16_t cap);
uint16_t protocore_lora_frame_build(const uint8_t *work, const protocore_lora_header *hdr, const uint8_t *payload, uint16_t len, uint8_t *out, uint16_t cap)
Build a frame (header + payload) into out.
embed_bool protocore_lora_send(const uint8_t *work, const protocore_lora_bus *bus, const uint8_t *frame, uint8_t len)
Load frame into the FIFO and start a transmit (the radio returns to .
embed_bool protocore_lora_init(const uint8_t *work, const protocore_lora_bus *bus, const protocore_lora_config *cfg)
Initialize the SX127x: verify the chip, switch to LoRa mode, and .
uint8_t(* protocore_lora_reg_read_fn)(uint8_t reg, void *ctx)
Read one SX127x register (reg is the bare 7-bit address).
void protocore_lora_set_rx(const uint8_t *work, const protocore_lora_bus *bus)
Put the radio in continuous-receive mode (call once, then poll .
embed_bool protocore_lora_tx_done(const uint8_t *work, const protocore_lora_bus *bus)
True once a transmit finished (RegIrqFlags TxDone); clears the .
embed_bool protocore_lora_frame_parse(const uint8_t *work, const uint8_t *raw, uint16_t len, protocore_lora_header *hdr, const uint8_t **payload, uint16_t *payload_len)
Split a received frame into its header and payload.
int protocore_lora_recv(const uint8_t *work, const protocore_lora_bus *bus, uint8_t *buf, uint8_t cap, int16_t *rssi)
If a frame has been received, copy it into buf and report its RSSI.
void(* protocore_lora_reg_write_fn)(uint8_t reg, uint8_t val, void *ctx)
Write one SX127x register (reg is the bare 7-bit address).
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
uint16_t(* frame_build)(const uint8_t *, const protocore_lora_header *, const uint8_t *, uint16_t, uint8_t *, uint16_t)
embed_bool(* frame_parse)(const uint8_t *, const uint8_t *, uint16_t, protocore_lora_header *, const uint8_t **, uint16_t *)
void(* set_rx)(const uint8_t *, const protocore_lora_bus *)
embed_bool(* send)(const uint8_t *, const protocore_lora_bus *, const uint8_t *, uint8_t)
embed_bool(* tx_done)(const uint8_t *, const protocore_lora_bus *)
int(* recv)(const uint8_t *, const protocore_lora_bus *, uint8_t *, uint8_t, int16_t *)
embed_bool(* init)(const uint8_t *, const protocore_lora_bus *, const protocore_lora_config *)
The register-access bus a driver call uses (your SPI + chip-select behind it).
protocore_lora_reg_write_fn write
protocore_lora_reg_read_fn read
Radio configuration applied by protocore_lora_init().
uint32_t freq_hz
carrier frequency in Hz (e.g. 868100000 / 915000000).
uint8_t bandwidth
bandwidth code 0..9 (7 = 125 kHz - the common default).
uint8_t sync_word
0x12 private / 0x34 LoRaWAN.
uint8_t spreading
spreading factor 6..12 (SF7 default is a good start).
uint8_t tx_power
PA_BOOST power 2..17 dBm.
uint8_t coding_rate
coding rate 1..4 (1 = 4/5).