Skip to content

pkg/openthread: core and tests#7082

Merged
aabadie merged 2 commits intoRIOT-OS:masterfrom
jia200x:openthread_core
Jun 1, 2017
Merged

pkg/openthread: core and tests#7082
aabadie merged 2 commits intoRIOT-OS:masterfrom
jia200x:openthread_core

Conversation

@jia200x
Copy link
Copy Markdown
Member

@jia200x jia200x commented May 18, 2017

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!

@jia200x jia200x mentioned this pull request May 18, 2017
Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some style issue and comments. But this is much better than in #5552. Thanks for keeping the effort on that @jia200x and @biboc !

{
_dev->driver->get(_dev, NETOPT_IPV6_IID, aIeee64Eui64, sizeof(eui64_t));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty lines that can be removed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was fixed in the last commit

_set_channel(aChannel);
return kThreadError_None;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line. One empty line between function impl is enough

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was fixed in the last commit

otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
{
(void)aInstance;
// TODO: Write me!
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ style comment. Maybe try to fix this TODO

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the platform abstraction function of the posix example in OpenThread, as seen here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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++) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be unsigned instead of int and then no need to cast I think

*
* @file
*
* @author José Ignacio Alamos <[email protected]>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encoding issue

# 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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed


otMessageInfo mPeer;

//Set dest address
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpp style comment

//Set dest address
memcpy(&mPeer.mPeerAddr.mFields, &(pkt->ip_addr), sizeof(ipv6_addr_t));

//Set dest port
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpp style comment

int _udp(int argc, char **argv)
{
if (argc < 3) {
return 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe print usage here

endif

ifneq (,$(filter at86rf2%,$(DRIVER)))
FEATURES_REQUIRED = periph_spi periph_gpio
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this line could be split in 2 until openthread is added to auto_init.

@jia200x jia200x force-pushed the openthread_core branch from 6265bac to b384548 Compare May 19, 2017 15:18
@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented May 19, 2017

@aabadie @biboc addressed all issues

void openthread_uart_run(void)
{
char buf[256];
// uint8_t index=0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

#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 */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the defined values could be aligned

Copy link
Copy Markdown
Member Author

@jia200x jia200x May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very weird... I have them aligned.
It seems to be a different file. I'm checking

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check if you see them aligned in your editor? with raw vi I can see them aligned...

@@ -0,0 +1,49 @@
APPLICATION = openthread_test
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just call application "openthread"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#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 */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not aligned, but maybe we are not looking at the same thing. I meant aligning (0x2238) with other values. The doxygen are right !

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agh, I also see the comments misaligned. I'm into that.


int main(void)
{
#if defined(MODULE_OPENTHREAD_CLI) || defined(MODULE_OPENTHREAD_NCP)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where MODULE_OPENTHREAD_CLI and MODULE_OPENTHREAD_NCP are defined.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so if I understand correctly, this PR only provides the ifconfig and udp commands provided in this main.c file ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I play with openthread_cli ?

--prefix=/ \
--enable-default-logging \
${OPENTHREAD_ARGS}
cd $(PKG_BUILDDIR) && make -j99 --no-print-directory DESTDIR=$(PKG_BUILDDIR)/output install PREFIX=/
Copy link
Copy Markdown
Contributor

@aabadie aabadie May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j99 is too much (my computer doesn't like that!). Please use something more realistic (-j4 is good)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'm on it

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented May 19, 2017

I could make it work on IoT-Lab ! Great!
The commands output in the test application could be improved.

#include "openthread/ncp.h"
#endif

#define ENABLE_DEBUG (1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. I'm on it


#include "openthread/types.h"
#include "openthread/platform/misc.h"
#include "periph/pm.h"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this include is required ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's for the pm_reset

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes indeed, sorry

#include "openthread/platform/radio.h"
#include "ot.h"

#define ENABLE_DEBUG (1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 0

#include "openthread/types.h"

#include "debug.h"
#define ENABLE_DEBUG (1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 0

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented May 19, 2017

@aabadie what would you add specifically to the commands output?
Cheers!

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to distinguish the different kind of addresses ? (link-local, RLOC, EID)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's fine like this.

${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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cp indentation looks weird. Can you have a look ?

int _udp(int argc, char **argv)
{
if (argc < 3) {
printf("Usage: udp server <port>\n");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is off here as well

OPENTHREAD_ARGS+= --enable-cli-app=mtd
endif
ifneq (,$(filter libopenthread-ncp-ftd,$(USEMODULE)))
$(info Compile OpenThread with NCP)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation issue here (1 or 2 extra space)

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented May 19, 2017

Please fix the indentation issues and squash and we are good

@jia200x jia200x force-pushed the openthread_core branch from 3f10679 to b466f29 Compare May 19, 2017 16:33
@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented May 19, 2017

@aabadie fixed and squashed. Can you check if everything is ok?

all: git-download
cd $(PKG_BUILDDIR) && PREFIX="/" ./bootstrap
cd $(PKG_BUILDDIR) && ./configure \
--enable-application-coap INSTALL="/usr/bin/install -p" CPP="$(CPP)" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/use/bin/install won't work on Mac I think. Maybe just using install is enough

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me check

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I broke the Makefile because of missing tabs. I'm pushing the fix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it fails if I remove the /usr/bin part

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the INSTALL part shouldn't be needed. I'm checking what happens if I remove that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did that. Now should work

otUdpOpen(ot_instance, &socket, _handle_receive, NULL);

message = otUdpNewMessage(ot_instance, true);
otMessageSetLength(message, pkt->len);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misalign

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented May 19, 2017

I'll be back in a couple of hours.

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented May 19, 2017

@aabadie ok, now it's working again. Let me know if everything is OK so I can squash.ç
Cheers

@kaspar030 kaspar030 added the Impact: major The PR changes a significant part of the code base. It should be reviewed carefully label May 20, 2017
@biboc
Copy link
Copy Markdown
Member

biboc commented May 22, 2017

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?

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented May 22, 2017

@biboc this might happen in the beginning, but after a while you should see only one leader.

Is not working for you?

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jun 1, 2017

Let me check if murdock passes this time

It won't since you added extra commits ;)

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jun 1, 2017

@aabadie why? Requires rebasing?

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jun 1, 2017

why? Requires rebasing?

Yes, you need to play with git history to keep the 2 commits (git rebase -i)

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jun 1, 2017

By the way, there are other issues (some reported by coccinelle and remaining trailing white spaces)

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jun 1, 2017

do you know what is this one?:

Running './dist/tools/headerguards/check.sh' x
Command output:

	pkg/openthread/include/ot.h


---
--- compile job results (1 failed, 11692 passed, 11693 total):

@jia200x jia200x force-pushed the openthread_core branch from ef33d93 to 9d4e1ce Compare June 1, 2017 16:52
}
#endif

#endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#endif /* OT_H */

and the warning will go away ;-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@jia200x jia200x force-pushed the openthread_core branch from 9d4e1ce to fa60436 Compare June 1, 2017 17:06
@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jun 1, 2017

@biboc I added a copyright header with your name in the test

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jun 1, 2017

@biboc @aabadie @miri64 murdock passed :)

Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few nits remaining

#include "openthread/udp.h"
#include "ot.h"

#define ENABLE_DEBUG (1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 0

#include "assert.h"
#include "openthread/types.h"

#include "debug.h"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include after define

* @brief Struct containing an OpenThread job
*/
typedef struct {
const char *command; /**< A pointer to the job name string. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doxygen not aligned

@biboc
Copy link
Copy Markdown
Member

biboc commented Jun 1, 2017

Ok @jia200x
I let you end this PR, i won't be available before next Tuesday.

@jia200x jia200x force-pushed the openthread_core branch from fa60436 to fc4fd62 Compare June 1, 2017 17:44
@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jun 1, 2017

@biboc ok. Thank you for all the contribution!

@aabadie Done

Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. Thanks for the hard work @jia200x and @biboc !

@aabadie aabadie merged commit 1a2097e into RIOT-OS:master Jun 1, 2017
@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jun 1, 2017

Now let's add support for NCP and MTD nodes. And add sock adaption :)

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jun 1, 2017

@aabadie @biboc thank you so much!
The sock UDP part is ready. I will adapt to the merged OT and push a PR.
Cheers

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jun 1, 2017

🎉 ✨ congratz @jia200x!

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Jun 1, 2017

🎉 ✨ congratz @jia200x!

Thanks!

@emmanuelsearch
Copy link
Copy Markdown
Member

emmanuelsearch commented Jun 2, 2017

great! Nice work! @jia200x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: major The PR changes a significant part of the code base. It should be reviewed carefully

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants