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
#ifndef _XBEELINK_H_
#define _XBEELINK_H_
#include <QObject>
#include <QString>
#include <qdebug.h>
#include <qmutex.h>
#include <qbytearray.h>
#include <list>
#include "XbeeLinkInterface.h"
#include <xbee.h>
#include "CallConv.h"
class XbeeLink : public XbeeLinkInterface
{
Q_OBJECT
public:
XbeeLink(QString portName = "", int baudRate=57600);
~XbeeLink();
public: // virtual functions from XbeeLinkInterface
QString getPortName() const;
void requestReset() { }
int getBaudRate() const;
public slots: // virtual functions from XbeeLinkInterface
bool setPortName(QString portName);
bool setBaudRate(int rate);
bool setRemoteAddressHigh(quint32 high);
bool setRemoteAddressLow(quint32 low);
public: // virtual functions from LinkInterface
int getId() const;
QString getName() const;
bool isConnected() const;
bool connect();
bool disconnect();
qint64 bytesAvailable();
// Extensive statistics for scientific purposes
qint64 getConnectionSpeed() const;
qint64 getCurrentOutDataRate() const;
qint64 getCurrentInDataRate() const;
public slots: // virtual functions from LinkInterface
void writeBytes(const char *bytes, qint64 length);
protected slots: // virtual functions from LinkInterface
void readBytes();
public:
void run(); // initiating the thread
protected:
xbee_con *m_xbeeCon;
int m_id;
char *m_portName;
unsigned int m_portNameLength;
int m_baudRate;
bool m_connected;
QString m_name;
quint32 m_addrHigh;
quint32 m_addrLow;
private:
bool hardwareConnect();
//void CALLTYPE portCallback(xbee_con *XbeeCon, xbee_pkt *XbeePkt);
};
#endif // _XBEELINK_H_