ambiot / ambpro2_arduino

AmebaPro2 Arduino third-party package SDK
https://www.amebaiot.com/en/ameba-arduino-summary/
MIT License
45 stars 20 forks source link

PPPoS support on AMB82-Mini board? #184

Open abhisheeekkk opened 8 months ago

abhisheeekkk commented 8 months ago

Hi team, I am using EG95 (EG95 is a cell modem provided by Quecetel) with AMB82mini on UART1 for internet connectivity, I have tried to create PPPoS client for my AMB82-Mini board but I am having issues when Arduino tries to link the libraries, please see the below code and attached error. If you know how it could be solved please provide help, Thanks in advance!

#include "netif/ppp/pppos.h"
#include "FreeRTOS.h"
#include "task.h"
#include <string.h>
#include "netif/ppp/ppp_opts.h"
#include "netif/ppp/ppp_impl.h"
#include "netif/ppp/pppapi.h"
#include "lwip/sys.h"
#include "lwip/err.h"
#include "lwip/dns.h"
#include "tcpip.h"

#define PPP_IPV4_SUPPORT 1

char* ppp_user = "";
char* ppp_pass = "";
String APN = "hologram";

#define BUF_SIZE (1024)
bool PPPOS_firststart = false;
bool PPPOS_connected = false;
bool PPPOS_started = false;
char *PPP_User = "";
char *PPP_Pass = "";
char PPPOS_out[BUF_SIZE];
String buffer = "";

String data = "";
bool atMode = true;

/* The PPP control block */
ppp_pcb *ppp;

/* The PPP IP interface */
struct netif ppp_netif;

/* PPP status callback example */
void ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx)
{
    struct netif *pppif = ppp_netif(pcb);
    LWIP_UNUSED_ARG(ctx);

    switch (err_code) {
    case PPPERR_NONE: {
        Serial.println("status_cb: Connected\n");
    #if PPP_IPV4_SUPPORT
            Serial.print(ipaddr_ntoa(&pppif->ip_addr));
            Serial.print(ipaddr_ntoa(&pppif->gw));
            Serial.print(ipaddr_ntoa(&pppif->netmask));
    #endif /* PPP_IPV4_SUPPORT */
    #if PPP_IPV6_SUPPORT
            Serial.print(ip6addr_ntoa(netif_ip6_addr(pppif, 0)));
    #endif /* PPP_IPV6_SUPPORT */
          PPPOS_connected = true;

        break;
    }
    case PPPERR_PARAM: {
        Serial.print("status_cb: Invalid parameter\n");
        break;
    }
    case PPPERR_OPEN: {
        Serial.print("status_cb: Unable to open PPP session\n");
        break;
    }
    case PPPERR_DEVICE: {
        Serial.print("status_cb: Invalid I/O device for PPP\n");
        break;
    }
    case PPPERR_ALLOC: {
        Serial.print("status_cb: Unable to allocate resources\n");
        break;
    }
    case PPPERR_USER: {
       Serial.print("status_cb: User interrupt\n");
       PPPOS_started = false;
       PPPOS_connected = false;
       break;
    }
    case PPPERR_CONNECT: {
       Serial.print("status_cb: Connection lost\n");
       PPPOS_started = false;
       PPPOS_connected = false;
       break;
    }
    case PPPERR_AUTHFAIL: {
        Serial.print("status_cb: Failed authentication challenge\n");
        PPPOS_started = false;
        PPPOS_connected = false;
        break;
    }
    case PPPERR_PROTOCOL: {
        Serial.print("status_cb: Failed to meet protocol\n");
        PPPOS_started = false;
        PPPOS_connected = false;
        break;
    }
    case PPPERR_PEERDEAD: {
        Serial.print("status_cb: Connection timeout\n");
        PPPOS_started = false;
        PPPOS_connected = false;
        break;
    }
    case PPPERR_IDLETIMEOUT: {
        Serial.print("status_cb: Idle Timeout\n");
        PPPOS_started = false;
        PPPOS_connected = false;
        break;
    }
    case PPPERR_CONNECTTIME: {
        Serial.print("status_cb: Max connect time reached\n");
        PPPOS_started = false;
        PPPOS_connected = false;
        break;
    }
    case PPPERR_LOOPBACK: {
        Serial.print("status_cb: Loopback detected\n");
        PPPOS_started = false;
        PPPOS_connected = false;
        break;
    }
    default: {
        Serial.println("status_cb: Unknown error code \n");
        Serial.print(err_code);
        PPPOS_started = false;
        PPPOS_connected = false;
        break;
    }
    }

    if (err_code == PPPERR_NONE) {
        return;
    }
    if (err_code == PPPERR_USER) {
        return;
    }
}

