0

I want to build openthread for Linux (POSIX) and using the library, I want to develop a CoAP client application.

Right now I have disabled UDP_FORWARD in Makefile-posix and enabled OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE 1 in src/core/config/platform.h file.

My build is failing with the following error:

Making all in apps Making all in cli   CC       ot_cli_ftd-main.o   C
C       ot_cli_mtd-main.o   CCLD     ot-cli-mtd   CCLD     ot-cli-ftd
../../../src/core/libopenthread-mtd.a(libopenthread_mtd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Open(void (*)(void*, otMessage*,
otMessageInfo const*), void*)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:84:
undefined reference to `otPlatUdpSocket'
../../../src/core/libopenthread-mtd.a(libopenthread_mtd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Bind(ot::Ip6::SockAddr const&)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:107:
undefined reference to `otPlatUdpBind'
../../../src/core/libopenthread-mtd.a(libopenthread_mtd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Close()':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:141:
undefined reference to `otPlatUdpClose'
../../../src/core/libopenthread-mtd.a(libopenthread_mtd_a-udp6.o): In
function `ot::Ip6::UdpSocket::SendTo(ot::Message&,
ot::Ip6::MessageInfo const&)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:193:
undefined reference to `otPlatUdpSend'
../../../src/core/libopenthread-mtd.a(libopenthread_mtd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Bind(ot::Ip6::SockAddr const&)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:114:
undefined reference to `otPlatUdpBind'
../../../src/core/libopenthread-mtd.a(libopenthread_mtd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Connect(ot::Ip6::SockAddr const&)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:130:
undefined reference to `otPlatUdpConnect' collect2: error: ld returned
1 exit status Makefile:1284: recipe for target 'ot-cli-mtd' failed
make[5]: *** [ot-cli-mtd] Error 1 make[5]: *** Waiting for unfinished
jobs....
../../../src/core/libopenthread-ftd.a(libopenthread_ftd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Open(void (*)(void*, otMessage*,
otMessageInfo const*), void*)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:84:
undefined reference to `otPlatUdpSocket'
../../../src/core/libopenthread-ftd.a(libopenthread_ftd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Bind(ot::Ip6::SockAddr const&)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:107:
undefined reference to `otPlatUdpBind'
../../../src/core/libopenthread-ftd.a(libopenthread_ftd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Close()':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:141:
undefined reference to `otPlatUdpClose'
../../../src/core/libopenthread-ftd.a(libopenthread_ftd_a-udp6.o): In
function `ot::Ip6::UdpSocket::SendTo(ot::Message&,
ot::Ip6::MessageInfo const&)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:193:
undefined reference to `otPlatUdpSend'
../../../src/core/libopenthread-ftd.a(libopenthread_ftd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Bind(ot::Ip6::SockAddr const&)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:114:
undefined reference to `otPlatUdpBind'
../../../src/core/libopenthread-ftd.a(libopenthread_ftd_a-udp6.o): In
function `ot::Ip6::UdpSocket::Connect(ot::Ip6::SockAddr const&)':
/home/projects/KNX/openthread/examples/../src/core/net/udp6.cpp:130:
undefined reference to `otPlatUdpConnect' collect2: error: ld returned
1 exit status Makefile:1280: recipe for target 'ot-cli-ftd' failed
make[5]: *** [ot-cli-ftd] Error 1 Makefile:442: recipe for target
'all-recursive' failed make[4]: *** [all-recursive] Error 1
Makefile:444: recipe for target 'all-recursive' failed make[3]: ***
[all-recursive] Error 1 Makefile:601: recipe for target
'all-recursive' failed make[2]: *** [all-recursive] Error 1
Makefile:527: recipe for target 'all' failed make[1]: *** [all] Error
2 examples/Makefile-posix:295: recipe for target
'do-build-x86_64-unknown-linux-gnu' failed make: ***
[do-build-x86_64-unknown-linux-gnu] Error 2

My ultimate goal is to use openthread library and develop a Coap Client application. Can anybody help me on this?

UKMonkey
  • 6,941
  • 3
  • 21
  • 30
rptech
  • 1
  • 1
  • Can't answer the full question, but the error message seems to indicate that the CoAP library shipped with OpenThread uses the ot::Ip6::UdpSocket abstraction and thus their network stack – so while you may get to build it without its 6LoWPAN parts (say, over any other network interface if supported on the devices), at least that part of OpenThread will be there. Is there a particular reason you're looking into the OpenTherad CoAP library and not any other implementation if you don't want to use it with Thread? – chrysn Nov 27 '19 at 09:15
  • @chrysn I want to develop a easy to use and customized IoT library. This library then can be used by other application developers to build their Client/Server applications without having the knowledge of Openthread (or other underlying infrastructure like libcoap, if I use that instead of Openthread). I found Openthread CoAP APIs quite user friendly for me and because Openthread is quite portable across different platform, I want to use Openthread. Also, I am targeting baremetal embedded devices, so I do not want to keep the additional part of Thread implementation part in my package. – rptech Nov 27 '19 at 09:49
  • From those requirements ("portable", "not keep additional part of thread") I see two ways forward: Find out how to strip down OpenThread (basically what you asked) *and* port its top half to all relevant platforms, or write your layer with pluggable CoAP backends (one of which is OpenThread); the latter sounds more practical to me. (edit: newline became send...) – chrysn Nov 27 '19 at 10:19
  • C & C++ are different languages. You are clearly only looking at C++. – UKMonkey Nov 27 '19 at 10:38
  • @UKMonkey, how is that relevant for this question? – rptech Nov 27 '19 at 11:12
  • @rptech you tagged your question wrong - and included a few million people who aren't interested in c++ questions. – UKMonkey Nov 27 '19 at 13:11

1 Answers1

0

Enabling OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE requires an implementation of the otPlatUdp* APIs.

For Linux, you can look to the POSIX app https://github.com/openthread/openthread/tree/master/src/posix.

jhui
  • 694
  • 4
  • 3