Problem creating AT Commands

Hello everybody,

I have a Fastrack Supreme 20 and I’m working on an application, that sends SMS’s when a GPIO receives a pulse. I figured out how to make like a “AT ‘set’ command” that tells the program, to what cellphone number it has to send a SMS and with what text, depending on what GPIO is activated. The number of cellphones that can receive this SMS is up to 5 and the “AT Command” that I created was:

at+optoc = <cellphone 1-5> , , <Text for the GPIO 21> ,

It works great when I just set one cellphone but when I give this “AT Command” for the 2nd, 3rd, 4th or 5th cellphone… (I mean, when I set more than one cellphone) there are problems with the variables, that store the cellphone number and the text for the GPIO’s

Here is my code:

/********************************************************************************************/
/*  signal_generator.c   -  Copyright Wavecom S.A. (c) 2006                                 */
/*                                                                                          */
/*                                                                                          */
/* DISCLAIMER OF WARRANTY                                                                   */
/* ======================                                                                   */
/* This Software is provided free of charge on an 'as is' basis. No warranty is given       */
/* by Wavecom S.A. in relation to the Software of the uses to which it may be put by you,   */
/* the user, or its merchantability, fitness or suitability for any particular purpose      */
/* or conditions; and/or that the use of the Software and all documentation relating        */
/* thereto by the Licensee will not infringe any third party copyright or other             */
/* intellectual property rights. Wavecom S.A. shall furthermore be under no obligation      */
/* to provide support of any nature for the Software and the Documentation.                 */
/*                                                                                          */
/* LIMIT OF LIABILITY                                                                       */
/* ==================                                                                       */
/* In no event shall Wavecom S.A. be liable for any loss or damages whatsoever or howsoever */
/* caused arising directly or indirectly in connection with this licence, the Software,     */
/* its use or otherwise except to the extent that such liability may not be lawfully        */
/* excluded. Notwithstanding the generality of the foregoing, Wavecom S.A. expressly        */
/* excludes liability for indirect, special, incidental or consequential loss or damage     */
/* which may arise in respect of the Software or its use, or in respect of other equipment  */
/* or property, or for loss of profit, business, revenue, goodwill or anticipated savings.  */
/*                                                                                          */
/********************************************************************************************/

/***************************************************************************/
/*  File      : signal_generator.c                                         */
/*-------------------------------------------------------------------------*/
/*  Scope     : Signal Generator sample (TCU interrupt handling sample)    */
/*                                                                         */
/***************************************************************************/

#include "adl_global.h"
#define GPIO_INPUT1 25
#define GPIO_INPUT 21

// GPIO service handle
static s32 MyGPIOHandle_IN1;
static s32 MyGPIOHandle_IN;
s32 ReadValue;
s32 ReadValue1;
adl_ioDefs_t GpioConfig_IN1 = ADL_IO_GPIO | GPIO_INPUT1 | ADL_IO_DIR_IN;
adl_ioDefs_t GpioConfig_IN = ADL_IO_GPIO | GPIO_INPUT | ADL_IO_DIR_IN;


/***************************************************************************/
/*  Mandatory variables (Call stack sizes)                                 */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024*3;


/***************************************************************************/
/*  Local variables                                                        */
/***************************************************************************/

// Commands strings
static const ascii * AtCmdStr_OPTOC = "AT+OPTOC";

//Variables para el celular 1
ascii *num1, *texth1, *textl1;
bool cel1=FALSE;

//Variables para el celular 2
ascii *num2, *texth2, *textl2;
bool cel2=FALSE;

//Variables para el celular 3
ascii *num3, *texth3, *textl3;
bool cel3=FALSE;

//Variables para el celular 4
ascii *num4, *texth4, *textl4;
bool cel4=FALSE;

//Variables para el celular 5
ascii *num5, *texth5, *textl5;
bool cel5=FALSE;