u32_t ppp_output_callback(ppp_pcb *pcb, u8_t *cmd, u32_t len, void *ctx)
{
  if (cmd != NULL) {
    for (u32_t i = 0; i < len; i++)
    {
      Serial1.print(cmd[i]);
    }
     return len;
  }
  else
  {
    Serial.println("error in ppp_output_callback");
    return -1;
  }

}

bool PPPOS_status(){
  return PPPOS_started;
}

void PPPOS_stop(){
  ppp_close(ppp, 0); 
}

String PPPOS_read(){
    String ss = "";
    while (Serial1.available())
    {
       char c = Serial1.read();
        ss+=c;
    }
    if (ss != " ") {
        return ss;
    } else {
        return "";
    }
}

void PPPOS_print(char* cmd){
  if (cmd != NULL) {
     int cmdSize = strlen(cmd);
     for (int i = 0; i < cmdSize; i++)
     {
        Serial1.print(cmd[i]);
     }

  }
}

void pppos_client_task(void *pvParameters)
{
    while (1) {  
        while (PPPOS_started && Serial1.available()) {
            // String ss = "";
            // char len = Serial1.read();
            // ss += len;
            // if (len > 0) {
            //     pppos_input(ppp, (uint8_t *)ss.c_str(), ss.length());
            // }

            char dataByte;
            while (Serial1.available()) {
                dataByte = Serial1.read();
                pppos_input(ppp, (uint8_t *)&dataByte, 1);
            }
            vTaskDelay(10 / portTICK_PERIOD_MS);
        }
        vTaskDelay(100 / portTICK_PERIOD_MS);
       }

}

bool PPPOS_isConnected(){
  return PPPOS_connected;
}

void PPPOS_start(){
  if (!PPPOS_firststart){
        ppp = pppos_create(&ppp_netif, ppp_output_callback, ppp_status_cb, NULL);

        if (ppp == NULL) {
            return;
        }
  }
        ppp_set_default(ppp);
        ppp_set_auth(ppp, PPPAUTHTYPE_ANY, "", "");
        ppp_set_usepeerdns(ppp, 1);
        ppp_connect(ppp, 0);

        PPPOS_started = true;
        PPPOS_firststart = true;
}

bool sendCommandWithAnswer(String cmd, String ans){
         PPPOS_print((char *)cmd.c_str());
         unsigned long _tg = millis();
         while(true){
          data = PPPOS_read();
          if (data != NULL){
            // char* dataCopy = strdup(data.c_str());
            char* dataCopy = &data[0];
            char* command = strtok(dataCopy, "\n");
            while (command != 0)
            {
              buffer = String(command);
              buffer.replace("\r", "");
              command = strtok(0, "\n");
              if (buffer != "") { Serial.println(buffer); }
              if (buffer == ans) {buffer = ""; return true; }
              buffer = "";
            } 
            free(dataCopy);
          }
            if (millis() > (_tg + 5000)) { buffer = ""; return false; } 
         }
         buffer = "";
         return false;
}

