GPRS registered but bearer not starts


#1

My code of cfg_gprs:

#include "adl_global.h"
#include "wip.h"
#define SEND_TRACE(x)   TRACE(( 1, x )); adl_atSendResponse ( ADL_AT_UNS, x );

#define GPRS_APN      "internet.beeline.ru"
#define GPRS_USER     "beeline"
#define GPRS_PASSWORD "beeline"
#define GPRS_PINCODE  ""

#define CREG_POLLING_PERIOD 20 /* in 100ms steps */

#define ASSERT( pred) \
if( !(pred)) wip_debug( "ASSERTION FAILURE line %i: " #pred "\n", __LINE__)
#define ASSERT_OK( v) ASSERT( 0 == (v))

static void (* appli_entry_point)( void);

static void evh_bearer( wip_bearer_t b, s8 event, void *ctx) {
	SEND_TRACE("bearer. ");
	if( WIP_BEV_IP_CONNECTED == event)
  {
	  SEND_TRACE("entry_point");
	  appli_entry_point();
  }
}

static void open_and_start_bearer( void) {
  int r;
  wip_bearer_t b;
  SEND_TRACE("open and start. ");
  r = wip_bearerOpen( &b, "GPRS", evh_bearer, NULL);
  ASSERT_OK( r);

  r = wip_bearerSetOpts( b, WIP_BOPT_GPRS_APN, GPRS_APN,
                         WIP_BOPT_LOGIN,       GPRS_USER,
                         WIP_BOPT_PASSWORD,    GPRS_PASSWORD,
                         WIP_BOPT_END);
  ASSERT_OK( r);
  r = wip_bearerStart( b);
  ASSERT( 0 == r || WIP_BERR_OK_INPROGRESS == r);
}

static void poll_creg( u8 Id );

static bool poll_creg_callback(adl_atResponse_t *Rsp) {
    ascii *rsp;
    ascii regStateString[3];
    s32 regStateInt;

    SEND_TRACE ("(poll_creg_callback) Enter.\r\n" );

    rsp = (ascii *)adl_memGet(Rsp->StrLength);
    wm_strRemoveCRLF(rsp, Rsp->StrData, Rsp->StrLength);

    wm_strGetParameterString(regStateString, Rsp->StrData, 2);
    regStateInt = wm_atoi(regStateString);

    if ( 1 == regStateInt || 5 ==regStateInt) {
        SEND_TRACE ("(poll_creg_callback) Registered on GPRS network.\r\n" );
        open_and_start_bearer();
    } else {
      /* Not ready yet, we'll check again later. Set a one-off timer. */
    	SEND_TRACE ("Not ready yet");
        adl_tmrSubscribe( FALSE, CREG_POLLING_PERIOD, ADL_TMR_TYPE_100MS, poll_creg);
    }
    return FALSE;
}

static void poll_creg( u8 Id ) {
  adl_atCmdCreate( "AT+CREG?", FALSE, poll_creg_callback, ADL_STR_CREG, NULL);
}

static void evh_sim( u8 event) {
  SEND_TRACE ("(evh_sim) Enter." );
  if( ADL_SIM_EVENT_FULL_INIT == event) {
    poll_creg( 0); /* argument 0 is dummy, see poll_reg() "Object" comment */
  }
}

void cfg_gprs ( void (* entry_point)(void)) {
  SEND_TRACE ("(c_g) Enter.");
  appli_entry_point = entry_point;
  adl_simSubscribe( evh_sim, GPRS_PINCODE);
}

But few days ago it’s working…
TRACES:
EA : Main(c_g) Enter.
(evh_sim) Enter.(evh_sim) Enter.
(evh_sim) Enter.(poll_creg_callback) Enter.
(poll_creg_callback) Registered on GPRS network.
EA : Main(c_g) Enter.
(evh_sim) Enter.(evh_sim) Enter.
(evh_sim) Enter.(poll_creg_callback) Enter.
(poll_creg_callback) Registered on GPRS network.
EA : Main(c_g) Enter.
(evh_sim) Enter.(evh_sim) Enter.
(evh_sim) Enter.(poll_creg_callback) Enter.
(poll_creg_callback) Registered on GPRS network.
EA : Main(c_g) Enter.
(evh_sim) Enter.(evh_sim) Enter.
(evh_sim) Enter.(poll_creg_callback) Enter.
(poll_creg_callback) Registered on GPRS network.
EA : Main(c_g) Enter.
(evh_sim) Enter.(evh_sim) Enter.
(evh_sim) Enter.(poll_creg_callback) Enter.
(poll_creg_callback) Registered on GPRS network.
EA : Main(c_g) Enter.
(evh_sim) Enter.(evh_sim) Enter.
(evh_sim) Enter.(poll_creg_callback) Enter.
(poll_creg_callback) Registered on GPRS network.
open and start.
EA : Main(c_g) Enter.
(evh_sim) Enter.(evh_sim) Enter.
(evh_sim) Enter.(poll_creg_callback) Enter.
(poll_creg_callback) Registered on GPRS network.
EA : Main(c_g) Enter.
(evh_sim) Enter.(evh_sim) Enter.
(evh_sim) Enter.(poll_creg_callback) Enter.
Not ready yet
(poll_creg_callback) Enter.
Not ready yet
(poll_creg_callback) Enter.
Not ready yet
(poll_creg_callback) Enter.
Not ready yet

What’s wrong? I’ve checked SIM-card on phone - it’s working correct.
May be it’s means that my home network customer service has a problem, not my code?


#2

I’ve tried several SIM-Cards. Nothing changes…


#3

try enabling wip_debug and u will see messages from the open-at OS which maybe will make things more clear…at first sight your code seem to be ok…


#4

you can also subscribe to the gprs_events.
then you can see what part of the registration is and what isn’t done


#5

Also:

  • Trace event codes;
  • Trace API return codes.

Nothing really special here - just normal debugging techniques!