Urgent Help about BEARER START


#1

Hi there,
we have a problem with “wip_bearerStart”. I write down the code here for better understanding…


/* bearer events handler */
void myHandler( wip_bearer_t br, s8 event, void context)
{
TRACE( (1, “myHandler()” ) );
switch( event)
{
case WIP_BEV_IP_CONNECTED:
/IP connectivity we can start IP application from here/
break;
case WIP_BEV_IP_DISCONNECTED:
/stop IP application/
break;
/
other events: /
default:
/cannot start bearer: report error to higher levels/
break;
}
}
/
bearer handle /
wip_bearer_t myBearer;
/
initialize and start GPRS bearer /
bool myConnectToGPRS( void)
{
TRACE( (1, “myConnectToGPRS()” ) );
/
open bearer and install our event handler /
if( wip_bearerOpen( &myBearer, “GPRS”, myHandler, NULL) != 0)
{
TRACE( (1, “wip_bearerOpen() : Fail” ) );
/
cannot open bearer /
return FALSE;
}
/
configure GPRS interface /
if( wip_bearerSetOpts ( myBearer, WIP_BOPT_GPRS_APN, “internet”, WIP_BOPT_LOGIN, “”, WIP_BOPT_PASSWORD, “”, WIP_BOPT_GPRS_HEADERCOMP, FALSE, WIP_BOPT_GPRS_DATACOMP, FALSE, WIP_BOPT_END) != 0)
{
TRACE( (1, “wip_bearerSetOpts() : Fail” ) );
/
cannot configure bearer /
wip_bearerClose( myBearer);
return FALSE;
}
/
start connection /
int x = wip_bearerStart( myBearer);
if( x != 0)
{
TRACE( (1, “wip_bearerStart() : Fail” ) );
/
cannot start bearer */

    TRACE( (1, "WIP_BERR_BASE: %d", WIP_BERR_BASE ) );
    TRACE( (1, "ERROR CODE: %d", x ) );
    wip_bearerClose( myBearer);
    return FALSE;
}
/* connection status will be reported to the event handler */
return TRUE;

}

void adl_main ( adl_InitType_e InitType )
{
TRACE( (1, “adl_main()” ) );

 if(wip_netInit() != 0)
{
    TRACE( (1, "wip_netInit() : Fail" ) );
    return;
}
else
{
    TRACE( (1, "wip_netInit() : Success" ) );
}

if(!myConnectToGPRS())
{
    TRACE( (1, "myConnectToGPRS() : Fail" ) );
}
else
{
    TRACE( (1, "myConnectToGPRS() : Success" ) );
    startClient();
}

}

and the trace screen is(when the program is running)

Trace IP 1 adl_main()
Trace IP 1 [GPRS]: initialized.
Trace IP 1 [GSM]: initialized.
Trace IP 1 [UART1]: initialized.
Trace IP 1 [UART2]: initialized.
Trace IP 1 []: initialized.
Trace IP 1 wip_netInit() : Success
Trace IP 1 myConnectToGPRS()
Trace IP 1 [GPRS]: open: -> DISCONNECTED
Trace IP 1 [GPRS]: start: GPRS setup failed: -9
Trace IP 1 wip_bearerStart() : Fail
Trace IP 1 WIP_BERR_BASE: -20
Trace IP 1 ERROR CODE: -35
Trace IP 1 [GPRS]: close: -> CLOSED
Trace IP 1 myConnectToGPRS() : Fail

Error code is -35…What’s it?Do you have any idea? We can connect the Q2687 to the gprs network via hyperterminal with the at commands. But we couldn’t connect it via code…

Could you please help?

Thank you,


#2

For any sort of understanding at all, you need to use the ‘code’ tags to preserve the layout, like this:

----------------------------------------------------------------------------------------------------------------------------------------------
/* bearer events handler */
void myHandler( wip_bearer_t br, s8 event, void *context)
{
    TRACE( (1, "myHandler()" ) );
    switch( event) 
    {
    case WIP_BEV_IP_CONNECTED:
    /*IP connectivity we can start IP application from here*/
    break;
    case WIP_BEV_IP_DISCONNECTED:
    /*stop IP application*/
    break;
    /* other events: */
    default:
    /*cannot start bearer: report error to higher levels*/
    break;
    }
}
/* bearer handle */
wip_bearer_t myBearer;
/* initialize and start GPRS bearer */
bool myConnectToGPRS( void)
{
    TRACE( (1, "myConnectToGPRS()" ) );
    /* open bearer and install our event handler */
    if( wip_bearerOpen( &myBearer, "GPRS", myHandler, NULL) != 0) 
    {
        TRACE( (1, "wip_bearerOpen() : Fail" ) );
        /* cannot open bearer */
        return FALSE;
    }
    /* configure GPRS interface */
    if( wip_bearerSetOpts ( myBearer, WIP_BOPT_GPRS_APN, "internet", WIP_BOPT_LOGIN, "", WIP_BOPT_PASSWORD, "", WIP_BOPT_GPRS_HEADERCOMP, FALSE, WIP_BOPT_GPRS_DATACOMP, FALSE, WIP_BOPT_END) != 0)
     {
        TRACE( (1, "wip_bearerSetOpts() : Fail" ) );
        /* cannot configure bearer */
        wip_bearerClose( myBearer);
        return FALSE;
    }
    /* start connection */
    int x = wip_bearerStart( myBearer);
    if( x != 0) 
    {
        TRACE( (1, "wip_bearerStart() : Fail" ) );
        /* cannot start bearer */
        
        TRACE( (1, "WIP_BERR_BASE: %d", WIP_BERR_BASE ) );
        TRACE( (1, "ERROR CODE: %d", x ) );
        wip_bearerClose( myBearer);
        return FALSE;
    }
    /* connection status will be reported to the event handler */
    return TRUE;
}

void adl_main ( adl_InitType_e InitType )
{
    TRACE( (1, "adl_main()" ) );
    
     if(wip_netInit() != 0)
    {
        TRACE( (1, "wip_netInit() : Fail" ) );
        return;
    }
    else
    {
        TRACE( (1, "wip_netInit() : Success" ) );
    }
    
    if(!myConnectToGPRS())
    {
        TRACE( (1, "myConnectToGPRS() : Fail" ) );
    }
    else
    {
        TRACE( (1, "myConnectToGPRS() : Success" ) );
        startClient();
    }

}

#3

See WIPLib documentation for bearer service error codes. (you have not entered PIN)


#4

dear Kaldvee,

the SIM card has no PIN code… And also we tried it with replacing the SIM card from the device and it gave still same error. So it is not because of the SIM card’s PIN code…

Any other idea you have?

Thanks,


#5

Dear awneil,

Sorry for the code tags, you’re right, I forgot the code tags… Because I was in a hurry yesterday…

Do you have any idea about this problem Awneil?


#6
Trace IP 1 WIP_BERR_BASE: -20
Trace IP 1 ERROR CODE: -35

Looks like an erre WIP_BERR_PIN_NOT_READY. Have you entered you PIN code and waited for the FULL_INIT ADL event (I can’t read you unindented code)? There’s some working connection establishment code in the file cfg_gprs.c in every WIP samples, as a source of inspiration.


#7

Have you actually looked at the definition of -35 in the list of Bearer Service Error Codes at the end of the WIP Development Guide?

It clearly says that it means “PIN Code Not Entered”

Remember: even if a SIM has no PIN, it takes a while before the SIM is ready to use.

Are you sure that the SIM is ready before you try to start the GPRS bearer?
You should check SIM events and/or +WIND indications to be sure…


#8

Hi, I have the same problem with my app, the source code is similar, and my SIM is ready before i launch the app.

Here is my code :

#include "adl_global.h"

#include "wip_net.h"
#include "wip_bearer.h"
#include "wip_ping.h"

void bearerHandler ( wip_bearer_t br, s8 event, void* ctx )
{
    if(event == WIP_BEV_CONN_FAILED)
    {
        TRACE (( 1, "Embedded : Bearer : Connection Failed" ));
    }
    else if (event == WIP_BEV_IP_CONNECTED)
    {
        TRACE (( 1, "Embedded : Bearer : Connected" ));
    }
    else if (event == WIP_BEV_IP_DISCONNECTED)
    {
        TRACE (( 1, "Embedded : Bearer : Disconnected" ));
    }
    else if (event == WIP_BEV_STOPPED)
    {
        TRACE (( 1, "Embedded : Bearer : Stopped" ));
    }
    
}

void Ping_EventHandler ( wip_event_t* ev, void* ctx )
{
    if (ev->kind == WIP_CEV_PING)
    {
        TRACE (( 1, "Embedded : PING WWW.GOOGLE.FR --> OK" ));    
    }
    else if (ev->kind == WIP_CEV_ERROR)
    {
        TRACE (( 1, "Embedded : PING WWW.GOOGLE.FR --> KO" ));
    }
}

void Ping_TimerHandler ( u8 ID )
{
    /* PING WWW.GOOGLE.FR */
    TRACE (( 1, "Embedded : PING WWW.GOOGLE.FR" ));
    
    wip_channel_t channel = wip_pingCreate("www.google.fr", Ping_EventHandler, NULL);
    
    if (channel)
    {
        TRACE (( 1, "Embedded : Channel OK" ));
    }
    else
    {
        TRACE (( 1, "Embedded : Channel KO" ));
    }
    
    adl_atSendResponse ( ADL_AT_UNS, "\r\nEnd Pinging Google\r\n" );
}


