Merge branch '500-rime-examples'
This commit is contained in:
commit
37f62f0219
29
examples/z1/sensys_scanner/.svn/all-wcprops
Normal file
29
examples/z1/sensys_scanner/.svn/all-wcprops
Normal file
|
@ -0,0 +1,29 @@
|
|||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 90
|
||||
/svnroot/contikiprojects/!svn/ver/212/uni-luebeck.de/interference_demo_2009/sensys_scanner
|
||||
END
|
||||
project-conf.h
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 105
|
||||
/svnroot/contikiprojects/!svn/ver/212/uni-luebeck.de/interference_demo_2009/sensys_scanner/project-conf.h
|
||||
END
|
||||
rssi-scanner.c
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 105
|
||||
/svnroot/contikiprojects/!svn/ver/107/uni-luebeck.de/interference_demo_2009/sensys_scanner/rssi-scanner.c
|
||||
END
|
||||
ViewRSSI.java
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 104
|
||||
/svnroot/contikiprojects/!svn/ver/107/uni-luebeck.de/interference_demo_2009/sensys_scanner/ViewRSSI.java
|
||||
END
|
||||
Makefile
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 99
|
||||
/svnroot/contikiprojects/!svn/ver/212/uni-luebeck.de/interference_demo_2009/sensys_scanner/Makefile
|
||||
END
|
164
examples/z1/sensys_scanner/.svn/entries
Normal file
164
examples/z1/sensys_scanner/.svn/entries
Normal file
|
@ -0,0 +1,164 @@
|
|||
10
|
||||
|
||||
dir
|
||||
223
|
||||
https://contikiprojects.svn.sourceforge.net/svnroot/contikiprojects/uni-luebeck.de/interference_demo_2009/sensys_scanner
|
||||
https://contikiprojects.svn.sourceforge.net/svnroot/contikiprojects
|
||||
|
||||
|
||||
|
||||
2011-03-02T00:54:21.968589Z
|
||||
212
|
||||
calbo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8c580c7b-aa3b-4e21-86b6-0d20d5e815df
|
||||
|
||||
project-conf.h
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-02T22:44:47.131897Z
|
||||
913b06d7cb84689da586ead20218272e
|
||||
2011-03-02T00:54:21.968589Z
|
||||
212
|
||||
calbo
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1919
|
||||
|
||||
rssi-scanner.c
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-02T22:44:47.131897Z
|
||||
f714b79fae9f42b1e28e27df090379d5
|
||||
2010-07-06T10:22:41.258196Z
|
||||
107
|
||||
calbo
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3188
|
||||
|
||||
ViewRSSI.java
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-02T22:44:47.131897Z
|
||||
11e5f871db316dbf78b62c1e459b9c1b
|
||||
2010-07-06T10:22:41.258196Z
|
||||
107
|
||||
calbo
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6675
|
||||
|
||||
Makefile
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-02T22:44:47.131897Z
|
||||
f4665e07610b39e505c258ed8b56eaf8
|
||||
2011-03-02T00:54:21.968589Z
|
||||
212
|
||||
calbo
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
508
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
K 14
|
||||
svn:executable
|
||||
V 1
|
||||
*
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 14
|
||||
svn:executable
|
||||
V 1
|
||||
*
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 14
|
||||
svn:executable
|
||||
V 1
|
||||
*
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 14
|
||||
svn:executable
|
||||
V 1
|
||||
*
|
||||
END
|
25
examples/z1/sensys_scanner/.svn/text-base/Makefile.svn-base
Normal file
25
examples/z1/sensys_scanner/.svn/text-base/Makefile.svn-base
Normal file
|
@ -0,0 +1,25 @@
|
|||
DEFINES=PROJECT_CONF_H=\"project-conf.h\"
|
||||
|
||||
# Define the target platform
|
||||
ifndef TARGET
|
||||
TARGET=sky
|
||||
endif
|
||||
|
||||
# Give a name to your project
|
||||
CONTIKI = ../../../../contiki-2.x/
|
||||
CONTIKI_PROJECT = rssi-scanner
|
||||
|
||||
# Compile project typing "make"
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
# Upload project typing "make upload"
|
||||
upload: $(CONTIKI_PROJECT).upload
|
||||
|
||||
%.class: %.java
|
||||
javac $(basename $<).java
|
||||
|
||||
viewrssi: ViewRSSI.class
|
||||
make login | java ViewRSSI
|
||||
|
||||
# ContikiProjects: including the makefile
|
||||
include ../../../Makefile.projects
|
155
examples/z1/sensys_scanner/.svn/text-base/ViewRSSI.java.svn-base
Normal file
155
examples/z1/sensys_scanner/.svn/text-base/ViewRSSI.java.svn-base
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (c) 2010, University of Luebeck, Germany.
|
||||
* 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.
|
||||
*
|
||||
* Author: Carlo Alberto Boano <cboano@iti.uni-luebeck.de>, Joakim Eriksson, <joakime@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class ViewRSSI extends JPanel{
|
||||
// Constants
|
||||
public static int TOTAL = 86; // Number of channel of 1 MHz sampled
|
||||
public static int DECREASE_RSSI = 2; // How many dBm the grey RSSI falls each sample
|
||||
public static int RSSI_MAX_VALUE = 100; // Maximum value obtainable from RSSI readings of CC2420.
|
||||
public static int MARGIN_BOTTOM = 20; // Margin from the bottom
|
||||
public static int MARGIN_RIGHT = 75; // Margin from the right
|
||||
public static int MARGIN_TOP = 12; // Margin from the top
|
||||
public static int INTERFERED_CHANNEL = 24; // Interfered channel
|
||||
|
||||
public InputStream inputstr;
|
||||
private int[] rssi = new int[TOTAL]; // Array of current Noise floor values (black line)
|
||||
private int[] rssiMax = new int[TOTAL]; // Array with past Noise floor values (grey line)
|
||||
|
||||
|
||||
public ViewRSSI() {
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
int h = getHeight();
|
||||
int w = getWidth();
|
||||
double factor = (h - (MARGIN_BOTTOM*1.0)) / RSSI_MAX_VALUE;
|
||||
double sSpacing = (w - MARGIN_RIGHT) / (TOTAL*1.0);
|
||||
int sWidth = (int) (sSpacing - 1);
|
||||
if (sWidth == 0) sWidth = 1;
|
||||
|
||||
// Set white background in the plot
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, w, h);
|
||||
|
||||
// Gradient example (ytics background)
|
||||
GradientPaint greytowhite = new GradientPaint(w-MARGIN_RIGHT,0,Color.WHITE,w, 0,Color.lightGray, false);
|
||||
g2.setPaint(greytowhite);
|
||||
g2.fillRect(w-MARGIN_RIGHT, 0, w, h);
|
||||
|
||||
// Draw the light grey channels from 11 to 26
|
||||
double xpos = 10;
|
||||
for(int i=4;i<TOTAL-4;i++){
|
||||
if (i==4+5*(INTERFERED_CHANNEL-11)) g.setColor(Color.cyan);
|
||||
else g.setColor(Color.lightGray);
|
||||
g.fillRect((int) (xpos+i*sSpacing), 0, (int) (sSpacing*3), h-MARGIN_BOTTOM);
|
||||
i = i + 4;
|
||||
g.setColor(Color.blue);
|
||||
g.drawString(String.valueOf(((i-8)/5)+11), (int) (xpos+(i-4)*sSpacing), MARGIN_TOP);
|
||||
}
|
||||
g.drawString(String.valueOf("Channel"), (int) (w-MARGIN_RIGHT+20), MARGIN_TOP);
|
||||
|
||||
// Write the y-axis with dBm
|
||||
int base_dBm = -100; // The bottom corresponds to -100 dBm
|
||||
int ytics = 10; // How many tics on the y-axis
|
||||
for(int i=-ytics;i<=0;i++){
|
||||
g.setColor(Color.red);
|
||||
g.drawString(String.valueOf(((ytics+i)*(base_dBm/ytics))+"dBm"), (int) (w-MARGIN_RIGHT+20), (int) (h+i*(h/ytics))-MARGIN_BOTTOM);
|
||||
// Dashed line for the ytics
|
||||
final float dash1[] = {10.0f};
|
||||
final BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
|
||||
g2.setStroke(dashed);
|
||||
g2.drawLine(0, (int) (h+i*(h/ytics))-MARGIN_BOTTOM, (int) (w-MARGIN_RIGHT+7), (int) (h+i*(h/ytics))-MARGIN_BOTTOM);
|
||||
}
|
||||
|
||||
// Write the x-axis with MHz
|
||||
g.setColor(Color.blue);
|
||||
int start_x_axis = 4;
|
||||
g.drawString(String.valueOf(2400+"MHz"), (int) xpos, (int) h-start_x_axis);
|
||||
g.drawString(String.valueOf(2442.5+"MHz"), (w-119)/2, (int) h-start_x_axis);
|
||||
g.drawString(String.valueOf(2485+"MHz"), w-119, (int) h-start_x_axis);
|
||||
|
||||
// Draw the old RSSI in each MHz channel (grey)
|
||||
g.setColor(Color.gray);
|
||||
double xposition = xpos;
|
||||
for (int i = 0, n = rssi.length; i < n; i++) {
|
||||
int rssi = (int) (rssiMax[i] * factor);
|
||||
g.fillRect((int) xposition, h - MARGIN_BOTTOM - rssi, sWidth, rssi + 1);
|
||||
xposition += sSpacing;
|
||||
}
|
||||
|
||||
// Draw the current RSSI in each MHz channel (black)
|
||||
g.setColor(Color.black);
|
||||
xposition = xpos;
|
||||
for (int i = 0, n = rssi.length; i < n; i++) {
|
||||
int rssiVal = (int) (rssi[i] * factor);
|
||||
g.fillRect((int) xposition, h - MARGIN_BOTTOM - rssiVal, sWidth, rssiVal + 1);
|
||||
xposition += sSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleInput() throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
while(true) {
|
||||
String line = reader.readLine();
|
||||
if (line.startsWith("RSSI:")) {
|
||||
try {
|
||||
String[] parts = line.substring(5).split(" ");
|
||||
for (int i = 0, n = parts.length; i < n; i++) {
|
||||
rssi[i] = Integer.parseInt(parts[i]); // An RSSI=0 corresponds to -100 dBm, an RSSI=100 corresponds to 0 dBm
|
||||
if (rssi[i] > rssiMax[i]) rssiMax[i] = rssi[i];
|
||||
else if (rssiMax[i] > 0) rssiMax[i] = rssiMax[i] - DECREASE_RSSI;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); /* Report error, but do not fail... */
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
JFrame win = new JFrame("RSSI Viewer");
|
||||
ViewRSSI panel;
|
||||
win.setBounds(10, 10, 590, 590);
|
||||
win.getContentPane().add(panel = new ViewRSSI());
|
||||
win.setVisible(true);
|
||||
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
panel.handleInput();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2010, University of Luebeck, Germany
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
|
||||
#undef NETSTACK_CONF_MAC
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
|
||||
#undef NETSTACK_CONF_RDC
|
||||
#define NETSTACK_CONF_RDC sicslowmac_driver
|
||||
|
||||
#undef NETSTACK_MAC
|
||||
#define NETSTACK_MAC nullmac_driver
|
||||
|
||||
#undef NETSTACK_RDC
|
||||
#define NETSTACK_RDC nullrdc_driver
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Swedish Institute of 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.
|
||||
*
|
||||
* $Id: rssi-scanner.c,v 1.2 2009/04/25 22:38:00 joxe Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Scanning 2.4 GHz radio frequencies using CC2420 and prints
|
||||
* the values
|
||||
* \author
|
||||
* Joakim Eriksson, joakime@sics.se
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rime.h"
|
||||
|
||||
#include "dev/leds.h"
|
||||
#include "dev/cc2420.h"
|
||||
#include "dev/cc2420_const.h"
|
||||
#include "dev/spi.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* This assumes that the CC2420 is always on and "stable" */
|
||||
static void
|
||||
set_frq(int c)
|
||||
{
|
||||
int f;
|
||||
// We can read even other channels with CC2420!
|
||||
// Fc = 2048 + FSCTRL ; Fc = 2405 + 5(k-11) MHz, k=11,12, ... , 26
|
||||
f = c + 352; // Start from 2400 MHz to 2485 MHz,
|
||||
FASTSPI_SETREG(CC2420_FSCTRL, f);
|
||||
FASTSPI_STROBE(CC2420_SRXON);
|
||||
}
|
||||
|
||||
static void
|
||||
do_rssi(void)
|
||||
{
|
||||
int channel;
|
||||
printf("RSSI:");
|
||||
for(channel = 0; channel <= 85; ++channel) {
|
||||
set_frq(channel);
|
||||
printf("%d ", cc2420_rssi() + 55);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(scanner_process, "RSSI Scanner");
|
||||
AUTOSTART_PROCESSES(&scanner_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(scanner_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
/* switch mac layer off, and turn radio on */
|
||||
rime_mac->off(0);
|
||||
cc2420_on();
|
||||
|
||||
while(1) {
|
||||
do_rssi();
|
||||
PROCESS_PAUSE();
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
33
examples/z1/sensys_scanner/Makefile
Executable file
33
examples/z1/sensys_scanner/Makefile
Executable file
|
@ -0,0 +1,33 @@
|
|||
DEFINES=PROJECT_CONF_H=\"project-conf.h\"
|
||||
|
||||
# Define the target platform
|
||||
ifndef TARGET
|
||||
TARGET=z1
|
||||
endif
|
||||
|
||||
CONTIKI_SOURCEFILES += cc2420-arch.c sensors.c sht11.c
|
||||
PROJECT_SOURCEFILES = i2cmaster.c tmp102.c adxl345.c battery-sensor.c sky-sensors.c #potentiometer-sensor.c
|
||||
|
||||
# Give a name to your project
|
||||
CONTIKI = ../../../../contiki-2.x/
|
||||
CONTIKI_PROJECT = rssi-scanner
|
||||
|
||||
# Compile project typing "make"
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
# Upload project typing "make upload"
|
||||
upload: $(CONTIKI_PROJECT).upload
|
||||
|
||||
%.class: %.java
|
||||
javac $(basename $<).java
|
||||
|
||||
viewrssi3d: ViewRSSI3D.class
|
||||
make login | java ViewRSSI3D
|
||||
|
||||
viewrssi: ViewRSSI.class
|
||||
make login | java ViewRSSI
|
||||
|
||||
# ContikiProjects: including the makefile
|
||||
#include ../../../Makefile.projects
|
||||
include $(CONTIKI)/Makefile.include
|
||||
|
BIN
examples/z1/sensys_scanner/ViewRSSI.class
Normal file
BIN
examples/z1/sensys_scanner/ViewRSSI.class
Normal file
Binary file not shown.
155
examples/z1/sensys_scanner/ViewRSSI.java
Executable file
155
examples/z1/sensys_scanner/ViewRSSI.java
Executable file
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (c) 2010, University of Luebeck, Germany.
|
||||
* 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.
|
||||
*
|
||||
* Author: Carlo Alberto Boano <cboano@iti.uni-luebeck.de>, Joakim Eriksson, <joakime@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class ViewRSSI extends JPanel{
|
||||
// Constants
|
||||
public static int TOTAL = 86; // Number of channel of 1 MHz sampled
|
||||
public static int DECREASE_RSSI = 2; // How many dBm the grey RSSI falls each sample
|
||||
public static int RSSI_MAX_VALUE = 100; // Maximum value obtainable from RSSI readings of CC2420.
|
||||
public static int MARGIN_BOTTOM = 20; // Margin from the bottom
|
||||
public static int MARGIN_RIGHT = 75; // Margin from the right
|
||||
public static int MARGIN_TOP = 12; // Margin from the top
|
||||
public static int INTERFERED_CHANNEL = 24; // Interfered channel
|
||||
|
||||
public InputStream inputstr;
|
||||
private int[] rssi = new int[TOTAL]; // Array of current Noise floor values (black line)
|
||||
private int[] rssiMax = new int[TOTAL]; // Array with past Noise floor values (grey line)
|
||||
|
||||
|
||||
public ViewRSSI() {
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
int h = getHeight();
|
||||
int w = getWidth();
|
||||
double factor = (h - (MARGIN_BOTTOM*1.0)) / RSSI_MAX_VALUE;
|
||||
double sSpacing = (w - MARGIN_RIGHT) / (TOTAL*1.0);
|
||||
int sWidth = (int) (sSpacing - 1);
|
||||
if (sWidth == 0) sWidth = 1;
|
||||
|
||||
// Set white background in the plot
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, w, h);
|
||||
|
||||
// Gradient example (ytics background)
|
||||
GradientPaint greytowhite = new GradientPaint(w-MARGIN_RIGHT,0,Color.WHITE,w, 0,Color.lightGray, false);
|
||||
g2.setPaint(greytowhite);
|
||||
g2.fillRect(w-MARGIN_RIGHT, 0, w, h);
|
||||
|
||||
// Draw the light grey channels from 11 to 26
|
||||
double xpos = 10;
|
||||
for(int i=4;i<TOTAL-4;i++){
|
||||
if (i==4+5*(INTERFERED_CHANNEL-11)) g.setColor(Color.cyan);
|
||||
else g.setColor(Color.lightGray);
|
||||
g.fillRect((int) (xpos+i*sSpacing), 0, (int) (sSpacing*3), h-MARGIN_BOTTOM);
|
||||
i = i + 4;
|
||||
g.setColor(Color.blue);
|
||||
g.drawString(String.valueOf(((i-8)/5)+11), (int) (xpos+(i-4)*sSpacing), MARGIN_TOP);
|
||||
}
|
||||
g.drawString(String.valueOf("Channel"), (int) (w-MARGIN_RIGHT+20), MARGIN_TOP);
|
||||
|
||||
// Write the y-axis with dBm
|
||||
int base_dBm = -100; // The bottom corresponds to -100 dBm
|
||||
int ytics = 10; // How many tics on the y-axis
|
||||
for(int i=-ytics;i<=0;i++){
|
||||
g.setColor(Color.red);
|
||||
g.drawString(String.valueOf(((ytics+i)*(base_dBm/ytics))+"dBm"), (int) (w-MARGIN_RIGHT+20), (int) (h+i*(h/ytics))-MARGIN_BOTTOM);
|
||||
// Dashed line for the ytics
|
||||
final float dash1[] = {10.0f};
|
||||
final BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
|
||||
g2.setStroke(dashed);
|
||||
g2.drawLine(0, (int) (h+i*(h/ytics))-MARGIN_BOTTOM, (int) (w-MARGIN_RIGHT+7), (int) (h+i*(h/ytics))-MARGIN_BOTTOM);
|
||||
}
|
||||
|
||||
// Write the x-axis with MHz
|
||||
g.setColor(Color.blue);
|
||||
int start_x_axis = 4;
|
||||
g.drawString(String.valueOf(2400+"MHz"), (int) xpos, (int) h-start_x_axis);
|
||||
g.drawString(String.valueOf(2442.5+"MHz"), (w-119)/2, (int) h-start_x_axis);
|
||||
g.drawString(String.valueOf(2485+"MHz"), w-119, (int) h-start_x_axis);
|
||||
|
||||
// Draw the old RSSI in each MHz channel (grey)
|
||||
g.setColor(Color.gray);
|
||||
double xposition = xpos;
|
||||
for (int i = 0, n = rssi.length; i < n; i++) {
|
||||
int rssi = (int) (rssiMax[i] * factor);
|
||||
g.fillRect((int) xposition, h - MARGIN_BOTTOM - rssi, sWidth, rssi + 1);
|
||||
xposition += sSpacing;
|
||||
}
|
||||
|
||||
// Draw the current RSSI in each MHz channel (black)
|
||||
g.setColor(Color.black);
|
||||
xposition = xpos;
|
||||
for (int i = 0, n = rssi.length; i < n; i++) {
|
||||
int rssiVal = (int) (rssi[i] * factor);
|
||||
g.fillRect((int) xposition, h - MARGIN_BOTTOM - rssiVal, sWidth, rssiVal + 1);
|
||||
xposition += sSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleInput() throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
while(true) {
|
||||
String line = reader.readLine();
|
||||
if (line.startsWith("RSSI:")) {
|
||||
try {
|
||||
String[] parts = line.substring(5).split(" ");
|
||||
for (int i = 0, n = parts.length; i < n; i++) {
|
||||
rssi[i] = Integer.parseInt(parts[i]); // An RSSI=0 corresponds to -100 dBm, an RSSI=100 corresponds to 0 dBm
|
||||
if (rssi[i] > rssiMax[i]) rssiMax[i] = rssi[i];
|
||||
else if (rssiMax[i] > 0) rssiMax[i] = rssiMax[i] - DECREASE_RSSI;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); /* Report error, but do not fail... */
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
JFrame win = new JFrame("RSSI Viewer");
|
||||
ViewRSSI panel;
|
||||
win.setBounds(10, 10, 590, 590);
|
||||
win.getContentPane().add(panel = new ViewRSSI());
|
||||
win.setVisible(true);
|
||||
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
panel.handleInput();
|
||||
}
|
||||
|
||||
}
|
140
examples/z1/sensys_scanner/ViewRSSI3D.java
Normal file
140
examples/z1/sensys_scanner/ViewRSSI3D.java
Normal file
|
@ -0,0 +1,140 @@
|
|||
/**
|
||||
* 3D RSSI Viewer - view RSSI values of 802.15.4 channels
|
||||
* ---------------------------------------------------
|
||||
* Note: run the rssi-scanner on a Sky or sentilla node connected to USB
|
||||
* then start with
|
||||
* make login | java ViewRSSI3D
|
||||
*
|
||||
* @author Joakim Eriksson, SICS
|
||||
*
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class ViewRSSI3D extends JPanel {
|
||||
public InputStream inputstr;
|
||||
|
||||
public static final int WIDTH = 6;
|
||||
public static final int HEIGHT = 4;
|
||||
|
||||
public static final int MAX_HISTORY = 50;
|
||||
public static final int MAX_VALUES = 86;
|
||||
|
||||
private int[][] values = new int[MAX_HISTORY][MAX_VALUES];
|
||||
private int pos = 0;
|
||||
|
||||
public ViewRSSI3D() {
|
||||
super(null);
|
||||
setBackground(Color.black);
|
||||
setOpaque(true);
|
||||
setPreferredSize(new Dimension(800, 400));
|
||||
}
|
||||
|
||||
long last = 0;
|
||||
Polygon pol = new Polygon();
|
||||
float[] dist = {0.0f, 0.3f, 0.6f, 1.0f};
|
||||
Color[] colors = {Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE};
|
||||
int[] lastPos = new int[MAX_VALUES];
|
||||
|
||||
public void paint(Graphics g) {
|
||||
//long t = System.currentTimeMillis();
|
||||
Graphics2D gfx = (Graphics2D) g;
|
||||
gfx.setColor(Color.black);
|
||||
gfx.fillRect(0, 0, getWidth(), getHeight());
|
||||
int oldPos = 0;
|
||||
int oldJPos = 0;
|
||||
int lastColor = -1;
|
||||
|
||||
int w = (getWidth() - MAX_HISTORY * 4) / MAX_VALUES;
|
||||
int h = w * HEIGHT / WIDTH;
|
||||
w = (getWidth() - MAX_HISTORY * h) / MAX_VALUES;
|
||||
int xs = h * MAX_HISTORY;
|
||||
int ys = (getHeight() - h * MAX_HISTORY) / 2;
|
||||
|
||||
for (int i = 0, n = MAX_HISTORY; i < n; i++) {
|
||||
Point2D start = new Point2D.Float(xs - i * h, ys - 100 + i * h);
|
||||
Point2D end = new Point2D.Float(xs - i * h, ys + i * h);
|
||||
LinearGradientPaint p =
|
||||
new LinearGradientPaint(start, end, dist, colors);
|
||||
|
||||
gfx.setPaint(p);
|
||||
for (int j = 0, m = MAX_VALUES; j < m; j++) {
|
||||
int val = (int) values[(i + pos) % MAX_HISTORY][j];
|
||||
if (i > 0 && j > 0) {
|
||||
pol.reset();
|
||||
pol.addPoint(xs + (j - 1) * w - i * h, ys + i * h - oldPos);
|
||||
pol.addPoint(xs + j * w - i * h, ys + i * h - val);
|
||||
pol.addPoint(xs + j * w - (i - 1) * h,
|
||||
ys + (i - 1) * h - lastPos[j]);
|
||||
pol.addPoint(xs + (j - 1) * w - (i - 1) * h,
|
||||
ys + (i - 1) * h - oldJPos);
|
||||
|
||||
gfx.fillPolygon(pol);
|
||||
}
|
||||
oldPos = val;
|
||||
oldJPos = lastPos[j];
|
||||
}
|
||||
gfx.setColor(Color.black);
|
||||
for (int j = 0, m = MAX_VALUES; j < m; j++) {
|
||||
int val = (int) values[(i + pos) % MAX_HISTORY][j];
|
||||
if (i > 0 && j > 0) {
|
||||
pol.reset();
|
||||
pol.addPoint(xs + (j - 1) * w - i * h, ys + i * h - oldPos);
|
||||
pol.addPoint(xs + j * w - i * h, ys + i * h - val);
|
||||
pol.addPoint(xs + j * w - (i - 1) * h,
|
||||
ys + (i - 1) * h - lastPos[j]);
|
||||
pol.addPoint(xs + (j - 1) * w - (i - 1) * h,
|
||||
ys + (i - 1) * h - oldJPos);
|
||||
|
||||
gfx.drawPolygon(pol);
|
||||
}
|
||||
oldPos = val;
|
||||
oldJPos = lastPos[j];
|
||||
lastPos[j] = val;
|
||||
}
|
||||
}
|
||||
|
||||
gfx.setColor(Color.gray);
|
||||
gfx.drawLine(xs - (MAX_HISTORY - 1) * h, ys + (MAX_HISTORY - 1) * h,
|
||||
xs - (MAX_HISTORY - 1) * h + (MAX_VALUES - 1) * w,
|
||||
ys + (MAX_HISTORY - 1) * h);
|
||||
gfx.drawLine(xs - (MAX_HISTORY - 1) * h + (MAX_VALUES - 1) * w,
|
||||
ys + (MAX_HISTORY - 1) * h,
|
||||
xs + (MAX_VALUES - 1) * w, ys);
|
||||
// System.out.println("Time: " + (System.currentTimeMillis() - t) + " last: " + (System.currentTimeMillis() - last));
|
||||
// last = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void handleInput() throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while(true) {
|
||||
String line = reader.readLine();
|
||||
if (line != null && line.startsWith("RSSI:")) {
|
||||
try {
|
||||
String[] parts = line.substring(5).split(" ");
|
||||
for (int i = 0, n = parts.length; i < n; i++) {
|
||||
values[pos][i] = Integer.parseInt(parts[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); /* Report error, but do not fail... */
|
||||
}
|
||||
pos = (pos + 1) % MAX_HISTORY;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
ViewRSSI3D mc = new ViewRSSI3D();
|
||||
JFrame window = new JFrame("3D RSSI Viewer");
|
||||
window.add(mc);
|
||||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
window.pack();
|
||||
window.setVisible(true);
|
||||
mc.handleInput();
|
||||
}
|
||||
}
|
46
examples/z1/sensys_scanner/project-conf.h
Executable file
46
examples/z1/sensys_scanner/project-conf.h
Executable file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2010, University of Luebeck, Germany
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
|
||||
#undef NETSTACK_CONF_MAC
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
|
||||
#undef NETSTACK_CONF_RDC
|
||||
#define NETSTACK_CONF_RDC sicslowmac_driver
|
||||
|
||||
#undef NETSTACK_MAC
|
||||
#define NETSTACK_MAC nullmac_driver
|
||||
|
||||
#undef NETSTACK_RDC
|
||||
#define NETSTACK_RDC nullrdc_driver
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
96
examples/z1/sensys_scanner/rssi-scanner.c
Executable file
96
examples/z1/sensys_scanner/rssi-scanner.c
Executable file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Swedish Institute of 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.
|
||||
*
|
||||
* $Id: rssi-scanner.c,v 1.2 2009/04/25 22:38:00 joxe Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Scanning 2.4 GHz radio frequencies using CC2420 and prints
|
||||
* the values
|
||||
* \author
|
||||
* Joakim Eriksson, joakime@sics.se
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rime.h"
|
||||
|
||||
#include "dev/leds.h"
|
||||
#include "dev/cc2420.h"
|
||||
#include "dev/cc2420_const.h"
|
||||
#include "dev/spi.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* This assumes that the CC2420 is always on and "stable" */
|
||||
static void
|
||||
set_frq(int c)
|
||||
{
|
||||
int f;
|
||||
// We can read even other channels with CC2420!
|
||||
// Fc = 2048 + FSCTRL ; Fc = 2405 + 5(k-11) MHz, k=11,12, ... , 26
|
||||
f = c + 352; // Start from 2400 MHz to 2485 MHz,
|
||||
//FASTSPI_SETREG(CC2420_FSCTRL, f);
|
||||
//FASTSPI_STROBE(CC2420_SRXON);
|
||||
CC2420_WRITE_REG(CC2420_FSCTRL, f);
|
||||
CC2420_STROBE(CC2420_SRXON);
|
||||
}
|
||||
|
||||
static void
|
||||
do_rssi(void)
|
||||
{
|
||||
int channel;
|
||||
printf("RSSI:");
|
||||
for(channel = 0; channel <= 85; ++channel) {
|
||||
set_frq(channel);
|
||||
printf("%d ", cc2420_rssi() + 55);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(scanner_process, "RSSI Scanner");
|
||||
AUTOSTART_PROCESSES(&scanner_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(scanner_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
/* switch mac layer off, and turn radio on */
|
||||
rime_mac->off(0);
|
||||
cc2420_on();
|
||||
|
||||
while(1) {
|
||||
do_rssi();
|
||||
PROCESS_PAUSE();
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -16,7 +16,8 @@
|
|||
#endif /* NETSTACK_CONF_MAC */
|
||||
|
||||
#ifndef NETSTACK_CONF_RDC
|
||||
#define NETSTACK_CONF_RDC contikimac_driver
|
||||
//#define NETSTACK_CONF_RDC contikimac_driver
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#endif /* NETSTACK_CONF_RDC */
|
||||
|
||||
#ifndef NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE
|
||||
|
|
|
@ -62,11 +62,13 @@
|
|||
/* Network setup for non-IPv6 (rime). */
|
||||
|
||||
#define NETSTACK_CONF_NETWORK rime_driver
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
//#define NETSTACK_CONF_MAC csma_driver
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
/* #define NETSTACK_CONF_RDC contikimac_driver */
|
||||
#define NETSTACK_CONF_RDC contikimac_driver
|
||||
//#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 //Enric like in SKY
|
||||
//#define NETSTACK_CONF_RDC contikimac_driver
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 128 //Enric like in SKY
|
||||
//#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 //like in SKY
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
|
||||
#define CC2420_CONF_AUTOACK 0
|
||||
|
|
Loading…
Reference in a new issue