forked from PiInTheSky/lora-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.h
148 lines (123 loc) · 3.25 KB
/
global.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
#include <curses.h>
#define RUNNING 1 // The main program is running
#define STOPPED 0 // The main program has stopped
#define MAX_PAYLOADS 32
struct TPayload
{
int InUse;
int Channel;
time_t LastPacketAt;
char Telemetry[256];
char Payload[32];
char Time[12];
unsigned int Counter, LastCounter;
double Longitude, Latitude;
unsigned int Altitude, PreviousAltitude;
float AscentRate;
unsigned long LastPositionAt;
}; struct TLoRaDevice {
double Frequency;
double Bandwidth;
double CurrentBandwidth;
int InUse; int DIO0; int DIO5; double activeFreq;
int AFC; // Enable Automatic Frequency Control
double MaxAFCStep; // Maximum adjustment, in kHz, per packet
int AFCTimeout; // Revert to original frequency if no packets for this period (in seconds)
int SpeedMode;
int Power;
int PayloadLength;
int ImplicitOrExplicit;
int ErrorCoding;
int SpreadingFactor;
int LowDataRateOptimize;
WINDOW * Window;
unsigned int TelemetryCount, SSDVCount, BadCRCCount, UnknownCount;
int Sending;
// unsigned long Seconds;
// double PredictedLongitude, PredictedLatitude;
// unsigned int Satellites;
time_t LastSSDVPacketAt, LastTelemetryPacketAt;
time_t ReturnToCallingModeAt;
time_t ReturnToOriginalFrequencyAt;
int InCallingMode;
int ActivityLED;
double UplinkFrequency;
int UplinkMode;
// Normal (non TDM) uplink
int UplinkTime;
int UplinkCycle;
int IdleUplink;
int SSDVUplink;
char UplinkMessage[256];
// Telnet uplink
char Telemetry[256];
unsigned char PacketID;
int TimeSinceLastTx;
int HABAck; // Received message ACKd our last Tx
int HABConnected; // 1 if HAB has telnet connection
char ToTelnetBuffer[256]; // Buffer for data Telnet --> LoRa
int ToTelnetBufferCount;
char FromTelnetBuffer[256]; // Buffer for data LoRa --> Telnet
int FromTelnetBufferCount;
char HABUplink[256];
int HABUplinkCount;
int GotHABReply;
int GotReply;
};
struct TConfig { char Tracker[16]; // Callsign or name of receiver
double latitude, longitude; // Receiver's location
int EnableHabitat;
int EnableSSDV;
int EnableTelemetryLogging;
int EnablePacketLogging;
int CallingTimeout;
char SSDVJpegFolder[100];
char ftpServer[100];
char ftpUser[32];
char ftpPassword[32];
char ftpFolder[64];
struct TLoRaDevice LoRaDevices[2];
struct TPayload Payloads[MAX_PAYLOADS];
int NetworkLED;
int InternetLED;
int ServerPort; // JSON port for telemetry, settings
int HABPort; // Telnet style port for comms with HAB
int HABTimeout; // Timeout in ms for telnet uplink
int HABChannel; // LoRa Channel for uplink
char SMSFolder[64];
char antenna[64];
int EnableDev;
char UplinkCode[64];
};
typedef struct {
int parent_status;
unsigned long packet_count;
} thread_shared_vars_t;
typedef struct {
short int Channel;
char Telemetry[257];
int Packet_Number;
} telemetry_t;
typedef struct {
short int Channel;
char SSDV_Packet[257];
int Packet_Number;
} ssdv_t;
struct TServerInfo
{
int Port;
int Connected;
int ServerIndex;
int sockfd;
};
extern struct TConfig Config;
extern int SSDVSendArrayIndex;
extern pthread_mutex_t ssdv_mutex;
void LogMessage( const char *format, ... );