bool startPPPOS(){  
      String apnSet = "AT+CGDCONT=1,\"IP\",\"" + APN + "\"\n";
      if (!sendCommandWithAnswer(apnSet, "OK")) 
      { 
         Serial.println("issues in apnSet"); 
        return false; }
      if (!sendCommandWithAnswer("AT+CGDATA=\"PPP\",1\n", "CONNECT")) 
      { 
        Serial.println("issues in CGDATA"); 
        return false; }

      atMode = false;
      PPPOS_start(); 
      unsigned long _tg = millis();
      while(!PPPOS_isConnected()) {
        if (millis() > (_tg + 10000)) { PPPOS_stop();  atMode = true; return false; }
      }
      Serial.println("PPPOS Started");
      return true;
}

void PPPOS_init(){
  xTaskCreate(&pppos_client_task, "pppos_client_task", 10048, NULL, 5, NULL);
}

void setup()
{

  // Start the serial communication with the PC
  Serial.begin(115200);

  delay(100);

  Serial1.end();
  Serial1.begin(115200);

  //Disable the echo it's important to run the modem thru Arduino
  Serial1.println("E0");
  String sK =  readResponse();

  delay(100);

  PPPOS_init();

  Serial.println("Starting PPPOS...");
  if (startPPPOS()) { Serial.println("Starting PPPOS... OK"); } else { Serial.println("Starting PPPOS... Failed"); }

}

void loop()
{ 
  if (!PPPOS_isConnected() || atMode){
    data = PPPOS_read();
    if (data != NULL){
      Serial.println(data);  
    }
  }

}

//this function reads character if available from modem's uart(SERIAL1), also it prints the received data over serial(SERIAL0) line of controller.
String readResponse() {
  String response = "";
  while (Serial1.available()) {
    char c = Serial1.read();
    response += c;
     Serial.print(c);
  }
  return response;
}

This is my pppopts.h file, I have enabled support for PPP, also changed some other parameters as well:

/*
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 */

#ifndef LWIP_PPP_OPTS_H
#define LWIP_PPP_OPTS_H

#include "lwip/opt.h"

/**
 * PPP_SUPPORT==1: Enable PPP.
 */
#ifndef PPP_SUPPORT
#define PPP_SUPPORT                     1
#endif

/**
 * PPPOE_SUPPORT==1: Enable PPP Over Ethernet
 */
#ifndef PPPOE_SUPPORT
#define PPPOE_SUPPORT                   0
#endif

/**
 * PPPOL2TP_SUPPORT==1: Enable PPP Over L2TP
 */
#ifndef PPPOL2TP_SUPPORT
#define PPPOL2TP_SUPPORT                0
#endif

/**
 * PPPOL2TP_AUTH_SUPPORT==1: Enable PPP Over L2TP Auth (enable MD5 support)
 */
#ifndef PPPOL2TP_AUTH_SUPPORT
#define PPPOL2TP_AUTH_SUPPORT           PPPOL2TP_SUPPORT
#endif

/**
 * PPPOS_SUPPORT==1: Enable PPP Over Serial
 */
#ifndef PPPOS_SUPPORT
#define PPPOS_SUPPORT                   PPP_SUPPORT
#endif

/**
 * LWIP_PPP_API==1: Enable PPP API (in pppapi.c)
 */
#ifndef LWIP_PPP_API
#define LWIP_PPP_API                    1//(PPP_SUPPORT && (NO_SYS == 0))
#endif

#if PPP_SUPPORT

/**
 * MEMP_NUM_PPP_PCB: the number of simultaneously active PPP
 * connections (requires the PPP_SUPPORT option)
 */
#ifndef MEMP_NUM_PPP_PCB
#define MEMP_NUM_PPP_PCB                1
#endif

/**
 * PPP_NUM_TIMEOUTS_PER_PCB: the number of sys_timeouts running in parallel per
 * ppp_pcb. See the detailed explanation at the end of ppp_impl.h about simultaneous
 * timers analysis.
 */
