Repeating GPRS Connection


#1

Hello,

I’m using a sample of WIP TCP/IP. Everything works fine but i would like to loop connection to put some info to website peridolicly.

I was trying to do it in many ways.

I’ve used a adl_tmrSubscribe to call external function which body contains

{
    int r;

  /* Initialize the stack */
  r = wip_netInitOpts( 
      WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART1, /* WIP traces on UART1 */
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART2,
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_TRACE,
      WIP_NET_OPT_END);

  /* Depending on the activated flag, take the proper config */
  cfg_gprs( appli_entry_point);
}

The result:

[GPRS]: initialized.
[GSM]: initialized.
[UART1]: initialized.
[UART2]: initialized.
[]: initialized.

and nothing else happens.

I’ve also tried to put cfg_gprs( appli_entry_point) in loop
in two ways
1.)

int r;
 r = wip_netInitOpts( 
      WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART1, /* WIP traces on UART1 */
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART2,
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_TRACE,
      WIP_NET_OPT_END);

  /* Depending on the activated flag, take the proper config */
for(licznik=0; licznik<=2; licznik++)
  {
    cfg_gprs( appli_entry_point);
  }

and 2.)

int r;
int licznik;

for(licznik=0; licznik<=2; licznik++)
  {
 r = wip_netInitOpts( 
      WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART1, /* WIP traces on UART1 */
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART2,
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_TRACE,
      WIP_NET_OPT_END);

  /* Depending on the activated flag, take the proper config */

    cfg_gprs( appli_entry_point);
  }

both with result

[GPRS]: initialized.
[GSM]: initialized.
[UART1]: initialized.
[UART2]: initialized.
[]: initialized.

+WIND: 1

+WIND: 7

+WIND: 4
[GPRS]: open: -> DISCONNECTED
[GPRS]: start: -> CONNECTING
ASSERTION FAILURE line 115: 0 == (r)

I’m pretty stucked in here. Are fimiliar with this issue? Hope you are :smiley:

Best redgards,
Lukasz


#2

It’s not clear what you are trying to do. Are you trying to have two connections open simultaneously?

Otherwise set up a timer to call your link, and don’t forget to close it, after you have done your transmission!


#3

No, no. What I’m trying to do is open connection and send data every minute, hour etc.

So:
00:00 Open connection, send data, close connection
01:00 Open connection, send data, close connection
02:00 Open connection, send data, close connection

etc.

but as far as I can open, send and close just once. If I try to put above code to loop or use timer connection simply doesnt work (as shown). It’s realy weird. Im intermediate in C and PC application should work just fine this way.

Other way to ask question could be - how to make the WIP TCP/IP Sample code to be repeated for example for 10 times?

I’m developing this app to my engineer diploma, so there is no option that I won’t find the answer.


#4

I think it should be obvious from this that you are not closing the connection properly?

The ‘open’ expects and requires the system to be in a certain state - if your ‘close’ does not return the system to exactly that state, then the next open will not work!

You need to debug your software to find exactly where & why the 2nd ‘open’ is not working - and that should lead you to what has not been correctly/completely cleared by the preceding ‘close’

Remember that all API calls return a result code that will inform you of the reason for any failure…

Read the section in the ADL User Guide about Debug Traces

Look at the State Transition Diagrams in the WIP User Guide that show you the sequence for opening & closing a Bearer and a Socket…


#5

Thanks for reply!

Sorry for misunderstand - once doesnt mean for the first time works, second time doesnt. If i put all the code form sample to adl_main it’s fine, if I put code in loop it’s not

so on example if adl main contains

int r;

r = wip_netInitOpts( 
      WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART1, /* WIP traces on UART1 */
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART2,
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_TRACE,
      WIP_NET_OPT_END);

  /* Depending on the activated flag, take the proper config */

    cfg_gprs( appli_entry_point);

it work. Even if I put all code or one part of the code in loop, example:

int r,i;

r = wip_netInitOpts( 
      WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART1, /* WIP traces on UART1 */
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART2,
      //WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_TRACE,
      WIP_NET_OPT_END);

  /* Depending on the activated flag, take the proper config */
for(i=0; i<=1; i++)
    cfg_gprs( appli_entry_point);

it fail. No matter does it’s first, or last step of loop.

Maybe it’s a problem with variable range?

Redgards,
Lukasz


#6

Note that you’ve just taken a very simplistic example - it was probably never designed to be used like this!

So you need to start Debugging!

Examine the traces to see where it is failing.

If the traces don’t give sufficient information (as it quite likely), then enhance them.

Look at the traces from the original example, and look at the traces when you put it into your loop - compare them, and look for differences that could explain why one works, and the other doesn’t.

Note that debugging is a key skill for software development - it is very important that you learn to do it well!


#7

There’s a lot that needs to be done in between wip_netInit, ensuring GSM registration, establishing the bearer and then sending data. Looks to me like you’re looping around things that kick off a process that fires subsequent events when that’s not the appropriate technique to be employing.

You need to understand how the program works to send a single block of data before you try adding loops. Trace away, as pointed out above.