Reincarnate the sensinode/cc2430 port
This commit is contained in:
parent
c78b5bad5c
commit
b7674c3636
114 changed files with 10044 additions and 3068 deletions
16
examples/sensinode/energy-scan/Makefile
Normal file
16
examples/sensinode/energy-scan/Makefile
Normal file
|
@ -0,0 +1,16 @@
|
|||
ifndef TARGET
|
||||
TARGET=sensinode
|
||||
endif
|
||||
|
||||
# Make absolutely certain that you specify your device here
|
||||
DEFINES+=MODEL_N740,PROJECT_CONF_H
|
||||
|
||||
PROJECT_SOURCEFILES += stub-rdc.c
|
||||
|
||||
CONTIKI_PROJECT = energy-scan
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
CONTIKI = ../../..
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
108
examples/sensinode/energy-scan/energy-scan.c
Normal file
108
examples/sensinode/energy-scan/energy-scan.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Loughborough University - Computer Science
|
||||
* 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
|
||||
* Minimalistic channel energy detection.
|
||||
*
|
||||
* \author
|
||||
* George Oikonomou - <oikonomou@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "cc2430_sfr.h"
|
||||
|
||||
#include "sensinode-debug.h"
|
||||
#include "dev/cc2430_rf.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static uint8_t channel;
|
||||
static int8_t j;
|
||||
static int8_t cmax;
|
||||
static int8_t rssi;
|
||||
static struct etimer et;
|
||||
static rtimer_clock_t t0;
|
||||
|
||||
#define RSSI_BASE -50
|
||||
#define RSSI_SAMPLES 30
|
||||
#define SAMPLE_INTERVAL (CLOCK_SECOND)
|
||||
#define CHANNEL_MIN 11
|
||||
#define CHANNEL_MAX 26
|
||||
/* ToDo: Do this in infinite RX. Take more samples */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(energy_scan, "Energy Scanner");
|
||||
AUTOSTART_PROCESSES(&energy_scan);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(energy_scan, ev, data)
|
||||
{
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Energy Scanner\n");
|
||||
printf("CCA Threshold: %d\n", (int8_t)RSSIH);
|
||||
printf("Channel scan range: [%u , %u]\n", CHANNEL_MIN, CHANNEL_MAX);
|
||||
printf("%u samples per channel, interval %u ticks\n",
|
||||
RSSI_SAMPLES, SAMPLE_INTERVAL);
|
||||
|
||||
channel = CHANNEL_MIN;
|
||||
while(1) {
|
||||
cmax = RSSI_BASE;
|
||||
cc2430_rf_channel_set(channel);
|
||||
clock_delay(200);
|
||||
|
||||
for(j = 0; j < RSSI_SAMPLES; j++) {
|
||||
t0 = RTIMER_NOW();
|
||||
rssi = RSSIL;
|
||||
if(rssi > cmax) {
|
||||
cmax = rssi;
|
||||
}
|
||||
while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + 25));
|
||||
}
|
||||
printf("%u [%3d]: ", channel, cmax);
|
||||
for(j = RSSI_BASE; j <= cmax; j++) {
|
||||
printf("#");
|
||||
}
|
||||
printf("\n");
|
||||
if(channel == CHANNEL_MAX) {
|
||||
printf("===============\n");
|
||||
channel = CHANNEL_MIN;
|
||||
} else {
|
||||
channel++;
|
||||
}
|
||||
|
||||
etimer_set(&et, SAMPLE_INTERVAL);
|
||||
PROCESS_YIELD();
|
||||
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
50
examples/sensinode/energy-scan/netstack.c
Normal file
50
examples/sensinode/energy-scan/netstack.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Loughborough University - Computer Science
|
||||
* 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
|
||||
* Stub file overriding core/net/netstack.c. What we want to achieve
|
||||
* here is call netstack_init from main without initialising the RDC,
|
||||
* MAC and Network layers. It will just turn on the radio instead.
|
||||
*
|
||||
* \author
|
||||
* George Oikonomou - <oikonomou@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#include "netstack.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
netstack_init(void)
|
||||
{
|
||||
NETSTACK_RADIO.init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
50
examples/sensinode/energy-scan/project-conf.h
Normal file
50
examples/sensinode/energy-scan/project-conf.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Loughborough University - Computer Science
|
||||
* 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
|
||||
* Project specific configuration defines for the sniffer example.
|
||||
*
|
||||
* We make sure that the radio driver outputs all packets in hexdump
|
||||
* format.
|
||||
*
|
||||
* \author
|
||||
* George Oikonomou - <oikonomou@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define NETSTACK_CONF_RDC stub_rdc_driver
|
||||
#define ADC_SENSOR_CONF_ON 0
|
||||
#define LPM_CONF_MODE 0
|
||||
|
||||
#endif /* PROJECT_CONF_H_ */
|
91
examples/sensinode/energy-scan/stub-rdc.c
Normal file
91
examples/sensinode/energy-scan/stub-rdc.c
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Loughborough University - Computer Science
|
||||
* 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
|
||||
* Definition of a fake RDC driver to be used with passive
|
||||
* examples. The code will never send packets and it will never
|
||||
* push incoming packets up the stack. We do this by defining this
|
||||
* driver as our RDC. We then drop everything
|
||||
*
|
||||
* \author
|
||||
* George Oikonomou - <oikonomou@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#include "net/mac/mac.h"
|
||||
#include "net/mac/rdc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
send(mac_callback_t sent, void *ptr)
|
||||
{
|
||||
if(sent) {
|
||||
sent(ptr, MAC_TX_OK, 1);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
input(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
on(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
off(int keep_radio_on)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
cca(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct rdc_driver stub_rdc_driver = {
|
||||
"stub-rdc",
|
||||
init,
|
||||
send,
|
||||
input,
|
||||
on,
|
||||
off,
|
||||
cca,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
Loading…
Add table
Add a link
Reference in a new issue