void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Embedded Application : Main" ));
    
    wip_bearer_t br;
    
    if(wip_netInit() < 0)
    {
        TRACE (( 1, "Embedded Application : Erreur initialisation network" ));
    }
    else
    {
        TRACE (( 1, "Embedded Application : network OK" ));
        
        
                
        if(wip_bearerOpen(&br, "GPRS", bearerHandler, NULL) < 0)
        {
            TRACE (( 1, "Embedded Application : Bearer Open Error" ));
        }
        else
        {
            TRACE (( 1, "Embedded Application : Bearer Open OK" ));
            s8 rval = wip_bearerStart(br); 
            if ( rval < 0)
            {
                TRACE (( 1, "Embedded Application : Bearer Start Error" ));
                if (rval == WIP_BERR_OK_INPROGRESS)
                {
                    TRACE (( 1, "Embedded Application : Bearer Connection in Progress" ));
                }
                else if (rval == WIP_BERR_BAD_HDL)
                {
                    TRACE (( 1, "Embedded Application : Bearer Bad Handle" ));
                }
                else if (rval == WIP_BERR_BAD_STATE)
                {
                    TRACE (( 1, "Embedded Application : Bearer Bad State" ));
                }
                else if (rval == WIP_BERR_DEV)
                {
                    TRACE (( 1, "Embedded Application : Bearer Device Error" ));
                }
                else
                {
                    TRACE (( 1, "Embedded Application : Bearer Error" ));
                }
                
                TRACE( (1, "WIP_BERR_BASE: %d", WIP_BERR_BASE ) );
                TRACE( (1, "ERROR CODE: %d", rval ) );
                
            }
            else
            {
                TRACE (( 1, "Embedded Application : Bearer Start OK" ));
                /* Positionne un timer cyclique de 6 secondes */
                adl_tmrSubscribe ( TRUE, 60, ADL_TMR_TYPE_100MS, Ping_TimerHandler );
            }
        }
    }    
}

And the trace it generates :

Trace		1	Embedded Application : Main
Trace		1	[GPRS]: initialized.
Trace		1	[GSM]: initialized.
Trace		1	[UART1]: initialized.
Trace		1	[UART2]: initialized.
Trace		1	[]: initialized.
Trace		1	Embedded Application : network OK
Trace		1	[GPRS]: open: -> DISCONNECTED
Trace		1	Embedded Application : Bearer Open OK
Trace		1	[GPRS]: start: GPRS setup failed: -9
Trace		1	Embedded Application : Bearer Start Error
Trace		1	Embedded Application : Bearer Error
Trace		1	WIP_BERR_BASE: -20
Trace		1	ERROR CODE: -35

The result of AT+CPIN :
AT+CPIN?
+CPIN: READY

I don’t understand why the app say my SIM is not ready to use.

Any help will be usefull,

Thanks.


#9

Be very careful you can get cpin ready before you get full init. Before you can start the bearer you need to wait for ADL_SIM_EVENT_FULL_INIT event only after that you can start the bearer right . If you say that your card has no pin find a way to wait until full init event occurs (it could take up to 1 minute maybe even 2 depending on what else are you doing, less then a minute i don’t think so) look for +wind 16 unsolicited response (i hope i am right with the code, check the documentation to be sure)


#10

I had the same problem. The problem occures only then pin-code is requered. (it may be 0000, but it is requered).
I waited for +wind:16, and after what call wip_bearerStart The result was -35.
When I used sim-card without pin-code. Everything was OK.

Then I added calling the function adl_simSubscribe. The problem resolves.


#11

Same problem; I have now a SIM card without PIN code, and I get that “-35” error.
Any idea?


#12

I did not solved that problem, but I managed to fix it by programming in an other way. I think that the SIM management is tricky. My last problem was with CGps initialization. It must be done after the SIM full init OK (seen somewhere in that forum).
It seems that you have to call the adl_simSubscribe function at the beginning of your program. Then wait for the full init ok event to begin your application…


#13

The AT Commands Manual lists the dependence of each AT Command on SIM state.

There really ought to be the corresponding information presented for each API call in the ADL User Guide.


#14

I always wait for ADL_SIM_EVENT_FULL_INIT or +WIND: 4 before starting GPRS connection (open bearer, set bearer opt, start bearer, etc).

Until now my GPRS connection never get error code like yours.
You can try to wait ADL_SIM_EVENT_FULL_INIT for playing safe.