summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialer.cpp28
-rw-r--r--noncore/apps/opie-console/io_modem.cpp8
-rw-r--r--noncore/apps/opie-console/io_serial.cpp22
-rw-r--r--noncore/apps/opie-console/io_serial.h2
-rw-r--r--noncore/apps/opie-console/test/senderui.cpp10
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
@@ -51,25 +51,25 @@ Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name
: QDialog(parent, name, true), m_fd(fd), m_profile(profile)
{
QVBoxLayout *vbox;
QLabel *desc;
//m_profile.writeEntry("InitString", "ATZ");
//m_profile.writeEntry("DialPrefix1", "ATDT");
//m_profile.writeEntry("Termination", "\n");
usercancel = 0;
cleanshutdown = 0;
- fcntl(m_fd, F_SETFL, O_NONBLOCK);
+// fcntl(m_fd, F_SETFL, O_NONBLOCK);
desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
progress = new QProgressBar(this);
status = new QLabel("", this);
status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
cancel = new QPushButton(QObject::tr("Cancel"), this);
vbox = new QVBoxLayout(this, 2);
vbox->add(desc);
vbox->add(progress);
vbox->add(status);
vbox->add(cancel);
@@ -94,24 +94,25 @@ void Dialer::setHangupOnly()
void Dialer::slotCancel()
{
if(state != state_online)
{
usercancel = 1;
reset();
}
else accept();
}
void Dialer::reset()
{
+ qWarning("reset");
switchState(state_cancel);
}
void Dialer::slotAutostart()
{
//state = state_preinit;
dial(m_profile.readEntry("Number"));
}
void Dialer::dial(const QString& number)
{
while(state != state_online)
@@ -125,68 +126,75 @@ void Dialer::dial(const QString& number)
}
if(usercancel)
{
// modem hangup
trydial(QString::null);
reject();
}
}
void Dialer::trydial(const QString& number)
{
+ qWarning("TryDial:%s", number.latin1() );
if(state != state_cancel) switchState(state_preinit);
if(cleanshutdown)
{
+ qWarning("HangupString " + m_profile.readEntry("HangupString"));
send(m_profile.readEntry("HangupString"));
//send("+++ATH");
send("");
}
if(state != state_cancel)
{
switchState(state_init);
//send("ATZ");
- send(m_profile.readEntry("InitString"));
+ qWarning("Init String " + m_profile.readEntry("InitString") );
+// send(m_profile.readEntry("InitString", "AT"));
+ send("AT\r");
QString response2 = receive();
if(!response2.contains("\nOK\r"))
reset();
}
- if(state != state_cancel)
+/* if(state != state_cancel)
{
switchState(state_options);
- send("ATM3L3");
+ qWarning("ATM3l3");
+ send("ATM3L3\r");
QString response3 = receive();
if(!response3.contains("\nOK\r"))
reset();
}
+*/
if(state != state_cancel)
{
switchState(state_dialtone);
- send("ATX1");
+ send("ATX1\r");
QString response4 = receive();
if(!response4.contains("\nOK\r"))
reset();
}
if(state != state_cancel)
{
+ qWarning("progress");
switchState(state_dialing);
- //send(QString("ATDT %1").arg(number));
- send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number));
+ send(QString("ATDT %1\r").arg(number));
+// send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number));
QString response5 = receive();
if(!response5.contains("\n" + m_profile.readEntry("DefaultConnect")))
{
if(response5.contains("BUSY"))
switchState(state_dialing);
else
{
QMessageBox::warning(this,
QObject::tr("Failure"),
QObject::tr("Dialing the number failed."));
slotCancel();
}
@@ -196,31 +204,33 @@ void Dialer::trydial(const QString& number)
if(state != state_cancel)
{
switchState(state_online);
}
}
void Dialer::send(const QString& msg)
{
QString m = msg;
int bytes;
QString termination;
- //qWarning("Sending: '%s'", m.latin1());
+ qWarning("Sending: %s", m.latin1());
- termination = "\r";
+/* termination = "\r";
//termination = m_profile.readEntry("Termination");
if(termination == "\n") m = m + "\n";
else if(termination == "\r") m = m + "\r";
else m = m + "\r\n";
+*/
+ m = m.replace(QRegExp("\n"), "\r");
bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
if(bytes < 0)
{
reset();
}
}
QString Dialer::receive()
{
QString buf;
char buffer[1024];
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
@@ -20,29 +20,31 @@ void IOModem::close() {
Dialer d(m_profile, fd);
d.setHangupOnly();
d.exec();
closeRawIO(fd);
IOSerial::close();
}
bool IOModem::open() {
bool ret = IOSerial::open();
if(!ret) return false;
- int fd = rawIO();
- Dialer d(m_profile, fd);
+// int fd = rawIO();
+ internDetach();
+ Dialer d(m_profile, m_fd);
int result = d.exec();
- closeRawIO(fd);
+ internAttach();
+// closeRawIO(fd);
if(result == QDialog::Accepted)
{
return true;
}
else
{
close();
return false;
}
}
void IOModem::reload( const Profile &config ) {
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
@@ -195,12 +195,34 @@ void IOSerial::closeRawIO(int fd) {
}
QBitArray IOSerial::supports()const {
QBitArray ar(3);
ar[0] = ar[2] = 0;
ar[1] = 1;
return ar;
}
bool IOSerial::isConnected() {
return m_connected;
}
+
+/*
+ * this is used to give the
+ * class below IOSerial
+ * the possibility of
+ * exclusive usage
+ */
+void IOSerial::internDetach() {
+ if (m_read )
+ disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
+ if (m_error )
+ disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
+}
+/*
+ * give power back
+ */
+void IOSerial::internAttach() {
+ if (m_read )
+ connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
+ if (m_error )
+ connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
+}
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
@@ -41,24 +41,26 @@ public:
bool isConnected();
/*signals:
void received(const QByteArray &);
void error(int, const QString &);
*/
public slots:
void send(const QByteArray &);
bool open();
void close();
void reload(const Profile &);
protected:
int baud(int baud) const;
+ void internDetach();
+ void internAttach();
protected slots:
void dataArrived();
void errorOccured();
protected:
QSocketNotifier *m_read;
QSocketNotifier *m_error;
QString m_device;
int m_baud;
int m_parity;
int m_dbits;
int m_sbits;
int m_flow;
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
@@ -11,27 +11,27 @@
#include "../filetransfer.h"
#include "../filereceive.h"
#include <opie/oprocess.h>
#include "senderui.h"
SenderUI::SenderUI()
: Sender() {
/* we do that manually */
Profile prof;
- QString str = "/dev/ttyS0";
+ QString str = "/dev/bty0";
prof.writeEntry("Device",str );
- prof.writeEntry("Baud", 115200 );
+ prof.writeEntry("Baud", 19200 );
qWarning("prof " + prof.readEntry("Device") + " " + str);
ser = new IOSerial(prof);
connect(ser, SIGNAL(received(const QByteArray& ) ),
this, SLOT(got(const QByteArray&) ) );
if ( ser->open() )
qWarning("opened!!!");
else
qWarning("could not open");
@@ -42,34 +42,36 @@ SenderUI::~SenderUI() {
void SenderUI::slotSendFile() {
sz = new FileTransfer(FileTransfer::SY, ser);
sz->sendFile("/home/ich/bootopie-v06-13.jffs2");
connect (sz, SIGNAL(sent()),
this, SLOT(fileTransComplete()));
}
void SenderUI::slotSend() {
QCString str = MultiLineEdit1->text().utf8();
qWarning("sending: %s", str.data() );
+ str = str.replace( QRegExp("\n"), "\r");
ser->send( str );
}
void SenderUI::got(const QByteArray& ar) {
+ qWarning("got:");
for ( uint i = 0; i < ar.count(); i++ ) {
printf("%c", ar[i] );
}
- //printf("\n");
+ printf("\n");
}
void SenderUI::fileTransComplete() {
qWarning("file transfer complete");
}
void SenderUI::send() {
}
void SenderUI::slotRev(){
qWarning("Going to receive!");
FileReceive *rev = new FileReceive( FileReceive::SZ, ser );
rev->receive();
-} \ No newline at end of file
+}