Sending sms

hi Friends,

I am new to this forum and GSM.I need code for sending sms can pls anyone help me.

kavitha

Start by reading the document, Getting Started with Open-AT - the clue is in the name!
This tells you how to install the tools

Then read the Tutorial for Open-AT - this takes you through building & running a simple “Hello, World” application.

Then look at the supplied sample applications - these include examples of sending SMS, and much more…

Hi kavithakg, :unamused:

After read all documents that awnei told you, try to run the code below. It is a very simple SMS example.

Good luck !!!

Gus

/***************************************************************************
PI Componentes - Gustavo M. Nunes

Objetivo:  Mandar e receber SMS

Descricao: 

  1) Cria um comando chamado "at+sndsms" para mandar SMS
  2) Mostrar na tela os dados recebidos no SMS
		   
Antes de ler esse exemplo, leia os seguintes exemplos:

  1) AtComV1

Upgrades:  

  1) Guarda infos da mensagem na Flash
  2) Verificar se tem mensagens nao lidas

Data Criacao:		30-Dez-2005
Ultima Atualizacao: 30-Dez-2005
/***************************************************************************/

#include "adl_global.h"

/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStack                                                      */
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
u32 wm_apmCustomStack [ 256 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );


/***************************************************************************/
/*  Local variables                                                        */
/***************************************************************************/
s8 Handle;  //Usado para SMS Subscribe

ascii buff[250]; //Usado para armazenar SMS recebidos

/***************************************************************************/
/*  Function   : tmrHandler                                                */
/*-------------------------------------------------------------------------*/
/*  Object     : Mostra o texto do SMS recebido                            */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  ID                |   |   |   |  ID do timer                           */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void tmrHandler(u8 ID){
	
	//Mostra a variavel "buff", que foi preenchida na funcao SMSHandler
	adl_atSendResponse ( ADL_AT_UNS, buff );

}

/***************************************************************************/
/*  Function   : SMSHandler                                                */
/*-------------------------------------------------------------------------*/
/*  Object     : Essa funcao é executada toda vez que o modulo receber um  */
/*               SMS                                                       */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  SmsTel            |   |   |   |  # do telefone do remetente            */
/*--------------------+---+---+---+----------------------------------------*/
/*  SmsTimeLength     |   |   |   |  SMS time stamp                        */
/*--------------------+---+---+---+----------------------------------------*/
/*  SmsText           |   |   |   |  Texto do SMS                          */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
bool SMSHandler (ascii *SmsTel, ascii *SmsTimeLength, ascii *SmsText){

	//Armazena o numero do telefone e a mensagem na variavel "buff"
	wm_sprintf(buff, "\r\n+SMS: %s\n\r%s\r\n", SmsTel, SmsText);

	//Dispara um timer de 1 seg
	adl_tmrSubscribe(FALSE,10,ADL_TMR_TYPE_100MS,tmrHandler);

	return TRUE;

}

/***************************************************************************/
/*  Function   : SMSCtrlHandler                                            */
/*-------------------------------------------------------------------------*/
/*  Object     : Eventos de controle do SMS, essa funcao é executada toda  */
/*               vez que algum evento de SMS ocorre                        */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  Event             |   |   |   |  Eventos do SMS                        */
/*--------------------+---+---+---+----------------------------------------*/
/*  Nb                |   |   |   |  Complemento do evento                 */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void SMSCtrlHandler (u8 Event, u16 Nb){

	switch(Event){
		case ADL_SMS_EVENT_SENDING_OK: //SMS enviado ao destinatario com sucesso
			adl_atSendResponse ( ADL_AT_UNS, "\n\rADL_SMS_EVENT_SENDING_OK\n\r" );
			break;
		case ADL_SMS_EVENT_SENDING_MR: //SMS enviado a rede da operadora
			adl_atSendResponse ( ADL_AT_UNS, "\n\rADL_SMS_EVENT_SENDING_MR\n\r" );
			break;
		default:
			adl_atSendResponse ( ADL_AT_UNS, "\n\rSMS Error\n\r" );
			break;
	}
}

