Re: Introducing certain delay between messages
Jan Derfinak <[email protected]> Fri, 15 Nov 2013 08:48:37 +0100
| Newsgroups | gmane.linux.drivers.gnokii |
|---|---|
| Message-ID | <[email protected]> |
Rodrigo Montiel wrote:
Hello.
> I was researching a little bit about how to introduce a sleep() function
> before each message is sent.
> The reason here is because in my country we are being blocked by telcos
> for any massive sms campaign attempt in order to preserve the gsm network.
>
...
>
> I also have been trying to put some sleep() functions sms_send_single /
> sms_send_long functions, for instance:
>
> ------
> static gn_error sms_send_single(gn_data *data, struct gn_statemachine
> *state)
> {
> sleep(60);
> ------
>
> Im not a guru in C coding, have made just some little (stupid) programs.
> Could you please kindly point me to which function I should review? I do
> not want to destroy this excellent/complex source code.
I think it can work. But if you need it because of smsd, I recommend not
to touch libgnokii code and implement it in smsd code.
You can introduce such delay in smsd/lowlevel.c:A_SendSMSMessage()
function. This code add dynamic delay added only if dealy from previous
message was less than 60 seconds.
Add
#include <time.h>
to includes section of lowlevel.c
Them modify A_SendSMSMessage function:
static gint A_SendSMSMessage (gpointer data)
{
D_SMSMessage *d = (D_SMSMessage *) data;
gn_data *dt;
gn_error status;
static time_t timer = time (NULL); // added
time_t timer_tmp; // added
if (!d)
...
gn_data_clear (dt);
dt->sms = d->sms;
timer_tmp = time (NULL); // added
if ((timer_tmp - timer) < 60) // added
sleep (60 - (timer_tmp - timer)); // added
d->status = gn_sms_send (dt, sm);
timer = time (NULL); // added
status = d->status;
/* we do not use sms reference numbers in smsd */
free (dt->sms->reference);
...
}
It is written from scratch, so maybe you n
>
> Thanks in advanced,
>
>
>
>
> _______________________________________________
> gnokii-users mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/gnokii-users
>