/[H9]/trunk/FlisServer/FlisServerDlg.cpp
ViewVC logotype

Diff of /trunk/FlisServer/FlisServerDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 173 by kevin, Thu Dec 6 07:14:17 2007 UTC revision 174 by kevin, Thu Dec 6 12:53:06 2007 UTC
# Line 66  BEGIN_MESSAGE_MAP(CFlisServerDlg, CDialo Line 66  BEGIN_MESSAGE_MAP(CFlisServerDlg, CDialo
66          ON_WM_QUERYDRAGICON()          ON_WM_QUERYDRAGICON()
67          //}}AFX_MSG_MAP          //}}AFX_MSG_MAP
68          ON_BN_CLICKED(IDCLOSE, OnBnClickedClose)          ON_BN_CLICKED(IDCLOSE, OnBnClickedClose)
         ON_BN_CLICKED(IDC_GSMPIN, OnBnClickedGsmpin)  
69          ON_BN_CLICKED(IDC_Start, OnBnClickedStart)          ON_BN_CLICKED(IDC_Start, OnBnClickedStart)
70  END_MESSAGE_MAP()  END_MESSAGE_MAP()
71    
# Line 225  void CFlisServerDlg::writeFrame(std::vec Line 224  void CFlisServerDlg::writeFrame(std::vec
224  }  }
225  void CFlisServerDlg::SetPin()  void CFlisServerDlg::SetPin()
226  {  {
227            bool ready = true;
228          CString tekst;          CString tekst;
229          std::vector<unsigned char> data;          std::vector<unsigned char> data;
230    
231          data.push_back('a');          data.push_back('a');
232          data.push_back('t');          data.push_back('t');
233          data.push_back('+');          data.push_back('+');
# Line 234  void CFlisServerDlg::SetPin() Line 235  void CFlisServerDlg::SetPin()
235          data.push_back('p');          data.push_back('p');
236          data.push_back('i');          data.push_back('i');
237          data.push_back('n');          data.push_back('n');
238          data.push_back('=');          data.push_back('?');
         data.push_back('2');  
         data.push_back('5');  
         data.push_back('9');  
         data.push_back('5');  
239    
240          writeFrame(data);          writeFrame(data);
241            Sleep(100);
242            if(Serial.getComstat().cbInQue > 0)
243            {
244                    std::vector<unsigned char> answer = readFrame();
245                    Sleep(50);
246    
247                    for (int i=0; i<answer.size(); i++)
248                            {
249                                    if ((answer[i] != 0x0A) && (answer[i] != 0x0D))
250                                    {
251                                            tekst.AppendChar(answer[i]);
252                                    }
253                            }
254                            AppendText(tekst);
255            }
256            Sleep(5);
257            if (tekst.MakeLower() == "+cpin: sim pin")
258            {
259                    data.clear();
260                    data.push_back('a');
261                    data.push_back('t');
262                    data.push_back('+');
263                    data.push_back('c');
264                    data.push_back('p');
265                    data.push_back('i');
266                    data.push_back('n');
267                    data.push_back('=');
268                    data.push_back('2');
269                    data.push_back('5');
270                    data.push_back('9');
271                    data.push_back('5');
272    
273                    writeFrame(data);
274    
275                    Sleep(500);
276    
277                    while (ready == true)
278                    {
279                            if (Serial.getComstat().cbInQue > 120)
280                            {
281                                    std::vector<unsigned char> answer = readFrame();
282                                    CString tekst;
283                            
284                                    for (int i=0; i<answer.size(); i++)
285                                    {
286                                            if ((answer[i] != 0x0A) && (answer[i] != 0x0D))
287                                            {
288                                                    tekst.AppendChar(answer[i]);
289                                            }
290                                    }
291                                    int n = tekst.Find("WIND: 11",0);
292                                    if (n > -1)
293                                    {
294                                            ready = false;
295                                    }
296                                    else
297                                    {
298                                            AppendText(tekst);
299                                    }
300                            }
301                            Sleep(10); //Small delay to avoid busy wait
302                    }
303            }
304            else if (tekst.MakeLower() == "+cpin: ready")
305            {
306                    AppendText("No pincode needed");
307            }
308            else
309            {
310                    AppendText("Error in pincode message");
311            }
312  }  }
313  void CFlisServerDlg::SendSmsData(std::vector<unsigned char> data)  void CFlisServerDlg::SendSmsData(std::vector<unsigned char> data)
314  {        {      
# Line 455  void CFlisServerDlg::OnBnClickedClose() Line 523  void CFlisServerDlg::OnBnClickedClose()
523          OnOK();          OnOK();
524    
525  }  }
   
 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<unsigned char> answer = readFrame();  
                         CString tekst;  
                   
                         for (int i=0; i<answer.size(); i++)  
                         {  
                                 if ((answer[i] != 0x0A) && (answer[i] != 0x0D))  
                                 {  
                                         tekst.AppendChar(answer[i]);  
                                 }  
                         }  
                         int n = tekst.Find("WIND: 11",0);  
                         if (n > -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();  
 }  
