STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
radio.h
Go to the documentation of this file.
1#ifndef RADIO_H
2#define RADIO_H
3
4#include <stddef.h>
5#include <stdint.h>
6
7namespace radio_link {
8
9// The answers a radio function can give.
10enum class RadioStatus : uint8_t {
11 Ok = 0, // it worked
12 ErrNotFound, // the radio chip did not answer
13 ErrTooLong, // a packet was bigger than the space we gave it
14 NoData, // nothing has arrived yet (this is not a failure)
15 ErrTimeout, // the operation did not complete before its deadline
16 NotImplemented, // no transport implementation is installed
17};
18
19// Check the radio chip is there and answering (for example by reading one of
20// its status registers). Call this once at boot.
21// Returns Ok if it answers, ErrNotFound if it does not.
23
24// Check whether a packet has arrived, without waiting. The caller provides a
25// box (`buf`) that holds up to `max_len` bytes.
26// - A packet is waiting: it is copied into `buf`, `len` is set to its size,
27// and the answer is Ok.
28// - Nothing is waiting: the answer is NoData and `len` is left alone.
29// - The waiting packet is bigger than `max_len`: it is thrown away and the
30// answer is ErrTooLong.
31RadioStatus radio_receive(uint8_t* buf, uint8_t max_len, uint8_t& len);
32
33// Send one packet: `len` bytes (1 to 255) starting at `bytes`.
34// Return Ok only after SX1262 TxDone, within a bounded driver timeout.
35// Queueing a packet is insufficient; no ground-station ACK is required.
36// Return ErrTimeout on expiry and NotImplemented for an absent transport.
37// Self-test sends heartbeats and reports; a no-op must never return Ok.
38RadioStatus radio_send(const uint8_t* bytes, uint8_t len);
39
40} // namespace radio_link
41
42#endif // RADIO_H