//Variables para mensajes
s8 handle;
void SimHandler(u8 Event);
void SmsCtrlHandler( u8 Event, u16 Nb );
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText );

//MyMsg
//ascii *myMsg;

//GPIO's
s32 MyGpioEventHandle;
s32 MyGpioEventHandle1;

// GPIO service handle
static s32 MyGPIOHandle_IN1 = ERROR;
static s32 MyGPIOHandle_IN = ERROR;

//Contadores
int counter1 = 1;
int counter2 = 1;
int conth = 0;
int contl = 0;

//Funciones
void celh1 (u8 Id);
void celh2 (u8 Id);
void celh3 (u8 Id);
void celh4 (u8 Id);
void celh5 (u8 Id);
void cell1 (u8 Id);
void cell2 (u8 Id);
void cell3 (u8 Id);
void cell4 (u8 Id);
void cell5 (u8 Id);

/***************************************************************************/
/*  Local functions                                                        */
/***************************************************************************/

/****************************************************************************/
/*  Function   : MyControlCommandHandler                                    */
/*--------------------------------------------------------------------------*/
/*  Scope  : AT+SIGNAL command handler                                      */
/*                                                                          */
/*  Return : VOID                                                           */
/*                                                                          */
/*--------------------+---+---+---------------------------------------------*/
/*  Variable Name     |IN |OUT|  Use                                        */
/*--------------------+---+---+---------------------------------------------*/
/* params             | X |   | Incoming AT command parameters              */
/*--------------------+---+---+---------------------------------------------*/
/****************************************************************************/
static void MyControlCommandHandler ( adl_atCmdPreParser_t * params )
{
    // Switch on command type
    switch ( params->Type )
    {
        // Parameters command
        case ADL_CMD_TYPE_PARA :
        {
        // Analyses parameters
            ascii * P0 = ADL_GET_PARAM ( params, 0 ),
				  * P1 = ADL_GET_PARAM ( params, 1 ),
                  * P2 = ADL_GET_PARAM ( params, 2 ),
                  * P3 = ADL_GET_PARAM ( params, 3 );
            u16 iP0;
            //u32 iP1;
            //char iP2; //iP3;

            adl_atSendResponse(ADL_AT_RSP, "\r\n");
            adl_atSendResponse(ADL_AT_RSP, "Celular: ");
            adl_atSendResponse(ADL_AT_RSP, P0);
            adl_atSendResponse(ADL_AT_RSP, "\r\n");
            adl_atSendResponse(ADL_AT_RSP, "Numero: ");
            adl_atSendResponse(ADL_AT_RSP, P1);
            adl_atSendResponse(ADL_AT_RSP, "\r\n");
            adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ARRIBA: ");
            adl_atSendResponse(ADL_AT_RSP, P2);
            adl_atSendResponse(ADL_AT_RSP, "\r\n");
            adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ABAJO: ");
            adl_atSendResponse(ADL_AT_RSP, P3);
            adl_atSendResponse(ADL_AT_RSP, "\r\n---------------------------------\r\n");

            if ((iP0 = wm_atoi ( P0 ))==1)
            {
            TRACE (( 1, "Celular 1 definido" ));
            adl_atSendResponse(ADL_AT_RSP, "OK");
            	num1=P1;
            	texth1=P2;
            	textl1=P3;
            	cel1=TRUE;
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Celular: ");
                adl_atSendResponse(ADL_AT_RSP, P0);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Numero: ");
                adl_atSendResponse(ADL_AT_RSP, num1);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ARRIBA: ");
                adl_atSendResponse(ADL_AT_RSP, texth1);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ABAJO: ");
                adl_atSendResponse(ADL_AT_RSP, textl1);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
            }

            if ((iP0 = wm_atoi ( P0 ))==2)
            {
            TRACE (( 1, "Celular 2 definido" ));
            adl_atSendResponse(ADL_AT_RSP, "OK");
                num2=P1;
                texth2=P2;
                textl2=P3;
                cel2=TRUE;
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Celular: ");
                adl_atSendResponse(ADL_AT_RSP, P0);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Numero: ");
                adl_atSendResponse(ADL_AT_RSP, num2);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ARRIBA: ");
                adl_atSendResponse(ADL_AT_RSP, texth2);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ABAJO: ");
                adl_atSendResponse(ADL_AT_RSP, textl2);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
            }

            if ((iP0 = wm_atoi ( P0 ))==3)
            {
            TRACE (( 1, "Celular 3 definido" ));
            adl_atSendResponse(ADL_AT_RSP, "OK");
                num3=P1;
                texth3=P2;
                textl3=P3;
                cel3=TRUE;
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Celular: ");
                adl_atSendResponse(ADL_AT_RSP, P0);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Numero: ");
                adl_atSendResponse(ADL_AT_RSP, num3);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ARRIBA: ");
                adl_atSendResponse(ADL_AT_RSP, texth3);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ABAJO: ");
                adl_atSendResponse(ADL_AT_RSP, textl3);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
            }

            if ((iP0 = wm_atoi ( P0 ))==4)
            {
            TRACE (( 1, "Celular 4 definido" ));
            adl_atSendResponse(ADL_AT_RSP, "OK");
                num4=P1;
                texth4=P2;
                textl4=P3;
                cel4=TRUE;
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Celular: ");
                adl_atSendResponse(ADL_AT_RSP, P0);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Numero: ");
                adl_atSendResponse(ADL_AT_RSP, num4);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ARRIBA: ");
                adl_atSendResponse(ADL_AT_RSP, texth4);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ABAJO: ");
                adl_atSendResponse(ADL_AT_RSP, textl4);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
            }

            if ((iP0 = wm_atoi ( P0 ))==5)
            {
            TRACE (( 1, "Celular 5 definido" ));
            adl_atSendResponse(ADL_AT_RSP, "OK");
                num5=P1;
                texth5=P2;
                textl5=P3;
                cel5=TRUE;
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Celular: ");
                adl_atSendResponse(ADL_AT_RSP, P0);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Numero: ");
                adl_atSendResponse(ADL_AT_RSP, num5);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ARRIBA: ");
                adl_atSendResponse(ADL_AT_RSP, texth5);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
                adl_atSendResponse(ADL_AT_RSP, "Mensaje Pera ABAJO: ");
                adl_atSendResponse(ADL_AT_RSP, textl5);
                adl_atSendResponse(ADL_AT_RSP, "\r\n");
            }
        }
    }
}


