libCATS
|
Packet handling; the core of the library. More...
Go to the source code of this file.
Classes | |
struct | cats_packet_t |
CATS packet structure. More... | |
Macros | |
#define | CATS_MAX_PKT_LEN 8191 |
Typedefs | |
typedef struct cats_packet_t | cats_packet_t |
CATS packet structure. | |
Functions | |
int | cats_packet_prepare (cats_packet_t **pkt) |
Initialize a cats_packet_t pointer. | |
int | cats_packet_destroy (cats_packet_t **pkt) |
Deinitialize a packet. | |
uint16_t | cats_packet_semi_encode (const cats_packet_t *pkt, uint8_t *out) |
Semi-encode a CATS packet; only pass through the Whisker and CRC portion of the CATS pipeline. Used for FELINET and radio interfacing. | |
uint16_t | cats_packet_encode (const cats_packet_t *pkt, uint8_t *out) |
Encode a CATS packet. | |
int | cats_packet_semi_decode (cats_packet_t *pkt, uint8_t *buf, size_t buf_len) |
Decode a semi-encoded CATS packet. | |
int | cats_packet_decode (cats_packet_t *pkt, uint8_t *buf, size_t buf_len) |
Decode a CATS packet. | |
int | cats_packet_add_identification (cats_packet_t *pkt, const char *callsign, uint8_t ssid, uint16_t icon) |
Add an identification whisker to a packet. | |
int | cats_packet_add_comment (cats_packet_t *pkt, const char *comment) |
Add a comment whisker to a packet. | |
int | cats_packet_add_gps (cats_packet_t *pkt, double lat, double lon, float alt, uint8_t error, uint8_t heading, float speed) |
Add a GPS whisker to a packet. | |
int | cats_packet_add_route (cats_packet_t *pkt, cats_route_whisker_t route) |
Add a route whisker to a packet. | |
int | cats_packet_add_destination (cats_packet_t *pkt, const char *callsign, uint8_t ssid, uint8_t ack) |
Add a destination whisker to a packet. | |
int | cats_packet_add_simplex (cats_packet_t *pkt, uint32_t frequency, cats_modulation_t modulation, uint8_t power) |
Add a simplex whisker to a packet. | |
int | cats_packet_add_repeater (cats_packet_t *pkt, uint32_t up, uint32_t down, cats_modulation_t modulation, uint32_t tone, uint8_t power, double lat, double lon, const char *name) |
Add a repeater whisker to a packet. | |
int | cats_packet_add_nodeinfo (cats_packet_t *pkt, cats_nodeinfo_whisker_t info) |
Add a nodeinfo whisker to a packet. | |
int | cats_packet_add_arbitrary (cats_packet_t *pkt, const uint8_t *data, size_t len) |
Add arbitrary data to a packet. | |
int | cats_packet_add_whisker_data (cats_packet_t *pkt, cats_whisker_type_t type, const cats_whisker_data_t *whisker_data, int len) |
Add raw whisker data to a packet. | |
int | cats_packet_add_whisker (cats_packet_t *pkt, const cats_whisker_t *whisker) |
Add a whisker to a packet. | |
int | cats_packet_add_timestamp (cats_packet_t *pkt, uint64_t timestamp) |
Add a timestamp to a packet. | |
int | cats_packet_get_identification (const cats_packet_t *pkt, cats_ident_whisker_t **out) |
Get the identification whisker from a packet. | |
int | cats_packet_get_comment (const cats_packet_t *pkt, char *out) |
Get the comment whisker from a packet. | |
int | cats_packet_get_gps (const cats_packet_t *pkt, cats_gps_whisker_t **out) |
Get the GPS whisker from a packet. | |
int | cats_packet_get_route (const cats_packet_t *pkt, cats_route_whisker_t **out) |
Get the route whisker from a packet. | |
int | cats_packet_get_destination (const cats_packet_t *pkt, cats_destination_whisker_t ***out) |
Get the destination whisker from a packet. | |
int | cats_packet_get_simplex (const cats_packet_t *pkt, cats_simplex_whisker_t ***out) |
Get the simplex whisker from a packet. | |
int | cats_packet_get_repeater (const cats_packet_t *pkt, cats_repeater_whisker_t ***out) |
Get the repeater whisker from a packet. | |
int | cats_packet_get_arbitrary (const cats_packet_t *pkt, cats_whisker_t ***out) |
Get arbitrary whiskers from a packet. | |
uint64_t | cats_packet_get_timestamp (const cats_packet_t *pkt) |
Get the timestamp from a packet. | |
int | cats_packet_get_nodeinfo (const cats_packet_t *pkt, cats_nodeinfo_whisker_t **out) |
Get the nodeinfo whisker from a packet. | |
int | cats_packet_find_whiskers (const cats_packet_t *pkt, cats_whisker_type_t type, cats_whisker_t ***out) |
Find whiskers of a certain type in a packet. | |
bool | cats_packet_should_digipeat (const cats_packet_t *pkt, const char *callsign, uint16_t ssid) |
Check if a packet should be digipeated. | |
Packet handling; the core of the library.
typedef struct cats_packet_t cats_packet_t |
CATS packet structure.
cats_packet_prepare
and cats_packet_destroy
int cats_packet_add_arbitrary | ( | cats_packet_t * | pkt, |
const uint8_t * | data, | ||
size_t | len ) |
Add arbitrary data to a packet.
pkt | Packet to add whisker to |
data | Data |
len | Length of data |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_comment | ( | cats_packet_t * | pkt, |
const char * | comment ) |
Add a comment whisker to a packet.
pkt | Packet to add whisker to |
comment | Comment |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_destination | ( | cats_packet_t * | pkt, |
const char * | callsign, | ||
uint8_t | ssid, | ||
uint8_t | ack ) |
Add a destination whisker to a packet.
pkt | Packet to add whisker to |
callsign | Callsign |
ssid | SSID |
ack | Acknowledgement |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_gps | ( | cats_packet_t * | pkt, |
double | lat, | ||
double | lon, | ||
float | alt, | ||
uint8_t | error, | ||
uint8_t | heading, | ||
float | speed ) |
Add a GPS whisker to a packet.
pkt | Packet to add whisker to |
lat | Latitude |
lon | Longitude |
alt | Altitude |
error | Error |
heading | Heading |
speed | Speed |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_identification | ( | cats_packet_t * | pkt, |
const char * | callsign, | ||
uint8_t | ssid, | ||
uint16_t | icon ) |
Add an identification whisker to a packet.
pkt | Packet to add whisker to |
callsign | Callsign |
ssid | SSID |
icon | Icon |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_nodeinfo | ( | cats_packet_t * | pkt, |
cats_nodeinfo_whisker_t | info ) |
Add a nodeinfo whisker to a packet.
pkt | Packet to add whisker to |
info | Nodeinfo |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_repeater | ( | cats_packet_t * | pkt, |
uint32_t | up, | ||
uint32_t | down, | ||
cats_modulation_t | modulation, | ||
uint32_t | tone, | ||
uint8_t | power, | ||
double | lat, | ||
double | lon, | ||
const char * | name ) |
Add a repeater whisker to a packet.
pkt | Packet to add whisker to |
up | Uplink frequency |
down | Downlink frequency |
modulation | Modulation |
tone | Tone |
power | Power |
lat | Latitude |
lon | Longitude |
name | Name |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_route | ( | cats_packet_t * | pkt, |
cats_route_whisker_t | route ) |
Add a route whisker to a packet.
pkt | Packet to add whisker to |
route | Route |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_simplex | ( | cats_packet_t * | pkt, |
uint32_t | frequency, | ||
cats_modulation_t | modulation, | ||
uint8_t | power ) |
Add a simplex whisker to a packet.
pkt | Packet to add whisker to |
frequency | Frequency |
modulation | Modulation |
power | Power |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_timestamp | ( | cats_packet_t * | pkt, |
uint64_t | timestamp ) |
Add a timestamp to a packet.
pkt | Packet to add whisker to |
timestamp | Timestamp |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_add_whisker | ( | cats_packet_t * | pkt, |
const cats_whisker_t * | whisker ) |
Add a whisker to a packet.
pkt | Packet to add whisker to |
whisker | Whisker to add |
CATS_SUCCESS
on success, CATS_FAIL
on failureint cats_packet_add_whisker_data | ( | cats_packet_t * | pkt, |
cats_whisker_type_t | type, | ||
const cats_whisker_data_t * | whisker_data, | ||
int | len ) |
Add raw whisker data to a packet.
pkt | Packet to add whisker to |
type | Whisker type |
whisker_data | Whisker data |
len | Length of whisker data |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_decode | ( | cats_packet_t * | pkt, |
uint8_t * | buf, | ||
size_t | buf_len ) |
Decode a CATS packet.
pkt | Packet to decode into |
buf | Input buffer |
buf_len | Length of input buffer |
CATS_SUCCESS
on success, CATS_FAIL
on failurepkt
MUST be prepared before calling this function int cats_packet_destroy | ( | cats_packet_t ** | pkt | ) |
Deinitialize a packet.
cats_packet_t
pointer, this can result in memory leaks due to whiskers not being properly deallocated. cats_packet_t
pointer uint16_t cats_packet_encode | ( | const cats_packet_t * | pkt, |
uint8_t * | out ) |
Encode a CATS packet.
out | Output buffer |
out
int cats_packet_find_whiskers | ( | const cats_packet_t * | pkt, |
cats_whisker_type_t | type, | ||
cats_whisker_t *** | out ) |
Find whiskers of a certain type in a packet.
pkt | Packet to search |
type | Whisker type to search for |
out | Output array of whiskers |
int cats_packet_get_arbitrary | ( | const cats_packet_t * | pkt, |
cats_whisker_t *** | out ) |
Get arbitrary whiskers from a packet.
pkt | Packet to get whisker from |
out | Output whisker |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_get_comment | ( | const cats_packet_t * | pkt, |
char * | out ) |
Get the comment whisker from a packet.
pkt | Packet to get whisker from |
out | Output comment |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_get_destination | ( | const cats_packet_t * | pkt, |
cats_destination_whisker_t *** | out ) |
Get the destination whisker from a packet.
pkt | Packet to get whisker from |
out | Output whisker |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_get_gps | ( | const cats_packet_t * | pkt, |
cats_gps_whisker_t ** | out ) |
Get the GPS whisker from a packet.
pkt | Packet to get whisker from |
out | Output whisker |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_get_identification | ( | const cats_packet_t * | pkt, |
cats_ident_whisker_t ** | out ) |
Get the identification whisker from a packet.
pkt | Packet to get whisker from |
out | Output whisker |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_get_nodeinfo | ( | const cats_packet_t * | pkt, |
cats_nodeinfo_whisker_t ** | out ) |
Get the nodeinfo whisker from a packet.
pkt | Packet to get whisker from |
out | Output whisker |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_get_repeater | ( | const cats_packet_t * | pkt, |
cats_repeater_whisker_t *** | out ) |
Get the repeater whisker from a packet.
pkt | Packet to get whisker from |
out | Output whisker |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_get_route | ( | const cats_packet_t * | pkt, |
cats_route_whisker_t ** | out ) |
Get the route whisker from a packet.
pkt | Packet to get whisker from |
out | Output whisker |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_get_simplex | ( | const cats_packet_t * | pkt, |
cats_simplex_whisker_t *** | out ) |
Get the simplex whisker from a packet.
pkt | Packet to get whisker from |
out | Output whisker |
CATS_SUCCESS
on success, CATS_FAIL
on failure uint64_t cats_packet_get_timestamp | ( | const cats_packet_t * | pkt | ) |
Get the timestamp from a packet.
pkt | Packet to get whisker from |
out | Output timestamp |
CATS_SUCCESS
on success, CATS_FAIL
on failure int cats_packet_prepare | ( | cats_packet_t ** | pkt | ) |
Initialize a cats_packet_t
pointer.
CATS_SUCCESS
on success, CATS_FAIL
on failurecats_packet_t
pkt
MUST NOT already be allocated, otherwise it will leak memory int cats_packet_semi_decode | ( | cats_packet_t * | pkt, |
uint8_t * | buf, | ||
size_t | buf_len ) |
Decode a semi-encoded CATS packet.
pkt | Packet to decode into |
buf | Input buffer |
buf_len | Length of input buffer |
CATS_SUCCESS
on success, CATS_FAIL
on failurepkt
MUST be prepared before calling this function uint16_t cats_packet_semi_encode | ( | const cats_packet_t * | pkt, |
uint8_t * | out ) |
Semi-encode a CATS packet; only pass through the Whisker and CRC portion of the CATS pipeline. Used for FELINET and radio interfacing.
out | Output buffer |
out
bool cats_packet_should_digipeat | ( | const cats_packet_t * | pkt, |
const char * | callsign, | ||
uint16_t | ssid ) |
Check if a packet should be digipeated.
pkt | Packet to check |
callsign | Local Callsign |
ssid | Local SSID |
true
if the packet should be digipeated, false
otherwise