4#ifndef PROTOCORE_LORA_H
5#define PROTOCORE_LORA_H
84 uint16_t (*frame_build)(uint8_t *,
const protocore_lora_header *,
const uint8_t *, uint16_t, uint8_t *, uint16_t);
104 const uint8_t **payload, uint16_t *payload_len);
116 uint16_t len, uint8_t *out, uint16_t cap);
int protocore_lora_recv(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_set_rx(uint8_t *work, const protocore_lora_bus *bus)
Put the radio in continuous-receive mode (call once, then poll .
proto_bool protocore_lora_tx_done(uint8_t *work, const protocore_lora_bus *bus)
True once a transmit has finished (RegIrqFlags TxDone); clears the .
proto_bool protocore_lora_init(uint8_t *work, const protocore_lora_bus *bus, const protocore_lora_config *cfg)
Initialize the SX127x: verify the chip, switch to LoRa mode, and .
uint16_t protocore_lora_frame_build(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.
uint8_t(* protocore_lora_reg_read_fn)(uint8_t reg, void *ctx)
Read one SX127x register (reg is the bare 7-bit address).
proto_bool protocore_lora_send(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 .
PROTOCORE_NS LoraNs Lora PROTOCORE_UNUSED
Module namespace.
proto_bool protocore_lora_frame_parse(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.
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_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.
proto_bool(* frame_parse)(uint8_t *, const uint8_t *, uint16_t, protocore_lora_header *, const uint8_t **, uint16_t *)
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).
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS