コード例 #1
0
ファイル: GSM.c プロジェクト: TKJElectronics/GSMWaterAlarm
void SendSMS(const char message[])   // Send SMS to danish number
{
    GSM_PowerOn();
    LED_On(); // Turn on LED
    GSM_Initialize(0);
    UART1_Write_Text_Constant("AT+CMGF=1");
    UART1_Write(13); //Carriage return (new line)
    Delay_ms(10);
    WaitForRecieveChar(0x0D);
    EmptySerialBuffer();
    CancelAlarmOnClick(); // Check if # is held - if true, disable the alarm and buzzer

    UART1_Write_Text_Constant("AT+CSCS=");
    UART1_Write(34); // "
    UART1_Write_Text_Constant("GSM");
    UART1_Write(34); // "
    UART1_Write(13); //Carriage return (new line)
    Delay_ms(10);
    WaitForRecieveChar(0x0D);
    EmptySerialBuffer();
    CancelAlarmOnClick(); // Check if # is held - if true, disable the alarm and buzzer

    // Set mobile number
    UART1_Write_Text_Constant("AT+CMGS=");
    UART1_Write(34); // "
    UART1_Write_Text_Constant("45"); // Country code (Denmark)
    UART1_Write_Text(MobileNumber);
    UART1_Write(34); // "
    UART1_Write(13); //Carriage return (new line)
    Delay_ms(500);
    WaitForRecieveChar(0x0A);

    // Write message
    i = 0;
    while (message[i] != 0)
    {
        UART1_Write(message[i]);
        i++;
    }
    UART1_Write(26); // Substitution (CTRL+Z)
    WaitForRecieveCharAndBlink(0x0A);
    EmptySerialBuffer();
    CancelAlarmOnClick(); // Check if # is held - if true, disable the alarm and buzzer

    Delay_ms(1000); // Give time to send the message
    GSM_PowerOff();
}
コード例 #2
0
ファイル: stm32f10x_it.c プロジェクト: fidiaslothes/stm32gps
void TIM2_IRQHandler(void)
{
	if ( TIM_GetITStatus(TIM2 , TIM_IT_Update) != RESET ) 
	{	
		TIM_ClearITPendingBit(TIM2 , TIM_FLAG_Update);

		/////////////////////////////////////////////////////////////////
		// Power OFF GPS and GSM before go into standby mode
		/////////////////////////////////////////////////////////////////
		GSM_TurnOnOff_delay();
#ifdef USE_STM32_GPS_BOARD_VB
		GPSPowerOff();
		GSM_PowerOff();
#endif
		/* Wait till RTC Second event occurs */
		RTC_ClearFlag(RTC_FLAG_SEC);
		while(RTC_GetFlagStatus(RTC_FLAG_SEC) == RESET);

		// normal working state
		if(BKP_TRUE == BKP_ReadBackupRegister(BKP_DR1))
		{
			/* Set the RTC Alarm after xx s */
			DEBUG("in timer2 bkptrue %d\n", (BKP_ReadBackupRegister(BKP_DR4) + BKP_ReadBackupRegister(BKP_DR4) <<16));
			RTC_SetAlarm(RTC_GetCounter()+ ((BKP_ReadBackupRegister(BKP_DR4) + BKP_ReadBackupRegister(BKP_DR4) <<16)/SLEEP_TIM2_RATIO));
		}
		else
		{
			DEBUG("in timer2 bkpfalse\n");
			RTC_SetAlarm(RTC_GetCounter()+ (SLEEP_NORMAL_SEC/SLEEP_TIM2_RATIO));
		}
	
		/* Wait until last write operation on RTC registers has finished */
		RTC_WaitForLastTask();		
		/* Request to enter STANDBY mode (Wake Up flag is cleared in PWR_EnterSTANDBYMode function) */
		PWR_EnterSTANDBYMode();
	}		 	
}