author | korovkin <korovkin> | 2006-03-19 14:54:05 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-03-19 14:54:05 (UTC) |
commit | 4c59235642953b2b1d2a07b47313540e85fa5f6a (patch) (side-by-side diff) | |
tree | a3e44c15846f9d6cae59e3053f05952ff40475f6 | |
parent | 700faa72b7e849db91ea4274531d9555161bf24c (diff) | |
download | opie-4c59235642953b2b1d2a07b47313540e85fa5f6a.zip opie-4c59235642953b2b1d2a07b47313540e85fa5f6a.tar.gz opie-4c59235642953b2b1d2a07b47313540e85fa5f6a.tar.bz2 |
Added connect command to rfcomm.
Added timeout.
-rw-r--r-- | noncore/net/opietooth/manager/rfcommhelper.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/noncore/net/opietooth/manager/rfcommhelper.cpp b/noncore/net/opietooth/manager/rfcommhelper.cpp index 0769da2..36e9086 100644 --- a/noncore/net/opietooth/manager/rfcommhelper.cpp +++ b/noncore/net/opietooth/manager/rfcommhelper.cpp @@ -44,8 +44,6 @@ void RfCommHelper::detach() { bool RfCommHelper::attach( const QString& bd_addr, int port ) { - int i =0; + int i = 0; bool ok = false; - while (!ok ) { - if (i == 4) break; + for (i = 0; i < 5 && !ok; i++) { ok = connect( i, bd_addr, port ); - i++; } @@ -85,3 +83,3 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) { sprintf( dev, "%d", devi ); - execlp( "rfcomm", "rfcomm", dev, bdaddr.latin1(), por, NULL ); + execlp( "rfcomm", "rfcomm", "connect", dev, bdaddr.latin1(), por, NULL ); char resultByte = 1; @@ -115,3 +113,2 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) { continue; // the other process is not yet ready? - break; @@ -129,5 +126,7 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) { timeout.tv_usec = 0; - + printf("do select\n"); sel = select( m_in2out[0]+1, &fds, NULL, NULL, &timeout ); - if ( sel ) + printf("Check select\n"); + if ( sel > 0) + { if (FD_ISSET(m_in2out[0], &fds ) ) { @@ -136,4 +135,6 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) { buf[0] = 0; + printf("read output\n"); len = read( m_in2out[0], buf, sizeof(buf) ); if ( len > 0 ) { + printf("%s", buf); QCString string( buf ); @@ -146,7 +147,7 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) { // now parese it - }else {// time out - // 5 seconds without input check terminate? - // - ; } + } else {// time out + terminate = true; + printf("terminate\n"); + } } |