GPIO question


[b] I am a beginner in openAT,when I try to read value from GPIO, i always got ADL_RET_ERR_UNKNOWN_HDL , and could anyone tell me how to know what value the adl_ioRead( ) return ,and how to know whether the gpio is set or not .
any suggestion will be appreciate.

void tmrHandle( u8 ID )
	adl_ioWrite( gpio4Handler, ADL_IO_Q24X6_GPIO_0 , 1 );
	blGPIO4State = adl_ioRead( gpio4Handler );
	blGPIO0State = adl_ioRead( gpio0Handler );
	if( blGPIO4State || blGPIO0State )

		smsHandler = adl_smsSubscribe(SmsHandle, SmsCtrlHandle, ADL_SMS_MODE_TEXT);
	if( blGPIO4State  )
		smsSendHandle( 1 );
	if( blGPIO0State  )
		smsSendHandle( 0 );

void adl_main ( adl_InitType_e InitType )
    TRACE (( 1, "Embedded Application : Main" ));
	gpio4Handler = adl_ioSubscribe( ADL_IO_Q24X6_GPIO_4, ADL_IO_Q24X6_GPIO_4, 0, 0, ( adl_ioHdlr_f) NULL );
	gpio0Handler = adl_ioSubscribe( ADL_IO_Q24X6_GPIO_0, ADL_IO_Q24X6_GPIO_0, 0, 0, ( adl_ioHdlr_f) NULL );	
	adl_tmrSubscribe( TRUE, 30, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t)tmrHandle );   



You should check if the subscription (adl_ioSubscribe()) proceeded OK or if it failed (the handle would be <0). Make sure (with AT+WIOM?) that the GPIO0 and GPIO4 are available.

You are writing to GPIO0, then you read it. That’s not possible. Even if it’s a GPIO, you have to choose it to be an Input or an Output. This decision is made at the adl_ioSubscribe() call.

It returns a bitmask, one bit for every input, output or GPIO. You have to check the documentation for the assignment (or find it out for yourself). Bits for an Output or a GPIO-output are always 0.

BTW, you should rename your functions… handler would be the function, and handle would be the value returned by adl_xxxSubscribe().
And I guess you’ll want to adl_smsSubscribe() only once, and not before every message send.

And, in the first place, make sure you’re really using OpenAT 3.x . That can be checked with AT+WOPEN=2.