Hi all, This is my first post to this mailing list. I am trying to use lwip on my LTE modem in PPP mode, which is connected to my STM32 nucleo board. I also use FreeRTOS.
I had a few issues already getting stuff up and running but I think I have most of it in the right place. Unfortunately I am still not able to connect to a socket (routing error). I don't really know what the problem is since I lack understanding of PPP and its negotiations. What I have so far: - Modem in PPP mode (I think, it returns "connected" on ATD*99#, no clue what else I can do to verify if it is properly setup in PPP mode. I read other topics where they have the issue that the modem reports back "no carrier". I do NOT have that problem, so I think I am good here). - Add my netif as "default". - Create the pppos client, connect it, and start the main thread. Code snippet: // initialize lwip/tcpip tcpip_init(tcpipInitDone, nullptr); // Wait for lwip tcpip thread while (!initDone) { } netif_set_status_callback(&pppos_netif, netif_status_callback); netif_set_up(&pppos_netif); netif_set_default(&pppos_netif); ppp = pppos_create(&pppos_netif, ppp_output_cb, ppp_link_status_cb, NULL); if (!ppp) { logger.WriteDebug(LoggingCategoryModem, "PPPOS example: Could not create PPP control interface"); return; } ppp_connect(ppp, 0); sys_thread_new("pppos_rx_thread", pppos_rx_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); After this code ran to completion, I create and connect a socket as follows: struct sockaddr_in addr; addr.sin_len = sizeof(addr); addr.sin_family = AF_INET; addr.sin_port = PP_HTONS(SOCK_TARGET_PORT); // 80 addr.sin_addr.s_addr = inet_addr(SOCK_TARGET_HOST); // "172.217.168.238" (google.com, just to see if I can connect to anything on the internet auto s = lwip_socket(AF_INET, SOCK_STREAM, 0); LWIP_ASSERT("s >= 0", s >= 0); auto ret = lwip_connect(s, (struct sockaddr*)&addr, sizeof(addr)); LWIP_ASSERT("ret == 0", ret == 0); The lwip_connect call returns -1. Stepping through the code I can see that the ip_route call is not satisfied with my default netif. I think because lwip never managed to get a proper IP address while negotiating with the otherside (but this is the part where I am on thin ice, I have too little knowledge about how this handshaking/negotiation process works). I also enabled lwip logging and instead of printing via printf, I send the loggings to my uart. I get the following loggings from lwip: netif: netmask of interface set to 255.0.0.0 netif: GW address of interface set to 127.0.0.1 netif_set_ipaddr: netif address being changed netif: added interface lo IP addr 127.0.0.1 netmask 255.0.0.0 gw 127.0.0.1 igmp_init: initializing dns_init: initializing PPPNETIF: WL0 is UP IPV4: Host at 0.0.0.0 mask 0.0.0.0 gateway 0.0.0.0 netif: setting default interface WL netif: netmask of interface WL set to 255.255.255.255 netif: added interface pp IP addr 0.0.0.0 netmask 255.255.255.255 gw 0.0.0.0 ppp phase changed[1]: phase=0 ppp_connect[1]: holdoff=0 ppp phase changed[1]: phase=3 pppos_connect: unit 1: connecting ppp_start[1] ppp phase changed[1]: phase=6 pppos_send_config[1]: out_accm=FF FF FF FF ppp_send_config[1] pppos_recv_config[1]: in_accm=FF FF FF FF ppp_recv_config[1] ppp: auth protocols: PAP=0 CHAP=0 CHAP_MD5=0 pbuf_alloc(length=24) pbuf_alloc(length=24) == 0x20010368 pbuf_alloc(length=0) pbuf_alloc(length=0) == 0x20010258 pbuf_free(0x20010258) pbuf_free: deallocating 0x20010258 pppos_write[1]: len=24 pbuf_free(0x20010368) pbuf_free: deallocating 0x20010368 ppp_start[1]: finished lwip_socket(PF_INET, SOCK_STREAM, 0) = 0 lwip_connect(0, addr=172.217.168.238 port=80) tcp_connect to port 80 ip4_route: No route to 172.217.168.238 lwip_connect(0) failed, err=-4 lwip_send(0, data=0x803518c, size=4, flags=0x0) tcp_write(pcb=0x20011744, data=0x803518c, len=4, apiflags=1) tcp_write() called in invalid state lwip_send(0) err=-11 written=0 dns_tmr: dns_check_entries I have pushed my latest changes to github here: basprins/freertos_lwip_stm32f446 (github.com) <https://github.com/basprins/freertos_lwip_stm32f446> It's a work in progress obviously, for example I commented out the part where I set the modem in PPP mode, I do this manually before I start this application on my microcontroller. Just to be more confident and to ensure PPP mode is properly set up before I start lwip. I really hope somebody can help me out further. And my apologies if I ask stupid questions/miss something really obvious. Again, I am not experienced in the PPP area.
_______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users