Gcoap and lwIP compatibility issue

I’m using the gcoap module to provide a CoAP Server.
Now I try to use/integrate libmodbus to have a Modbus RTU/TCP module.

Therefore, I need a TCP socket, which seems not to be implemented (yet): TCP Sockets can not be used
Fortunately there is a workaround mentioned using lwIP.

Now I’ve got the problem that gcoap and lwIP seem to be incompatible since I get errors in

RIOT/sys/net/gnrc/sock/include/gnrc_sock_internal.h

and

RIOT/sys/net/gnrc/sock/gnrc_sock.c

with comments like

error: unknown type name ‘gnrc_sock_reg_t’; did you mean ‘lwip_sock_cb_t’?

The error is easily reproducible by adding USEMODULE += gcoap to the Makefile of RIOT/tests/lwip.

Could someone give me a hint how to solve this?
Thank You :slight_smile:

Hi!

might I know on which version of RIOT you are? I just checked adding USEMODULE += gcoap to tests/lwip on current master and the 2020.10 release and it compiled like a charm (so it is safe to assume it will also work for the upcoming 2021.01 release). gcoap used to be incompatible to other stacks than GNRC, but this was fixed in the past year. Not sure, but you might need to add an lwIP-specific branch to the gcoap dependencies here for gcoap to actually work (adding lwip_sock_async should do the trick). I’d happily ACK a PR, if that’s the case :-).

Thank you for the hint, I was on Version: 2020.10-devel-328-g4f54c-HEAD. Now I updated to the current master 2021.04-devel-443-gd6e43 and it works.
Adding lwip_sock_async was not necessary and seemed not to change anything.

But I had to remove these modules which usually are included in the gcoap example:

USEMODULE += gnrc_netdev_default
USEMODULE += auto_init_gnrc_netif
USEMODULE += gnrc_ipv6_default\

since there was a very similar error to the one mentioned above, but with other suggested types.
Now the ifconfig command is not available anymore, which is adverse for getting the IPv6 address of the CoAP server.
Nevertheless I was able to get a response via coap-client.

The lwIP test provides an ifconfig command as well, but that one is not available although I added all the modules from the lwIP Makefile to my gcoap example. I don’t know why that’s the case.

Unfortunately there occurred another problem:

In function ‘_parse_endpoint’:
…/gcoap_cli.c:235: undefined reference to ‘gnrc_netif_numof’
…/gcoap_cli.c:237: undefined reference to ‘gnrc_netif_iter’
…/gcoap_cli.c:245: undefined reference to ‘gnrc_netif_get_by_pid’

I simply disabled the gcoap_cli in my code, since I do not necessarily need it for my stuff and as I said, the CoAP server was running well without it. Anyway, shall I open a new topic for this problem?