#ifndef PPP_NUM_TIMEOUTS_PER_PCB
#define PPP_NUM_TIMEOUTS_PER_PCB        (1 + PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT + CCP_SUPPORT)
#endif

/* The number of sys_timeouts required for the PPP module */
#define PPP_NUM_TIMEOUTS                (PPP_SUPPORT * PPP_NUM_TIMEOUTS_PER_PCB * MEMP_NUM_PPP_PCB)

/**
 * MEMP_NUM_PPPOS_INTERFACES: the number of concurrently active PPPoS
 * interfaces (only used with PPPOS_SUPPORT==1)
 */
#ifndef MEMP_NUM_PPPOS_INTERFACES
#define MEMP_NUM_PPPOS_INTERFACES       MEMP_NUM_PPP_PCB
#endif

/**
 * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
 * interfaces (only used with PPPOE_SUPPORT==1)
 */
#ifndef MEMP_NUM_PPPOE_INTERFACES
#define MEMP_NUM_PPPOE_INTERFACES       1
#endif

/**
 * MEMP_NUM_PPPOL2TP_INTERFACES: the number of concurrently active PPPoL2TP
 * interfaces (only used with PPPOL2TP_SUPPORT==1)
 */
#ifndef MEMP_NUM_PPPOL2TP_INTERFACES
#define MEMP_NUM_PPPOL2TP_INTERFACES       1
#endif

/**
 * MEMP_NUM_PPP_API_MSG: Number of concurrent PPP API messages (in pppapi.c)
 */
#ifndef MEMP_NUM_PPP_API_MSG
#define MEMP_NUM_PPP_API_MSG 5
#endif

/**
 * PPP_DEBUG: Enable debugging for PPP.
 */
#ifndef PPP_DEBUG
#define PPP_DEBUG                       LWIP_DBG_ON
#endif

/**
 * PPP_INPROC_IRQ_SAFE==1 call pppos_input() using tcpip_callback().
 *
 * Please read the "PPPoS input path" chapter in the PPP documentation about this option.
 */
#ifndef PPP_INPROC_IRQ_SAFE
#define PPP_INPROC_IRQ_SAFE             1
#endif

/**
 * PRINTPKT_SUPPORT==1: Enable PPP print packet support
 *
 * Mandatory for debugging, it displays exchanged packet content in debug trace.
 */
#ifndef PRINTPKT_SUPPORT
#define PRINTPKT_SUPPORT                1
#endif

/**
 * PPP_IPV4_SUPPORT==1: Enable PPP IPv4 support
 */
#ifndef PPP_IPV4_SUPPORT
#define PPP_IPV4_SUPPORT                (LWIP_IPV4)
#endif

/**
 * PPP_IPV6_SUPPORT==1: Enable PPP IPv6 support
 */
#ifndef PPP_IPV6_SUPPORT
#define PPP_IPV6_SUPPORT                (LWIP_IPV6)
#endif

/**
 * PPP_NOTIFY_PHASE==1: Support PPP notify phase support
 *
 * PPP notify phase support allows you to set a callback which is
 * called on change of the internal PPP state machine.
 *
 * This can be used for example to set a LED pattern depending on the
 * current phase of the PPP session.
 */
#ifndef PPP_NOTIFY_PHASE
#define PPP_NOTIFY_PHASE                0
#endif

/**
 * pbuf_type PPP is using for LCP, PAP, CHAP, EAP, CCP, IPCP and IP6CP packets.
 *
 * Memory allocated must be single buffered for PPP to works, it requires pbuf
 * that are not going to be chained when allocated. This requires setting
 * PBUF_POOL_BUFSIZE to at least 512 bytes, which is quite huge for small systems.
 *
 * Setting PPP_USE_PBUF_RAM to 1 makes PPP use memory from heap where continuous
 * buffers are required, allowing you to use a smaller PBUF_POOL_BUFSIZE.
 */
