Merge branch 'develop' into lafka-include-guards

This commit is contained in:
Simon Duquennoy 2018-06-17 12:42:41 +02:00 committed by GitHub
commit a0f176e4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 825 additions and 42 deletions

View File

@ -0,0 +1,7 @@
CONTIKI_PROJECT = node
all: $(CONTIKI_PROJECT)
MODULES += os/services/deployment
CONTIKI = ../../..
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,3 @@
A simple example of how to use the deployment module. Intended for Cooja,
with a Cooja motes, as in the provided simulation file `sim.csc`. For use
in a real deployment, set DEPLOYMENT_MAPPING to your own ID-MAC mapping table.

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 2018, RISE SICS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* Benchmark: the root sends requests to all nodes in a randomized
* order, and receives resopnses back.
* \author
* Simon Duquennoy <simon.duquennoy@ri.se>
*/
#include "contiki.h"
#include "contiki-net.h"
#include "services/deployment/deployment.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_INFO
#include "services/deployment/deployment.h"
/** \brief A mapping table for a 8-node Cooja mote simulation.
* Define your own for any given deployment environment */
const struct id_mac deployment_cooja8[] = {
{ 1, {{0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01}}},
{ 2, {{0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02}}},
{ 3, {{0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03}}},
{ 4, {{0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04}}},
{ 5, {{0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05}}},
{ 6, {{0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06}}},
{ 7, {{0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07}}},
{ 8, {{0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08}}},
{ 0, {{0}}}
};
/** \brief An example mapping for Openmotes in Flocklab.
* To use, set DEPLOYMENT_MAPPING to deployment_flocklab_openmotes */
const struct id_mac deployment_flocklab_openmotes[] = {
{ 3, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0x29}}},
{ 6, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0x34}}},
{ 8, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0x1f}}},
{ 15, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0x85}}},
{ 16, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0x00}}},
{ 18, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0x37}}},
{ 22, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0x08}}},
{ 23, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0x5f}}},
{ 31, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0x9b,0xb1}}},
{ 0, {{0}}}
};
/*---------------------------------------------------------------------------*/
PROCESS(app_process, "App process");
AUTOSTART_PROCESSES(&app_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(app_process, ev, data)
{
static struct etimer timer;
static uip_ipaddr_t ipaddr;
static linkaddr_t lladdr;
static int i;
PROCESS_BEGIN();
if(node_id == ROOT_ID) {
/* We are the root, start a DAG */
NETSTACK_ROUTING.root_start();
/* Setup a periodic timer that expires after 10 seconds. */
etimer_set(&timer, CLOCK_SECOND * 10);
/* Wait until all nodes have joined */
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
etimer_reset(&timer);
/* Log expected IPv6 addresses of all nodes */
LOG_INFO("Node list:\n");
for(i = 0; i<deployment_node_count(); i++) {
int id;
id = deployment_id_from_index(i);
/* Set ipaddr with DODAG ID, so we get the prefix */
NETSTACK_ROUTING.get_root_ipaddr(&ipaddr);
/* Set IID */
deployment_iid_from_id(&ipaddr, id);
/* Get lladdr */
deployment_lladdr_from_id(&lladdr, id);
LOG_INFO("-- ID: %02u, Link-layer address: ", id);
LOG_INFO_LLADDR(&lladdr);
LOG_INFO_(", IPv6 address: ");
LOG_INFO_6ADDR(&ipaddr);
LOG_INFO_("\n");
}
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,12 @@
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* The node-id of the root */
#define ROOT_ID 1
/* The deployment map (ID<->MAC) */
#define DEPLOYMENT_MAPPING deployment_cooja8
/* Compact address logging (both link-layer and IPv6).
* Shows an abbreviated form that contains the node-id */
#define LOG_CONF_WITH_COMPACT_ADDR 1
#endif /* PROJECT_CONF_H_ */

View File

@ -0,0 +1,275 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project EXPORT="discard">[APPS_DIR]/mrm</project>
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
<project EXPORT="discard">[APPS_DIR]/avrora</project>
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
<simulation>
<title>My simulation</title>
<randomseed>123456</randomseed>
<motedelay_us>1000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>100.0</interference_range>
<success_ratio_tx>1.0</success_ratio_tx>
<success_ratio_rx>1.0</success_ratio_rx>
</radiomedium>
<events>
<logoutput>40000</logoutput>
</events>
<motetype>
org.contikios.cooja.contikimote.ContikiMoteType
<identifier>mtype90</identifier>
<description>Cooja Mote Type #1</description>
<source>[CONTIKI_DIR]/examples/libs/deployment/node.c</source>
<commands>make node.cooja TARGET=cooja</commands>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<symbols>false</symbols>
</motetype>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>12.478629242391953</x>
<y>42.201041276604826</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>1</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype90</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>25.625935608473608</x>
<y>82.53975431376661</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>2</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype90</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>51.615094138350024</x>
<y>59.70602651475372</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>3</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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etype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>41.04314122620578</x>
<y>121.24693889311891</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>4</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype90</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>64.9463558635099</x>
<y>104.25039302469283</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>5</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype90</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>93.59263858654369</x>
<y>75.40399148300003</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>6</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype90</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>75.6297158696234</x>
<y>139.97002035548905</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>7</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.coo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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype90</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>104.34293924684245</x>
<y>116.07658566915099</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>8</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>280</width>
<z>2</z>
<height>160</height>
<location_x>400</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<moterelations>true</moterelations>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<viewport>2.4250860844175466 0.0 0.0 2.4250860844175466 35.26895372864869 -46.9106236441515</viewport>
</plugin_config>
<width>400</width>
<z>3</z>
<height>400</height>
<location_x>1</location_x>
<location_y>1</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter>App</filter>
<formatted_time />
<coloring />
</plugin_config>
<width>827</width>
<z>0</z>
<height>665</height>
<location_x>681</location_x>
<location_y>-1</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.TimeLine
<plugin_config>
<mote>0</mote>
<mote>1</mote>
<mote>2</mote>
<mote>3</mote>
<mote>4</mote>
<mote>5</mote>
<mote>6</mote>
<mote>7</mote>
<showRadioRXTX />
<showRadioHW />
<showLEDs />
<zoomfactor>500.0</zoomfactor>
</plugin_config>
<width>1539</width>
<z>1</z>
<height>263</height>
<location_x>0</location_x>
<location_y>709</location_y>
</plugin>
</simconf>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Swedish Institute of Computer Science.
* Copyright (c) 2018, RISE SICS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Swedish Institute of Computer Science.
* Copyright (c) 2018, RISE SICS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -258,7 +258,11 @@ uip_sr_link_snprint(char *buf, int buflen, uip_sr_node_t *link)
NETSTACK_ROUTING.get_sr_node_ipaddr(&child_ipaddr, link);
NETSTACK_ROUTING.get_sr_node_ipaddr(&parent_ipaddr, link->parent);
index += uiplib_ipaddr_snprint(buf+index, buflen-index, &child_ipaddr);
if(LOG_WITH_COMPACT_ADDR) {
index += log_6addr_compact_snprint(buf+index, buflen-index, &child_ipaddr);
} else {
index += uiplib_ipaddr_snprint(buf+index, buflen-index, &child_ipaddr);
}
if(index >= buflen) {
return index;
}
@ -273,7 +277,11 @@ uip_sr_link_snprint(char *buf, int buflen, uip_sr_node_t *link)
if(index >= buflen) {
return index;
}
index += uiplib_ipaddr_snprint(buf+index, buflen-index, &parent_ipaddr);
if(LOG_WITH_COMPACT_ADDR) {
index += log_6addr_compact_snprint(buf+index, buflen-index, &parent_ipaddr);
} else {
index += uiplib_ipaddr_snprint(buf+index, buflen-index, &parent_ipaddr);
}
if(index >= buflen) {
return index;
}

View File

@ -94,7 +94,11 @@ rpl_neighbor_snprint(char *buf, int buflen, rpl_nbr_t *nbr)
const struct link_stats *stats = rpl_neighbor_get_link_stats(nbr);
clock_time_t clock_now = clock_time();
index += uiplib_ipaddr_snprint(buf+index, buflen-index, rpl_neighbor_get_ipaddr(nbr));
if(LOG_WITH_COMPACT_ADDR) {
index += log_6addr_compact_snprint(buf+index, buflen-index, rpl_neighbor_get_ipaddr(nbr));
} else {
index += uiplib_ipaddr_snprint(buf+index, buflen-index, rpl_neighbor_get_ipaddr(nbr));
}
if(index >= buflen) {
return index;
}

View File

@ -0,0 +1,141 @@
/*
* Copyright (c) 2018, RISE SICS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \addtogroup deployment
* @{
*/
/**
* \file
* Code managing id<->mac address<->IPv6 address mapping, and doing this
* for different deployment scenarios: Cooja, Nodes, Indriya or Twist testbeds
*
* \author Simon Duquennoy <simonduq@sics.se>
*/
#include "contiki.h"
#include "contiki-net.h"
#include "deployment.h"
#include "sys/node-id.h"
#include <string.h>
#include <stdio.h>
/**
* \brief List of ID<->MAC mapping used for different deployments
*/
extern const struct id_mac DEPLOYMENT_MAPPING[];
/**
* \brief The number of nodes in the deployment
*/
static int node_count = 0;
/*---------------------------------------------------------------------------*/
void
deployment_init(void)
{
const struct id_mac *curr = DEPLOYMENT_MAPPING;
/* Initialize node_id */
node_id = deployment_id_from_lladdr((const linkaddr_t *)&linkaddr_node_addr);
/* Count nodes */
node_count = 0;
while(curr->id != 0) {
node_count++;
curr++;
}
}
/*---------------------------------------------------------------------------*/
int
deployment_node_count(void)
{
return node_count;
}
/*---------------------------------------------------------------------------*/
uint16_t
deployment_id_from_lladdr(const linkaddr_t *lladdr)
{
const struct id_mac *curr = DEPLOYMENT_MAPPING;
if(lladdr == NULL) {
return 0;
}
while(curr->id != 0) {
/* Assume network-wide unique 16-bit MAC addresses */
if(linkaddr_cmp(lladdr, &curr->mac)) {
return curr->id;
}
curr++;
}
return 0;
}
/*---------------------------------------------------------------------------*/
void
deployment_lladdr_from_id(linkaddr_t *lladdr, uint16_t id)
{
const struct id_mac *curr = DEPLOYMENT_MAPPING;
if(id == 0 || lladdr == NULL) {
return;
}
while(curr->id != 0) {
if(curr->id == id) {
linkaddr_copy(lladdr, &curr->mac);
return;
}
curr++;
}
}
/*---------------------------------------------------------------------------*/
uint16_t
deployment_id_from_iid(const uip_ipaddr_t *ipaddr)
{
const linkaddr_t lladdr;
uip_ds6_set_lladdr_from_iid((uip_lladdr_t *)&lladdr, ipaddr);
return deployment_id_from_lladdr(&lladdr);
}
/*---------------------------------------------------------------------------*/
void
deployment_iid_from_id(uip_ipaddr_t *ipaddr, uint16_t id)
{
linkaddr_t lladdr;
deployment_lladdr_from_id(&lladdr, id);
uip_ds6_set_addr_iid(ipaddr, (uip_lladdr_t *)&lladdr);
}
/*---------------------------------------------------------------------------*/
uint16_t
deployment_id_from_index(uint16_t index)
{
if(index < deployment_node_count()) {
return DEPLOYMENT_MAPPING[index].id;
} else {
return 0;
}
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 2018, RISE SICS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \addtogroup deployment
* @{
*
* \file
Per-deployment MAC <-> nodeid mapping
* \author Simon Duquennoy <simon.duquennoy@ri.se>
*
*/
#ifndef DEPLOYMENT_H_
#define DEPLOYMENT_H_
#include "contiki-conf.h"
#include "sys/node-id.h"
#include "net/ipv6/uip.h"
#include "net/linkaddr.h"
/**
* \brief ID<->MAC address mapping structure
*/
struct id_mac {
uint16_t id;
linkaddr_t mac;
};
/**
* DEPLOYMENT_MAPPING:
* A table of struct id_mac that provides ID-MAC mapping for a deployment.
* Example with four nodes:
* In configuration file:
* \#define DEPLOYMENT_MAPPING custom_array
* In a .c file:
* const struct id_mac custom_array[] = {
{ 1, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb6,0x14}}},
{ 2, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb1,0xe7}}},
{ 3, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb4,0x35}}},
{ 4, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb1,0xcf}}},
{ 0, {{0}}}
};
*/
/**
* Initialize the deployment module
*/
void deployment_init(void);
/**
* Get the number of nodes for the deployment (length of mapping table)
*
* \return The number of nodes in the deployment
*/
int deployment_node_count(void);
/**
* Get node ID from a link-layer address, from the deployment mapping table
*
* \param lladdr The link-layer address to look up for
* \return Node ID from a corresponding link-layer address
*/
uint16_t deployment_id_from_lladdr(const linkaddr_t *lladdr);
/**
* Get node link-layer address from a node ID, from the deployment mapping table
*
* \param lladdr A pointer where to write the link-layer address
* \param id The node ID to look up for
*/
void deployment_lladdr_from_id(linkaddr_t *lladdr, uint16_t id);
/**
* Get node ID from the IID of an IPv6 address
*
* \param ipaddr The IPv6 (global or link-local) address that contains the IID
* \return Node ID from a corresponding IID
*/
uint16_t deployment_id_from_iid(const uip_ipaddr_t *ipaddr);
/**
* Get IPv6 IID from node IDs
*
* \param ipaddr The IPv6 where to write the IID
* \param id The node ID
*/
void deployment_iid_from_id(uip_ipaddr_t *ipaddr, uint16_t id);
/**
* Get node ID from index in mapping table
*
* \param index The index in the deployment mapping table
* \return Node ID at the corresponding index
*/
uint16_t deployment_id_from_index(uint16_t index);
#endif /* DEPLOYMENT_H_ */
/** @} */

View File

@ -0,0 +1 @@
#define BUILD_WITH_DEPLOYMENT 1

View File

@ -45,6 +45,7 @@
#include "contiki.h"
#include "shell.h"
#include "shell-commands.h"
#include "lib/list.h"
#include "sys/log.h"
#include "dev/watchdog.h"
#include "net/ipv6/uip.h"
@ -76,7 +77,8 @@ static uint16_t curr_ping_datalen;
#if TSCH_WITH_SIXTOP
static shell_command_6top_sub_cmd_t sixtop_sub_cmd = NULL;
#endif /* TSCH_WITH_SIXTOP */
static struct shell_command_set_t builtin_shell_command_set;
LIST(shell_command_sets);
/*---------------------------------------------------------------------------*/
static const char *
ds6_nbr_state_to_str(uint8_t state)
@ -345,15 +347,16 @@ PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
static
PT_THREAD(cmd_help(struct pt *pt, shell_output_func output, char *args))
{
struct shell_command_t *cmd_ptr;
struct shell_command_set_t *set;
const struct shell_command_t *cmd;
PT_BEGIN(pt);
SHELL_OUTPUT(output, "Available commands:\n");
cmd_ptr = shell_commands;
while(cmd_ptr->name != NULL) {
SHELL_OUTPUT(output, "%s\n", cmd_ptr->help);
cmd_ptr++;
/* Note: we explicitly don't expend any code space to deal with shadowing */
for(set = list_head(shell_command_sets); set != NULL; set = list_item_next(set)) {
for(cmd = set->commands; cmd->name != NULL; ++cmd) {
SHELL_OUTPUT(output, "%s\n", cmd->help);
}
}
PT_END(pt);
@ -729,12 +732,48 @@ PT_THREAD(cmd_6top(struct pt *pt, shell_output_func output, char *args))
void
shell_commands_init(void)
{
list_init(shell_command_sets);
list_add(shell_command_sets, &builtin_shell_command_set);
/* Set up Ping Reply callback */
uip_icmp6_echo_reply_callback_add(&echo_reply_notification,
echo_reply_handler);
}
/*---------------------------------------------------------------------------*/
struct shell_command_t shell_commands[] = {
void
shell_command_set_register(struct shell_command_set_t *set)
{
list_push(shell_command_sets, set);
}
/*---------------------------------------------------------------------------*/
int
shell_command_set_deregister(struct shell_command_set_t *set)
{
if(!list_contains(shell_command_sets, set)) {
return !0;
}
list_remove(shell_command_sets, set);
return 0;
}
/*---------------------------------------------------------------------------*/
const struct shell_command_t *
shell_command_lookup(const char *name)
{
struct shell_command_set_t *set;
const struct shell_command_t *cmd;
for(set = list_head(shell_command_sets);
set != NULL;
set = list_item_next(set)) {
for(cmd = set->commands; cmd->name != NULL; ++cmd) {
if(!strcmp(cmd->name, name)) {
return cmd;
}
}
}
return NULL;
}
/*---------------------------------------------------------------------------*/
const struct shell_command_t builtin_shell_commands[] = {
{ "help", cmd_help, "'> help': Shows this help" },
{ "reboot", cmd_reboot, "'> reboot': Reboot the board by watchdog_reboot()" },
{ "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" },
@ -765,4 +804,8 @@ struct shell_command_t shell_commands[] = {
{ NULL, NULL, NULL },
};
static struct shell_command_set_t builtin_shell_command_set = {
.next = NULL,
.commands = builtin_shell_commands,
};
/** @} */

View File

@ -53,8 +53,14 @@ struct shell_command_t {
const char *help;
};
/* The set of supported commands */
extern struct shell_command_t shell_commands[];
struct shell_command_set_t {
struct shell_command_set_t *next;
const struct shell_command_t *const commands;
};
void shell_command_set_register(struct shell_command_set_t *);
int shell_command_set_deregister(struct shell_command_set_t *);
const struct shell_command_t *shell_command_lookup(const char *);
/**
* Initializes Shell-commands module

View File

@ -89,7 +89,7 @@ output_prompt(shell_output_func output)
PT_THREAD(shell_input(struct pt *pt, shell_output_func output, const char *cmd))
{
static char *args;
static struct shell_command_t *cmd_ptr;
static const struct shell_command_t *cmd_descr = NULL;
PT_BEGIN(pt);
@ -105,20 +105,14 @@ PT_THREAD(shell_input(struct pt *pt, shell_output_func output, const char *cmd))
args++;
}
/* Lookup for command */
cmd_ptr = shell_commands;
while(cmd_ptr->name != NULL) {
if(strcmp(cmd, cmd_ptr->name) == 0) {
static struct pt cmd_pt;
PT_SPAWN(pt, &cmd_pt, cmd_ptr->func(&cmd_pt, output, args));
goto done;
}
cmd_ptr++;
cmd_descr = shell_command_lookup(cmd);
if(cmd_descr != NULL) {
static struct pt cmd_pt;
PT_SPAWN(pt, &cmd_pt, cmd_descr->func(&cmd_pt, output, args));
} else {
SHELL_OUTPUT(output, "Command not found. Type 'help' for a list of commands\n");
}
SHELL_OUTPUT(output, "Command not found. Type 'help' for a list of commands\n");
done:
output_prompt(output);
PT_END(pt);
}

View File

@ -46,7 +46,8 @@
#ifndef __LOG_CONF_H__
#define __LOG_CONF_H__
/* Log only the last 16 bytes of link-layer and IPv6 addresses */
/* Log only the last 16 bytes of link-layer and IPv6 addresses (or, if)
* the deployment module is enabled, the node IDs */
#ifdef LOG_CONF_WITH_COMPACT_ADDR
#define LOG_WITH_COMPACT_ADDR LOG_CONF_WITH_COMPACT_ADDR
#else /* LOG_CONF_WITH_COMPACT_ADDR */

View File

@ -51,6 +51,7 @@
#include "sys/log.h"
#include "net/ipv6/ip64-addr.h"
#include "net/ipv6/uiplib.h"
#include "deployment/deployment.h"
int curr_log_level_rpl = LOG_CONF_LEVEL_RPL;
int curr_log_level_tcpip = LOG_CONF_LEVEL_TCPIP;
@ -90,22 +91,36 @@ log_6addr(const uip_ipaddr_t *ipaddr)
LOG_OUTPUT("%s", buf);
}
/*---------------------------------------------------------------------------*/
int
log_6addr_compact_snprint(char *buf, size_t size, const uip_ipaddr_t *ipaddr)
{
if(ipaddr == NULL) {
return snprintf(buf, size, "6A-NULL");
} else {
char *prefix = NULL;
if(uip_is_addr_mcast(ipaddr)) {
prefix = "6M";
} else if(uip_is_addr_linklocal(ipaddr)) {
prefix = "6L";
} else {
prefix = "6G";
}
#if BUILD_WITH_DEPLOYMENT
return snprintf(buf, size, "%s-%03u", prefix, deployment_id_from_iid(ipaddr));
#else /* BUILD_WITH_DEPLOYMENT */
return snprintf(buf, size, "%s-%04x", prefix, UIP_HTONS(ipaddr->u16[sizeof(uip_ipaddr_t)/2-1]));
#endif /* BUILD_WITH_DEPLOYMENT */
}
}
/*---------------------------------------------------------------------------*/
void
log_6addr_compact(const uip_ipaddr_t *ipaddr)
{
if(ipaddr == NULL) {
LOG_OUTPUT("6A-NULL");
} else if(uip_is_addr_mcast(ipaddr)) {
LOG_OUTPUT("6M-%04x", UIP_HTONS(ipaddr->u16[sizeof(uip_ipaddr_t)/2-1]));
} else if(uip_is_addr_linklocal(ipaddr)) {
LOG_OUTPUT("6L-%04x", UIP_HTONS(ipaddr->u16[sizeof(uip_ipaddr_t)/2-1]));
} else {
LOG_OUTPUT("6G-%04x", UIP_HTONS(ipaddr->u16[sizeof(uip_ipaddr_t)/2-1]));
}
char buf[8];
log_6addr_compact_snprint(buf, sizeof(buf), ipaddr);
LOG_OUTPUT("%s", buf);
}
#endif /* NETSTACK_CONF_WITH_IPV6 */
/*---------------------------------------------------------------------------*/
void
log_lladdr(const linkaddr_t *lladdr)
@ -130,11 +145,15 @@ log_lladdr_compact(const linkaddr_t *lladdr)
if(lladdr == NULL || linkaddr_cmp(lladdr, &linkaddr_null)) {
LOG_OUTPUT("LL-NULL");
} else {
#if BUILD_WITH_DEPLOYMENT
LOG_OUTPUT("LL-%04u", deployment_id_from_lladdr(lladdr));
#else /* BUILD_WITH_DEPLOYMENT */
#if LINKADDR_SIZE == 8
LOG_OUTPUT("LL-%04x", UIP_HTONS(lladdr->u16[LINKADDR_SIZE/2-1]));
#elif LINKADDR_SIZE == 2
LOG_OUTPUT("LL-%04x", UIP_HTONS(lladdr->u16));
#endif
#endif /* BUILD_WITH_DEPLOYMENT */
}
}
/*---------------------------------------------------------------------------*/

View File

@ -194,6 +194,17 @@ void log_6addr(const uip_ipaddr_t *ipaddr);
*/
void log_6addr_compact(const uip_ipaddr_t *ipaddr);
/**
* Write at most size - 1 characters of the IP address to the output string,
* in a compact representation. The output is always null-terminated, unless
* size is 0.
*
* \param buf A pointer to an output string with at least size bytes.
* \param size The max number of characters to write to the output string.
* \param ipaddr A pointer to a uip_ipaddr_t that will be printed with printf().
*/
int log_6addr_compact_snprint(char *buf, size_t size, const uip_ipaddr_t *ipaddr);
#endif /* NETSTACK_CONF_WITH_IPV6 */
/**

View File

@ -40,12 +40,17 @@
#include "contiki.h"
#include "sys/node-id.h"
#include "net/linkaddr.h"
#include "services/deployment/deployment.h"
uint16_t node_id = 0;
void
node_id_init(void) {
#if BUILD_WITH_DEPLOYMENT
deployment_init();
#else /* BUILD_WITH_DEPLOYMENT */
/* Initialize with a default value derived from linkaddr */
node_id = linkaddr_node_addr.u8[LINKADDR_SIZE - 1]
+ (linkaddr_node_addr.u8[LINKADDR_SIZE - 2] << 8);
#endif /* BUILD_WITH_DEPLOYMENT */
}

View File

@ -66,6 +66,7 @@ rpl-border-router/openmote-cc2538 \
libs/ipv6-hooks/openmote-cc2538 \
libs/shell/openmote-cc2538 \
libs/simple-energest/openmote-cc2538 \
libs/deployment/openmote-cc2538 \
TOOLS=

@ -1 +1 @@
Subproject commit 81cd4cbe5e05e4fa97782d1859ed15b769f4bf2b
Subproject commit edb3c8c73c4688ebd336b278450db216512a769b

View File

@ -5,7 +5,7 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential doxygen git wget unzip python-serial python-pip \
default-jdk ant srecord iputils-tracepath rlwrap \
mosquitto mosquitto-clients \
mosquitto mosquitto-clients gdb \
&& apt-get clean
# Install ARM toolchain