Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTDevice.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTDevice.h | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTDevice.h b/noncore/settings/networksettings2/opietooth2/OTDevice.h new file mode 100644 index 0000000..c2abb09 --- a/dev/null +++ b/noncore/settings/networksettings2/opietooth2/OTDevice.h | |||
@@ -0,0 +1,116 @@ | |||
1 | #ifndef OTDEVICE_H | ||
2 | #define OTDEVICE_H | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <qstring.h> | ||
6 | |||
7 | #include <bluezlib.h> | ||
8 | |||
9 | #include <OTGateway.h> | ||
10 | |||
11 | // define if you want to use the process hciattach for detection | ||
12 | // #define USEHCIPROC | ||
13 | |||
14 | class QTimerEvent; | ||
15 | |||
16 | namespace Opie { | ||
17 | namespace Core { | ||
18 | class OProcess; | ||
19 | } | ||
20 | } | ||
21 | |||
22 | namespace Opietooth2 { | ||
23 | |||
24 | /** | ||
25 | * Device takes care of attaching serial | ||
26 | * devices to the blueZ stack. | ||
27 | * After attaching it hciconfig ups it | ||
28 | */ | ||
29 | class OTDevice : public QObject { | ||
30 | |||
31 | Q_OBJECT | ||
32 | |||
33 | public: | ||
34 | |||
35 | /** | ||
36 | * Brings up the device. | ||
37 | * will detech which device is needed | ||
38 | * Usage example: new Device(/dev/ttySB0, csr) | ||
39 | * | ||
40 | */ | ||
41 | OTDevice( OTGateway * _OT ); | ||
42 | |||
43 | /** | ||
44 | * unloads the device | ||
45 | */ | ||
46 | ~OTDevice(); | ||
47 | |||
48 | inline OTGateway * gateway() const | ||
49 | { return OT; } | ||
50 | |||
51 | inline bool needsAttach( void ) const | ||
52 | { return NeedsAttach; } | ||
53 | |||
54 | inline int deviceNr() const | ||
55 | { return m_deviceNr; } | ||
56 | |||
57 | /** | ||
58 | * attach the device | ||
59 | * @return bool which is TRUE if command started sucessfully | ||
60 | */ | ||
61 | bool attach(); | ||
62 | |||
63 | /** | ||
64 | * detach the device | ||
65 | * @return bool which is TRUE if command started sucessfully | ||
66 | */ | ||
67 | bool detach(); | ||
68 | |||
69 | /** | ||
70 | * Is the device loaded? | ||
71 | * @return bool, if the device is loaded | ||
72 | */ | ||
73 | bool isAttached()const; | ||
74 | |||
75 | // check current state of attachment | ||
76 | bool checkAttach(); | ||
77 | |||
78 | // returns pattern that points to the proper | ||
79 | // RFCOMM device file. Put %1 where device nr should be put | ||
80 | // e.g. : /dev/bluetooth/rfcomm/%1 or /def/rfcomm%1 | ||
81 | QString getRFCommDevicePattern(); | ||
82 | |||
83 | signals: | ||
84 | |||
85 | /** | ||
86 | * Signals if the attach/detach of the device produced | ||
87 | * errors | ||
88 | * @param Mesg contains an error message | ||
89 | */ | ||
90 | void error( const QString & mesg ); | ||
91 | void isEnabled( int devnr, bool ); | ||
92 | |||
93 | private slots: | ||
94 | |||
95 | void slotStdOut(Opie::Core::OProcess*, char*, int ); | ||
96 | void slotStdErr(Opie::Core::OProcess*, char*, int ); | ||
97 | |||
98 | private: | ||
99 | |||
100 | void detectDeviceType( QString & Device, | ||
101 | QString & Mode, | ||
102 | unsigned long & Speed ); | ||
103 | pid_t getPidOfHCIAttach( void ); | ||
104 | |||
105 | Opie::Core::OProcess* m_hciattach; // ptr to hciattach proces | ||
106 | |||
107 | int m_deviceNr; // x as in hci(x) | ||
108 | pid_t m_hciattachPid; // pid of hciattach program | ||
109 | |||
110 | // backpointer | ||
111 | OTGateway * OT; | ||
112 | bool NeedsAttach; | ||
113 | }; | ||
114 | }; | ||
115 | |||
116 | #endif | ||