526  void CFlisServerDlg::DeleteSms()  void CFlisServerDlg::DeleteSms()
527  {  {
528          vector<unsigned char> atcommand;          vector<unsigned char> atcommand;
# Line 670  void CFlisServerDlg::MyMainThread() Line 694  void CFlisServerDlg::MyMainThread()
694                          {                          {
695                                  SendConfig(sIDnr,sCommandID,sInstallationsID);                                  SendConfig(sIDnr,sCommandID,sInstallationsID);
696                          }                          }
697                          Sleep(500);                          Sleep(300);
698    
699                          CheckAcknowledges();                          CheckAcknowledges();
700                          Sleep(500);                          Sleep(500);
# Line 821  int CFlisServerDlg::tversum(__int64 inpu Line 845  int CFlisServerDlg::tversum(__int64 inpu
845  void CFlisServerDlg::OnBnClickedStart()  void CFlisServerDlg::OnBnClickedStart()
846  {  {
847  // TODO: Add your control notification handler code here  // TODO: Add your control notification handler code here
848    
849            m_Textwindow.SetWindowText("Indsætter Pinkode, og venter på modem bliver klar, hvis pinkode er nødvendig");
850            UpdateWindow();
851            SetPin();
852            
853            Sleep(100); //Give the modem a chance to send the last data
854            while(Serial.getComstat().cbInQue > 0)
855            {
856                    Serial.readByte(); //Flush the incoming queue
857                    Sleep(1);
858            }
859            
860          continueThread = 1;          continueThread = 1;
861          keepaliveandread();          keepaliveandread();
# Line 836  void CFlisServerDlg::AppendText(CString Line 871  void CFlisServerDlg::AppendText(CString
871          Tekst.Append("\r\n");          Tekst.Append("\r\n");
872          Tekst.Append(s);          Tekst.Append(s);
873          m_Textwindow.SetWindowText(Tekst);          m_Textwindow.SetWindowText(Tekst);
874            Sleep(5);
875          int g = m_Textwindow.GetScrollLimit(SB_VERT);          int g = m_Textwindow.GetScrollLimit(SB_VERT);
876          if (g > 0)          if (g > 0)
877          {          {
878          m_Textwindow.SetScrollPos(g,1,false);          m_Textwindow.SetSel(m_Textwindow.GetWindowTextLength() -1,m_Textwindow.GetWindowTextLength(),false);
879          }          }
880    
881  }  }
# Line 927  void CFlisServerDlg::CheckAcknowledges() Line 963  void CFlisServerDlg::CheckAcknowledges()
963          }          }
964  }  }
965    
966  void CFlisServerDlg::DumpAckList()  void CFlisServerDlg::DumpAckList()      /* Debug tool */
967  {  {
968            
969          CTime now = CTime::GetCurrentTime();          CTime now = CTime::GetCurrentTime();
970          OutputDebugString("-------------------------------\n");          OutputDebugString("-------------------------------\n");
971          int count = 0;          int count = 0;
# Line 989  vector<keepalive> CFlisServerDlg::keepal Line 1026  vector<keepalive> CFlisServerDlg::keepal
1026          }          }
1027    
1028                    
 }  
1029    }

Legend:
Removed from v.173  
changed lines
  Added in v.174

  ViewVC Help
Powered by ViewVC 1.1.20