Exemple #1
0
BOOL CRFIDprototypeApp::CheckGSM()
{
	int nRate;
	nRate = _ttoi(m_strRate);

	while (!::OpenComm(m_strPort, nRate))
	{
		CString strError;
		strError.Format(L"无法打开端口%s! 现在设置吗?", m_strPort);
		if (AfxMessageBox(strError, MB_YESNO) == IDNO) return FALSE;

		CSetting dlg;
		dlg.m_strPort = m_strPort;
		dlg.m_strRate = m_strRate;
		dlg.m_strSmsc = m_strSmsc;
		if (dlg.DoModal() == IDOK)
		{
			m_strPort = dlg.m_strPort;
			m_strRate = dlg.m_strRate;
			m_strSmsc = dlg.m_strSmsc;
		
		}
		else
		{
			return FALSE;
		}
	}

	if (!gsmInit())
	{
		CString strError;
		strError.Format(L"端口%s上没有发现MODEM!", m_strPort);
		AfxMessageBox(strError, MB_OK);
		CloseComm();
		return FALSE;
	}

	if (m_strSmsc.IsEmpty())
	{
		AfxMessageBox(L"请设置SMSC!");
		 
 		CSetting dlg;
 		dlg.m_strPort = m_strPort;
 		dlg.m_strRate = m_strRate;
 		dlg.m_strSmsc = m_strSmsc;
 		if (dlg.DoModal() == IDOK)
 		{
 			m_strPort = dlg.m_strPort;
 			m_strRate = dlg.m_strRate;
 			m_strSmsc = dlg.m_strSmsc;
 		}
 		else
 		{
			CloseComm();
 			return FALSE;
 		}
	}

	return TRUE;
}
Exemple #2
0
void NORETURN gsmTesting(Serial *port) {

	gsmInit(port);
	gsmPowerOn();
	gsmSMSConf(0);

	//gsmUpdateConf();
	//DELAY(1000);

	//DELAY(5000);
	//gsmSMSSend("+393473153808", "Test message from RFN");
	while (1) {
		gsmUpdateCSQ();
		DELAY(5000);
		//gsmSMSSend("+393473153808", "Test message from RFN");
		//gsmSMSSend("+393357963938", "Test message from RFN");
		//DELAY(10000);
	}

//  Prova invio messaggio molto lungo, che impiega tutti i 160 caratteri a
//	disposizione per un singolo SMS. Vediamo se i buffer disponibili sono
//	sufficienti.  Ciao


	for(uint8_t i=1; i<100; i++) {

		LOG_INFO("Iteration %d/100\n", i);

		gsmSMSList();
		DELAY(1000);

		//gsmSMSLast(&msg);
		for (uint8_t j=1; j<10; j++) {
			gsmSMSByIndex(&msg,j);
			DELAY(500);
		}

		gsmSMSDelRead();

		if (!(i%3))
			gsmSMSSend("+393357963938", "Test message from RFN");

		DELAY(10000);
	}

	DELAY(15000);
	gsmPowerOff();
}