-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 28 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_modem.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 22 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/senderui.cpp | 10 |
5 files changed, 54 insertions, 16 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 5056040..ce2b688 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp | |||
@@ -57,13 +57,13 @@ Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name | |||
57 | //m_profile.writeEntry("DialPrefix1", "ATDT"); | 57 | //m_profile.writeEntry("DialPrefix1", "ATDT"); |
58 | //m_profile.writeEntry("Termination", "\n"); | 58 | //m_profile.writeEntry("Termination", "\n"); |
59 | 59 | ||
60 | usercancel = 0; | 60 | usercancel = 0; |
61 | cleanshutdown = 0; | 61 | cleanshutdown = 0; |
62 | 62 | ||
63 | fcntl(m_fd, F_SETFL, O_NONBLOCK); | 63 | //fcntl(m_fd, F_SETFL, O_NONBLOCK); |
64 | 64 | ||
65 | desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); | 65 | desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); |
66 | progress = new QProgressBar(this); | 66 | progress = new QProgressBar(this); |
67 | status = new QLabel("", this); | 67 | status = new QLabel("", this); |
68 | status->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 68 | status->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
69 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 69 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
@@ -100,12 +100,13 @@ void Dialer::slotCancel() | |||
100 | } | 100 | } |
101 | else accept(); | 101 | else accept(); |
102 | } | 102 | } |
103 | 103 | ||
104 | void Dialer::reset() | 104 | void Dialer::reset() |
105 | { | 105 | { |
106 | qWarning("reset"); | ||
106 | switchState(state_cancel); | 107 | switchState(state_cancel); |
107 | } | 108 | } |
108 | 109 | ||
109 | void Dialer::slotAutostart() | 110 | void Dialer::slotAutostart() |
110 | { | 111 | { |
111 | //state = state_preinit; | 112 | //state = state_preinit; |
@@ -131,56 +132,63 @@ void Dialer::dial(const QString& number) | |||
131 | reject(); | 132 | reject(); |
132 | } | 133 | } |
133 | } | 134 | } |
134 | 135 | ||
135 | void Dialer::trydial(const QString& number) | 136 | void Dialer::trydial(const QString& number) |
136 | { | 137 | { |
138 | qWarning("TryDial:%s", number.latin1() ); | ||
137 | if(state != state_cancel) switchState(state_preinit); | 139 | if(state != state_cancel) switchState(state_preinit); |
138 | if(cleanshutdown) | 140 | if(cleanshutdown) |
139 | { | 141 | { |
142 | qWarning("HangupString " + m_profile.readEntry("HangupString")); | ||
140 | send(m_profile.readEntry("HangupString")); | 143 | send(m_profile.readEntry("HangupString")); |
141 | //send("+++ATH"); | 144 | //send("+++ATH"); |
142 | send(""); | 145 | send(""); |
143 | } | 146 | } |
144 | 147 | ||
145 | if(state != state_cancel) | 148 | if(state != state_cancel) |
146 | { | 149 | { |
147 | switchState(state_init); | 150 | switchState(state_init); |
148 | //send("ATZ"); | 151 | //send("ATZ"); |
149 | send(m_profile.readEntry("InitString")); | 152 | qWarning("Init String " + m_profile.readEntry("InitString") ); |
153 | // send(m_profile.readEntry("InitString", "AT")); | ||
154 | send("AT\r"); | ||
150 | QString response2 = receive(); | 155 | QString response2 = receive(); |
151 | if(!response2.contains("\nOK\r")) | 156 | if(!response2.contains("\nOK\r")) |
152 | reset(); | 157 | reset(); |
153 | } | 158 | } |
154 | 159 | ||
155 | if(state != state_cancel) | 160 | /*if(state != state_cancel) |
156 | { | 161 | { |
157 | switchState(state_options); | 162 | switchState(state_options); |
158 | 163 | ||
159 | send("ATM3L3"); | 164 | qWarning("ATM3l3"); |
165 | send("ATM3L3\r"); | ||
160 | QString response3 = receive(); | 166 | QString response3 = receive(); |
161 | if(!response3.contains("\nOK\r")) | 167 | if(!response3.contains("\nOK\r")) |
162 | reset(); | 168 | reset(); |
163 | } | 169 | } |
170 | */ | ||
164 | 171 | ||
165 | if(state != state_cancel) | 172 | if(state != state_cancel) |
166 | { | 173 | { |
167 | switchState(state_dialtone); | 174 | switchState(state_dialtone); |
168 | 175 | ||
169 | send("ATX1"); | 176 | send("ATX1\r"); |
170 | QString response4 = receive(); | 177 | QString response4 = receive(); |
171 | if(!response4.contains("\nOK\r")) | 178 | if(!response4.contains("\nOK\r")) |
172 | reset(); | 179 | reset(); |
173 | } | 180 | } |
174 | 181 | ||
175 | if(state != state_cancel) | 182 | if(state != state_cancel) |
176 | { | 183 | { |
184 | qWarning("progress"); | ||
177 | switchState(state_dialing); | 185 | switchState(state_dialing); |
178 | 186 | ||
179 | //send(QString("ATDT %1").arg(number)); | 187 | send(QString("ATDT %1\r").arg(number)); |
180 | send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); | 188 | // send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); |
181 | QString response5 = receive(); | 189 | QString response5 = receive(); |
182 | if(!response5.contains("\n" + m_profile.readEntry("DefaultConnect"))) | 190 | if(!response5.contains("\n" + m_profile.readEntry("DefaultConnect"))) |
183 | { | 191 | { |
184 | if(response5.contains("BUSY")) | 192 | if(response5.contains("BUSY")) |
185 | switchState(state_dialing); | 193 | switchState(state_dialing); |
186 | else | 194 | else |
@@ -202,19 +210,21 @@ void Dialer::trydial(const QString& number) | |||
202 | void Dialer::send(const QString& msg) | 210 | void Dialer::send(const QString& msg) |
203 | { | 211 | { |
204 | QString m = msg; | 212 | QString m = msg; |
205 | int bytes; | 213 | int bytes; |
206 | QString termination; | 214 | QString termination; |
207 | 215 | ||
208 | //qWarning("Sending: '%s'", m.latin1()); | 216 | qWarning("Sending: %s", m.latin1()); |
209 | 217 | ||
210 | termination = "\r"; | 218 | /*termination = "\r"; |
211 | //termination = m_profile.readEntry("Termination"); | 219 | //termination = m_profile.readEntry("Termination"); |
212 | if(termination == "\n") m = m + "\n"; | 220 | if(termination == "\n") m = m + "\n"; |
213 | else if(termination == "\r") m = m + "\r"; | 221 | else if(termination == "\r") m = m + "\r"; |
214 | else m = m + "\r\n"; | 222 | else m = m + "\r\n"; |
223 | */ | ||
224 | m = m.replace(QRegExp("\n"), "\r"); | ||
215 | 225 | ||
216 | bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit())); | 226 | bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit())); |
217 | if(bytes < 0) | 227 | if(bytes < 0) |
218 | { | 228 | { |
219 | reset(); | 229 | reset(); |
220 | } | 230 | } |
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp index d4ea0b2..b7901b9 100644 --- a/noncore/apps/opie-console/io_modem.cpp +++ b/noncore/apps/opie-console/io_modem.cpp | |||
@@ -26,17 +26,19 @@ void IOModem::close() { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | bool IOModem::open() { | 28 | bool IOModem::open() { |
29 | bool ret = IOSerial::open(); | 29 | bool ret = IOSerial::open(); |
30 | if(!ret) return false; | 30 | if(!ret) return false; |
31 | 31 | ||
32 | int fd = rawIO(); | 32 | //int fd = rawIO(); |
33 | Dialer d(m_profile, fd); | 33 | internDetach(); |
34 | Dialer d(m_profile, m_fd); | ||
34 | 35 | ||
35 | int result = d.exec(); | 36 | int result = d.exec(); |
36 | closeRawIO(fd); | 37 | internAttach(); |
38 | //closeRawIO(fd); | ||
37 | if(result == QDialog::Accepted) | 39 | if(result == QDialog::Accepted) |
38 | { | 40 | { |
39 | return true; | 41 | return true; |
40 | } | 42 | } |
41 | else | 43 | else |
42 | { | 44 | { |
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index e6d1688..0540d9e 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -201,6 +201,28 @@ QBitArray IOSerial::supports()const { | |||
201 | return ar; | 201 | return ar; |
202 | } | 202 | } |
203 | 203 | ||
204 | bool IOSerial::isConnected() { | 204 | bool IOSerial::isConnected() { |
205 | return m_connected; | 205 | return m_connected; |
206 | } | 206 | } |
207 | |||
208 | /* | ||
209 | * this is used to give the | ||
210 | * class below IOSerial | ||
211 | * the possibility of | ||
212 | * exclusive usage | ||
213 | */ | ||
214 | void IOSerial::internDetach() { | ||
215 | if (m_read ) | ||
216 | disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | ||
217 | if (m_error ) | ||
218 | disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | ||
219 | } | ||
220 | /* | ||
221 | * give power back | ||
222 | */ | ||
223 | void IOSerial::internAttach() { | ||
224 | if (m_read ) | ||
225 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | ||
226 | if (m_error ) | ||
227 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | ||
228 | } | ||
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h index 7a1ea1d..edceac6 100644 --- a/noncore/apps/opie-console/io_serial.h +++ b/noncore/apps/opie-console/io_serial.h | |||
@@ -47,12 +47,14 @@ public slots: | |||
47 | void send(const QByteArray &); | 47 | void send(const QByteArray &); |
48 | bool open(); | 48 | bool open(); |
49 | void close(); | 49 | void close(); |
50 | void reload(const Profile &); | 50 | void reload(const Profile &); |
51 | protected: | 51 | protected: |
52 | int baud(int baud) const; | 52 | int baud(int baud) const; |
53 | void internDetach(); | ||
54 | void internAttach(); | ||
53 | protected slots: | 55 | protected slots: |
54 | void dataArrived(); | 56 | void dataArrived(); |
55 | void errorOccured(); | 57 | void errorOccured(); |
56 | protected: | 58 | protected: |
57 | QSocketNotifier *m_read; | 59 | QSocketNotifier *m_read; |
58 | QSocketNotifier *m_error; | 60 | QSocketNotifier *m_error; |
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp index 2ce3f6d..4026808 100644 --- a/noncore/apps/opie-console/test/senderui.cpp +++ b/noncore/apps/opie-console/test/senderui.cpp | |||
@@ -17,15 +17,15 @@ | |||
17 | 17 | ||
18 | SenderUI::SenderUI() | 18 | SenderUI::SenderUI() |
19 | : Sender() { | 19 | : Sender() { |
20 | 20 | ||
21 | /* we do that manually */ | 21 | /* we do that manually */ |
22 | Profile prof; | 22 | Profile prof; |
23 | QString str = "/dev/ttyS0"; | 23 | QString str = "/dev/bty0"; |
24 | prof.writeEntry("Device",str ); | 24 | prof.writeEntry("Device",str ); |
25 | prof.writeEntry("Baud", 115200 ); | 25 | prof.writeEntry("Baud", 19200 ); |
26 | 26 | ||
27 | qWarning("prof " + prof.readEntry("Device") + " " + str); | 27 | qWarning("prof " + prof.readEntry("Device") + " " + str); |
28 | ser = new IOSerial(prof); | 28 | ser = new IOSerial(prof); |
29 | connect(ser, SIGNAL(received(const QByteArray& ) ), | 29 | connect(ser, SIGNAL(received(const QByteArray& ) ), |
30 | this, SLOT(got(const QByteArray&) ) ); | 30 | this, SLOT(got(const QByteArray&) ) ); |
31 | 31 | ||
@@ -48,19 +48,21 @@ void SenderUI::slotSendFile() { | |||
48 | this, SLOT(fileTransComplete())); | 48 | this, SLOT(fileTransComplete())); |
49 | } | 49 | } |
50 | 50 | ||
51 | void SenderUI::slotSend() { | 51 | void SenderUI::slotSend() { |
52 | QCString str = MultiLineEdit1->text().utf8(); | 52 | QCString str = MultiLineEdit1->text().utf8(); |
53 | qWarning("sending: %s", str.data() ); | 53 | qWarning("sending: %s", str.data() ); |
54 | str = str.replace( QRegExp("\n"), "\r"); | ||
54 | ser->send( str ); | 55 | ser->send( str ); |
55 | } | 56 | } |
56 | void SenderUI::got(const QByteArray& ar) { | 57 | void SenderUI::got(const QByteArray& ar) { |
58 | qWarning("got:"); | ||
57 | for ( uint i = 0; i < ar.count(); i++ ) { | 59 | for ( uint i = 0; i < ar.count(); i++ ) { |
58 | printf("%c", ar[i] ); | 60 | printf("%c", ar[i] ); |
59 | } | 61 | } |
60 | //printf("\n"); | 62 | printf("\n"); |
61 | } | 63 | } |
62 | 64 | ||
63 | void SenderUI::fileTransComplete() { | 65 | void SenderUI::fileTransComplete() { |
64 | 66 | ||
65 | qWarning("file transfer complete"); | 67 | qWarning("file transfer complete"); |
66 | } | 68 | } |
@@ -69,7 +71,7 @@ void SenderUI::send() { | |||
69 | } | 71 | } |
70 | void SenderUI::slotRev(){ | 72 | void SenderUI::slotRev(){ |
71 | qWarning("Going to receive!"); | 73 | qWarning("Going to receive!"); |
72 | FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); | 74 | FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); |
73 | rev->receive(); | 75 | rev->receive(); |
74 | 76 | ||
75 | } \ No newline at end of file | 77 | } |