-
Notifications
You must be signed in to change notification settings - Fork 204
/
SoftRF.h
251 lines (212 loc) · 6.02 KB
/
SoftRF.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
* SoftRF.h
* Copyright (C) 2016-2021 Linar Yusupov
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http:https://www.gnu.org/licenses/>.
*/
#ifndef SOFTRF_H
#define SOFTRF_H
#if defined(ARDUINO)
#include <Arduino.h>
#endif /* ARDUINO */
#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
#include <TimeLib.h>
#endif /* ENERGIA_ARCH_CC13XX || ENERGIA_ARCH_CC13X2 */
#if defined(RASPBERRY_PI)
#include <raspi/raspi.h>
#endif /* RASPBERRY_PI */
#define SOFTRF_FIRMWARE_VERSION "1.0-rc9"
#define SOFTRF_IDENT "SoftRF-"
#define ENTRY_EXPIRATION_TIME 10 /* seconds */
#define LED_EXPIRATION_TIME 5 /* seconds */
#define EXPORT_EXPIRATION_TIME 5 /* seconds */
/*
* If you need for SoftRF to operate in wireless
* client mode - specify your local AP's SSID/PSK:
*
* #define MY_ACCESSPOINT_SSID "My_AP_SSID"
* #define MY_ACCESSPOINT_PSK "My_AP_PSK"
*
* If SoftRF's built-in AP is not stable enough for you, consider
* to use "reverse" operation when your smartphone is acting
* as an AP for the SoftRF unit as a client:
*
* #define MY_ACCESSPOINT_SSID "AndroidAP"
* #define MY_ACCESSPOINT_PSK "12345678"
*/
// Default mode is AP with
// SSID: SoftRF-XXXXXX
// KEY: 12345678
// IP: 192.168.1.1
// NETMASK: 255.255.255.0
#define MY_ACCESSPOINT_SSID ""
#define MY_ACCESSPOINT_PSK ""
#define RELAY_DST_PORT 12390
#define RELAY_SRC_PORT (RELAY_DST_PORT - 1)
#define GDL90_DST_PORT 4000
#define NMEA_UDP_PORT 10110
#define NMEA_TCP_PORT 2000
/*
* Serial I/O default values.
* Can be overridden by platfrom-specific code.
*/
#if !defined(SERIAL_IN_BR)
/*
* 9600 is default value of NMEA baud rate
* for most of GNSS modules
* being used in SoftRF project
*/
#define SERIAL_IN_BR 9600
#endif
#if !defined(SERIAL_IN_BITS)
#define SERIAL_IN_BITS SERIAL_8N1
#endif
/*
* 38400 is known as maximum baud rate
* that HC-05 Bluetooth module
* can handle without symbols loss.
*
* Applicable for Standalone Edition. Inherited by most of other SoftRF platforms.
*/
#define STD_OUT_BR 38400
#define STD_OUT_BITS SERIAL_8N1
#if !defined(SERIAL_OUT_BR)
#define SERIAL_OUT_BR STD_OUT_BR
#endif
#if !defined(SERIAL_OUT_BITS)
#define SERIAL_OUT_BITS STD_OUT_BITS
#endif
#define UAT_RECEIVER_BR 2000000
#if defined(PREMIUM_PACKAGE) && !defined(RASPBERRY_PI)
#define ENABLE_AHRS
#endif /* PREMIUM_PACKAGE */
typedef struct UFO {
uint8_t raw[34];
time_t timestamp;
uint8_t protocol;
uint32_t addr;
uint8_t addr_type;
float latitude;
float longitude;
float altitude;
float pressure_altitude;
float course; /* CoG */
float speed; /* ground speed in knots */
uint8_t aircraft_type;
float vs; /* feet per minute */
bool stealth;
bool no_track;
int8_t ns[4];
int8_t ew[4];
float geoid_separation; /* metres */
uint16_t hdop; /* cm */
int8_t rssi; /* SX1276 only */
/* 'legacy' specific data */
float distance;
float bearing;
int8_t alarm_level;
/* bitmap of issued voice/tone/ble/... alerts */
uint8_t alert;
/* ADS-B (ES, UAT, GDL90) specific data */
uint8_t callsign[8];
} ufo_t;
typedef struct hardware_info {
byte model;
byte revision;
byte soc;
byte rf;
byte gnss;
byte baro;
byte display;
#if defined(ENABLE_AHRS)
byte ahrs;
#endif /* ENABLE_AHRS */
} hardware_info_t;
typedef struct IODev_ops_struct {
const char name[16];
void (*setup)();
void (*loop)();
void (*fini)();
int (*available)(void);
int (*read)(void);
size_t (*write)(const uint8_t *buffer, size_t size);
} IODev_ops_t;
enum
{
SOFTRF_MODE_NORMAL,
SOFTRF_MODE_WATCHOUT,
SOFTRF_MODE_BRIDGE,
SOFTRF_MODE_RELAY,
SOFTRF_MODE_TXRX_TEST,
SOFTRF_MODE_LOOPBACK,
SOFTRF_MODE_UAV,
SOFTRF_MODE_RECEIVER
};
enum
{
SOFTRF_MODEL_STANDALONE,
SOFTRF_MODEL_PRIME,
SOFTRF_MODEL_UAV,
SOFTRF_MODEL_PRIME_MK2,
SOFTRF_MODEL_RASPBERRY,
SOFTRF_MODEL_UAT,
SOFTRF_MODEL_SKYVIEW,
SOFTRF_MODEL_RETRO,
SOFTRF_MODEL_SKYWATCH,
SOFTRF_MODEL_DONGLE,
SOFTRF_MODEL_MULTI,
SOFTRF_MODEL_UNI,
SOFTRF_MODEL_MINI,
SOFTRF_MODEL_BADGE
};
enum
{
SOFTRF_SHUTDOWN_NONE,
SOFTRF_SHUTDOWN_DEFAULT,
SOFTRF_SHUTDOWN_DEBUG,
SOFTRF_SHUTDOWN_ABORT,
SOFTRF_SHUTDOWN_WATCHDOG,
SOFTRF_SHUTDOWN_NMEA,
SOFTRF_SHUTDOWN_BUTTON,
SOFTRF_SHUTDOWN_LOWBAT,
SOFTRF_SHUTDOWN_SENSOR
};
static inline uint32_t DevID_Mapper(uint32_t id)
{
/* remap address to avoid overlapping with congested FLARM range */
if (((id & 0x00FFFFFF) >= 0xDD0000) && ((id & 0x00FFFFFF) <= 0xDFFFFF)) {
id += 0x100000;
}
return id;
}
extern ufo_t ThisAircraft;
extern hardware_info_t hw_info;
extern const float txrx_test_positions[90][2] PROGMEM;
extern void shutdown(int);
#define TXRX_TEST_NUM_POSITIONS (sizeof(txrx_test_positions) / sizeof(float) / 2)
#define TXRX_TEST_ALTITUDE 438.0
#define TXRX_TEST_COURSE 280.0
#define TXRX_TEST_SPEED 50.0
#define TXRX_TEST_VS -300.0
//#define ENABLE_TTN
//#define ENABLE_BT_VOICE
//#define TEST_PAW_ON_NICERF_SV610_FW466
#define DO_GDL90_FF_EXT
#define LOGGER_IS_ENABLED 0
#if LOGGER_IS_ENABLED
#define StdOut LogFile
#else
#define StdOut Serial
#endif /* LOGGER_IS_ENABLED */
#endif /* SOFTRF_H */