-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLttoComms.h
More file actions
134 lines (104 loc) · 5.15 KB
/
LttoComms.h
File metadata and controls
134 lines (104 loc) · 5.15 KB
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
#ifndef LTTOCOMMS_H
#define LTTOCOMMS_H
#include <QObject>
#include <QTimer>
#include "Defines.h"
#include "LazerSwarm.h"
#include "SerialUSBcomms.h"
#include "TCPComms.h"
class LttoComms : public QObject
{
Q_OBJECT
private:
explicit LttoComms(QObject *parent = nullptr);
static LttoComms *instance;
public:
static LttoComms *getInstance();
void initialise();
bool getConnectionStatus();
bool checkIPaddress();
bool sendPacket(char type, int data = 0, bool dataFormat = false);
void sendLCDtext(QString textToSend, int lineNumber, bool drawScreen);
void sendLCDtext(int xCursor, int yCursor, QString text, int fontSize, int colour, bool clearDisp, bool drawDisplay);
void sendLEDcolour(int Red = 0, int Green = 0, int Blue = 0);
void sendLEDcolour(QString colour);
void sendOTAtext(QString ssidText, QString pswdText);
void sendPing(QString pingText);
void sendHeartBeat();
void sendEspRestart();
void sendDisconnectClient();
void sendGetFirmwareVersion();
bool getUseLazerSwarm() const;
void setUseLazerSwarm(bool value);
bool getDontAnnounceGame() const;
void setDontAnnounceGame(bool value);
int getMissedAnnounceCount() const;
void setMissedAnnounceCount(int value);
void androidRxPacket(QByteArray data);
bool getTcpCommsConnected() const;
// void setTcpCommsConnected(bool value);
bool getDontAnnounceFailedSignal() const;
void setDontAnnounceFailedSignal(bool value);
void nonBlockingDelay(int mSec);
bool getIsUSBinitialised() const;
void setIsUSBinitialised(bool value);
int ConvertDecToBCD(int dec);
int ConvertBCDtoDec(int bcd);
bool getSerialUSBcommsConnected() const;
// void setSerialUSBcommsConnected(bool value);
bool getUseLongDataPacketsOverTCP() const;
void setUseLongDataPacketsOverTCP(bool value);
void closePorts();
int getCurrentTaggerBeingHosted() const;
void setCurrentTaggerBeingHosted(int value);
bool getHostingCommsActive() const;
void setHostingCommsActive(bool value);
public slots:
void setTcpCommsConnected(bool value);
signals:
void RequestJoinGame(int Game, int Tagger, int Flags, bool isLtar);
void AckPlayerAssignment(int Game, int Tagger, bool isLtar);
void TimerBlock(bool StartStop);
void sendSerialData(QByteArray dataToSend);
void TagSummaryReceived(int game, int teamAndPlayer, int tagsTaken, int survivedMinutes, int survivedSeconds, int zoneTimeMinutes, int zoneTimeSeconds, int flags);
void Team1TagReportReceived(int game, int teamAndPlayer, int tagsReceivedfromPlayer[]);
void Team1TagReportReceived(int game, int teamAndPlayer, int tagsP1, int tagsP2, int tagsP3, int tagsP4, int tagsP5, int tagsP6, int tagsP7, int tagsP8);
void Team2TagReportReceived(int game, int teamAndPlayer, int tagsP1, int tagsP2, int tagsP3, int tagsP4, int tagsP5, int tagsP6, int tagsP7, int tagsP8);
void Team3TagReportReceived(int game, int teamAndPlayer, int tagsP1, int tagsP2, int tagsP3, int tagsP4, int tagsP5, int tagsP6, int tagsP7, int tagsP8);
void BeaconReceived(int beaconData);
void PongReceived(QString pongText);
void OtaReceived(QString response);
void HbAckReceived(QString response);
void BattVoltsReceived(QString battVolts);
void FirmwareVersionReceived(QString firmwareVersion);
private slots:
void receivePacket(QByteArray RxData);
private:
int calculatedCheckSumTx;
int calculatedCheckSumRx;
int currentTaggerBeingHosted;
QByteArray irDataIn;
QByteArrayList rxPacketList;
QString packetString;
bool useLazerSwarm;
bool dontAnnounceGame;
bool dontAnnounceFailedSignal;
bool tcpCommsConnected;
bool serialUSBcommsConnected;
int missedAnnounceCount;
bool useLongDataPacketsOverTCP;
bool hostingCommsActive; //the HostGameWindow is open and sending regular messages (used to disable heartbeat).
// int tagsReceivedfromPlayer[8];
TCPComms *tcpComms;
SerialUSBcomms *serialUSBcomms;
LazerSwarm *lazerSwarm;
void processPacket(QList<QByteArray> data);
int extract(QList<QByteArray> &data);
void findSerialPort();
bool isCheckSumCorrect(int _command, int _game, int _tagger, int _flags, int _checksum);
bool isCheckSumCorrect(int _command, int _game, int _tagger, int _taggerInfo, int _smartDeviceInfo, int _checksum);
bool isCheckSumCorrect(int _command, int _game, int _tagsTaken, int _teamAndPlayer, int _survivedMinutes, int _survivedSeconds, int _zoneTimeMinutes, int _zoneTimeSeconds, int _flags, int _checksum);
bool isCheckSumCorrect(int _command, int _game, int _teamAndPlayer, int _playersInReportByte, int _tagsP1, int _tagsP2, int _tagsP3, int _tagsP4, int _tagsP5, int _tagsP6, int _tagsP7, int _tagsP8, int _checksum);
QString createIRstring(int data);
};
#endif // LTTOCOMMS_H