Ive seen a code of a fellow forumer and im building a application similar to him. However i have problems understanding some of the codes which are similar to sms_automation sample.
bool SMS_AUTO_Handler(ascii *SmsTel, ascii *SmsTimeOrLength, ascii *SmsText)
{
u16 pos_sms = 0;
bool sms_tobe_fwd = TRUE;
ascii * reply_text = “DATA from Wavecom Supreme”; ascii Keyword_comp[wm_strlen(smsreply_keyword)]; //this is creating a new string with the same length as smsreply_keyword? i dont see //smsreply_keyword being declared anywhere
}
//SMS contains Keyword(getdata)?
if(Keyword_comp==smsreply_keyword)
{
TRACE (( AUTO_TRACE_LEVEL, “Keyword match”)); *SmsTel=SmsTel_send; // what does this line do? i know *SmsTel is the phone number of the sms that was sent to the modem
}
else
{
TRACE (( AUTO_TRACE_LEVEL, "Keyword no match ")); sms_tobe_fwd=FALSE; //what does this forward function do?
}
Sorry Shaffer, but this code is a total mess. You better start from the scratch (or wavecom sample) than using this.
As soon as program will start it will enter infinite loop, trying to subscribe to SMS service and to send an SMS (without even phone number and SMS text provided). This code is both syntactically and semantically wrong so you can trash it and forget about it.
basically whenever my GSM modem recieves an sms it will check for a certain string and if its a match, it replies to the sender with “correct” and so does the opposite for no match.
/* includes */
#include "adl_global.h"
/* variables */
static s8 sms_automaton_Handle_txt;
static u8 AUTO_TRACE_LEVEL = 2;
static s8 chk = "toaster"; //This is the string to check
/* Constants */
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024;
/***************************************************************************/
/* Function : SMS_AUTO_ctrl_Handler */
/*-------------------------------------------------------------------------*/
/* Objet : SMS Automaton SMS Service Event Handler */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* Event | | | | Event from SMS Service */
/*--------------------+---+---+---+----------------------------------------*/
/* Nb | | | | SMS location */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void SMS_AUTO_ctrl_Handler(u8 Event, u16 Nb)
{
// Does nothing
}
/***************************************************************************/
/* Function : SIM_AUTO_handler */
/*-------------------------------------------------------------------------*/
/* Objet : SMS Automaton SMS Service Data Handler */
/* */
/* Return : sms_tobe_fwd to or not to forward the SMS */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* SmsTel | | | | SMS Data */
/*--------------------+---+---+---+----------------------------------------*/
/* SmsTimeOrLength | | | | SMS Data */
/*--------------------+---+---+---+----------------------------------------*/
/* SmsText | | | | SMS Data */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
bool SMS_AUTO_Handler(ascii *SmsTel, ascii *SmsTimeOrLength, ascii *SmsText)
{
bool sms_tobe_fwd = TRUE;
//check if SmsText is equals to string
if(SmsText == chk){
adl_smsSend(sms_automaton_Handle_txt, SmsTel, "Correct", ADL_SMS_MODE_TEXT); //if it equals, reply sms with "correct"
}
else{
adl_smsSend(sms_automaton_Handle_txt, SmsTel, "Wrong", ADL_SMS_MODE_TEXT); //if it does not equals, reply sms with "Wrong"
}
return sms_tobe_fwd;
}
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Objet : Customer ADL application initialisation */
/* */
/* Return : */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* adlInitType | | | | Application starting mode */
/***************************************************************************/
void adl_main(adl_InitType_e adlInitType)
{
// SMS automaton test application
TRACE (( 1, "SMS automaton sample main" ));
TRACE (( 1, __DATE__ ));
TRACE (( 1, __TIME__ ));
TRACE (( AUTO_TRACE_LEVEL, "Start SMS_Automaton application" ));
// Subscribe to the SMS Service
sms_automaton_Handle_txt = adl_smsSubscribe(SMS_AUTO_Handler, SMS_AUTO_ctrl_Handler, ADL_SMS_MODE_TEXT);
}
Firstly is this correct? and i would like to know since my serial port on the modem is not being used, will it be idle for the whole period of time from modem startup?
Nothing to do with Wavecom or Open-AT, but the basics of the ‘C’ programming language:
The ‘==’ operator cannot be used to compare strings like that!
I think it would probably be easier if you spend some time learning the ‘C’ programming language in a “conventional” environment before trying to apply it in Open-AT.
There are loads of books and tools for learning the ‘C’ programming language on the PC, etc…
Serial ports, as the name suggests, are for Serial Data!
If you take a look at the ADL Open Device Service (specifically, the Open UART Interface) you might be able to do something with that - I’ve never tried it myself…