-
Notifications
You must be signed in to change notification settings - Fork 204
/
SoftRF.h
208 lines (176 loc) · 5.05 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
/*
* SoftRF.h
* Copyright (C) 2016-2019 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)
#include <TimeLib.h>
#endif /* ENERGIA_ARCH_CC13XX */
#if defined(RASPBERRY_PI)
#include <raspi/raspi.h>
#endif /* RASPBERRY_PI */
#define SOFTRF_FIRMWARE_VERSION "1.0-rc7"
#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
#if !defined(SERIAL_OUT_BR)
/*
* 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 SERIAL_OUT_BR 38400
#endif
#if !defined(SERIAL_OUT_BITS)
#define SERIAL_OUT_BITS SERIAL_8N1
#endif
#define UAT_BOOT_BR 9600
#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;
/* 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;
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
};
extern ufo_t ThisAircraft;
extern hardware_info_t hw_info;
extern const float txrx_test_positions[90][2] PROGMEM;
extern void shutdown(const char *);
#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 */