Channel is not in WIP_CSTATE_READY state


#1

Friends!
In my application I want via GPRS and TCP/IP send some data. After wip_bearerOpen
wip_bearer_setOpts
wip_bearerStart (return -27) Why?
wip_TCPClientCreate
I try send data with function wip_write out of commandHandler, but this function aborted because wip_getState return -999 (the channel is not in WIP_CSTATE_READY state)
How i must this get this state and send data with function wip_write
Thanks


#2

Hi mlab !

Have a look to the WIP documentation. Under “Error Codes” section (“bearer service error codes” subsection) you can read that event -27 is WIP_BER_OK_INPROGRESS. So that mean everything’s OK, but you have to wait. Wait for the WIP_BEV_IP_CONNECTED event. Then you can open a TCP socket.

By the way, there are exemples in the WIP doc too


#3

colin-tfe
Thanks
But my experimens show me that I very long time not getting reply
And I not sending data with wip_write, because the channel is not ready for operation read/write. Read/write work only inside commandHandler declared in wip_TCPClientCreate, but I want send data outside this handler.


#4

I want send data outside this handler.

The channel is not ready immediately after wip_TCPClientCreate(). It signals when it’s ready by sending the event WIP_CEV_OPEN. Once this event is received you can start writing, but not before.

In practice, since you can’t call wip_write() just after wip_TCPClientCreate(), putting it in the event handler really is the simplest option, even if it forces you you refactor your code.

The alternative option would be to put it in a timer callback, but that would also force you to refactor your code, will be much uglier and more unsafe: connection time can vary, e.g. due to DNS response times, or bad signal, and if you don’t properly take WIP_CEV_WRITE and WIP_CEV_READ events into consideration, your application will suffer underflow and overflow errors.