--- trunk/FlisServer/FlisServerDlg.cpp 2007/12/05 16:03:05 166 +++ trunk/FlisServer/FlisServerDlg.cpp 2007/12/06 12:53:06 174 @@ -66,7 +66,6 @@ ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDCLOSE, OnBnClickedClose) - ON_BN_CLICKED(IDC_GSMPIN, OnBnClickedGsmpin) ON_BN_CLICKED(IDC_Start, OnBnClickedStart) END_MESSAGE_MAP() @@ -225,8 +224,10 @@ } void CFlisServerDlg::SetPin() { + bool ready = true; CString tekst; std::vector data; + data.push_back('a'); data.push_back('t'); data.push_back('+'); @@ -234,13 +235,80 @@ data.push_back('p'); data.push_back('i'); data.push_back('n'); - data.push_back('='); - data.push_back('2'); - data.push_back('5'); - data.push_back('9'); - data.push_back('5'); + data.push_back('?'); writeFrame(data); + Sleep(100); + if(Serial.getComstat().cbInQue > 0) + { + std::vector answer = readFrame(); + Sleep(50); + + for (int i=0; i 120) + { + std::vector answer = readFrame(); + CString tekst; + + for (int i=0; i -1) + { + ready = false; + } + else + { + AppendText(tekst); + } + } + Sleep(10); //Small delay to avoid busy wait + } + } + else if (tekst.MakeLower() == "+cpin: ready") + { + AppendText("No pincode needed"); + } + else + { + AppendText("Error in pincode message"); + } } void CFlisServerDlg::SendSmsData(std::vector data) { @@ -455,50 +523,6 @@ OnOK(); } - -void CFlisServerDlg::OnBnClickedGsmpin() -{ - // TODO: Add your control notification handler code here - bool ready = true; - m_Textwindow.SetWindowText("Indsætter Pinkode, og venter på modem bliver klar"); - UpdateWindow(); - SetPin(); - Sleep(500); - - while (ready == true) - { - if (Serial.getComstat().cbInQue > 120) - { - std::vector answer = readFrame(); - CString tekst; - - for (int i=0; i -1) - { - ready = false; - } - else - { - AppendText(tekst); - } - } - Sleep(10); //Small delay to avoid busy wait - } - Sleep(100); //Give the modem a chance to send the last data - while(Serial.getComstat().cbInQue > 0) - { - Serial.readByte(); //Flush the incoming queue - Sleep(1); - } - OnBnClickedStart(); -} void CFlisServerDlg::DeleteSms() { vector atcommand; @@ -533,10 +557,10 @@ { while (continueThread != 0) { - Reader(); + MyMainThread(); } } -void CFlisServerDlg::Reader() +void CFlisServerDlg::MyMainThread() { if(Serial.getComstat().cbInQue > 0) { @@ -544,7 +568,6 @@ std::vector answer = readFrame(); Sleep(500); CString tekst, oldtekst; - int lol; for (int i=0; i 0) + { + Serial.readByte(); //Flush the incoming queue + Sleep(1); + } continueThread = 1; keepaliveandread(); @@ -837,6 +871,12 @@ Tekst.Append("\r\n"); Tekst.Append(s); m_Textwindow.SetWindowText(Tekst); + Sleep(5); + int g = m_Textwindow.GetScrollLimit(SB_VERT); + if (g > 0) + { + m_Textwindow.SetSel(m_Textwindow.GetWindowTextLength() -1,m_Textwindow.GetWindowTextLength(),false); + } } void ConfigFile::ReadSettings() @@ -923,8 +963,9 @@ } } -void CFlisServerDlg::DumpAckList() +void CFlisServerDlg::DumpAckList() /* Debug tool */ { + CTime now = CTime::GetCurrentTime(); OutputDebugString("-------------------------------\n"); int count = 0; @@ -981,6 +1022,7 @@ DBConnect(); AppendText("DB connection started again"); } + return buffer; }