summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-03-19 14:54:05 (UTC)
committer korovkin <korovkin>2006-03-19 14:54:05 (UTC)
commit4c59235642953b2b1d2a07b47313540e85fa5f6a (patch) (unidiff)
treea3e44c15846f9d6cae59e3053f05952ff40475f6
parent700faa72b7e849db91ea4274531d9555161bf24c (diff)
downloadopie-4c59235642953b2b1d2a07b47313540e85fa5f6a.zip
opie-4c59235642953b2b1d2a07b47313540e85fa5f6a.tar.gz
opie-4c59235642953b2b1d2a07b47313540e85fa5f6a.tar.bz2
Added connect command to rfcomm.
Added timeout.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/rfcommhelper.cpp25
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() {
44bool RfCommHelper::attach( const QString& bd_addr, int port ) { 44bool RfCommHelper::attach( const QString& bd_addr, int port ) {
45 int i =0; 45 int i = 0;
46 bool ok = false; 46 bool ok = false;
47 while (!ok ) { 47 for (i = 0; i < 5 && !ok; i++) {
48 if (i == 4) break;
49 ok = connect( i, bd_addr, port ); 48 ok = connect( i, bd_addr, port );
50 i++;
51 } 49 }
@@ -85,3 +83,3 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) {
85 sprintf( dev, "%d", devi ); 83 sprintf( dev, "%d", devi );
86 execlp( "rfcomm", "rfcomm", dev, bdaddr.latin1(), por, NULL ); 84 execlp( "rfcomm", "rfcomm", "connect", dev, bdaddr.latin1(), por, NULL );
87 char resultByte = 1; 85 char resultByte = 1;
@@ -115,3 +113,2 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) {
115 continue; // the other process is not yet ready? 113 continue; // the other process is not yet ready?
116
117 break; 114 break;
@@ -129,5 +126,7 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) {
129 timeout.tv_usec = 0; 126 timeout.tv_usec = 0;
130 127 printf("do select\n");
131 sel = select( m_in2out[0]+1, &fds, NULL, NULL, &timeout ); 128 sel = select( m_in2out[0]+1, &fds, NULL, NULL, &timeout );
132 if ( sel ) 129 printf("Check select\n");
130 if ( sel > 0)
131 {
133 if (FD_ISSET(m_in2out[0], &fds ) ) { 132 if (FD_ISSET(m_in2out[0], &fds ) ) {
@@ -136,4 +135,6 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) {
136 buf[0] = 0; 135 buf[0] = 0;
136 printf("read output\n");
137 len = read( m_in2out[0], buf, sizeof(buf) ); 137 len = read( m_in2out[0], buf, sizeof(buf) );
138 if ( len > 0 ) { 138 if ( len > 0 ) {
139 printf("%s", buf);
139 QCString string( buf ); 140 QCString string( buf );
@@ -146,7 +147,7 @@ bool RfCommHelper::connect(int devi, const QString& bdaddr, int port) {
146 // now parese it 147 // now parese it
147 }else {// time out
148 // 5 seconds without input check terminate?
149 //
150 ;
151 } 148 }
149 } else {// time out
150 terminate = true;
151 printf("terminate\n");
152 }
152 } 153 }