Closed ihidchaos closed 1 year ago
I also tyied with option "BUILD_SHARED_LIBS=ON" from link when building ot-br-posix, but useless.
Did you ever solve your problem?
Did you ever solve your problem?
I haven't solved it yet. Could you @jwhui please give us some guidance and help?
I recommend you to use Unix socket for communicate with otbr-agent. Here is an example code,
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
int main(int argc, char* argv[])
{
int ret;
int sock;
struct sockaddr_un server;
char buffer[512];
if (argc < 2) {
exit(1);
}
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
perror("opening stream socket");
exit(1);
}
server.sun_family = AF_UNIX;
strcpy(server.sun_path, argv[1]);
if (connect(sock, (struct sockaddr*)&server, sizeof(struct sockaddr_un)) < 0) {
close(sock);
perror("connecting stream socket");
exit(1);
}
if (write(sock, "version", sizeof("version")) < 0)
perror("writing on stream socket");
if (read(sock, buffer, sizeof(buffer)) == -1) {
perror("read");
exit(1);
}
buffer[sizeof(buffer) - 1] = 0;
printf("Result = %s\n", buffer);
if (write(sock, "rcp version", sizeof("rcp version")) < 0)
perror("writing on stream socket");
if (read(sock, buffer, sizeof(buffer)) == -1) {
perror("read");
exit(1);
}
buffer[sizeof(buffer) - 1] = 0;
printf("Result = %s\n", buffer);
close(sock);
return 0;
}
And the output as follow,
root@OpenWrt:/tmp# ./demo run/openthread-wpan0.sock
Result = OPENTHREAD/thread-reference-20200818-1205-g69bfc4b1c; POSIX; Feb 15 2021 15:22:37
Done
>
Result = OPENTHREAD/thread-reference-20200818-1205-g69bfc4b1c; NRF52840; Sep 6 2021 14:39:16
Done
>
Closing stale issue.
I have an ARM OpenWrt-based OTBR that uses RCP, and I want to operate the Thread network by writing a program that calls the corresponding API, such as setting panid, channel, and so on. After building ot-br-posix, I get the following libraries:
On the one hand, I put these libs in the cross-compile toolchain, and add the following configs to my CMakeLists.txt:
And when I start build, I get the following errors:
I guess this is because I don't have incomplete lib such as libopenthread-api.a.
On the other hand, I also tried to build these libraries from openthread repo:
from the output it shows toolchain has been configured correctly.
However when I try
make -f src/posix/Makefile-posix
, it failed:Could you please guide me on how to get these libraries right?
Thanks in advance.
Best,
Yuchao