--- trunk/FlisServer/FlisServerDlg.cpp 2007/12/06 12:30:39 173 +++ 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; @@ -670,7 +694,7 @@ { SendConfig(sIDnr,sCommandID,sInstallationsID); } - Sleep(500); + Sleep(300); CheckAcknowledges(); Sleep(500); @@ -821,6 +845,17 @@ void CFlisServerDlg::OnBnClickedStart() { // TODO: Add your control notification handler code here + + m_Textwindow.SetWindowText("Indsætter Pinkode, og venter på modem bliver klar, hvis pinkode er nødvendig"); + UpdateWindow(); + SetPin(); + + 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); + } continueThread = 1; keepaliveandread(); @@ -836,10 +871,11 @@ 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.SetScrollPos(g,1,false); + m_Textwindow.SetSel(m_Textwindow.GetWindowTextLength() -1,m_Textwindow.GetWindowTextLength(),false); } } @@ -927,8 +963,9 @@ } } -void CFlisServerDlg::DumpAckList() +void CFlisServerDlg::DumpAckList() /* Debug tool */ { + CTime now = CTime::GetCurrentTime(); OutputDebugString("-------------------------------\n"); int count = 0; @@ -989,4 +1026,4 @@ } -} \ No newline at end of file +}