예제 #1
0
void CallTask(uint32_t rtc)
{
		uint8_t pdu2uniBuf[256];
		uint16_t smsLen = 0;
		if(VoiceCallTask_GetPhase() == INCOMING_CALL)
		{
			if(atCmdCallParser.getIncomingNumber
				 && locationSms.flag != SMS_NEW_MSG
			)
			{
				addrSendToUserFlag = 1;
				atCmdCallParser.autoAnswer = 1;
				getAddrFlag = 1;
				askAddrCnt = 0;
				smsLen =sprintf((char *)pdu2uniBuf,"%s!\nhttp://maps.google.com/maps?q=%.6f,%.6f",smsCallReportLocation,lastGpsInfo.lat,lastGpsInfo.lon);
				smsLen = utf8s_to_ucs2s((int16_t *)locationAskSmsBuf,pdu2uniBuf);
				big2litel_endian((uint16_t *)locationAskSmsBuf,unilen((uint16_t *)locationAskSmsBuf));
				smsLen *= 2;

				if(ComparePhoneNumber((char *)atCmdCallParser.incomingCallPhoneNo,(char *)sysCfg.userPhone) != NULL)
				{
					Sms_SendMsg(&locationSms,sysCfg.userPhone,(uint8_t *)locationAskSmsBuf,smsLen,SMS_PDU16_MODE,30000,3);
				}
				else
					return;
			}
		}
}
void vGSM_GPRS_Task(void *arg)
{
		Timeout_Type tApp_100MS;
		uint32_t timer100msCnt = 0;
		InitTimeout(&tApp_100MS,SYSTICK_TIME_MS(100));
		AMPM_GSM_Init("internet","mms","mms",vTcpIpTask,vTcpIpTaskInit);
		while(1)
		{
			AMPM_GSM_MainTask();
			
			//Call and dtmf test
			if(incomingCall.state == CALL_INCOMING)
			{
					if(ampm_GotIncomingNumberFlag)
					{
						if(Ampm_ComparePhoneNumber((char *)ampm_IncomingCallPhoneNo,BOSS_PHONE_NUMBER))
						{
							incomingCall.dtmf = &dtmfRingBuf;
							Ampm_VoiceCallSetAction(&incomingCall,CALL_PICKUP_WHEN_INCOMING);
						}
						else
						{
							Ampm_VoiceCallCancel(&incomingCall);
						}		
					}
			}
			
			if(incomingCall.state == CALL_ACTIVE)
			{
				if(RINGBUF_Get(&dtmfRingBuf,&c) == 0)
				{
					DbgCfgPrintf("\r\nDTMF:%c",c);
					if(c == '1')
					{
						Ampm_VoiceCallCancel(&incomingCall);
						Ampm_VoiceCallSetup(&callUser,(uint8_t *)BOSS_PHONE_NUMBER,&dtmfRingBuf,CALL_HANGUP_WHEN_ALERTING,NULL,6,60,1);
						//Ampm_VoiceCallSetup(&callUser,BOSS_PHONE_NUMBER,&dtmfRingBuf,CALL_HANGUP_WHEN_ACTIVE,NULL,6,60,1);
					}
				}
			}
			//SMS test
			//Send Sms with interval = 3600s
			if(CheckTimeout(&tSendSmsTime) == SYSTICK_TIMEOUT)
			{
				InitTimeout(&tSendSmsTime,SYSTICK_TIME_SEC(3600));
				smsLen =	sprintf((char *)pdu2uniBuf,"Xin chào!\n");
				smsLen = utf8s_to_ucs2s((int16_t *)replySmsBuf,pdu2uniBuf);
				big2litel_endian((uint16_t *)replySmsBuf,unilen((uint16_t *)replySmsBuf));
				smsLen *= 2;
				Ampm_Sms_SendMsg(&smsUser,(uint8_t *)BOSS_PHONE_NUMBER,(uint8_t *)replySmsBuf,smsLen,SMS_PDU16_MODE,30/*interval resend*/,3/*resend times*/);
			}
			// 0.1 sec process 
			if(CheckTimeout(&tApp_100MS) == SYSTICK_TIMEOUT)
			{
				InitTimeout(&tApp_100MS,SYSTICK_TIME_MS(100));
				timer100msCnt += 100;
				CtrLed(timer100msCnt);
			}
		}
}
예제 #3
0
int wcslen( const wchar_t *_wc )
{ return unilen( (const unicode *)_wc ); }