Connect two native Contiki NG motes over SLIP

191 views Asked by At

Since the RPL border router example works as either a Cooja mote or a native mote, I thought using the SLIP code in /services/rpl-border-router/native might work. I made a copy of hello-world. I edited hello-world.c to read

#include "contiki.h"
#include "services/rpl-border-router/native/border-router.h"
#include <stdio.h> /* For printf() */

extern int contiki_argc;
extern char **contiki_argv;

/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
  static struct etimer timer;

  PROCESS_BEGIN();

  /* Setup a periodic timer that expires after 10 seconds. */
  etimer_set(&timer, CLOCK_SECOND * 10);
  
  slip_config_handle_arguments(contiki_argc, contiki_argv);
  slip_init();

  while(1) {
    printf("Hello, world\n");

    /* Wait for the periodic timer to expire and then restart the timer. */
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
    etimer_reset(&timer);
  }

  PROCESS_END();
}

And edited the makefile:

CONTIKI_PROJECT = hello-world
all: $(CONTIKI_PROJECT)

CONTIKI = ../..
include $(CONTIKI)/Makefile.dir-variables
MODULES += $(CONTIKI_NG_SERVICES_DIR)/rpl-border-router
include $(CONTIKI)/Makefile.include

This inclusion of rpl-border-router module was done because I was getting undefined reference to ‘slip_init()’... and undefined reference to ‘slip_config_handle_arguments(contiki_argc, contiki_argv);’... errors when compiling, despite the #include "services/rpl-border-router/native/border-router.h" line in hello-world.c. This does appear to be the right header to include for declarations of these functions, but if I am mistaken please say so.

From the folder where the edited hello-world code resides, I did make distclean, and then make TARGET=native. If I run this edited hello-world with sudo ./hello-world.native fd00::3 -s ttyS0

it looks like it is starting up, but I see:

…[INFO: Native    ] Added global IPv6 address fd00::302:304:506:708
********SLIP started on ``/dev/ttyS0''
Hello, world
[INFO: BR        ] RPL-Border router started
********SLIP started on ``/dev/ttyS0''
opened tun device ``/dev/tun0''

So it is trying to start up the border router as well as opening the SLIP interface, and just below the ifconfig tun0 output (which looks fine) I see

…hello-world.native: serial_input: read: Success
ifconfig tun0 down
netstat -nr | awk '{ if ($2 == "tun0") print "route delete -net "$1; }' | sh

So, it seems I need to do something to stop from starting the border router module. I have seen that there are 'slip.c' and 'slip.h' in os/dev/, used in the slip-radio example but the declaration of 'slip_arch_init()' in slip.h without a definition of slip_arch_init() in slip.c has me confused, and motivated me to use 'slip_init()' from the /services/rpl-border-router/native folder, since in there I can see a pretty normal bit of code opening up a serial interface.

I have done a lot of google searching and searched through several of the more complex examples for something similar to what I am trying to do, but haven’t found anything that seems very close. If there is something ready made then or course that would be the greatest help, but I am sure it must be obvious that my understanding of Make and file interrelations is nowhere near where it needs to be.

Just to be clear, my goal at the moment is to get a SLIP interface up and running on the remote VM so that I can get a ping6 response on the VM with the border router. I will worry about writing the callback once I have some baseline connectivity. Maybe this is a misunderstanding on my part as well.

0

There are 0 answers