0

I am using STM32F7 with development board Nucleo-F746ZG. I have activated UART, LWIP middleware and its PPPoS support.

I can make STM32F7 communicate with Telit GL865 GSM modem by using AT commands over UART, (i.e) make the modem establish static IP of its SIM card and checking pings, it is all OK.

However, I want LWiP PPPoS to establish the static IP instead AT commands just after sending ATD*99***1#.

I deeply searched the web and could not find a particular example that contains LWiP PPPoS Server for STM32F to communicate with Telit GL865 GSM. I have seen codes like

sio_fd_t ppp_sio = sio_open(sio_idx);

However, I could not relate them with STM32 cube functions.

I have seen examples that are using pppInit(void), pppOverSerialOpen(PPP_SERIAL_PORT, linkStatusCB, &connected) functions, but I guess those commands are not supported for the current stack.

Did anyone relate the STM CUBE's uart handle with PPPoS of LWiP stack? Do you have any initialization outline or advice to start with and continue to obtain the static IP? (i.e INIT, DISCONNECTING, DISCONNECTED, CONNECTING, CONNECTED, LWIP loop)

Kind Regards

Ugnius Malūkas
  • 2,649
  • 7
  • 29
  • 42

1 Answers1

1

Sio is the "Serial IO" interface layer, implemented by a specific port (specific platform). Once implemented, the TCP/IP stack handles the rest including PPP negotiation and configuration (LCP/IPCP etc.), which includes obtaining IP addresses (own IP, gateway, netmask, dns1, dns2). Therefore all you need to do is to implement the low-level functions that read and write data over UART. The responsibility for handling PPP is on the TCP/IP stack's end.

While I don't have the exact implementation for STM32, it should be easy enough to implement it yourself. How it's implemented may (or may not) depend on your own configuration, e.g. whether or not you use FreeRTOS and therefore its queues/mutexes to handle UART communication. For overall description of how all components are generally layered in TCP/IP stacks in relation to PPP - I gave an answer some time ago here: STM32 LWIP PPPos implementation.

When it comes to LwIP's sio layer, a quite good documentation can be found under here: http://lwip.wikia.com/wiki/PPP. How the functions should behave is also described quite well in the common lwip/src/include/lwip/sio.h header file.

A sample UNIX implementation, in case you find it useful, can be found here: https://github.com/dreamcat4/lwip/blob/master/contrib/ports/unix/netif/sio.c

J_S
  • 2,985
  • 3
  • 15
  • 38
  • Sir, first of all thank you very much for replying. I had read your other answer several times and got a notion. I have implemented HAL_UART_Transmit_IT(&huart1, buffer, sizeof(buffer)), where huart is my uart handle and the buffer that contains the commands, and HAL_UART_Receive_IT(...) for interrupt based uart communication. I am sending and receiving AT commands through these functions. Can we say that these functions are the low-level functions that I need and already implemented or, how should I have a connection/relation with them as sio_ functions do have with PPPoS? – Sarp Engin Daltaban May 08 '18 at 19:35
  • 1
    Exactly, these are the the low level functions indeed. Keep in mind that the moment you do the `ATD*99***1#`, you won't be able to send AT commands to the modem, as it'll be transmitting binary (PPP) data over this uart instead. From this moment it's only the IP stack talking to the modem. The datasheets describe it as you no longer being in the command (AT command) mode. This is universal across all modems I've worked with. To leave this mode you do one of the following: 1. Restart modem or 2. Exit PPP mode using PPP disconnect or 3. Use escape sequence "+++" (this doesn't close connection). – J_S May 08 '18 at 19:43
  • Sir, after calling ATD*99***1# is it the first thing to apply the functions below ? ppp = pppos_create(&ppp_netif, ppp_output_cb, pppLinkStatusCallback, NULL); ppp_connect(ppp, 0); or Should I also implement sio_open() function to relate my uart handle with PPPoS? I could not find a way to relate my UART with PPP rather than the function sio_fd_t ppp_sio = sio_open(sio_idx); and also I do not know how to relate sio_open with my uart handle. The second unknown for me is, how to tell the modem have its IP using PPP commands instead AT. There is not an example that is why I ask too much.. – Sarp Engin Daltaban May 09 '18 at 06:20
  • 1
    As far as I'm aware `sio_open` really only makes sense on systems such as UNIX, where you actually need to open the port. In case of STM32, if you already have your UART configured there's not much to be done there. As for the `sio_idx`- this is the index of the serial interface that is understood by the tcp/ip stack. Same index always maps to same uart. If you only have one uart for LwIP's SIO, then you don't need to worry about this parameter at all. As for the IP address - you should call `ppp_connect` to tell the stack to start configuration. You can use callbacks to get information back. – J_S May 09 '18 at 07:00
  • Sir, just after sending `ATD*99***1#`, I received a few packages of data like as follows: `~ÿ}#À!}!}!} }4}"}&} } } } }#}$À#}%}&ô}"}#} º½` and after that, I get a `NO CARRIER` message. Should I send those few packages by `pppos_input(ppp, receivedBuffer, sizeof(receivedBuffer));` or should I use the functions first: `ppp = pppos_create(&ppp_netif, ppp_output_cb, pppLinkStatusCallback, NULL); ppp_set_default(ppp); and ppp_connect(ppp, 0);` before `pppos_input()`? By the way, I could not make the modem take IP using `ppp_connect(ppp,0)` after reception of lcp. – Sarp Engin Daltaban May 09 '18 at 13:22
  • 1
    You see this data because your modem started communicating using PPP (it no longer talks over AT commands). Then you see `NO CARRIER` because your end didn't respond so the modem left PPP mode. As for forwarding received data to the TCP/IP stack - if you don't use tasks (e.g. RTOS), then indeed, you use `pppos_input(pd, receiveBuffer, numReceivedBytes)`, as explained here: http://lwip.wikia.com/wiki/PPP – J_S May 09 '18 at 13:45
  • Sir, I am pushing the data of LCP packages one by one to `pppos_input(pd, receiveBuffer, numReceivedBytes)` or package by package. I am checking the data buffered in the debug mode and then `NO CARRIER` error still comes after them. It may be because I do not answer by using `ppp_output_cb(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx)` and I do not know what or how to answer those LCP packages sent by the GSM module. Is the output callback to be called automatically by the PPP core when it is created over `pppos_create(&ppp_netif, ppp_output_cb, pppLinkStatusCallback, NULL);` to answer LCP? – Sarp Engin Daltaban May 09 '18 at 18:10