Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OTHCISocket.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 /***************************************************************************
00003  *   Copyright (C) 2003 by Fred Schaettgen                                 *
00004  *   kdebluetooth@schaettgen.de                                            *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  ***************************************************************************/
00011 
00012 #ifndef OTHCISOCKET_H
00013 #define OTHCISOCKET_H
00014 
00015 #include <qobject.h>
00016 #include <qsocketnotifier.h>
00017 #include <qsocketdevice.h>
00018 #include <qguardedptr.h>
00019 
00020 class QSocket;
00021 
00022 namespace Opietooth2 {
00023 
00032 class OTDriver;
00033 
00034 class OTHCISocket : public QObject {
00035 
00036     Q_OBJECT
00037 
00038 public:
00039 
00040     OTHCISocket( OTDriver * ConnectTo );
00041     virtual ~OTHCISocket();
00042 
00046     virtual bool open();
00047 
00049     virtual void close();
00050 
00051     bool sendCommand( unsigned char ogf, 
00052                       unsigned short ocf,
00053                       QByteArray buf
00054                     );
00055     bool readStatus( unsigned char ogf, 
00056                      unsigned short ocf, 
00057                      int *status, 
00058                      int timeout_ms = 1000);
00059     
00068     /*bool readEvent(unsigned char &packetType,
00069                       unsigned char &eventCode, unsigned char &buflen,
00070                       char* paramBuf);*/
00071 
00072     enum Error { ErrSocket = 1 };
00073 
00075     void readEvent( void );
00076 
00078     int socket( void );
00079 
00080     inline QSocketDevice & socketDevice() 
00081       { return HCISocket; }
00082 
00083     inline OTDriver * driver() const
00084       { return Driver; }
00085 
00086 signals:
00087 
00088     void event( unsigned char eventCode, QByteArray buf);
00089     void error( QString message );
00090     void connectionClosed( );
00091 
00092 private:
00093 
00094     void updateStatus( const QByteArray& data );
00095 
00096     //QSocketDevice hciSocket;
00097     QGuardedPtr<QSocketNotifier> HCIReadNotifier;
00098     QSocketDevice                HCISocket;
00099     OTDriver *                   Driver ;
00100     
00101     bool                         BStatusSet;
00102     unsigned short               LastStatusOcf;
00103     unsigned char                LastStatusOgf;
00104     int                          LastStatus;
00105 
00106 private slots:
00107 
00108     void slotSocketActivated();
00109     void slotSocketError(int);
00110     void slotConnectionClosed();
00111 
00112 };
00113 
00114 }
00115 
00116 #endif

Generated on Sat Nov 5 16:17:55 2005 for OPIE by  doxygen 1.4.2