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'); |
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 |
|
|
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) |
425 |
} |
} |
426 |
void CFlisServerDlg::ReadSms() |
void CFlisServerDlg::ReadSms() |
427 |
{ |
{ |
428 |
CString tekst, oldtekst; |
CString tekst; |
429 |
Sleep(950); //Holder en pause for at lade hele sms'en komme ind i serial køen. |
Sleep(950); //Holder en pause for at lade hele sms'en komme ind i serial køen. |
430 |
if(Serial.getComstat().cbInQue > 0) |
if(Serial.getComstat().cbInQue > 0) |
431 |
{ |
{ |
446 |
} |
} |
447 |
void CFlisServerDlg::SmsSplit(CString data) |
void CFlisServerDlg::SmsSplit(CString data) |
448 |
{ |
{ |
449 |
CString FyrData, TlfNr, SmsCount, Temper, Flamme, Flis, FremFejl, PowerFail, oldtekst; |
CString FyrData, TlfNr, SmsCount, Temper, Flamme, Flis, FremFejl, PowerFail; |
|
char CharData[150]; |
|
|
strcpy(CharData,data); |
|
450 |
TlfNr = data.Mid(24,8); |
TlfNr = data.Mid(24,8); |
451 |
FyrData = data.Mid(57,data.GetLength()-59); |
FyrData = data.Mid(57,data.GetLength()-59); |
452 |
FyrData.Append(":"); |
FyrData.Append(":"); |
581 |
Sleep(250); |
Sleep(250); |
582 |
std::vector<unsigned char> answer = readFrame(); |
std::vector<unsigned char> answer = readFrame(); |
583 |
Sleep(500); |
Sleep(500); |
584 |
CString tekst, oldtekst; |
CString tekst; |
585 |
|
|
586 |
for (int i=0; i<answer.size(); i++) |
for (int i=0; i<answer.size(); i++) |
587 |
{ |
{ |
621 |
{ |
{ |
622 |
if (command.MakeLower() == "cmti") |
if (command.MakeLower() == "cmti") |
623 |
{ |
{ |
624 |
CString smscount, oldteskst; |
CString smscount; |
625 |
int pos = tekst.Find(',',0); |
int pos = tekst.Find(',',0); |
626 |
if (pos != -1) |
if (pos != -1) |
627 |
{ |
{ |
629 |
smscount.Remove(':'); |
smscount.Remove(':'); |
630 |
ResetSms++; |
ResetSms++; |
631 |
} |
} |
632 |
////////////////Read sms ting////////////////// |
|
633 |
std::vector<unsigned char> data; |
std::vector<unsigned char> data; |
634 |
data.push_back('a'); |
data.push_back('a'); |
635 |
data.push_back('t'); |
data.push_back('t'); |
636 |
data.push_back('+'); |
data.push_back('+'); |
637 |
data.push_back('c'); |
data.push_back('c'); |
638 |
data.push_back('m'); |
data.push_back('m'); |
639 |
data.push_back('g'); |
data.push_back('g'); |
640 |
data.push_back('r'); |
data.push_back('r'); |
641 |
data.push_back('='); |
data.push_back('='); |
642 |
|
|
643 |
for (int i=0; i< smscount.GetLength(); i++) |
for (int i=0; i< smscount.GetLength(); i++) |
644 |
{ |
{ |
645 |
data.push_back(smscount[i]); |
data.push_back(smscount[i]); |
646 |
} |
} |
647 |
m_Textwindow.GetWindowText(oldteskst); |
AppendText(CString(&data[0])); |
648 |
oldteskst.Append("\r\n"); |
writeFrame(data); |
649 |
for (int i=0; i<data.size();i++) |
Sleep(200); |
650 |
{ |
ReadSms(); |
|
oldteskst.AppendChar(data[i]); |
|
|
} |
|
|
m_Textwindow.SetWindowText(oldteskst); |
|
|
writeFrame(data); |
|
|
Sleep(200); |
|
|
ReadSms(); |
|
|
ResetSms++; |
|
651 |
|
|
652 |
} |
} |
653 |
else if(command.MakeLower() == "wind") |
else if(command.MakeLower() == "wind") |
853 |
{ |
{ |
854 |
// TODO: Add your control notification handler code here |
// TODO: Add your control notification handler code here |
855 |
|
|
856 |
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"); |
857 |
UpdateWindow(); |
UpdateWindow(); |
858 |
SetPin(); |
SetPin(); |
859 |
|
|
863 |
Serial.readByte(); //Flush the incoming queue |
Serial.readByte(); //Flush the incoming queue |
864 |
Sleep(1); |
Sleep(1); |
865 |
} |
} |
866 |
|
Sleep(5); |
867 |
|
|
868 |
continueThread = 1; |
continueThread = 1; |
869 |
keepaliveandread(); |
keepaliveandread(); |
870 |
Sleep(150); |
Sleep(150); |
871 |
m_Textwindow.SetWindowText(CString("Server phonenr read from db: ") + Alive.Phonenr ); |
AppendText(CString("Server phonenr read from db: ") + Alive.Phonenr ); |
872 |
AppendText("Started"); |
AppendText("Started"); |
873 |
AfxBeginThread(threadWrapper,AfxGetMainWnd()); |
AfxBeginThread(threadWrapper,AfxGetMainWnd()); |
874 |
} |
} |
875 |
void CFlisServerDlg::AppendText(CString s) |
void CFlisServerDlg::AppendText(CString s) |
876 |
{ |
{ |
877 |
|
CTime now = CTime::GetCurrentTime(); |
878 |
CString Tekst; |
CString Tekst; |
879 |
m_Textwindow.GetWindowText(Tekst); |
m_Textwindow.GetWindowText(Tekst); |
880 |
Tekst.Append("\r\n"); |
Tekst.AppendFormat("%02d:%02d:%02d : ", now.GetHour(), now.GetMinute(), now.GetSecond()); |
881 |
Tekst.Append(s); |
Tekst.Append(s); |
882 |
|
Tekst.Append("\r\n"); |
883 |
|
|
884 |
m_Textwindow.SetWindowText(Tekst); |
m_Textwindow.SetWindowText(Tekst); |
885 |
Sleep(5); |
Sleep(5); |
886 |
int g = m_Textwindow.GetScrollLimit(SB_VERT); |
int g = m_Textwindow.GetScrollLimit(SB_VERT); |
919 |
database = value; |
database = value; |
920 |
else if (key == "comport") |
else if (key == "comport") |
921 |
comport = value; |
comport = value; |
922 |
|
else if (key == "pincode") |
923 |
|
pincode = value; |
924 |
} |
} |
925 |
|
|
926 |
} |
} |