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

io_bt.cpp

Go to the documentation of this file.
00001 
00002 #include "io_bt.h"
00003 
00004 IOBt::IOBt( const Profile &config ) : IOSerial( config ) {
00005     m_attach = 0;
00006 }
00007 
00008 
00009 IOBt::~IOBt() {
00010     if ( m_attach ) {
00011         delete m_attach;
00012     }
00013 }
00014 
00015 
00016 void IOBt::close() {
00017 
00018     IOSerial::close();
00019     // still need error handling
00020     if ( m_attach ) {
00021         delete m_attach;
00022         m_attach = 0;
00023     }
00024 }
00025 
00026 bool IOBt::open() {
00027     bool ret = false;
00028 
00029     // only set up bt stuff if mac address was set, otherwise use the device set
00030     if ( !m_mac.isEmpty() ) {
00031 
00032         // now it should also be checked, if there is a connection to the device with that mac allready
00033         // hciattach here
00034         m_attach = new Opie::Core::OProcess();
00035         *m_attach << "hciattach /dev/ttyS2 any 57600";
00036 
00037         // then start hcid, then rcfomm handling (m_mac)
00038 
00039         connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ),
00040                  this, SLOT( slotExited(Opie::Core::OProcess*) ) );
00041 
00042         if ( m_attach->start() ) {
00043             ret = IOSerial::open();
00044         } else {
00045             delete m_attach;
00046             m_attach = 0;
00047         }
00048     } else {
00049         // directly to the normal serial
00050         // TODO: look first if the connection really exists. ( is set up )
00051 
00052         ret =IOSerial::open();
00053     }
00054     return ret;
00055 }
00056 
00057 void IOBt::reload( const Profile &config ) {
00058     m_device = config.readEntry("Device", BT_DEFAULT_DEVICE);
00059     m_mac = config.readEntry("Mac", BT_DEFAULT_MAC);
00060     m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD);
00061     m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY);
00062     m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS);
00063     m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS);
00064     m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW);
00065 }
00066 
00067 
00068 QString IOBt::identifier() const {
00069     return "bluetooth";
00070 }
00071 
00072 QString IOBt::name() const {
00073     return "BLuetooth IO Layer";
00074 }
00075 
00076 void IOBt::slotExited( Opie::Core::OProcess* proc ){
00077     close();
00078     delete proc;
00079 }

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