[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sending multiple SMSs via libgnokii
From: |
Peter Koch |
Subject: |
Re: Sending multiple SMSs via libgnokii |
Date: |
Wed, 30 Mar 2011 16:26:22 +0200 |
Dear Pawel Kot:
2011/3/25 Pawel Kot <address@hidden>
>
> On Fri, Mar 25, 2011 at 22:14, Peter Koch <address@hidden> wrote:
> > I'm trying to send multiple SMS via libgnokii API-calls. There seems to be
> > no documentation for the API - at least I could not find any.
>
> Use case of multiple is not much different than single SMS.
> .............
>
> You'd need to repeat only step 2b and 4.
Thanks very much for your answer, but I must be overlooking some trivial
detail. It still does not work without reinitializing gnokii between every
SMS.
I would very much appreciate if you could have a look at the following
source. Whenever state==NULL this routine will sucessfully send
a SMS. If state!=NULL (i.e. state still contains the value from a
previous invocation of gnokii_send) gn_sms_send will fail with a
timout-error. My production code contains lots of debugging and
error-handling code, which I removed to enhance readability.
Kind regards,
Peter
static void gnokii_send(
char *nr,
char *msg
){
static struct gn_statemachine *state=NULL;
static gn_sms_message_center msg_center;
gn_data *data;
gn_sms sms;
if(!state){
if(gn_lib_phoneprofile_load_from_file("/etc/gnokiirc",NULL,&state)!=GN_ERR_NONE)
goto err;
if(gn_lib_phone_open(state)!=GN_ERR_NONE) goto err;
data=&state->sm_data;
data->sms=&sms;
gn_sms_default_submit(data->sms);
data->message_center=&msg_center;
data->message_center->id=1;
if(gn_sm_functions(GN_OP_GetSMSCenter, data,
state)!=GN_ERR_NONE) goto err;
}
data=&state->sm_data;
data->sms=&sms;
gn_sms_default_submit(data->sms);
snprintf(sms.smsc.number, sizeof(sms.smsc.number), "%s",
msg_center.smsc.number);
sms.smsc.type=msg_center.smsc.type;
snprintf(sms.remote.number,sizeof(sms.remote.number), "%s", nr);
sms.remote.type=GN_GSM_NUMBER_Unknown;
sms.user_data[0].type=GN_SMS_DATA_Text;
sprintf(sms.user_data[0].u.text, "%.918s", msg);
sms.user_data[0].length=strlen(sms.user_data[0].u.text);
sms.user_data[1].type=GN_SMS_DATA_None;
if(gn_sms_send(data, state)!=GN_ERR_NONE) goto err;
return;
err:
if(state){
gn_lib_phone_close(state);
gn_lib_phoneprofile_free(&state);
gn_lib_library_free();
}
state=NULL;
}