soc
December 16, 2008, 9:36pm
1
Hi,
I am new to Wavecom programming and having read all the documentation and run Eclipse, I cannot find any simple
samples that I can use to send and receive SMS text messages.
It would be very useful to have code to receive specific text message when an IO port line toggles state and to turn ON
an output if a specific text message is sent.
I use a Q2686 module and any code implementation in Lua. AT or C would be appreciated.
Thanks.
davidc
December 17, 2008, 4:25am
2
Hiya,
Have a look at the Telemetry sample application, included in the OpenAT/Oasis sample directory.
cheers, Dave
soc
December 20, 2008, 7:26pm
3
Thanks, Dave.
However, this code is only for inputs. How do I send specific text message to turn on/off an output pin ?
Rgds
Jay
February 6, 2009, 1:25pm
4
Here is a complete sample to toggle an output pin (here GPIO44) when an incoming SMS message arrives with the text “ON” or “OFF”:
#include "adl_global.h"
const u16 wm_apmCustomStackSize = 2048;
// select the IO pin (here GPIO44) --> Check the Product Technical Specification of your Wireless CPU
#define OUTPUT_PIN 44
adl_ioDefs_t output_pin = ADL_IO_GPIO | OUTPUT_PIN;
// configure the IO pin as output with default level set to LOW
adl_ioDefs_t output_pin_cfg = ADL_IO_GPIO | OUTPUT_PIN | ADL_IO_DIR_OUT | ADL_IO_LEV_LOW;
// io handle
s32 output_pin_hdl;
// sms handle
s8 sms_handle;
void toggle_output( bool state )
{
adl_ioWriteSingle ( output_pin_hdl, &output_pin , state );
}
void SMS_ctrl_Handler( u8 Event, u16 Nb )
{
TRACE (( 1, "SMS_ctrl_Handler: Event=%d Nb=%d", Event, Nb ));
}
s32 SMS_Handler( ascii *SmsTel, ascii *SmsTimeOrLength, ascii *SmsText )
{
TRACE (( 1, "SMS_Handler: new SMS message received" ));
if ( ! wm_strncmp( SmsText, "ON", 2 ) )
{
TRACE (( 1, "SMS_Handler: message received to turn ON GPIO%d", OUTPUT_PIN ));
toggle_output( TRUE );
return FALSE; // don't show the SMS indication
}
else if ( ! wm_strncmp( SmsText, "OFF", 3 ) )
{
TRACE (( 1, "SMS_Handler: message received to turn OFF GPIO%d", OUTPUT_PIN ));
toggle_output( FALSE );
return FALSE; // don't show the SMS indication
}
else
{
TRACE (( 1, "SMS_Handler: Unknown message" ));
}
return TRUE; // show the SMS indication
}
void adl_main ( adl_InitType_e InitType )
{
output_pin_hdl = adl_ioSubscribe( 1, &output_pin_cfg, 0, 0, 0 );
if ( output_pin_hdl < 0 )
{
TRACE (( 1, "Failed to subscribe to GPIO%d (error=%d)", OUTPUT_PIN, output_pin_hdl ));
return;
}
sms_handle = adl_smsSubscribe( SMS_Handler, SMS_ctrl_Handler, ADL_SMS_MODE_TEXT );
}
I tested it on OASiS 2.20 (OS 6.20).
I hope this will help you
Jay
soc
February 9, 2009, 11:03pm
5
Thanks, Jay - I will try it out later.
Sean.
llans
March 4, 2009, 3:15pm
6
Hi !
I can’t find how to clear SMS memory.
When I have 30 SMS, new SMS didn’t call SMS handler. I must call AT+CMGD=0,4 from terminal. Is there any other way?
Andrey
Jay
June 5, 2009, 2:59pm
7
If you don’t want to store the SMS messages into the SIM card, then you have just to return FALSE instead of TRUE in the SMS handler.
+++
Jay