Introducing certain delay between messages

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Introducing certain delay between messages

Rodrigo Montiel
Hi list,

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 have download the latest version of gnokii/smsd and compiled as it is shown below:

Host system:        linux-gnu
    Gnokii version:     0.6.31
    Xgnokii version:    1.0
    SMSD version:       1.5.2
    X (GTK+) support:   no
    smsd support:       yes
    Postgres support:   no
    SQLite support:     no
    MySQL support:      yes
    Debug:              yes
    XDebug:             yes
    RLPDebug:           yes
    NLS:                yes
    IrDA:               yes
    ical read support:  no
    Bluetooth:          no
    libusb support:     no
    phonet support:     no
    libpcsclite support:no
    readline support:   no
    Security:           no
    Build Shared Lib:   yes
    Build Static Lib:   yes
    Windows:            no
    Prefix:             /opt/daemon

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.

Thanks in advanced,



_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users
Reply | Threaded
Open this post in threaded view
|

Re: Introducing certain delay between messages

Jan Derfinak


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
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/gnokii-users
>

_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users
Reply | Threaded
Open this post in threaded view
|

Re: Introducing certain delay between messages

Jan Derfinak
Jan Derfinak wrote:

Hello

A accidentally hit the Send button instead of Save. :)

So the last sentence should be:
It is written from scratch, so maybe you need some debugging and tuning.

Best regards.
Jan


>
>
> 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
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/gnokii-users
>>


_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users
Reply | Threaded
Open this post in threaded view
|

Re: Introducing certain delay between messages

Rodrigo Montiel
Thank you Jan!

Let's give a try, will let you know the results as soon as I test it.

Kind Rgds,

-Rod

On Fri, 2013-11-15 at 08:56 +0100, Jan Derfinak wrote:
Jan Derfinak wrote:

Hello

A accidentally hit the Send button instead of Save. :)

So the last sentence should be:
It is written from scratch, so maybe you need some debugging and tuning.

Best regards.
Jan


> 
> 
> 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
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/gnokii-users
>>


_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users

--
Rodrigo Montiel
Ing. en Telecomunicaciones
Elastix Certified Engineer ECE#209728189
Mikrotik Certified MTCNA#1210NA066

Cel: +549 351 2581376

Freetech Solutions
www.freetechsolutions.com.ar
Tel/Fax: +54 351 6387585


_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users
Reply | Threaded
Open this post in threaded view
|

Re: Introducing certain delay between messages

Rodrigo Montiel
Hi Jan, just to let you know this worked out as expected, many thanks!

I have just modified the first static declaration as follow:

static time_t timer; // added
timer = time (NULL);  // added

instead of:

static time_t timer = time (NULL); // added

I will try to get a way to have the initial delay as a variable (i.e, 60 secs, then 40, then 50, ).
This is because I have noticed different behaviors in different GSM telcos with regards to the sms speed.

Anyway, your input was flawlessly. Thanks so much.

-Rod

On Fri, 2013-11-15 at 09:02 -0300, Rodrigo Montiel wrote:
Thank you Jan!

Let's give a try, will let you know the results as soon as I test it.

Kind Rgds,

-Rod

On Fri, 2013-11-15 at 08:56 +0100, Jan Derfinak wrote:
Jan Derfinak wrote:

Hello

A accidentally hit the Send button instead of Save. :)

So the last sentence should be:
It is written from scratch, so maybe you need some debugging and tuning.

Best regards.
Jan


> 
> 
> 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
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/gnokii-users
>>


_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users

_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users




--
Rodrigo Montiel
Ing. en Telecomunicaciones
Elastix Certified Engineer ECE#209728189
Mikrotik Certified MTCNA#1210NA066

Cel: +549 351 2581376

Freetech Solutions
www.freetechsolutions.com.ar
Tel/Fax: +54 351 6387585


_______________________________________________
gnokii-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/gnokii-users