/[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 175 by kevin, Thu Dec 6 12:53:06 2007 UTC revision 176 by kevin, Thu Dec 6 14:12:31 2007 UTC
# Line 254  void CFlisServerDlg::SetPin() Line 254  void CFlisServerDlg::SetPin()
254                          AppendText(tekst);                          AppendText(tekst);
255          }          }
256          Sleep(5);          Sleep(5);
257          if (tekst.MakeLower() == "+cpin: sim pin")          tekst.MakeLower();
258            int pos = tekst.Find("+cpin: ",0);
259            if (pos != -1)
260            {
261                    tekst = tekst.Right( tekst.GetLength() - pos -1);
262            }
263    
264            if (tekst == "cpin: sim pin")
265          {          {
266                    CString pin;
267                    ConfigFile config;
268                    try {
269                            config.ReadSettings();
270                    } catch(...) {
271                            MessageBox("Could not open config file");
272                    }
273                    Sleep(50);
274    
275                  data.clear();                  data.clear();
276                  data.push_back('a');                  data.push_back('a');
277                  data.push_back('t');                  data.push_back('t');
# Line 265  void CFlisServerDlg::SetPin() Line 281  void CFlisServerDlg::SetPin()
281                  data.push_back('i');                  data.push_back('i');
282                  data.push_back('n');                  data.push_back('n');
283                  data.push_back('=');                  data.push_back('=');
284                  data.push_back('2');                  for (int i = 0; i<config.pincode.GetLength(); i++)
285                  data.push_back('5');                  {
286                  data.push_back('9');                  data.push_back(config.pincode[i]);
287                  data.push_back('5');                  }
288    
289                  writeFrame(data);                  writeFrame(data);
290    
# Line 301  void CFlisServerDlg::SetPin() Line 317  void CFlisServerDlg::SetPin()
317                          Sleep(10); //Small delay to avoid busy wait                          Sleep(10); //Small delay to avoid busy wait
318                  }                  }
319          }          }
320          else if (tekst.MakeLower() == "+cpin: ready")          else if (tekst == "cpin: ready")
321          {          {
322                  AppendText("No pincode needed");                  AppendText("No pincode needed");
323          }          }
324          else          else
325          {          {
326                  AppendText("Error in pincode message");                  AppendText("Error in set pin part of the code");
327          }          }
328  }  }
329  void CFlisServerDlg::SendSmsData(std::vector<unsigned char> data)  void CFlisServerDlg::SendSmsData(std::vector<unsigned char> data)
# Line 630  void CFlisServerDlg::MyMainThread() Line 646  void CFlisServerDlg::MyMainThread()
646                                                  {                                                  {
647                                                          data.push_back(smscount[i]);                                                          data.push_back(smscount[i]);
648                                                  }                                                  }
649                                                  m_Textwindow.GetWindowText(oldteskst);                                                  AppendText(CString(&data[0]));
                                                 oldteskst.Append("\r\n");  
                                                 for (int i=0; i<data.size();i++)  
                                                 {  
                                                         oldteskst.AppendChar(data[i]);  
                                                 }  
                                                 m_Textwindow.SetWindowText(oldteskst);  
650                                                  writeFrame(data);                                                  writeFrame(data);
651                                                  Sleep(200);                                                  Sleep(200);
652                                                  ReadSms();                                                  ReadSms();
# Line 846  void CFlisServerDlg::OnBnClickedStart() Line 856  void CFlisServerDlg::OnBnClickedStart()
856  {  {
857  // TODO: Add your control notification handler code here  // TODO: Add your control notification handler code here
858    
859          m_Textwindow.SetWindowText("Indsætter Pinkode, og venter på modem bliver klar, hvis pinkode er nødvendig");          AppendText("Indsætter Pinkode, og venter på modem bliver klar, hvis pinkode er nødvendig");
860          UpdateWindow();          UpdateWindow();
861          SetPin();          SetPin();
862                    
# Line 856  void CFlisServerDlg::OnBnClickedStart() Line 866  void CFlisServerDlg::OnBnClickedStart()
866                  Serial.readByte(); //Flush the incoming queue                  Serial.readByte(); //Flush the incoming queue
867                  Sleep(1);                  Sleep(1);
868          }          }
869            Sleep(5);
870    
871          continueThread = 1;          continueThread = 1;
872          keepaliveandread();          keepaliveandread();
873          Sleep(150);          Sleep(150);
874          m_Textwindow.SetWindowText(CString("Server phonenr read from db: ") + Alive.Phonenr );          AppendText(CString("Server phonenr read from db: ") + Alive.Phonenr );
875          AppendText("Started");          AppendText("Started");
876          AfxBeginThread(threadWrapper,AfxGetMainWnd());          AfxBeginThread(threadWrapper,AfxGetMainWnd());
877  }  }
878  void CFlisServerDlg::AppendText(CString s)  void CFlisServerDlg::AppendText(CString s)
879  {  {
880            CTime now = CTime::GetCurrentTime();
881          CString Tekst;          CString Tekst;
882          m_Textwindow.GetWindowText(Tekst);          m_Textwindow.GetWindowText(Tekst);
883          Tekst.Append("\r\n");          Tekst.AppendFormat("%02d:%02d:%02d : ", now.GetHour(), now.GetMinute(), now.GetSecond());
884          Tekst.Append(s);          Tekst.Append(s);
885            Tekst.Append("\r\n");
886    
887          m_Textwindow.SetWindowText(Tekst);          m_Textwindow.SetWindowText(Tekst);
888          Sleep(5);          Sleep(5);
889          int g = m_Textwindow.GetScrollLimit(SB_VERT);          int g = m_Textwindow.GetScrollLimit(SB_VERT);
# Line 908  void ConfigFile::ReadSettings() Line 922  void ConfigFile::ReadSettings()
922                                  database = value;                                  database = value;
923                          else if (key == "comport")                          else if (key == "comport")
924                                  comport = value;                                  comport = value;
925                            else if (key == "pincode")
926                                    pincode = value;
927                  }                  }
928    
929          }          }

Legend:
Removed from v.175  
changed lines
  Added in v.176

  ViewVC Help
Powered by ViewVC 1.1.20