pkg/openthread: core and tests#7082
Conversation
| { | ||
| _dev->driver->get(_dev, NETOPT_IPV6_IID, aIeee64Eui64, sizeof(eui64_t)); | ||
| } | ||
|
|
There was a problem hiding this comment.
empty lines that can be removed
There was a problem hiding this comment.
this was fixed in the last commit
| _set_channel(aChannel); | ||
| return kThreadError_None; | ||
| } | ||
|
|
There was a problem hiding this comment.
empty line. One empty line between function impl is enough
There was a problem hiding this comment.
this was fixed in the last commit
| otPlatResetReason otPlatGetResetReason(otInstance *aInstance) | ||
| { | ||
| (void)aInstance; | ||
| // TODO: Write me! |
There was a problem hiding this comment.
C++ style comment. Maybe try to fix this TODO
There was a problem hiding this comment.
This is the platform abstraction function of the posix example in OpenThread, as seen here
There was a problem hiding this comment.
ok, then let's leave it like this!
| char cpu_id[CPUID_LEN]; | ||
| cpuid_get(cpu_id); | ||
| uint32_t seed = 0; | ||
| for (int i = 0; i < (int) CPUID_LEN; i++) { |
There was a problem hiding this comment.
should be unsigned instead of int and then no need to cast I think
pkg/openthread/include/ot.h
Outdated
| * | ||
| * @file | ||
| * | ||
| * @author José Ignacio Alamos <[email protected]> |
tests/openthread/Makefile
Outdated
| # Comment this out to disable code in RIOT that does safety checking | ||
| # which is not needed in a production environment but helps in the | ||
| # development process: | ||
|
|
tests/openthread/main.c
Outdated
|
|
||
| otMessageInfo mPeer; | ||
|
|
||
| //Set dest address |
tests/openthread/main.c
Outdated
| //Set dest address | ||
| memcpy(&mPeer.mPeerAddr.mFields, &(pkt->ip_addr), sizeof(ipv6_addr_t)); | ||
|
|
||
| //Set dest port |
tests/openthread/main.c
Outdated
| int _udp(int argc, char **argv) | ||
| { | ||
| if (argc < 3) { | ||
| return 1; |
tests/openthread/Makefile
Outdated
| endif | ||
|
|
||
| ifneq (,$(filter at86rf2%,$(DRIVER))) | ||
| FEATURES_REQUIRED = periph_spi periph_gpio |
There was a problem hiding this comment.
Then this line could be split in 2 until openthread is added to auto_init.
pkg/openthread/contrib/openthread.c
Outdated
| void openthread_uart_run(void) | ||
| { | ||
| char buf[256]; | ||
| // uint8_t index=0; |
pkg/openthread/include/ot.h
Outdated
| #define OPENTHREAD_XTIMER_MSG_TYPE_EVENT (0x2235) /**< xtimer message receiver event*/ | ||
| #define OPENTHREAD_NETDEV_MSG_TYPE_EVENT (0x2236) /**< message received from driver */ | ||
| #define OPENTHREAD_SERIAL_MSG_TYPE_EVENT (0x2237) /**< event indicating a serial (UART) message was sent to OpenThread */ | ||
| #define OPENTHREAD_MSG_TYPE_RECV (0x2238) /**< event for frame reception */ |
There was a problem hiding this comment.
nit: the defined values could be aligned
There was a problem hiding this comment.
this is very weird... I have them aligned.
It seems to be a different file. I'm checking
There was a problem hiding this comment.
can you check if you see them aligned in your editor? with raw vi I can see them aligned...
tests/openthread/Makefile
Outdated
| @@ -0,0 +1,49 @@ | |||
| APPLICATION = openthread_test | |||
There was a problem hiding this comment.
just call application "openthread"
pkg/openthread/include/ot.h
Outdated
| #define OPENTHREAD_XTIMER_MSG_TYPE_EVENT (0x2235) /**< xtimer message receiver event*/ | ||
| #define OPENTHREAD_NETDEV_MSG_TYPE_EVENT (0x2236) /**< message received from driver */ | ||
| #define OPENTHREAD_SERIAL_MSG_TYPE_EVENT (0x2237) /**< event indicating a serial (UART) message was sent to OpenThread */ | ||
| #define OPENTHREAD_MSG_TYPE_RECV (0x2238) /**< event for frame reception */ |
There was a problem hiding this comment.
still not aligned, but maybe we are not looking at the same thing. I meant aligning (0x2238) with other values. The doxygen are right !
There was a problem hiding this comment.
agh, I also see the comments misaligned. I'm into that.
tests/openthread/main.c
Outdated
|
|
||
| int main(void) | ||
| { | ||
| #if defined(MODULE_OPENTHREAD_CLI) || defined(MODULE_OPENTHREAD_NCP) |
There was a problem hiding this comment.
I don't see where MODULE_OPENTHREAD_CLI and MODULE_OPENTHREAD_NCP are defined.
There was a problem hiding this comment.
ah, I actually I can safely remove that because they will be handled in @biboc examples (FTD, MTD, etc). I would leave it in the core files because they will be needed.
There was a problem hiding this comment.
ok, so if I understand correctly, this PR only provides the ifconfig and udp commands provided in this main.c file ?
There was a problem hiding this comment.
How can I play with openthread_cli ?
pkg/openthread/Makefile
Outdated
| --prefix=/ \ | ||
| --enable-default-logging \ | ||
| ${OPENTHREAD_ARGS} | ||
| cd $(PKG_BUILDDIR) && make -j99 --no-print-directory DESTDIR=$(PKG_BUILDDIR)/output install PREFIX=/ |
There was a problem hiding this comment.
j99 is too much (my computer doesn't like that!). Please use something more realistic (-j4 is good)
|
I could make it work on IoT-Lab ! Great! |
| #include "openthread/ncp.h" | ||
| #endif | ||
|
|
||
| #define ENABLE_DEBUG (1) |
There was a problem hiding this comment.
you are right. I'm on it
|
|
||
| #include "openthread/types.h" | ||
| #include "openthread/platform/misc.h" | ||
| #include "periph/pm.h" |
There was a problem hiding this comment.
Are you sure this include is required ?
| #include "openthread/platform/radio.h" | ||
| #include "ot.h" | ||
|
|
||
| #define ENABLE_DEBUG (1) |
| #include "openthread/types.h" | ||
|
|
||
| #include "debug.h" | ||
| #define ENABLE_DEBUG (1) |
|
@aabadie what would you add specifically to the commands output? |
tests/openthread/main.c
Outdated
| for (const otNetifAddress *addr = otIp6GetUnicastAddresses(ot_instance); addr; addr = addr->mNext) { | ||
| char addrstr[IPV6_ADDR_MAX_STR_LEN]; | ||
| ipv6_addr_to_str(addrstr, (ipv6_addr_t *) &addr->mAddress.mFields, sizeof(addrstr)); | ||
| printf("inet6 %s\n", addrstr); |
There was a problem hiding this comment.
Is there a way to distinguish the different kind of addresses ? (link-local, RLOC, EID)
There was a problem hiding this comment.
Not sure on OT side. Probably yes. Anyway, it's always possible to check the beginning of the ipv6 addr and print it next to the IP.
There was a problem hiding this comment.
Ok, that's fine like this.
pkg/openthread/Makefile
Outdated
| ${OPENTHREAD_ARGS} | ||
| cd $(PKG_BUILDDIR) && make -j4 --no-print-directory DESTDIR=$(PKG_BUILDDIR)/output install PREFIX=/ | ||
|
|
||
| cp $(PKG_BUILDDIR)/output/lib/libmbedcrypto.a ${BINDIR}/libmbedcrypto.a |
There was a problem hiding this comment.
The cp indentation looks weird. Can you have a look ?
tests/openthread/main.c
Outdated
| int _udp(int argc, char **argv) | ||
| { | ||
| if (argc < 3) { | ||
| printf("Usage: udp server <port>\n"); |
There was a problem hiding this comment.
indentation is off here as well
pkg/openthread/Makefile
Outdated
| OPENTHREAD_ARGS+= --enable-cli-app=mtd | ||
| endif | ||
| ifneq (,$(filter libopenthread-ncp-ftd,$(USEMODULE))) | ||
| $(info Compile OpenThread with NCP) |
There was a problem hiding this comment.
indentation issue here (1 or 2 extra space)
|
Please fix the indentation issues and squash and we are good |
|
@aabadie fixed and squashed. Can you check if everything is ok? |
pkg/openthread/Makefile
Outdated
| all: git-download | ||
| cd $(PKG_BUILDDIR) && PREFIX="/" ./bootstrap | ||
| cd $(PKG_BUILDDIR) && ./configure \ | ||
| --enable-application-coap INSTALL="/usr/bin/install -p" CPP="$(CPP)" \ |
There was a problem hiding this comment.
/use/bin/install won't work on Mac I think. Maybe just using install is enough
There was a problem hiding this comment.
I broke the Makefile because of missing tabs. I'm pushing the fix
There was a problem hiding this comment.
it fails if I remove the /usr/bin part
There was a problem hiding this comment.
the INSTALL part shouldn't be needed. I'm checking what happens if I remove that.
There was a problem hiding this comment.
did that. Now should work
tests/openthread/main.c
Outdated
| otUdpOpen(ot_instance, &socket, _handle_receive, NULL); | ||
|
|
||
| message = otUdpNewMessage(ot_instance, true); | ||
| otMessageSetLength(message, pkt->len); |
|
I'll be back in a couple of hours. |
|
@aabadie ok, now it's working again. Let me know if everything is OK so I can squash.ç |
|
I tried OpenThread example with two nodes and it appears that they both become leader. This mean that they are not on same network (because there is only one leader in a network) Have you tried again your example? |
|
@biboc this might happen in the beginning, but after a while you should see only one leader. Is not working for you? |
It won't since you added extra commits ;) |
|
@aabadie why? Requires rebasing? |
Yes, you need to play with git history to keep the 2 commits (git rebase -i) |
|
By the way, there are other issues (some reported by coccinelle and remaining trailing white spaces) |
|
do you know what is this one?: |
pkg/openthread/include/ot.h
Outdated
| } | ||
| #endif | ||
|
|
||
| #endif |
There was a problem hiding this comment.
#endif /* OT_H */and the warning will go away ;-)
|
@biboc I added a copyright header with your name in the test |
| #include "openthread/udp.h" | ||
| #include "ot.h" | ||
|
|
||
| #define ENABLE_DEBUG (1) |
| #include "assert.h" | ||
| #include "openthread/types.h" | ||
|
|
||
| #include "debug.h" |
pkg/openthread/include/ot.h
Outdated
| * @brief Struct containing an OpenThread job | ||
| */ | ||
| typedef struct { | ||
| const char *command; /**< A pointer to the job name string. */ |
|
Ok @jia200x |
|
Now let's add support for NCP and MTD nodes. And add sock adaption :) |
|
🎉 ✨ congratz @jia200x! |
Thanks! |
|
great! Nice work! @jia200x |
This is the OpenThread core from #5552 . I'm spliting #5552 into multiple PR for an easier review.
After merging this one, I can push the sock adoption.
Cheers!