//Entrada 21: Pera de nivel que se encuentra ARRIBA
void MyGpioEventHandler ( s32 GpioHandle, adl_ioEvent_e Event, u32 Size, void * Param )
{
   TRACE (( 1, "EVENT" ));

// Check event
switch ( Event )
	{
	case ADL_IO_EVENT_INPUT_CHANGED :
    adl_atSendResponse(ADL_AT_RSP, "\r\nEntrada 21");
	   if ( counter1 % 2 == 0)
	   {
		   TRACE (( 1, "Mandando SMS E21" ));
		   if (cel1==TRUE)
			   adl_tmrSubscribe ( FALSE, 1, ADL_TMR_TYPE_100MS, celh1);
		   if (cel2==TRUE)
			   adl_tmrSubscribe ( FALSE, 71, ADL_TMR_TYPE_100MS, celh2);
		   if (cel3==TRUE)
			   adl_tmrSubscribe ( FALSE, 141, ADL_TMR_TYPE_100MS, celh3);
		   if (cel4==TRUE)
			   adl_tmrSubscribe ( FALSE, 211, ADL_TMR_TYPE_100MS, celh4);
		   if (cel5==TRUE)
			   adl_tmrSubscribe ( FALSE, 281, ADL_TMR_TYPE_100MS, celh5);
	   }
	counter1 ++;
	}
}