/***************************************************************************/
/*  Function   : AtSndSMS                                                  */
/*-------------------------------------------------------------------------*/
/*  Object     : Mandar SMS                                                */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  paras             |   |   |   |  Paramentos do comando                 */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void AtSndSMS (adl_atCmdPreParser_t * paras)
{
	//Variaveis
	ascii * phone;
	ascii * text;

	char msg[20];

	//Capturar os parametros do comando
	phone = ADL_GET_PARAM(paras,0);

	text = ADL_GET_PARAM(paras,1);

	//Manda o SMS
	adl_smsSend(Handle,phone,text,ADL_SMS_MODE_TEXT);

	adl_atSendResponse ( ADL_AT_RSP, "\n\rOK\n\r" );

}

/***************************************************************************/
/*  Function   : SmsInit                                                   */
/*-------------------------------------------------------------------------*/
/*  Object     : Inicializacao dos seviços SMS   	                       */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*		              |   |   |   |					                       */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void SmsInit()
{
	//SMS Subscribe
	Handle = adl_smsSubscribe(SMSHandler,SMSCtrlHandler,ADL_SMS_MODE_TEXT);

	//AT Subscribe
	adl_atCmdSubscribe("at+sndsms",AtSndSMS,ADL_CMD_TYPE_PARA|0x0022);

	//Mensagem de retorno
	adl_atSendResponse ( ADL_AT_UNS, "\n\rServico SMS iniciado !!\n\r");
}

/***************************************************************************/
/*  Function   : SimHandler                                                */
/*-------------------------------------------------------------------------*/
/*  Object     : Eventos do SimCard					                       */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  Event             |   |   |   |  Eventos do SimCard                    */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void SimHandler (u8 Event){

	switch(Event){

	//Normal Events
	case ADL_SIM_EVENT_PIN_OK: //PIN Code correto
			adl_atSendResponse ( ADL_AT_UNS, "PIN Ok\n\r");
	break;
	case ADL_SIM_EVENT_REMOVED: //SimCard foi removido
			adl_atSendResponse ( ADL_AT_UNS, "PIN Removido\n\r");
	break;
	case ADL_SIM_EVENT_INSERTED: //SimCard foi inserido
			adl_atSendResponse ( ADL_AT_UNS, "PIN Inserido\n\r");
	break;
	case ADL_SIM_EVENT_FULL_INIT: //SimCard foi totalmente iniciado
			adl_atSendResponse ( ADL_AT_UNS, "SimCard iniciado !!\n\r");
		
			SmsInit(); //Inicia as funcoes do SMS
	break;

	//Error Events
	case ADL_SIM_EVENT_PIN_ERROR: //PIN Code incorreto
			adl_atSendResponse ( ADL_AT_UNS, "PIN Incorreto\n\r");
	break;

	/*Erro quando se e necessario inserir o PIN Code
	  Por comandos AT, insera o PIN Code usando
	  AT+CPIN="xxxx", onde xxxx e o codigo de 4 digitos*/
	case ADL_SIM_EVENT_PIN_WAIT:
			adl_atSendResponse ( ADL_AT_UNS, "Entre com o PIN Code\n\r");
	break;
	}
}

/***************************************************************************/
/*  Function   : adl_main                                                  */
/*-------------------------------------------------------------------------*/
/*  Object     : Customer application initialisation                       */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  InitType          |   |   |   |  Application start mode reason         */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
	//Inicio da aplicacao
	adl_atSendResponse(ADL_AT_UNS, "\n\rInicio da aplicacao\n\r");

	//Sim Card
	adl_simSubscribe(SimHandler,NULL);

}

Yeah!! SMPP Server should have its focus on creating personalized and custom solutions for customers for empowering their business communications and for providing an affordable platform for interacting with thousands of individuals within a very short span of time.