-
Notifications
You must be signed in to change notification settings - Fork 1
/
radar.h
152 lines (123 loc) · 5.33 KB
/
radar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* radar.h -- a definition for ADS-B receiving stations ("radar")
* Author: Michael J. Tubby B.Sc. MIET [email protected]
*/
#ifndef _RADAR_H
#define _RADAR_H
#include <stdint.h>
#include "defs.h"
#include "stats.h"
#include "telemetry.h"
#include "authtag.h"
#define RADAR_PORT 5997
#define RADAR_PROTOCOL_NONE 0
#define RADAR_PROTOCOL_BEAST_TCP 1
#define RADAR_PROTOCOL_AVR 2
#define RADAR_PROTOCOL_BEAST_SERIAL 3
#define RADAR_PROTOCOL_GNS_SERIAL 4
#define RADAR_OPCODE_RESERVED 0x00
#define RADAR_OPCODE_MODE_AC 0x01
#define RADAR_OPCODE_MODE_S 0x02
#define RADAR_OPCODE_MODE_ES 0x03
#define RADAR_OPCODE_MODE_ES_MULTIFRAME 0x20
#define RADAR_OPCODE_KEEPALIVE 0x80
#define RADAR_OPCODE_SYSTEM_TELEMETRY 0x81
#define RADAR_OPCODE_RADIO_STATS 0x82
#define RADAR_OPCODE_CONFIG_REQ 0xC1
#define RADAR_OPCODE_CONGIG_ACK 0xC2
extern int protocol;
typedef struct {
uint8_t mlat[MLAT_LEN]; /* Multi-lateration timestamp */
uint8_t rssi; /* Received signal strength indication */
uint8_t data[MODE_ES_LEN]; /* data */
} __attribute__((packed)) mode_es_frame_t;
/*
* radar message type: Generic message (header)
*/
typedef struct {
uint64_t key; /* API key for this radar station */
uint64_t ts; /* Timestamp (uS) */
uint32_t seq; /* Message sequence number */
uint8_t opcode; /* opcode - message type */
uint8_t data[]; /* variable length data */
} __attribute__((packed)) radar_msg_t;
/*
* radar message type: Mode-A/C ident/altitude (2 bytes)
*/
typedef struct {
uint64_t key; /* API key for this radar station */
uint64_t ts; /* Timestamp (uS) */
uint32_t seq; /* Message sequence number */
uint8_t opcode; /* Opcode: message type */
uint8_t mlat[MLAT_LEN]; /* Multi-lateration timestamp */
uint8_t rssi; /* Received signal strength indication */
uint8_t data[MODE_AC_LEN]; /* data */
uint8_t atag[AUTHTAG_LEN]; /* Authentication tag */
} __attribute__((packed)) radar_mode_ac_t;
/*
* radar message type: Mode-S Short Squitter (7 bytes)
*/
typedef struct {
uint64_t key; /* API key for this radar station */
uint64_t ts; /* Timestamp (uS) */
uint32_t seq; /* Message sequence number */
uint8_t opcode; /* Opcode: message type */
uint8_t mlat[MLAT_LEN]; /* Multi-lateration timestamp */
uint8_t rssi; /* Received signal strength indication */
uint8_t data[MODE_SS_LEN]; /* data */
uint8_t atag[AUTHTAG_LEN]; /* Authentication tag */
} __attribute__((packed)) radar_mode_ss_t;
/*
* radar message type: Mode-S Extended Squitter (14 bytes)
*/
typedef struct {
uint64_t key; /* API key for this radar station */
uint64_t ts; /* Message timestamp (uS) */
uint32_t seq; /* Message sequence number */
uint8_t opcode; /* Opcode: message type */
uint8_t mlat[MLAT_LEN]; /* Multi-lateration timestamp */
uint8_t rssi; /* Received signal strength indication */
uint8_t data[MODE_ES_LEN]; /* data */
uint8_t atag[AUTHTAG_LEN]; /* Authentication tag */
} __attribute__((packed)) radar_mode_es_t;
/*
* radar message type: keepalive for when there is no data
*/
typedef struct {
uint64_t key; /* API key for this radar station */
uint64_t ts; /* Timestamp (uS) */
uint32_t seq; /* Message sequence number */
uint8_t opcode; /* Opcode: message type */
uint8_t data[10];
uint8_t atag[AUTHTAG_LEN]; /* Authentication tag */
} __attribute__((packed)) radar_keepalive_t;
/*
* radar message type: stats - statistics about messages observed on the radio channel (see stats.c,h)
*/
typedef struct {
uint64_t key; /* API key for this radar station */
uint64_t ts; /* Timestamp (uS) */
uint32_t seq; /* Message sequence number */
uint8_t opcode; /* Opcode: message type */
stats_t stats; /* Radar (radio channel) statistics */
uint8_t atag[AUTHTAG_LEN]; /* Authentication tag */
} __attribute__((packed)) radar_stats_t;
/*
* radar message type: telemetry about operation of the receiver system (see telemetry.c,h)
*/
typedef struct {
uint64_t key; /* API key for this radar station */
uint64_t ts; /* Timestamp (uS) */
uint32_t seq; /* Message sequence number */
uint8_t opcode; /* Opcode: message type */
telemetry_t telemetry; /* Receiver platform telemetry */
uint8_t atag[AUTHTAG_LEN]; /* Authentication tag */
} __attribute__((packed)) radar_telemetry_t;
/*
* external functions
*/
void radar_process(uint8_t mlat[MLAT_LEN], uint8_t rssi, uint8_t *buf, int size);
void radar_send_keepalive(void);
void radar_send_stats(void);
void radar_send_telemetry(void);
#endif