Problem when sending sms using a button


I 'm try to send a sms when SW300 is pressed. I read in the document that SW300 pressed is detected by COL0 (PIN 59) and
ROW0 (PIN 68). So I decided to use 1 GPO at 59 and 1 GPI at 68. But when I subscribe it using adl_ioSubscribe, the value return is -11 and it didn’t word. I don’t know why. Can anybody explain me please.

Here is my code:

#include "adl_global.h"
#define GPIO_OUTPUT_PIN 59		//COL0
#define GPIO_INPUT_PIN 68		//ROW0

//SMS service handle
static s8 SmsAutoHandle;

// GPIO service handle
static s32 GPIOHandle_OUT;
static s32 GPIOHandle_IN;
s32 ReadValue;
adl_ioDefs_t GpioConfig_IN = ADL_IO_GPIO | GPIO_INPUT_PIN | ADL_IO_DIR_IN;
const u16 wm_apmCustomStackSize = 1024*3;

s32 GpioEventHandle;

static void SmsCtrlHandler ( u8 Event, u16 Nb )
    /* Does nothing */
			adl_atSendResponse(ADL_AT_RSP,"SMS Sent Successfully");
			adl_atSendResponse(ADL_AT_RSP,"Error sending sms");
			TRACE (( 1, "Error sending sms, try again" ));
			TRACE (( 1, "SMS Sent Successfully" ));
			adl_atSendResponse(ADL_AT_UNS,"Inside default");

static bool SmsHandler ( ascii *SmsTel, ascii *SmsTimeOrLength,
                ascii *SmsText )
	//Do nothing
	return 0;
void GpioEventHandler ( s32 GpioHandle, adl_ioEvent_e Event, u32 Size, void * Param )
	s32 ReadValue_IN;
	s32 ReadValue_OUT;
	TRACE (( 1, "In GpioEventHandler" ));

	// Check event
	switch ( Event )
			ReadValue_IN = adl_ioReadSingle (GPIOHandle_IN, &GpioConfig_IN);
			TRACE (( 1, "Read Value of ROW0" ));
			if (ReadValue_IN == 1)
				TRACE (( 1, "If ROW0 is HIGH, send sms to my cell phone" ));
				//adl_ioWriteSingle ( GPIOHandle_OUT, &GpioConfig_OUT, TRUE );
				//ReadValue = adl_ioReadSingle (GPIOHandle_IN, &GpioConfig_IN);
				adl_smsSend(SmsAutoHandle, "0935020991", "Button 0 is pressed", ADL_SMS_MODE_TEXT);
		//adl_ioWriteSingle ( GPIOHandle_OUT, &GpioConfig_OUT, FALSE );

void adl_main ( adl_InitType_e InitType )
	s32 ReadValue_IN, ReadValue_OUT;

	//SMS Subscribe
	TRACE (( 1, "In Main Application" ));
	SmsAutoHandle = adl_smsSubscribe((adl_smsHdlr_f)SmsHandler,
	    		(adl_smsCtrlHdlr_f)SmsCtrlHandler, ADL_SMS_MODE_TEXT);
	TRACE (( 1, "SMS is subscribed" ));
	TRACE (( 1, "SmsAutoHandle value is %d", SmsAutoHandle ));

	//GPIO Subscribe
	GpioEventHandle = adl_ioEventSubscribe (GpioEventHandler);
	TRACE (( 1, "GPIO Event is subscribed" ));
	TRACE (( 1, "GpioEventHandle value is %d", GpioEventHandle ));

	GPIOHandle_OUT = adl_ioSubscribe ( 1, &GpioConfig_OUT, 0, 0, 0 );
	GPIOHandle_IN = adl_ioSubscribe ( 1, &GpioConfig_IN, ADL_TMR_TYPE_100MS, 1, GpioEventHandle );

	TRACE (( 1, "GPIOHandle_OUT value is %d", GPIOHandle_OUT ));
	TRACE (( 1, "GPIOHandle_IN value is %d", GPIOHandle_IN ));

	//adl_ioWriteSingle ( GPIOHandle_OUT, &GpioConfig_OUT, TRUE );
	//TRACE (( 1, "SET COL0 HIGH" ));

	ReadValue_IN = adl_ioReadSingle (GPIOHandle_IN, &GpioConfig_IN);		//Read ROW0
	ReadValue_OUT = adl_ioReadSingle (GPIOHandle_OUT, &GpioConfig_OUT);		//Read COL0
	TRACE (( 1, "ROW0 value is %d", ReadValue_IN ));
	TRACE (( 1, "COL0 value is %d", ReadValue_OUT ));

Trace view:


Did you look up the meaning of a return code of -11 :question:


Yes. It means:
ADL_RET_ERR_DONE -11 ///< The required iterative process is now terminated

But I don’t understand. My English is not good so can u explain it for me, please


Perhaps you should look through the documentation about GPIO some more.

There is no GPIO 59 and GPIO 68.
Those are the pin numbers on the module, but not the GPIO id’s.

For example if you look in the PTS for Q268x you can see that ROW0 is multiplexed with GPIO 9, so your

#define GPIO_INPUT_PIN 68

should be

#define GPIO_INPUT_PIN 9


OK. It’s my fault. Tks. But when I change it.

#define GPIO_INPUT_PIN 4   //COL0
#define GPIO_INPUT_PIN 9   //ROW0

The returned value is still -11 ADL_RET_ERR_DONE -11 ///< The required iterative process is now terminated
I don’t know why. Can you help me please?


If you’re looking at “COL” and “ROW”, shouldn’t you be using the keypad interface - rather than “raw” GPIO :question:

You might have to disable the keypad interface first before you can use those as “raw” GPIO…


I still don’t understand. My idea is using SW300 like a button to send a sms. Can you tell me how to detect when the SW300 is pressed. And how to use or disable the keypad interface. I can’t find it in the document


Study the DevKit documentation to see how the KEYPAD buttons are connected to the Module.

You will also need to study the [b]Product Technical Spec /b for the Module.

Look at the ‘DTMF Keyboard’ sample…