Hi all,
I'm in the process of learning about OpenThread with the view of
building a small embedded metering/control device with it. The hardware
we have is built around the TI CC2538SF53 microcontroller, and I'm
coding it using the GNU ARM gcc tools (specifically, GNU Tools for ARM
Embedded Processors 6-2017-q1-update) on Linux.
I have two CC2538EM+SmartRF06 board set-ups, sitting about 1m apart,
both of which are plugged into USB ports on my laptop. One will run the
NCP firmware, the other the CLI firmware hacked to also support CoAP.
My aim at the moment is to try and measure the light sensor and blink
the on-board LEDs using CoAP calls.
The best resource I've seen on doing this has been Nordic
Semiconductor's example code, which has given me an idea on how I am
supposed to call the CoAP-related functions, but it seems there are some
gaps in my knowledge as I have not gotten things working.
The branch I'm working on is this:
https://github.com/vrtsystems/openthread/tree/feature/WH-288-cc2538dk-support
The earlier commits in this branch try to add support for the CC2538DK's
on-board hardware, using some code from Zolertia's Firefly branch.
Basically my intent here was to separate SoC support code from the
actual surrounding board hardware so that the CC2538DK, Zolertia
Firefly, our own CC2538-based device, and anyone else's devices, can be
supported.
I'm open to suggestions on how to achieve this.
The actual CoAP action happens here:
https://github.com/vrtsystems/openthread/blob/feature/WH-288-cc2538dk-support/examples/apps/cli/coap.c
With this code, I can build a binary with:
> $ ./bootstrap && make -f examples/Makefile-cc2538 BOARD=cc2538dk COAP=1
and I get four binaries, two CLI ones (a MTD and FTD version), and two
NCP ones (again, a MTD and FTD version). I'm not sure what the
difference is between the FTD and MTD versions are, the documentation
for the CC2538[1] makes no mention of these two versions or what I
should be using. So far the FTD version is what I've been using.
Flashing ot-cli-ftd to one board and ot-ncp-ftd to the other, I can get
both up on a network, and have `wpantund` link my laptop in. From my
laptop, I can ping the device running `ot-cli-ftd`.
Great. Now I pull out Firefox and use the Copper extension to try and
talk to the device. Right off the bat, I can click Ping, and get a
response almost immediately (61 msec). There are supposed to be two
endpoints: `/leds` and `/als`.
Doing a `GET` of either of those, hangs. The microcontroller is still
responsive, but it doesn't seem to reply.
`tcpdump` reports the following when I try a `GET /leds`…
> 15:58:22.072173 IP6 fdde:ad00:beef:0:ded9:f9f3:b3e7:5641.57450 > fdde:ad00:beef:0:530:dfc9:acd2:c9ac.5683: UDP, length 11
> 0x0000: 6007 b59f 0013 1140 fdde ad00 beef 0000
> 0x0010: ded9 f9f3 b3e7 5641 fdde ad00 beef 0000
> 0x0020: 0530 dfc9 acd2 c9ac e06a 1633 0013 64b1
> 0x0030: 4001 c2d6 b46c 6564 73c1 02
… `wpantund` reports:
> wpantund[32003]: TunnelIPv6Interface::on_link_state_changed() UP=1 RUNNING=1
> wpantund[32003]: TunnelIPv6Interface::on_link_state_changed() UP=1 RUNNING=1
> wpantund[32003]: [->NCP] IPv6 len:59 type:17(cksum 0x64b1) [SECURE]
> wpantund[32003]: to(remote):[fdde:ad00:beef:0:530:dfc9:acd2:c9ac]:5683
> wpantund[32003]: from(local):[fdde:ad00:beef:0:ded9:f9f3:b3e7:5641]:57450
> wpantund[32003]: ↳ 8003723B006007B59F00131140FDDEAD00BEEF0000DED9F9F3B3E75641FDDEAD00BEEF00000530DFC9ACD2C9ACE06A1633001364B14001C2D6B46C656473C102
> wpantund[32003]: Tickle...
> wpantund[32003]: [->NCP] CMD_NOOP tid:6
> wpantund[32003]: ↳ 8600
> wpantund[32003]: [NCP->] CMD_PROP_VALUE_IS(PROP_LAST_STATUS) tid:6
> wpantund[32003]: [-NCP-]: Last status (STATUS_OK, 0)
By comparison, if I just do a ping, I get this:
> wpantund[32003]: [->NCP] IPv6 len:52 type:17(cksum 0xb370) [SECURE]
> wpantund[32003]: to(remote):[fdde:ad00:beef:0:530:dfc9:acd2:c9ac]:5683
> wpantund[32003]: from(local):[fdde:ad00:beef:0:ded9:f9f3:b3e7:5641]:46418
> wpantund[32003]: ↳ 800372340060066CBC000C1140FDDEAD00BEEF0000DED9F9F3B3E75641FDDEAD00BEEF00000530DFC9ACD2C9ACB5521633000CB37040002ED1
> wpantund[32003]: [NCP->] CMD_PROP_VALUE_IS(PROP_STREAM_NET) tid:0
> wpantund[32003]: [NCP->] IPv6 len:52 type:17(cksum 0x8370) [SECURE]
> wpantund[32003]: to(local):[fdde:ad00:beef:0:ded9:f9f3:b3e7:5641]:46418
> wpantund[32003]: from(remote):[fdde:ad00:beef:0:530:dfc9:acd2:c9ac]:5683
> 16:00:28.314615 IP6 fdde:ad00:beef:0:ded9:f9f3:b3e7:5641.46418 > fdde:ad00:beef:0:530:dfc9:acd2:c9ac.5683: UDP, length 4
> 0x0000: 6006 6cbc 000c 1140 fdde ad00 beef 0000
> 0x0010: ded9 f9f3 b3e7 5641 fdde ad00 beef 0000
> 0x0020: 0530 dfc9 acd2 c9ac b552 1633 000c b370
> 0x0030: 4000 2ed1
> 16:00:28.344467 IP6 fdde:ad00:beef:0:530:dfc9:acd2:c9ac.5683 > fdde:ad00:beef:0:ded9:f9f3:b3e7:5641.46418: UDP, length 4
> 0x0000: 6000 0000 000c 1140 fdde ad00 beef 0000
> 0x0010: 0530 dfc9 acd2 c9ac fdde ad00 beef 0000
> 0x0020: ded9 f9f3 b3e7 5641 1633 b552 000c 8370
> 0x0030: 7000 2ed1
So it isn't firewalling or routing, the two *can* talk… just the CoAP
server decides to get the 'umph and refuses to talk, thus clearly I have
missed something.
Does anyone have any ideas?
1.
https://github.com/openthread/openthread/tree/master/examples/platforms/cc2538
Regards,
--
_ ___ Stuart Longland - Systems Engineer
\ /|_) | T:
+61 7 3535 9619
\/ | \ | 38b Douglas Street F:
+61 7 3535 9699
SYSTEMS Milton QLD 4064
http://www.vrt.com.au