//Entrada 25: Pera de nivel que se encuentra ABAJO
void MyGpioEventHandler1 ( s32 GpioHandle, adl_ioEvent_e Event, u32 Size, void * Param )
{
   TRACE (( 1, "EVENT" ));

// Check event
switch ( Event )
	{

   case ADL_IO_EVENT_INPUT_CHANGED :
	   adl_atSendResponse(ADL_AT_RSP, "\r\nEntrada 25");
	   if ( counter2 % 2 == 0)
	   {
		   TRACE (( 1, "Mandando SMS E25" ));
		   if (cel1==TRUE)
			   adl_tmrSubscribe ( FALSE, 1, ADL_TMR_TYPE_100MS, cell1);
		   if (cel2==TRUE)
			   adl_tmrSubscribe ( FALSE, 71, ADL_TMR_TYPE_100MS, cell2);
		   if (cel3==TRUE)
			   adl_tmrSubscribe ( FALSE, 141, ADL_TMR_TYPE_100MS, cell3);
		   if (cel4==TRUE)
			   adl_tmrSubscribe ( FALSE, 211, ADL_TMR_TYPE_100MS, cell4);
		   if (cel5==TRUE)
			   adl_tmrSubscribe ( FALSE, 281, ADL_TMR_TYPE_100MS, cell5);
	   }
	counter2 ++;
	}
}

void celh1 (u8 Id)
{
	ascii *myMsg1;
	myMsg1 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg1[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg1, "%s", texth1);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg1);
		adl_smsSend( handle, num1 , myMsg1, ADL_SMS_MODE_TEXT );
   	adl_memRelease(myMsg1);
}

void celh2 (u8 Id)
{
	ascii *myMsg2;
	myMsg2 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg2[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg2, "%s", texth2);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg2);
		adl_smsSend( handle, num2 , myMsg2, ADL_SMS_MODE_TEXT );
   	adl_memRelease(myMsg2);
}

void celh3 (u8 Id)
{
	ascii *myMsg3;
	myMsg3 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg3[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg3, "%s", texth3);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg3);
		adl_smsSend( handle, num3 , myMsg3, ADL_SMS_MODE_TEXT );
	adl_memRelease(myMsg3);
}

void celh4 (u8 Id)
{
	ascii *myMsg4;
	myMsg4 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg4[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg4, "%s", texth4);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg4);
		adl_smsSend( handle, num4 , myMsg4, ADL_SMS_MODE_TEXT );
  	adl_memRelease(myMsg4);
}

void celh5 (u8 Id)
{
	ascii *myMsg5;
	myMsg5 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg5[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg5, "%s", texth5);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg5);
		adl_smsSend( handle, num5 , myMsg5, ADL_SMS_MODE_TEXT );
  	adl_memRelease(myMsg5);
}

void cell1 (u8 Id)
{
	ascii *myMsg6;
	myMsg6 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg6[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg6, "%s", textl1);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg6);
		adl_smsSend( handle, num1 , myMsg6, ADL_SMS_MODE_TEXT );
   	adl_memRelease(myMsg6);
}

void cell2 (u8 Id)
{
	ascii *myMsg7;
	myMsg7 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg7[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg7, "%s", textl2);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg7);
		adl_smsSend( handle, num2 , myMsg7, ADL_SMS_MODE_TEXT );
   	adl_memRelease(myMsg7);
}

void cell3 (u8 Id)
{
	ascii *myMsg8;
	myMsg8 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg8[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg8, "%s", textl3);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg8);
		adl_smsSend( handle, num3 , myMsg8, ADL_SMS_MODE_TEXT );
	adl_memRelease(myMsg8);
}

void cell4 (u8 Id)
{
	ascii *myMsg9;
	myMsg9 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg9[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg9, "%s", textl4);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg9);
		adl_smsSend( handle, num4 , myMsg9, ADL_SMS_MODE_TEXT );
  	adl_memRelease(myMsg9);
}