#ifndef PPP_USE_PBUF_RAM
#define PPP_USE_PBUF_RAM                1
#endif

/**
 * PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation for PPPoS
 */
#ifndef PPP_FCS_TABLE
#define PPP_FCS_TABLE                   1
#endif

/**
 * PAP_SUPPORT==1: Support PAP.
 */
#ifndef PAP_SUPPORT
#define PAP_SUPPORT                     1
#endif

/**
 * CHAP_SUPPORT==1: Support CHAP.
 */
#ifndef CHAP_SUPPORT
#define CHAP_SUPPORT                    1
#endif

/**
 * MSCHAP_SUPPORT==1: Support MSCHAP.
 */
#ifndef MSCHAP_SUPPORT
#define MSCHAP_SUPPORT                  1
#endif
#if MSCHAP_SUPPORT
/* MSCHAP requires CHAP support */
#undef CHAP_SUPPORT
#define CHAP_SUPPORT                    1
#endif /* MSCHAP_SUPPORT */

/**
 * EAP_SUPPORT==1: Support EAP.
 */
#ifndef EAP_SUPPORT
#define EAP_SUPPORT                     1
#endif

/**
 * CCP_SUPPORT==1: Support CCP.
 */
#ifndef CCP_SUPPORT
#define CCP_SUPPORT                     1
#endif

/**
 * MPPE_SUPPORT==1: Support MPPE.
 */
#ifndef MPPE_SUPPORT
#define MPPE_SUPPORT                    1
#endif
#if MPPE_SUPPORT
/* MPPE requires CCP support */
#undef CCP_SUPPORT
#define CCP_SUPPORT                     1
/* MPPE requires MSCHAP support */
#undef MSCHAP_SUPPORT
#define MSCHAP_SUPPORT                  1
/* MSCHAP requires CHAP support */
#undef CHAP_SUPPORT
#define CHAP_SUPPORT                    1
#endif /* MPPE_SUPPORT */

/**
 * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
 */
#ifndef CBCP_SUPPORT
#define CBCP_SUPPORT                    0
#endif

/**
 * ECP_SUPPORT==1: Support ECP. CURRENTLY NOT SUPPORTED! DO NOT SET!
 */
#ifndef ECP_SUPPORT
#define ECP_SUPPORT                     0
#endif

/**
 * DEMAND_SUPPORT==1: Support dial on demand. CURRENTLY NOT SUPPORTED! DO NOT SET!
 */
#ifndef DEMAND_SUPPORT
#define DEMAND_SUPPORT                  0
#endif

/**
 * LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets.
 */
#ifndef LQR_SUPPORT
#define LQR_SUPPORT                     1
#endif

/**
 * PPP_SERVER==1: Enable PPP server support (waiting for incoming PPP session).
 *
 * Currently only supported for PPPoS.
 */
#ifndef PPP_SERVER
#define PPP_SERVER                      0
#endif

#if PPP_SERVER
/*
 * PPP_OUR_NAME: Our name for authentication purposes
 */
#ifndef PPP_OUR_NAME
#define PPP_OUR_NAME                    "lwIP"
#endif
#endif /* PPP_SERVER */

/**
 * VJ_SUPPORT==1: Support VJ header compression.
 */
#ifndef VJ_SUPPORT
#define VJ_SUPPORT                      1
#endif
/* VJ compression is only supported for TCP over IPv4 over PPPoS. */
#if !PPPOS_SUPPORT || !PPP_IPV4_SUPPORT || !LWIP_TCP
#undef VJ_SUPPORT
#define VJ_SUPPORT                      0
#endif /* !PPPOS_SUPPORT */

/**
 * PPP_MD5_RANDM==1: Use MD5 for better randomness.
 * Enabled by default if CHAP, EAP, or L2TP AUTH support is enabled.
 */
#ifndef PPP_MD5_RANDM
#define PPP_MD5_RANDM                   (CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT)
#endif

