Unable to connect socket over PPPOS

persan666
Posts: 28
Joined: Fri Feb 16, 2018 9:17 am

Unable to connect socket over PPPOS

Postby persan666 » Fri Oct 02, 2020 1:58 pm

HI,

I'm using esp-idf 4.1 with custom hardware with a Ublox Sara-R4 modem. Previously I was using esp-idf 3.3 and that is working.
My problem is that I can not communicate using standard sockets functions. All the PPPOS stages are ok. Im getting the IP address from the modem. It seams that the socket layer is not attatch with the PPPOS layer in some way. If I call i.e connect I get the error message "Host is unreachable". I have placed som dubug prints in the functions "modem_netif_receive_cb" and "esp_modem_dte_transmit" in the file "esp_modem_netif.c" but these callbacks are not being called when i.e call connect (lwip/sockets.h).

persan666
Posts: 28
Joined: Fri Feb 16, 2018 9:17 am

Re: Unable to connect socket over PPPOS

Postby persan666 » Tue Oct 06, 2020 2:14 pm

Even though I get the event 'IP_EVENT_PPP_GOT_IP', the local IP address never gets set.

So when calling socket connect I get back the error 'Socket unable to connect: errno 118'
The error comes from the line with bold text (the code is devided at this line) in the file 'esp-idf\components\lwip\lwip\src\core\tcp.c'. And the reason is becuase 'pcb->local_ip = '0.0.0.0''


Code: Select all

[Codebox=c file=Untitled.c]
err_t
tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
            tcp_connected_fn connected)
{
  struct netif *netif = NULL;
  err_t ret;
  u32_t iss;
  u16_t old_local_port;

  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ERROR("tcp_connect: invalid pcb", pcb != NULL, return ERR_ARG);
  LWIP_ERROR("tcp_connect: invalid ipaddr", ipaddr != NULL, return ERR_ARG);

  LWIP_ERROR("tcp_connect: can only connect from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN);

  LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port));
  ip_addr_set(&pcb->remote_ip, ipaddr);
  pcb->remote_port = port;

  if (pcb->netif_idx != NETIF_NO_INDEX) {
    netif = netif_get_by_index(pcb->netif_idx);
  } else {
    /* check if we have a route to the remote host */
[/Codebox]

netif = ip_route(&pcb->local_ip, &pcb->remote_ip);

Code: Select all

[Codebox=c file=Untitled.c]
  }
  if (netif == NULL) {
    /* Don't even try to send a SYN packet if we have no route since that will fail. */
    return ERR_RTE;
  }

  /* check if local IP has been assigned to pcb, if not, get one */
  if (ip_addr_isany(&pcb->local_ip)) {
	
	 const ip_addr_t *local_ip = ip_netif_get_local_ip(netif, ipaddr);
    if (local_ip == NULL) {
    
    	return ERR_RTE;
    }
    
    ip_addr_copy(pcb->local_ip, *local_ip);
  }

[/Codebox]

persan666
Posts: 28
Joined: Fri Feb 16, 2018 9:17 am

Re: Unable to connect socket over PPPOS

Postby persan666 » Mon Dec 21, 2020 11:34 am

This is now resolved using esp-idf 4.2. Not sure if it still not work in 4.1.

Who is online

Users browsing this forum: omerfurkan.ipek and 267 guests