void cell5 (u8 Id)
{
	ascii *myMsg0;
	myMsg0 = adl_memGet(sizeof(ascii)*128);    // allocate memory for string
	myMsg0[0] = 0x00;                          // ensure string starts with 'NUL'
	wm_sprintf(myMsg0, "%s", textl5);
		adl_atSendResponse(ADL_AT_RSP,"\r\n");
		adl_atSendResponse(ADL_AT_RSP, myMsg0);
		adl_smsSend( handle, num5 , myMsg0, ADL_SMS_MODE_TEXT );
  	adl_memRelease(myMsg0);
}

void SimHandler(u8 Event)
{
TRACE((1, " In Sim Handler"));
switch(Event)
{
case ADL_SIM_EVENT_REMOVED:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_REMOVED");
break;
case ADL_SIM_EVENT_INSERTED:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_INSERTED");
break;
case ADL_SIM_EVENT_FULL_INIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_FULL_INIT");
break;
case ADL_SIM_EVENT_PIN_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_ERROR");
break;
case ADL_SIM_EVENT_PIN_OK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_OK");
break;
case ADL_SIM_EVENT_PIN_WAIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_WAIT");
break;
case ADL_SIM_EVENT_PUK_WAIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PUK_WAIT");
break;
case ADL_SIM_EVENT_PUK_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PUK_ERROR");
break;
case ADL_SIM_EVENT_FAILURE:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_FAILURE");
break;
case ADL_SIM_EVENT_NET_LOCK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_NET_LOCK");
break;
}
}
void SmsCtrlHandler( u8 Event, u16 Nb )
{
TRACE((1, " IN SMS Ctrl handler"));
switch(Event)
{
case ADL_SMS_EVENT_SENDING_OK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_OK");
break;
case ADL_SMS_EVENT_SENDING_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_ERROR");
break;
case ADL_SMS_EVENT_SENDING_MR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_MR");
break;
}
}
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText )
{
TRACE((1, " IN SMS data handler"));
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Phone Number: ");
adl_atSendResponse(ADL_AT_RSP, SmsTel);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Time: ");
adl_atSendResponse(ADL_AT_RSP, SmsTimeOrLength);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Text: ");
adl_atSendResponse(ADL_AT_RSP, SmsText);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
return TRUE;
}