/**
 * PolarSSL embedded library
 *
 *
 * lwIP contains some files fetched from the latest BSD release of
 * the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption
 * methods we need for lwIP PPP support.
 *
 * The PolarSSL files were cleaned to contain only the necessary struct
 * fields and functions needed for lwIP.
 *
 * The PolarSSL API was not changed at all, so if you are already using
 * PolarSSL you can choose to skip the compilation of the included PolarSSL
 * library into lwIP.
 *
 * If you are not using the embedded copy you must include external
 * libraries into your arch/cc.h port file.
 *
 * Beware of the stack requirements which can be a lot larger if you are not
 * using our cleaned PolarSSL library.
 */

/**
 * LWIP_USE_EXTERNAL_POLARSSL: Use external PolarSSL library
 */
#ifndef LWIP_USE_EXTERNAL_POLARSSL
#define LWIP_USE_EXTERNAL_POLARSSL      0
#endif

/**
 * LWIP_USE_EXTERNAL_MBEDTLS: Use external mbed TLS library
 */
#ifndef LWIP_USE_EXTERNAL_MBEDTLS
#define LWIP_USE_EXTERNAL_MBEDTLS       0
#endif

/*
 * PPP Timeouts
 */

/**
 * FSM_DEFTIMEOUT: Timeout time in seconds
 */
#ifndef FSM_DEFTIMEOUT
#define FSM_DEFTIMEOUT                  6
#endif

/**
 * FSM_DEFMAXTERMREQS: Maximum Terminate-Request transmissions
 */
#ifndef FSM_DEFMAXTERMREQS
#define FSM_DEFMAXTERMREQS              2
#endif

/**
 * FSM_DEFMAXCONFREQS: Maximum Configure-Request transmissions
 */
#ifndef FSM_DEFMAXCONFREQS
#define FSM_DEFMAXCONFREQS              10
#endif

/**
 * FSM_DEFMAXNAKLOOPS: Maximum number of nak loops
 */
#ifndef FSM_DEFMAXNAKLOOPS
#define FSM_DEFMAXNAKLOOPS              5
#endif

/**
 * UPAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req
 */
#ifndef UPAP_DEFTIMEOUT
#define UPAP_DEFTIMEOUT                 6
#endif

/**
 * UPAP_DEFTRANSMITS: Maximum number of auth-reqs to send
 */
#ifndef UPAP_DEFTRANSMITS
#define UPAP_DEFTRANSMITS               10
#endif

#if PPP_SERVER
/**
 * UPAP_DEFREQTIME: Time to wait for auth-req from peer
 */
#ifndef UPAP_DEFREQTIME
#define UPAP_DEFREQTIME                 30
#endif
#endif /* PPP_SERVER */

/**
 * CHAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req
 */
#ifndef CHAP_DEFTIMEOUT
#define CHAP_DEFTIMEOUT                 6
#endif

/**
 * CHAP_DEFTRANSMITS: max # times to send challenge
 */
#ifndef CHAP_DEFTRANSMITS
#define CHAP_DEFTRANSMITS               10
#endif

#if PPP_SERVER
/**
 * CHAP_DEFRECHALLENGETIME: If this option is > 0, rechallenge the peer every n seconds
 */
#ifndef CHAP_DEFRECHALLENGETIME
#define CHAP_DEFRECHALLENGETIME         0
#endif
#endif /* PPP_SERVER */

/**
 * EAP_DEFREQTIME: Time to wait for peer request
 */
#ifndef EAP_DEFREQTIME
#define EAP_DEFREQTIME                  6
#endif

/**
 * EAP_DEFALLOWREQ: max # times to accept requests
 */
#ifndef EAP_DEFALLOWREQ
#define EAP_DEFALLOWREQ                 10
#endif

#if PPP_SERVER
/**
 * EAP_DEFTIMEOUT: Timeout (seconds) for rexmit
 */
