00001 #ifndef OTDEVICE_H 00002 #define OTDEVICE_H 00003 00004 #include <qobject.h> 00005 #include <qstring.h> 00006 00007 #include <bluezlib.h> 00008 00009 #include <OTGateway.h> 00010 00011 // define if you want to use the process hciattach for detection 00012 // #define USEHCIPROC 00013 00014 class QTimerEvent; 00015 00016 namespace Opie { 00017 namespace Core { 00018 class OProcess; 00019 } 00020 } 00021 00022 namespace Opietooth2 { 00023 00029 class OTDevice : public QObject { 00030 00031 Q_OBJECT 00032 00033 public: 00034 00041 OTDevice( OTGateway * _OT ); 00042 00046 ~OTDevice(); 00047 00048 inline OTGateway * gateway() const 00049 { return OT; } 00050 00051 inline bool needsAttach( void ) const 00052 { return NeedsAttach; } 00053 00054 inline int deviceNr() const 00055 { return m_deviceNr; } 00056 00061 bool attach(); 00062 00067 bool detach(); 00068 00073 bool isAttached()const; 00074 00075 // check current state of attachment 00076 bool checkAttach(); 00077 00078 // returns pattern that points to the proper 00079 // RFCOMM device file. Put %1 where device nr should be put 00080 // e.g. : /dev/bluetooth/rfcomm/%1 or /def/rfcomm%1 00081 QString getRFCommDevicePattern(); 00082 00083 signals: 00084 00090 void error( const QString & mesg ); 00091 void isEnabled( int devnr, bool ); 00092 00093 private slots: 00094 00095 void slotStdOut(Opie::Core::OProcess*, char*, int ); 00096 void slotStdErr(Opie::Core::OProcess*, char*, int ); 00097 00098 private: 00099 00100 void detectDeviceType( QString & Device, 00101 QString & Mode, 00102 unsigned long & Speed ); 00103 pid_t getPidOfHCIAttach( void ); 00104 00105 Opie::Core::OProcess* m_hciattach; // ptr to hciattach proces 00106 00107 int m_deviceNr; // x as in hci(x) 00108 pid_t m_hciattachPid; // pid of hciattach program 00109 00110 // backpointer 00111 OTGateway * OT; 00112 bool NeedsAttach; 00113 }; 00114 } 00115 00116 #endif
1.4.2