adl_gprsSetup(pdp_id,gprs_parameters)

Hi there,

Here is a snippet of the code that I am having problems with understanding the if part.
s8 pdp_id =1;
bool wind4_handler (adl_atUnsolicited_t *params)
{
adl_gprsSetupParams_t gprs_parameters;
gprs_parameters.APN = “portalnmms”;
gprs_parameters.FixedIP= NULL;
gprs_parameters.Login ="";
gprs_parameters.Password ="";

  if (adl_gprsSetup(pdp_id,gprs_parameters)!=0;
  {
     TRACE((1, "PDP parameters could not be sent"));
  }
  else
  {
     TRACE((1, "PDP parameters set successfully"))
   }

I would like to know how the if statement is executed. I know that one argument of adl_gprsSetup which is pdp_id has a value of 1. However, I am failing to determine the value of the argument gprs_parameters.

May anyone please help me or shed light on the value of gprs_parameters is obtained hecne how the if else part is determined and how a result of the adl_gprsSetup being 0 or another value is determined to execute the if else statement.

Regards,
Nomagugu

Hiya,

It helps everyone if you can post your code using the code tags. This will retain the formatting and help us all to read your code.

Your code (reformatted):

s8 pdp_id =1;
bool wind4_handler (adl_atUnsolicited_t *params)
{
	adl_gprsSetupParams_t gprs_parameters;
	gprs_parameters.APN = "portalnmms";
	gprs_parameters.FixedIP= NULL;
	gprs_parameters.Login ="";
	gprs_parameters.Password ="";

	if (adl_gprsSetup(pdp_id,gprs_parameters)!=0;
	{
		TRACE((1, "PDP parameters could not be sent"));
	}
	else
	{
		TRACE((1, "PDP parameters set successfully"))
	}

}

First thing I notice is that your if statement is wrong - in fact, there are two errors in it. I’m not even sure that your code would compile…

Error 1: You are missing a closing bracket after the 0. The compiler should have barfed and stopped compiling at this point - at the very least it should have issued a warning here.

Error 2: There should not be a semi-colon (;) at the end of the if statement - you have created an if statement with no actions by doing this. Therefore the two code blocks after the if statement will probably not be executed. Also, you should get a compiler error or warning along the lines of “else without if”.

Try changing the if statement to the following:

if ( adl_gprsSetup(pdp_id,gprs_parameters) != 0)

and let us know how you get on.

ciao, Dave

HI there,

The problem is not with the code. I must have copied the if statement wrongly.

My problem is with the parameters received during the if statement i.e. adl_gprsSetup(pdp_id,gprs_parameters).
I know that pdp_id =1, what I do not know is the value of gprs_parameters. The conditions for the if statement are that

if (adl_gprsSetup(pdp_id,gprs_parameters)!=0)
{
do this
}
else
{
do that
}
where do they get the argument gprs_parameters from. This argument is required to make the result of the if statement true or false.

I am new to open at and this forum and did not really know that there was a specific way of writing code. I am using sample code 12 and don’t understand where the return value of gprs_parameters come from to be used in the if statement .

Regards,

gugulethu

You need to obtain these details from your GPRS Service Provider - they are the APN name, username, and password for the service.

Hi

Thank you for the reply.That helps towards clarifying my situation. Another question is still towards the if statement. How does the mathematics work to make the result of the if statement condition an integer value such as a zero or another number? I know that the value of the pdp_id is 1, what integer value do the APN,IP etc have so as to make the condition of the if statement true or false?

Regards,

gugulethu

This is really a basic ‘C’ question and nothing to do with Wavecom or Open-AT.

You need a basic ‘C’ textbook to tell you how a basic ‘if’ statement works in ‘C’ :exclamation:

You need to look at the description of the adl_gprsSetup function in the ADL User guide - that will tell you what values it can return, and what they mean…