How to shut down WIP correctly

Hi all,

in difficult conditions it is possible that I can’t get a connection with:
wip_netInit ()
wip_bearerOpen ()

at the first try (using GPRS).
Second possibility is, that the connection is shut down during operation due to lost GPRS connection.

In those cases i try to disconnect correctly via:

wip_close ( io_channel );

wip_bearerStop ( &bearer );

On wip_bearerStop i get an error.

So the question is, how to shut down the GPRS wip connection correctly.
I have tried several other sequences including wip_close, wip_bearerStop, wip_bearerClose without any luck but several RTK errors.

Thanks for your help


You can only use wip_bearerStop on a bearer that you have previously started with wip_bearerStart.

wip_bearerOpen/wip_bearerClose is a “pair”
wip_bearerStart/wip_bearerStop is a “pair”

Normal would be



You should also take care to look at the events that your event handler receives, for example when you lose GPRS.

If a bearer has been stopped due to disconnection you should have received an event to that effect and should know if you need to do wip_bearerStop or not.

I’m still fighting this.
I followed the tip for paired functions but I still get RTK errors.
Do i need to call wip_shutdown paired to wip_TCPClientCreate too?
If not, what else?


channel closed (with wip_shutdown)
bearer stop (wip_bearerStop)
_BAD_HDL (for wip_bearerStop)
_BAD_HDL ( for wip_bearerClose)


The same, when not calling wip_shutdown.

Thanks for your help

Hi list,

as many of you will have seen that

wip_bearerStop ( &bearer );

is a dumb, it needs to be “bearer”, not “&bearer”.

I’m closer to the solution now, but one thing is left:

The sequence


shows WIP_BERR_BAD_STATE for the close statement.
Do i need a delay in this sequence?



If i am correct, the bearerClose() function will stop the associated bearer and close as well but you will not get the WIP_BEV_STOPPED event in your bearer handle. If you only call the bearerStop() function it will stop the bearer but the recources will not be freed and you will get the WIP_BEV_STOPPED event.

Strange, because i don’t see the WIP_BERR_BAD_STATE return code in the documentation for the bearerClose() function (WIPlib 1.10). Which version do you use?

Best Regards,


We use the newest of wavecom openat (4.11, IDE 1.02.03) and WipLib 1.10.02.
I always check for non documented result codes :slight_smile:. Did they promise a complete documentation?:smiley:

I tried to call bearerClose only, but this leads to a RTK error again.
Using wip_bearerStop only results in _OK_INPROGRESS, not showing WIP_BEV_STOPPED at all.
I have a bearerClose in the eventHandler for WIP_BEV_STOPPED that is never called.

For safety i think, i better stay with bearerStop AND bearerClose in the hope that _BAD_STATE is not realy true.

Any other ideas?
Thanks for your help!


I also have a RTK exception problem on wip_bearerStop function. It happens most of the time but not always… It looks like a wip librairy or OS bug… I’m working on a Q2686H under OS4.12, 6.61 and wip 1.10.03. Have you solve this issue since your last mail ? Thanks.

Hi all,
i already solved this problem.
The most important part is, not to close wip at all.
In my case i need a timer controlled start routine for wip and for the tcp connection, so that under rough conditions i can always reconnect.


try wip-connect sequence
->error: start wip-reconnect timer
->success: try to start tcp client

try tcp-connect sequence
->error: start tcp reconnect timer
->success: start transfering data

->start tcp reconnect timer

->start wip reconnect timer

Call wip_bearerClose on wip-handler messages that require it, but call wip_bearerStop only on a manually invoked shutdown.

For the communication itself i only use


as a flow control, never touching the lower leveled wip-functions, when i can avoid it.

Thats how it works for me.




i have the same error. i use HTTP library. Here is my HTTP Handler :

void BL_GPRS_HTTP_Hdlr(wip_event_t *ev, void *ctx){
    wip_channel_t tChannel;
    tChannel = ev->channel;
    u32 * ret;
        case WIP_CEV_OPEN :         
        case WIP_CEV_READ :         
        case WIP_CEV_WRITE :   
        case WIP_CEV_ERROR :                   
        case WIP_CEV_PEER_CLOSE :               
            wip_getOpts(tChannel, WIP_COPT_HTTP_STATUS_CODE, &ret, WIP_COPT_END);
            if(ret != 200){
                TRACE((1,"Result Code %d", ret));
        default :

With this code, i’m able to do several request to my server. When WIP_CEV_PEER_CLOSE event occured with a succesfully HTTP request :

  • HTTP result Code is 200
  • HTTP Channel close properly (wip_close())
  • bearerStop() properly too
  • WIP_BEV_STOPPED event occured and here i use bearerClose()

So, in this case all it’s right.

But, when WIP_CEV_ERROR event occured or WIP_CEV_PEER_CLOSE event with HTTP result Code return an error (for e.g. HTTP error 400)

  • HTTP Channel close properly (wip_close())
  • but bearerStop() will reset the module.

Why module reset ? it seems that when an error occured (HTTP error or WIP_CEV_ERROR), you shouldn’t close bearer at all. But why ? If bearer not closed after an error, how can i do a HTTP communication next times ???
Can someone help me or explain to me how bearerStop() / bearerClose() / wip_close() working ?!

Thank in advance.