44 #include <QtNetwork/QUdpSocket>
46 class UAVTALK_EXPORT
UAVTalk :
public QObject
65 bool sendObject(
UAVObject *obj,
bool acked,
bool allInstances);
66 bool sendObjectRequest(
UAVObject *obj,
bool allInstances);
67 bool requestFile(quint32 fileId, quint32 offset);
80 void fileDataReceived(quint32 fileId, quint32 offset, quint8 *
data,
81 quint32 dataLen,
bool eof,
bool lastInSeq);
84 void processInputStream(
void);
88 static const int VER_MASK = 0x70;
89 static const int TYPE_MASK = 0x0f;
91 static const int TYPE_VER = 0x20;
92 static const int TYPE_OBJ = 0x00;
93 static const int TYPE_OBJ_REQ = 0x01;
94 static const int TYPE_OBJ_ACK = 0x02;
95 static const int TYPE_ACK = 0x03;
96 static const int TYPE_NACK = 0x04;
97 static const int TYPE_FILEREQ = 0x08;
98 static const int TYPE_FILEDATA = 0x09;
100 static const int MIN_HEADER_LENGTH = 8;
101 static const int MAX_HEADER_LENGTH = MIN_HEADER_LENGTH + 2;
103 static const int CHECKSUM_LENGTH = 1;
105 static const int MAX_PACKET_LENGTH = 256;
107 static const int MAX_PAYLOAD_LENGTH = (MAX_PACKET_LENGTH - CHECKSUM_LENGTH - MAX_HEADER_LENGTH);
109 static const quint16 ALL_INSTANCES = 0xFFFF;
110 static const quint16 OBJID_NOTFOUND = 0x0000;
112 static const int TX_BACKLOG_SIZE = 2 * 1024;
130 static const quint8 FILEDATA_FLAG_EOF = 0x01;
131 static const quint8 FILEDATA_FLAG_LAST = 0x02;
135 QPointer<QIODevice>
io;
141 quint8 rxBuffer[MAX_PACKET_LENGTH * 12];
142 quint8 txBuffer[MAX_PACKET_LENGTH];
152 bool objectTransaction(
UAVObject *obj, quint8 type,
bool allInstances);
153 bool receiveObject(quint8 type, quint32 objId, quint16 instId,
154 quint8 *
data, quint32 length);
155 bool receiveFileChunk(quint32 fileId, quint8 *
data, quint32 length);
156 UAVObject *updateObject(quint32 objId, quint16 instId, quint8 *
data);
157 bool transmitNack(quint32 objId);
158 bool transmitObject(
UAVObject *obj, quint8 type,
bool allInstances);
159 bool transmitSingleObject(
UAVObject *obj, quint8 type,
bool allInstances);
160 quint8 updateCRC(quint8
crc,
const quint8 *
data, qint32 length);
161 bool transmitFrame(quint32 length,
bool incrTxObj =
true);
UAVObjectManager * objMngr