#ifndef EAP_DEFTIMEOUT
#define EAP_DEFTIMEOUT                  6
#endif

/**
 * EAP_DEFTRANSMITS: max # times to transmit
 */
#ifndef EAP_DEFTRANSMITS
#define EAP_DEFTRANSMITS                10
#endif
#endif /* PPP_SERVER */

/**
 * LCP_DEFLOOPBACKFAIL: Default number of times we receive our magic number from the peer
 * before deciding the link is looped-back.
 */
#ifndef LCP_DEFLOOPBACKFAIL
#define LCP_DEFLOOPBACKFAIL             10
#endif

/**
 * LCP_ECHOINTERVAL: Interval in seconds between keepalive echo requests, 0 to disable.
 */
#ifndef LCP_ECHOINTERVAL
#define LCP_ECHOINTERVAL                1
#endif

/**
 * LCP_MAXECHOFAILS: Number of unanswered echo requests before failure.
 */
#ifndef LCP_MAXECHOFAILS
#define LCP_MAXECHOFAILS                3
#endif

/**
 * PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char.
 */
#ifndef PPP_MAXIDLEFLAG
#define PPP_MAXIDLEFLAG                 100
#endif

/**
 * PPP Packet sizes
 */

/**
 * PPP_MRU: Default MRU
 */
#ifndef PPP_MRU
#define PPP_MRU                         1500
#endif

/**
 * PPP_DEFMRU: Default MRU to try
 */
#ifndef PPP_DEFMRU
#define PPP_DEFMRU                      1500
#endif

/**
 * PPP_MAXMRU: Normally limit MRU to this (pppd default = 16384)
 */
#ifndef PPP_MAXMRU
#define PPP_MAXMRU                      1500
#endif

/**
 * PPP_MINMRU: No MRUs below this
 */
#ifndef PPP_MINMRU
#define PPP_MINMRU                      128
#endif

/**
 * PPPOL2TP_DEFMRU: Default MTU and MRU for L2TP
 * Default = 1500 - PPPoE(6) - PPP Protocol(2) - IPv4 header(20) - UDP Header(8)
 * - L2TP Header(6) - HDLC Header(2) - PPP Protocol(2) - MPPE Header(2) - PPP Protocol(2)
 */
#if PPPOL2TP_SUPPORT
#ifndef PPPOL2TP_DEFMRU
#define PPPOL2TP_DEFMRU                 1450
#endif
#endif /* PPPOL2TP_SUPPORT */

/**
 * MAXNAMELEN: max length of hostname or name for auth
 */
#ifndef MAXNAMELEN
#define MAXNAMELEN                      256
#endif

/**
 * MAXSECRETLEN: max length of password or secret
 */
#ifndef MAXSECRETLEN
#define MAXSECRETLEN                    256
#endif

/* ------------------------------------------------------------------------- */

/*
 * Build triggers for embedded PolarSSL
 */
#if !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS

/* CHAP, EAP, L2TP AUTH and MD5 Random require MD5 support */
#if CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM
#define LWIP_INCLUDED_POLARSSL_MD5      1
#endif /* CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM */

#if MSCHAP_SUPPORT

/* MSCHAP require MD4 support */
#define LWIP_INCLUDED_POLARSSL_MD4      1
/* MSCHAP require SHA1 support */
#define LWIP_INCLUDED_POLARSSL_SHA1     1
/* MSCHAP require DES support */
#define LWIP_INCLUDED_POLARSSL_DES      1

/* MS-CHAP support is required for MPPE */
#if MPPE_SUPPORT
/* MPPE require ARC4 support */
#define LWIP_INCLUDED_POLARSSL_ARC4     1
#endif /* MPPE_SUPPORT */

#endif /* MSCHAP_SUPPORT */

#endif /* !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS */

