libCATS
Loading...
Searching...
No Matches
packet.h
Go to the documentation of this file.
1
6#ifndef CATS_PACKET_H
7#define CATS_PACKET_H
8
9#include "whisker.h"
10
11#include <stdint.h>
12#include <stddef.h>
13#include <stdbool.h>
14
15#define CATS_MAX_PKT_LEN 8191
16
21typedef struct cats_packet_t {
22 uint8_t len;
23 uint8_t numWhiskers;
24 cats_whisker_t* whiskers;
26
36
44
51uint16_t cats_packet_semi_encode(const cats_packet_t* pkt, uint8_t* out);
52
59uint16_t cats_packet_encode(const cats_packet_t* pkt, uint8_t* out);
60
71int cats_packet_semi_decode(cats_packet_t* pkt, uint8_t* buf, size_t buf_len);
72
83int cats_packet_decode(cats_packet_t* pkt, uint8_t* buf, size_t buf_len);
84
94int cats_packet_add_identification(cats_packet_t* pkt, const char* callsign, uint8_t ssid, uint16_t icon);
95
103int cats_packet_add_comment(cats_packet_t* pkt, const char* comment);
104
117int cats_packet_add_gps(cats_packet_t* pkt, double lat, double lon, float alt, uint8_t error, uint8_t heading, float speed);
118
127
137int cats_packet_add_destination(cats_packet_t* pkt, const char* callsign, uint8_t ssid, uint8_t ack);
138
148int cats_packet_add_simplex(cats_packet_t* pkt, uint32_t frequency, cats_modulation_t modulation, uint8_t power);
149
164int 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);
165
174
183int cats_packet_add_arbitrary(cats_packet_t* pkt, const uint8_t* data, size_t len);
184
194int cats_packet_add_whisker_data(cats_packet_t* pkt, cats_whisker_type_t type, const cats_whisker_data_t* whisker_data, int len);
195
206
214int cats_packet_add_timestamp(cats_packet_t* pkt, uint64_t timestamp);
215
224
232int cats_packet_get_comment(const cats_packet_t* pkt, char* out);
233
242
251
260
269
278
287
295uint64_t cats_packet_get_timestamp(const cats_packet_t* pkt);
296
305
314int cats_packet_find_whiskers(const cats_packet_t* pkt, cats_whisker_type_t type, cats_whisker_t*** out);
315
324bool cats_packet_should_digipeat(const cats_packet_t* pkt, const char* callsign, uint16_t ssid);
325
326#endif // CATS_PACKET_H
int cats_packet_add_timestamp(cats_packet_t *pkt, uint64_t timestamp)
Add a timestamp to a packet.
Definition timestamp.c:34
uint64_t cats_packet_get_timestamp(const cats_packet_t *pkt)
Get the timestamp from a packet.
Definition timestamp.c:17
int cats_packet_add_route(cats_packet_t *pkt, cats_route_whisker_t route)
Add a route whisker to a packet.
Definition route.c:189
int cats_packet_add_arbitrary(cats_packet_t *pkt, const uint8_t *data, size_t len)
Add arbitrary data to a packet.
Definition arbitrary.c:19
int cats_packet_destroy(cats_packet_t **pkt)
Deinitialize a packet.
Definition packet.c:29
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.
Definition destination.c:54
int cats_packet_get_destination(const cats_packet_t *pkt, cats_destination_whisker_t ***out)
Get the destination whisker from a packet.
Definition destination.c:32
int cats_packet_get_repeater(const cats_packet_t *pkt, cats_repeater_whisker_t ***out)
Get the repeater whisker from a packet.
Definition repeater.c:62
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.
Definition packet.c:183
int cats_packet_get_route(const cats_packet_t *pkt, cats_route_whisker_t **out)
Get the route whisker from a packet.
Definition route.c:172
int cats_packet_get_arbitrary(const cats_packet_t *pkt, cats_whisker_t ***out)
Get arbitrary whiskers from a packet.
Definition arbitrary.c:8
int cats_packet_add_comment(cats_packet_t *pkt, const char *comment)
Add a comment whisker to a packet.
Definition comment.c:36
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.
Definition packet.c:147
bool cats_packet_should_digipeat(const cats_packet_t *pkt, const char *callsign, uint16_t ssid)
Check if a packet should be digipeated.
Definition packet.c:221
uint16_t cats_packet_encode(const cats_packet_t *pkt, uint8_t *out)
Encode a CATS packet.
Definition packet.c:76
int cats_packet_get_gps(const cats_packet_t *pkt, cats_gps_whisker_t **out)
Get the GPS whisker from a packet.
Definition gps.c:57
int cats_packet_get_comment(const cats_packet_t *pkt, char *out)
Get the comment whisker from a packet.
Definition comment.c:9
int cats_packet_get_identification(const cats_packet_t *pkt, cats_ident_whisker_t **out)
Get the identification whisker from a packet.
Definition identification.c:32
int cats_packet_get_simplex(const cats_packet_t *pkt, cats_simplex_whisker_t ***out)
Get the simplex whisker from a packet.
Definition simplex.c:33
int cats_packet_add_whisker(cats_packet_t *pkt, const cats_whisker_t *whisker)
Add a whisker to a packet.
Definition packet.c:157
int cats_packet_add_nodeinfo(cats_packet_t *pkt, cats_nodeinfo_whisker_t info)
Add a nodeinfo whisker to a packet.
Definition nodeinfo.c:172
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.
Definition gps.c:74
struct cats_packet_t cats_packet_t
CATS packet structure.
int cats_packet_decode(cats_packet_t *pkt, uint8_t *buf, size_t buf_len)
Decode a CATS packet.
Definition packet.c:123
int cats_packet_prepare(cats_packet_t **pkt)
Initialize a cats_packet_t pointer.
Definition packet.c:15
int cats_packet_get_nodeinfo(const cats_packet_t *pkt, cats_nodeinfo_whisker_t **out)
Get the nodeinfo whisker from a packet.
Definition nodeinfo.c:156
int cats_packet_semi_decode(cats_packet_t *pkt, uint8_t *buf, size_t buf_len)
Decode a semi-encoded CATS packet.
Definition packet.c:95
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.
Definition simplex.c:55
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....
Definition packet.c:52
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.
Definition repeater.c:84
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.
Definition identification.c:48
Definition whisker.h:139
Definition whisker.h:115
Definition whisker.h:109
Definition whisker.h:162
CATS packet structure.
Definition packet.h:21
Definition whisker.h:151
Definition whisker.h:132
Definition whisker.h:145
Definition whisker.h:190
Definition whisker.h:179
Whisker handling.