XbeeLink.h 1.85 KB
Newer Older
Franz's avatar
Franz committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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
akistanov's avatar
akistanov committed
23
	QString getPortName() const;
24
	void requestReset() { }
akistanov's avatar
akistanov committed
25
	int getBaudRate() const;
26
27
28
29
30
    
    // These are left unimplemented in order to cause linker errors which indicate incorrect usage of
    // connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
    bool connect(void);
    bool disconnect(void);
Franz's avatar
Franz committed
31
32
33
34

public slots: // virtual functions from XbeeLinkInterface
	bool setPortName(QString portName);
	bool setBaudRate(int rate);
oberion's avatar
oberion committed
35
36
	bool setRemoteAddressHigh(quint32 high);
	bool setRemoteAddressLow(quint32 low);
Franz's avatar
Franz committed
37

38
39
public:
    // virtual functions from LinkInterface
40
41
    QString getName() const;
    bool isConnected() const;
Franz's avatar
Franz committed
42

43
44
45
46
47
    // Extensive statistics for scientific purposes
    qint64 getConnectionSpeed() const;
    qint64 getCurrentOutDataRate() const;
    qint64 getCurrentInDataRate() const;

48
private slots: // virtual functions from LinkInterface
49
	void _writeBytes(const QByteArray bytes);
Franz's avatar
Franz committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63

protected slots: // virtual functions from LinkInterface
	void readBytes();

public:
	void run(); // initiating the thread

protected:
	xbee_con *m_xbeeCon;
	char *m_portName;
	unsigned int m_portNameLength;
	int m_baudRate;
	bool m_connected;
	QString m_name;
oberion's avatar
oberion committed
64
65
	quint32 m_addrHigh;
	quint32 m_addrLow;
Franz's avatar
Franz committed
66
67

private:
68
69
    // From LinkInterface
    virtual bool _connect(void);
Don Gagne's avatar
Don Gagne committed
70
    virtual void _disconnect(void);
71
72

    bool hardwareConnect();
Franz's avatar
Franz committed
73
74
75
76
	//void CALLTYPE portCallback(xbee_con *XbeeCon, xbee_pkt *XbeePkt);
};


77
#endif // _XBEELINK_H_