/****************************************************************************/
/*  Function   : adl_main                                                   */
/*--------------------------------------------------------------------------*/
/*  Scope      : Customer application initialisation                        */
/*                                                                          */
/*--------------------+---+---+---------------------------------------------*/
/*  Variable Name     |IN |OUT|  Use                                        */
/*--------------------+---+---+---------------------------------------------*/
/* InitType           | X |   | Application start mode reason               */
/*--------------------+---+---+---------------------------------------------*/
/****************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Visual sample: Main" ));

    // Subscribe to the control command
    adl_atCmdSubscribe ( (ascii*) AtCmdStr_OPTOC, MyControlCommandHandler, ADL_CMD_TYPE_PARA | 0x41 );
    // Subscribe the SIM
    adl_simSubscribe ((adl_simHdlr_f)SimHandler, NULL);
    handle = adl_smsSubscribe((adl_smsHdlr_f)SmsHandler, (adl_smsCtrlHdlr_f)SmsCtrlHandler, ADL_SMS_MODE_TEXT );

       // set up and connect to GPIO
       MyGpioEventHandle = adl_ioEventSubscribe (MyGpioEventHandler);
       MyGpioEventHandle1 = adl_ioEventSubscribe (MyGpioEventHandler1);
       MyGPIOHandle_IN = adl_ioSubscribe ( 1, &GpioConfig_IN, 1, 1, MyGpioEventHandle );
       TRACE (( 1, "GPIO_IN handle: %d", MyGPIOHandle_IN ));
       MyGPIOHandle_IN1 = adl_ioSubscribe ( 1, &GpioConfig_IN1, 1, 1, MyGpioEventHandle1 );
       TRACE (( 1, "GPIO_IN1 handle: %d", MyGPIOHandle_IN1  ));

       // operate on GPIO
       adl_ioWriteSingle ( MyGPIOHandle_IN1, &GpioConfig_IN1, TRUE );
       adl_ioWriteSingle ( MyGPIOHandle_IN, &GpioConfig_IN, TRUE );
       ReadValue = adl_ioReadSingle (MyGPIOHandle_IN, &GpioConfig_IN);
       TRACE (( 1, "PIN IN : %d",ReadValue ));
       ReadValue1 = adl_ioReadSingle (MyGPIOHandle_IN1, &GpioConfig_IN1);
       TRACE (( 1, "PIN IN : %d",ReadValue1 ));

       //TRACE (( 1, "GPIO (%d): %d", GPIO_OUTPUT_PIN, &GpioConfig_OUT ));
       ReadValue = adl_ioReadSingle (MyGPIOHandle_IN, &GpioConfig_IN);
       TRACE (( 1, "PIN IN : %d",ReadValue ));
       ReadValue1 = adl_ioReadSingle (MyGPIOHandle_IN1, &GpioConfig_IN1);
       TRACE (( 1, "PIN IN : %d",ReadValue1 ));

       //TRACE (( 1, "GPIO (%d): %d", GPIO_INPUT_PIN, &GpioConfig_OUT ));
       ReadValue = adl_ioReadSingle (MyGPIOHandle_IN, &GpioConfig_IN);
       TRACE (( 1, "PIN IN : %d",ReadValue ));
       ReadValue1 = adl_ioReadSingle (MyGPIOHandle_IN1, &GpioConfig_IN1);
       TRACE (( 1, "PIN IN : %d",ReadValue1 ));

}

Can anyone please help me?? I really don’t have any idea, why this problem is happening… Please help me with this :unamused: All answers would be very much apreciated!! :blush:

Thanks!!

Pd.- Sorry if there are some phrases in the programm in spanish, but I was a little bit lazy to change them… so just focus on the code :mrgreen:

oh c’mon, is anyone out there?? Please answer…

How about explaining what you actually mean by, “there are problems with the variables” :question:

What debugging have you done so far :question:

The problem with the variables is that they don’t store what I save in them. I write this command that I created and they are supposed to store:

  • The cellphonumber
  • The text to send, when the GPIO 21 is activated
  • The text to send, when the GPIO 25 is activated

in order to take this data and use it to send the “user’s specified text” to the “user’s specified number”. When I defined just ONE number, it works great, it stores the data and when any of the GPIO (21,25) is activated it sends the text that I wrote with the command, but when I want to do that for more cellphones, I mean, when I want to send a message to more cellphones when a GPIO is activated, the variables stores nothing… I check with a “adl_atSendResponse” instruction, what do the ascii variables (used to store the data from the ATCommand) have and it gives me just:

&
&
?_*

So that’s why I say that “there are problems with the variables” because I actually don’t know what’s happening with them, I don’t know if they store the data or not… I just don’t see what the error is, there’s no watchdog, there´s no crash, it just doesn’t store what I give, and therefore (obviously) the SMS is not sent.

Thanks for your reply…

So you need to get debugging!

Use the TRACE and DUMP facilities to see what is actually happening.

I suggest that you start again, from scratch, with just the AT Command stuff. Once you have that working, then add the GPIO and SMS stuff.

And remember: always check the return value from any dynamic memory allocation function before using it!

In fact, why use dynamic memory allocation at all?

Your application has to provide storage for 5 settings anyhow - so why not just make a statically-allocated array?

Keep it Simple!

I didn’t think on something like that… I’ll try it :slight_smile:

Thanks dude!!