/* Default value if unset */
#ifndef LWIP_INCLUDED_POLARSSL_MD4
#define LWIP_INCLUDED_POLARSSL_MD4      0
#endif /* LWIP_INCLUDED_POLARSSL_MD4 */
#ifndef LWIP_INCLUDED_POLARSSL_MD5
#define LWIP_INCLUDED_POLARSSL_MD5      0
#endif /* LWIP_INCLUDED_POLARSSL_MD5 */
#ifndef LWIP_INCLUDED_POLARSSL_SHA1
#define LWIP_INCLUDED_POLARSSL_SHA1     0
#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */
#ifndef LWIP_INCLUDED_POLARSSL_DES
#define LWIP_INCLUDED_POLARSSL_DES      0
#endif /* LWIP_INCLUDED_POLARSSL_DES */
#ifndef LWIP_INCLUDED_POLARSSL_ARC4
#define LWIP_INCLUDED_POLARSSL_ARC4     0
#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */

#endif /* PPP_SUPPORT */

/* Default value if unset */
#ifndef PPP_NUM_TIMEOUTS
#define PPP_NUM_TIMEOUTS                0
#endif /* PPP_NUM_TIMEOUTS */

#endif /* LWIP_PPP_OPTS_H */

This is the exact issue I am facing, directly copied from Arduino Serial Monitor:

c:/users/abhishek.shukla/appdata/local/arduino15/packages/realtek/tools/ameba_pro2_toolchain/1.0.1-p1/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\abhishek.shukla\AppData\Local\Temp\arduino\sketches\9194102C42145A6333A404D5D158324C\sketch\Iteration1.ino.cpp.o: in function `PPPOS_stop()':
Iteration1.ino.cpp:(.text._Z10PPPOS_stopv+0x8): undefined reference to `ppp_close'
c:/users/abhishek.shukla/appdata/local/arduino15/packages/realtek/tools/ameba_pro2_toolchain/1.0.1-p1/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\abhishek.shukla\AppData\Local\Temp\arduino\sketches\9194102C42145A6333A404D5D158324C\sketch\Iteration1.ino.cpp.o: in function `PPPOS_start()':
Iteration1.ino.cpp:(.text._Z11PPPOS_startv+0x1a): undefined reference to `ppp_set_auth'
c:/users/abhishek.shukla/appdata/local/arduino15/packages/realtek/tools/ameba_pro2_toolchain/1.0.1-p1/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: Iteration1.ino.cpp:(.text._Z11PPPOS_startv+0x2a): undefined reference to `ppp_connect'
c:/users/abhishek.shukla/appdata/local/arduino15/packages/realtek/tools/ameba_pro2_toolchain/1.0.1-p1/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: Iteration1.ino.cpp:(.text._Z11PPPOS_startv+0x3e): undefined reference to `pppos_create'
c:/users/abhishek.shukla/appdata/local/arduino15/packages/realtek/tools/ameba_pro2_toolchain/1.0.1-p1/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\abhishek.shukla\AppData\Local\Temp\arduino\sketches\9194102C42145A6333A404D5D158324C\sketch\Iteration1.ino.cpp.o: in function `pppos_client_task(void*)':
Iteration1.ino.cpp:(.text._Z17pppos_client_taskPv+0x2e): undefined reference to `pppos_input'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

I raised this issue here on the official forum - Forum Link

On the forum, Support engineer suggested me that probably the low level design hasn't been implemented for PPPoS. I request you engineers to please provide support for this feature, since my project is based on this feature. If you need any other details, please don't hesitate to ask, Thanks!!

github-actions[bot] commented 8 months ago

Hello, hope this message finds you well. Congrats to your first Issue! We will review it as soon as possiable. Feel free to have a look at https://www.amebaiot.com/en/ameba-arduino-summary/ for more information

dano1nr commented 7 months ago

Hi, we also need PPPoS to interface an LTE module.

github-actions[bot] commented 7 months ago

This issue is stale because it has been open for 14 days with no activity.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 14 days with no activity.