Skip to content

Commit 546a5da

Browse files
author
Juan Flores
committed
Updating the 6lowpan tutorial
1 parent 96e9a85 commit 546a5da

3 files changed

Lines changed: 288 additions & 37 deletions

File tree

13.8 KB
Loading
-5.48 KB
Loading

‎_docs/tutorials/advanced/nuttx_getting_started/index.md‎

Lines changed: 288 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -677,64 +677,315 @@ Once the firmware was configured and uploaded, we need to connect the breakout b
677677

678678
Finally, connect the mini USB cable to the USB OTG1, and the connections should look like this:
679679

680+
680681
![image](imgs/olimex_mrf24j40.jpg)
681682

682683
Once the wiring is done, open a console and you should see this:
683684

684-
![image](imgs/6lowpan_nsh.png)
685+
```bash
686+
nsh> ?
687+
help usage: help [-v] [<cmd>]
688+
689+
[ cd df help ls mw set true
690+
? cp echo hexdump mb ps sh uname
691+
addroute cmp exec ifconfig mkdir pwd sleep umount
692+
basename dirname exit ifdown mh rm test unset
693+
break dd false ifup mount rmdir telnetd usleep
694+
cat delroute free kill mv route time xd
695+
696+
Builtin Apps:
697+
udp_6lowpan ping6 i8sak
698+
```
699+
700+
Execute the App ``udp_6lowpan``.
701+
When you execute it, the app will ask you if you want to do an auto-configuration.
702+
The first time that we execute this app after the initialization of the board, we need to configure the network. If you execute the autoconfiguration, the configuration process will be simplified, otherwise, you will need to configure manually. **If you don't configure the board, it won't work properly.**
703+
If you type 'Y', it should appear the next output:
704+
705+
```bash
706+
nsh> udp_6lowpan
707+
Do you want to execute the automatic WPAN configuration? (y/n)
708+
Starting WPAN configuration
709+
Type C to be coordinator
710+
Type N to be node
711+
712+
```
713+
714+
This is asking if you want to be a coordinator or a node.
715+
The difference between a coordinator and a node is that the first one can work as a router, coordinating the network traffic of up to 8 nodes.
716+
On the other hand, the node is an endpoint device which only sends and receive data, it doesn't coordinate the traffic of the other devices.
717+
718+
**Note:** A coordinator should be bring-up before the node configuration.
719+
720+
If you choose coordinator, type 'C' and it should return the next output:
721+
722+
```bash
723+
ifdown wpan0...OK
724+
i8sak: resetting MAC layer
725+
i8sak: starting PAN
726+
Choose your ID (00 to FF)
727+
```
728+
Type the ID that you want, it should be between 00 and FF (Hexadecimal value).
729+
**Caution:** Avoid to use the same ID in two devices,or you will get and IP conflict.The ID must be unique.
730+
731+
Once you write your ID, it should return the next data:
732+
```bash
733+
Your hardware address is: i8sak set eaddr 00:fa:de:00:de:ad:be:00
734+
735+
i8sak: accepting all assoc requests
736+
i8sak: daemon started
737+
ifup wpan0...OK
738+
Mounting proc file system
739+
wpan0 Link encap:6LoWPAN HWaddr 00:be:ad:de:00:de:fa:00 at UP
740+
inet6 addr: fe80::2be:adde:de:fa00/64
741+
inet6 DRaddr: ::/64
685742
686-
First we need to type the next command in both boards to bring-down the connection: `ifdown wpan0`
743+
RX: Received Fragment Errors
744+
00000000 00000000 00000000
745+
IPv6 Dropped
746+
00000000 00000000
747+
TX: Queued Sent Errors Timeouts
748+
00000000 00000000 00000000 00000000
749+
Total Errors: 00000000
687750
688-
We already know that we have two different roles, **Client** and **Server**. So we need to configure each board with one role:
689-
**- Server Configuration:**
690-
- `i8sak wpan0 startpan cd:ab `
691-
- `i8sak set chan 11`
692-
- `i8sak set panid cd:ab `
693-
- `i8sak set saddr 42:01 `
694-
- `i8sak acceptassoc `
695751
696-
Now it's time to configure the client. It's important to follow this configuration order.
697-
**- Client Configuration:**
698-
- `i8sak wpan0`
699-
- `i8sak set chan 11 `
700-
- `i8sak set panid cd:ab `
701-
- `i8sak set saddr 42:02 `
702-
- `i8sak set ep_saddr 42:01`
703-
- `i8sak assoc`
704752
705-
If everything goes fine, you should see something like this:
706-
**Server Board**
707753
708-
![image](imgs/6lowpan_accept.png)
754+
Available commands
755+
-To send a package type: write
756+
-To receive a package type: read
757+
-To exit type: quit
709758
710-
**Client Board**
759+
```
760+
761+
Now the coordinator network is ready to send and receive packages. Also is prepared to receive an association request from the nodes. This association request is a tool of node to be coordinated by a coordinator.
762+
763+
Coming back to the role menu, if you choose a node, will also ask for an ID (**Remember, the ID must be unique.**). And it should look like this:
764+
765+
```bash
766+
nsh> udp_6lowpan
767+
Do you want to execute the automatic WPAN configuration? (y/n)
768+
Starting WPAN configuration
769+
Type C to be coordinator
770+
Type N to be node
771+
772+
773+
ifdown wpan0...OK
774+
Choose your ID (00 to FF)
775+
776+
```
777+
The node can send and receive a message with and without a coordinator. After giving a valid ID, we can have the next two output:
778+
779+
- If a coordinator is available in the network:
711780
712-
![image](imgs/6lowpan_assoc.png)
781+
```bash
782+
Your hardware address is: i8sak set eaddr 00:fa:de:00:de:ad:be:01
713783
714-
It is only left to bring-up the network, so type this command in both boards: `ifup wpan0`.
784+
i8sak: daemon started
785+
i8sak: issuing ASSOC. request 1
786+
i8sak: ASSOC.request succeeded
787+
ifup wpan0...OK
788+
Mounting proc file system
789+
i8sak: daemon closing
790+
wpan0 Link encap:6LoWPAN HWaddr 01:be:ad:de:00:de:fa:00 at UP
791+
inet6 addr: fe80::3be:adde:de:fa00/64
792+
inet6 DRaddr: ::/64
715793
716-
At this point, the set-up is complete and it's the moment to use the UDP server and client to have a communication between the boards.
717-
So, first we need to know the IP of the server board. Type the next commands in the server board:
718-
- `mount -t procfs /proc`
719-
- `ifconfig`
794+
RX: Received Fragment Errors
795+
00000000 00000000 00000000
796+
IPv6 Dropped
797+
00000000 00000000
798+
TX: Queued Sent Errors Timeouts
799+
00000000 00000000 00000000 00000000
800+
Total Errors: 00000000
720801
721-
You should see something like in the image. The red square is the IP of the board.
722-
![image](imgs/6lowpan_ip.png)
723802
724-
Finally in the Server board, execute the Server, typing:
725-
- `udpserver &`
726803
727-
![image](imgs/6lowpan_server.png)
728-
Now the UDP server, it's ready to work.
729804
730-
To use the UDP client, we need to type the next command in the client board:
731-
- `udpclient <IP of the server board>`
805+
Available commands
806+
-To send a package type: write
807+
-To receive a package type: read
808+
-To exit type: quit
809+
810+
```
811+
- No coordinator is available:
812+
813+
```bash
814+
Your hardware address is: i8sak set eaddr 00:fa:de:00:de:ad:be:01
815+
816+
i8sak: daemon started
817+
i8sak: issuing ASSOC. request 1
818+
i8sak: ASSOC.request failed: No ack
819+
ifup wpan0...OK
820+
Mounting proc file system
821+
i8sak: daemon closing
822+
wpan0 Link encap:6LoWPAN HWaddr 01:be:ad:de:00:de:fa:00 at UP
823+
inet6 addr: fe80::3be:adde:de:fa00/64
824+
inet6 DRaddr: ::/64
825+
826+
RX: Received Fragment Errors
827+
00000000 00000000 00000000
828+
IPv6 Dropped
829+
00000000 00000000
830+
TX: Queued Sent Errors Timeouts
831+
00000000 00000000 00000000 00000000
832+
Total Errors: 00000000
732833
733-
![image](imgs/6lowpan_client.png)
734834
735-
Now the UDP Client, will send a `HelloWorld` to the UDP Server.
736835
737836
837+
Available commands
838+
-To send a package type: write
839+
-To receive a package type: read
840+
-To exit type: quit
841+
842+
```
843+
You can notice that the difference is at the ```ASSOC.request``` which failed or succeed. If in the future you want to have a coordinator in your network, you can associate a node to it, as easy as executing again the autoconfiguration.
844+
845+
At this point, remember to copy the IP address of your device. The IP of the board is the value of **inet6 addr**. For this example is fe80::3be:adde: de:fa00.
846+
If you can't find in the output of this app, just type ```quit``` and the application will close and you will be at the NSH console again. At this moment, type ```ifconfig``` and all the data of the connection will be shown.
847+
848+
```bash
849+
nsh> ifconfig
850+
wpan0 Link encap:6LoWPAN HWaddr 01:be:ad:de:00:de:fa:00 at UP
851+
inet6 addr: fe80::3be:adde:de:fa00/64
852+
inet6 DRaddr: ::/64
853+
854+
RX: Received Fragment Errors
855+
00000000 00000000 00000000
856+
IPv6 Dropped
857+
00000000 00000000
858+
TX: Queued Sent Errors Timeouts
859+
00000000 00000000 00000000 00000000
860+
Total Errors: 00000000
861+
862+
IPv6 TCP UDP ICMPv6
863+
Received 0000 0000 0000 0000
864+
Dropped 0000 0000 0000 0000
865+
IPv6 VHL: 0000
866+
Checksum ---- 0000 0000 ----
867+
TCP ACK: 0000 SYN: 0000
868+
RST: 0000 0000
869+
Type 0000 ---- ---- 0000
870+
Sent 0000 0000 0000 0000
871+
Rexmit ---- 0000 ---- ----
872+
```
873+
874+
Everything is ready to send and receive UDP package from/to the 6lowpan network. The way to use it is exactly the same in both modes (coordinator and node).
875+
876+
The ```udp_6lowpan``` give us the next options:
877+
878+
```bash
879+
Available commands
880+
-To send a package type: write
881+
-To receive a package type: read
882+
-To exit type: quit
883+
884+
```
885+
886+
To send a package, type ```write``` and push enter.
887+
The application will ask for the next information:
888+
- Destination IP: The IPV6 of the board that we want to send a package.
889+
- Destination Port: The open port of the destination board.
890+
- Origin port: The port that we want to use to send the data in the emitter board.
891+
(Is mandatory to push enter once you write the asked data).
892+
893+
Once all the data are introduced, it should return something like this:
894+
```bash
895+
Introduce the IVP6 Destination
896+
Introduce the port destination
897+
Introduce the port origin
898+
Conection data:
899+
-Dest_IP: fe80::2be:adde:de:fa00
900+
-Dest_Port: 61616
901+
-Origin_Port: 61617
902+
Introduce a message to send:
903+
904+
```
905+
Now you're able to send messages to fe80::2be:adde:de:fa00 port 61616.
906+
If you want to close the connection and not send any more packages, you can type ```quit``` plus enter, and it should return to the main app menu.
907+
908+
If you want to use your device as receiver, just type ```read``` in the main app menu. This will ask you which port should it use to accept packages.
909+
(Is possible to receive and send messages at the same type, but you will need to create a custom app)
910+
After type the number of the port and press enter(For this example, we're going to use the port 61616), it should output the next:
911+
```bash
912+
Available commands
913+
-To send a package type: write
914+
-To receive a package type: read
915+
-To exit type: quit
916+
Introduce the reception port
917+
Listening on 61616 for input packets
918+
919+
```
920+
921+
This the output that you should see when you send a package and when you receive:
922+
- Sending a package:
923+
924+
```bash
925+
wpan0 Link encap:6LoWPAN HWaddr 00:be:ad:de:00:de:fa:00 at UP
926+
inet6 addr: fe80::2be:adde:de:fa00/64
927+
inet6 DRaddr: ::/64
928+
929+
RX: Received Fragment Errors
930+
00000000 00000000 00000000
931+
IPv6 Dropped
932+
00000000 00000000
933+
TX: Queued Sent Errors Timeouts
934+
00000000 00000000 00000000 00000000
935+
Total Errors: 00000000
936+
937+
938+
939+
940+
Available commands
941+
-To send a package type: write
942+
-To receive a package type: read
943+
-To exit type: quit
944+
Introduce the IVP6 Destination
945+
Introduce the port destination
946+
Introduce the port origin
947+
Conection data:
948+
-Dest_IP: fe80::3be:adde:de:fa00
949+
-Dest_Port: 61616
950+
-Origin_Port: 61617
951+
Introduce a message to send:
952+
Sending 13 characters: micro-ROS
953+
954+
Introduce a message to send:
955+
```
956+
957+
- Receiving a package:
958+
959+
```bash
960+
wpan0 Link encap:6LoWPAN HWaddr 01:be:ad:de:00:de:fa:00 at UP
961+
inet6 addr: fe80::3be:adde:de:fa00/64
962+
inet6 DRaddr: ::/64
963+
964+
RX: Received Fragment Errors
965+
00000000 00000000 00000000
966+
IPv6 Dropped
967+
00000000 00000000
968+
TX: Queued Sent Errors Timeouts
969+
00000000 00000000 00000000 00000000
970+
Total Errors: 00000000
971+
972+
973+
974+
975+
Available commands
976+
-To send a package type: write
977+
-To receive a package type: read
978+
-To exit type: quit
979+
Introduce the reception port
980+
Listening on 61616 for input packets
981+
Received 13 bytes from 80fe:0000:0000:0000:be02:dead:de00:00fa port 61617
982+
Received packet: micro-ROS
983+
984+
```
985+
986+
This version of the 6lowpan stack, have interoperability with 6lowpan stack of Linux. So we can have communication between NuttX and 6lowpan.
987+
988+
The ping between NuttX devices work properly, but with Linux, devices don't work properly and a final point to know is the dynamic association and multi-hop communication doesn't work properly. So, communications are only point-to-point.
738989
739990
## How to use the ADC demo
740991

0 commit comments

Comments
 (0)