OpenThread CLI test client "undefined reference ..."

Hi,

I cloned the latest code from the mesh/develop branch…

git clone --recursive -b mesh-develop https://github.com/particle-iot/firmware.git

… build the pubsub example in firmware/user/tests/app/mesh/pubsub and deployed it on a Xenon

cd main
make PLATFORM=xenon MODULAR=n DEBUG_BUILD=y TEST=app/mesh/pubsub
dfu-util -d 2b04:d00e -a 0 -s 0x30000 -D …/build/target/main/platform-14/pubsub.bin

This worked fine!

Now, I’d like to write a small test client, which uses the openthread CLI API https://openthread.io/reference/group/api-cli

If I compile the code below, then I get the following error "undefined reference to `otCliConsoleInit’ ".
Apparently the cli libs are missing in the path.

make PLATFORM=xenon MODULAR=n DEBUG_BUILD=y TEST=app/mesh/cli

Unfortunately I do not know your build system very well…

Where can I find the missing libs and how can I add them to the path?
Am I missing something else?

Thanks in advance!

@rickkas7, @ScruffR, @peekay123, @nrobinson2000,@avtolstoy Any ideas?

// Thread CLI test client

#include "application.h"
#include "openthread/cli.h"
#include "openthread/platform/radio.h"
#include "ot_api.h"

SYSTEM_MODE(AUTOMATIC);

int otConsoleOutputCallback(const char *aBuf, uint16_t aBufLength, void *aContext) {
	// to be implemented!
	return aBufLength;
}

void setup() {
    Serial.begin(115200);
    int8_t meshRssi = otPlatRadioGetRssi(ot_get_instance()); // this works
    otCliConsoleInit(ot_get_instance(), otConsoleOutputCallback, NULL); // fails with "undefined reference to `otCliConsoleInit'"
}

void loop() {
	// to be implemented!	
}

Have you cloned the submodule dependencies for the mesh firmware repo?

git submodule update --init

Yes, I got the submodule dependencies (As far as I understand git the "--recursive" does the same as "git submodule update --init" after clone).

I still get ...

../build/target/user/platform-14/tests/app/mesh/cli//libuser.a(cli.o): In function setup': /Volumes/Media/VMWareShare/Particle/fw-test-mesh-cli/firmware/user/tests/app/mesh/cli/cli.cpp:21: undefined reference to otCliConsoleInit'
collect2: error: ld returned 1 exit status
make: *** [../build/target/main/platform-14/cli.elf] Error 1

If I comment out the "otCliConsoleInit(...)" line and leave the "int8_t meshRssi = otPlatRadioGetRssi(...)" as is the code compiles. The libs containing "otPlatRadioGetRssi(...)" are in the path (../third_party/...).

Are you able to compile the above code?

I tried compiling for xenon v0.8.0-rc.27 and here is the error I get:

Creating module_user_memory.ld ...
/Users/nrobinson/projects/temp/erich/firmware/main.cpp: In function 'void setup()':
/Users/nrobinson/projects/temp/erich/firmware/main.cpp:17:12: warning: unused variable 'meshRssi' [-Wunused-variable]
     int8_t meshRssi = otPlatRadioGetRssi(ot_get_instance()); // this works
            ^
../../../build/target/user/platform-14-m/firmware//libuser.a(main.o): In function `setup':
/Users/nrobinson/projects/temp/erich/firmware/main.cpp:17: undefined reference to `ot_get_instance'
/Users/nrobinson/projects/temp/erich/firmware/main.cpp:17: undefined reference to `otPlatRadioGetRssi'
/Users/nrobinson/projects/temp/erich/firmware/main.cpp:18: undefined reference to `ot_get_instance'
/Users/nrobinson/projects/temp/erich/firmware/main.cpp:18: undefined reference to `otCliConsoleInit'
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/nrobinson/projects/temp/erich/bin/erich-xenon.elf] Error 1
make: *** [modules/xenon/user-part] Error 2

Could you please put the code in the directory “firmware/user/tests/app/mesh/cli” -> Filename: cli.cpp

and compile with …

make PLATFORM=xenon MODULAR=n DEBUG_BUILD=y TEST=app/mesh/cli

Thanks for you support!

I just tried doing a monolithic build and I still get an error:

/Users/nrobinson/projects/temp/erich/firmware/main.cpp: In function 'void setup()':
/Users/nrobinson/projects/temp/erich/firmware/main.cpp:17:12: warning: unused variable 'meshRssi' [-Wunused-variable]
     int8_t meshRssi = otPlatRadioGetRssi(ot_get_instance()); // this works
            ^
src/control/storage.cpp:61:50: note: #pragma message: External flash is not supported
 #pragma message("External flash is not supported")
                                                  ^
../build/target/user/platform-14/firmware//libuser.a(main.o): In function `setup':
/Users/nrobinson/projects/temp/erich/firmware/main.cpp:18: undefined reference to `otCliConsoleInit'
collect2: error: ld returned 1 exit status
make: *** [/Users/nrobinson/projects/temp/erich/bin/erich-xenon.elf] Error 1
1 Like

Okay, looks the same. Thanks for your effort.

I’ll contact particle support. Hope they can help me…:wink:

I don't know if the OpenThread API is fully implemented yet. You could post an issue on GitHub:

https://github.com/particle-iot/firmware/issues