Sdk Sample Sms Control - NetModule NB1600 User Manual

Hide thumbs Also See for NB1600:
Table of Contents

Advertisement

A.6. SDK Sample SMS Control
/* This script will execute commands received by SMS and may report the status of the system . */
INTERVAL
= 10;
MAXMSG
= 5;
MAXAGE
= 300;
MAXLINES
= 32;
AUTH
= 1;
ADMPWD
=
" "
;
SENDERS
= mkarray (
/* "+123456789" */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - startup - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* check if we should perform authe ntication */
( argc == 2 && argv [1] ==
" noauth "
if
AUTH = 0;
}
/* retrieve password */
( AUTH ) {
if
( strlen ( ADMPWD ) == 0) {
if
/* use configured admin password */
ADMPWD = nb_config_get (
( strlen ( ADMPWD ) > 0) {
if
nb_syslog (
" using admin password for au then ticat ion "
}
{
else
/* not there -> use a default password instead */
nb_syslog (
" using default password for auth enti catio n "
ADMPWD =
" admin01 "
}
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - functions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* parse message */
string parse ( string msg )
{
/* read by line */
lnr = 0;
ishdr = 1;
tlnr = 0;
allowed = ( length ( SENDERS ) == 0) ? 1 : 0;
lp = msg ;
( lnr = 0; lnr < MAXLINES && strlen ( lp ) > 0; lnr ++) {
for
pos = strchr ( lp ,
" \ n "
) ;
( is_void ( pos ) ) pos = strlen ( lp ) ;
if
line = left ( lp , pos ) ;
lp = substr ( lp , pos + 1) ;
( strlen ( line ) == 0) {
if
/* saw header separator */
ishdr = 0;
;
co ntinue
}
( ishdr ) {
if
/* saw header line */
( left ( line , 5) ==
if
/* check age of message */
sentdate = trim ( substr ( line , 5) ) ;
sent = strptime ( sentdate ,
(! is_void ( sent ) ) {
if
/* got a valid sent date */
now = localtime ( time () ) ;
age = mktime ( now ) - mktime ( sent ) ;
nb_syslog (
( age > MAXAGE ) {
if
nb_syslog (
return
}
}
{
else
nb_syslog (
}
}
( left ( line , 5) ==
else if
from = substr ( line , 6) ;
( length ( SENDERS ) > 0) {
if
( s = 0; s < length ( SENDERS ) ; s ++) {
for
sender = SENDERS [ s ];
NB1600 User Manual
/* only run every 10 seconds
/* process max . 5 msgs
/* message mustn t be older than 5 mins
/* max . number of lines in msg ( incl . header )
/* perform authe ntication
/* password used for authen tication
) ;
/* allowed senders
) {
" admin . password "
) ;
;
" Sent : "
) {
" %Y -% m -% d % H :% M :% S "
" message has been sent % ds ago "
" rejecting too old message "
) ;
" "
;
" time check has been omitted "
) ;
" From : "
) {
146
) ;
) ;
) ;
, age ) ;
*/
*/
*/
*/
*/
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the NB1600 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents