lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] ppp over serial using gsm modem getting config acknowledgem


From: rohanm
Subject: [lwip-users] ppp over serial using gsm modem getting config acknowledgement reject packet.
Date: Wed, 18 Feb 2015 06:56:35 -0700 (MST)

hii,
i am trying to implement ppp over serial using lwip version 1.4.1 for our
project.i am working on this from last 15 to 20 days.i have first
initialized gsm modem SIM900D and dial using ATD*99# command and once it
gets connected call below code .




 tcpip_init(lwIPInit,NULL);
xTaskCreate(vPPPApplication, "vPPPApplication", configMINIMAL_STACK_SIZE,
NULL, tskIDLE_PRIORITY, NULL );

i am confuse about gsm_init function call so i have made dummy function .
err_t GSM_init( struct netif *pxNetIf )
{

    return ERR_OK;
}


void lwIPInit( void *pvArgument )
{

ip_addr_t xIPAddr, xNetMask, xGateway;
static struct netif xNetIf;

        ( void ) pvArgument;

        SysConfigGetLocalIPAddress(&ipAddr1, &ipAddr2, &ipAddr3, &ipAddr4);

//       Set up the network interface.
        ip_addr_set_zero( &xGateway );
        ip_addr_set_zero( &xIPAddr );
        ip_addr_set_zero( &xNetMask );

        LWIP_PORT_INIT_GW(&xGateway);
        LWIP_PORT_INIT_IPADDR(&xIPAddr);
        LWIP_PORT_INIT_NETMASK(&xNetMask);

        netif_set_default( netif_add( &xNetIf, &xIPAddr, &xNetMask, &xGateway,
NULL,GSM_init, tcpip_input ) );//ethernetif_init
        netif_set_up( &xNetIf );

}

vPPPApplication code is as follows:

u8_t buffer[PPPOS_RX_BUFSIZE];
    
void vPPPApplication(void)
{
  ppp_pcb *ppps;
  char *username = "test";
  char *password = "test";

  int connected = 0;
  int pd;

  ppps = pppapi_new();

  /* set the method of authentication. Use PPPAUTHTYPE_PAP, or
   * PPPAUTHTYPE_CHAP for more security .
   * If this is not called, the default is PPPAUTHTYPE_NONE.
   */
  pppapi_set_auth(ppps, PPPAUTHTYPE_NONE, username,
password);//PPPAUTHTYPE_PAP

  pppapi_over_serial_create(ppps, 0, linkStatusCB, NULL);

  pppapi_open(ppps, 0);
  while(1)
  {
    int len;
    memset(ppp_rcvbuffer,0,sizeof(ppp_rcvbuffer));
    len = sio_read(0, ppp_rcvbuffer, PPPOS_RX_BUFSIZE);
    if(len <= 0) {
          vTaskDelay(10/portTICK_RATE_MS);
    } else {
      pppos_input(ppps, ppp_rcvbuffer, len);
    }

  }
}


u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len)
{
#if 1
    int ret;
    u8_t* Rec_Buf1 = (u8_t*)data;
    unsigned int Val = 0;
    u32_t k = 0;
    // latch the Queue count
    Val = UART_Queue[GSM_QUEUE].QCount;
    //  Total = Total + Val;
    for(k=0;k<Val;k++){
        // cannot copy more than the input buffer size
        if(k >= len){
                break;
        }
        Rec_Buf1[k] =
UART_Queue[GSM_QUEUE].QBuf[UART_Queue[GSM_QUEUE].QGet];
//      Print_Byte(ptr_Rec->Rec_Buf[i]);
        UART_Queue[GSM_QUEUE].QGet++;
        if(UART_Queue[GSM_QUEUE].QGet >= MAX_SERIAL_Q_SIZE){
                UART_Queue[GSM_QUEUE].QGet = 0;
        }
    }
    //RM
fd=(sio_fd_t)UART_Queue[GSM_QUEUE].QBuf[UART_Queue[GSM_QUEUE].QGet];
    //No of bytes read = i;
    if(k > 0){
        // the count value should not be changed during decrementing it's
value as below
        // the count value is expected to change only when there is some
data entry - serial port
        // therefore the interrupt is disabled which will not allow the
serial port to read the data
        // and hence the count will not be SET

        // TBD : user enter critical section
        INTDisableInterrupts();
    //          DisableSerialInterrupt2();
        UART_Queue[GSM_QUEUE].QCount -= k;
        // after decrement, again enable the interrupts to receive the data
from serial port
        INTEnableInterrupts();
    ///         EnableSerialInterrupt2();
  }
    return k;//RM For testing
#endif
}

linkStatusCB code ...
void linkStatusCB(void *arg, int errCode, void *ctx)
{
   
   int *connected = (int *) ctx;

   struct ppp_addrs *addrs = arg;


   if (errCode == PPPERR_NONE) {
       /* We are connected */
       *connected = 1;

   } else {
       switch(errCode)
       {
               
           case PPPERR_PARAM:


           break;
           case PPPERR_OPEN:
           break;
           case PPPERR_DEVICE:
           break;
           case PPPERR_ALLOC:
           break;
           case PPPERR_USER:
           break;
           case PPPERR_CONNECT:
           break;
           case PPPERR_AUTHFAIL:
           break;
           case PPPERR_PROTOCOL:
           break;



       }
      

   }
}

using this code i have  getting Config reject packet continuously.
is there any thing wrong with the code or i need to do some initlaization
before calling tcp thread and ppp serial thread.or there is any thing wrong
with gsm modem dialing.??
pls help me on this ....
thank you.  




--
View this message in context: 
http://lwip.100.n7.nabble.com/ppp-over-serial-using-gsm-modem-getting-config-acknowledgement-reject-packet-tp23912.html
Sent from the lwip-users mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]