From 0c6fd04f44715f473f278a77436ccce5ffe9a2ae Mon Sep 17 00:00:00 2001 From: "Enric M. Calvo" Date: Thu, 3 Mar 2011 13:44:28 +0100 Subject: [PATCH] Modified contiki-conf.h and added sensys-scanner. --- examples/z1/sensys_scanner/.svn/all-wcprops | 29 ++++ examples/z1/sensys_scanner/.svn/entries | 164 ++++++++++++++++++ .../.svn/prop-base/Makefile.svn-base | 5 + .../.svn/prop-base/ViewRSSI.java.svn-base | 5 + .../.svn/prop-base/project-conf.h.svn-base | 5 + .../.svn/prop-base/rssi-scanner.c.svn-base | 5 + .../.svn/text-base/Makefile.svn-base | 25 +++ .../.svn/text-base/ViewRSSI.java.svn-base | 155 +++++++++++++++++ .../.svn/text-base/project-conf.h.svn-base | 46 +++++ .../.svn/text-base/rssi-scanner.c.svn-base | 94 ++++++++++ examples/z1/sensys_scanner/Makefile | 26 +++ examples/z1/sensys_scanner/ViewRSSI.class | Bin 0 -> 4106 bytes examples/z1/sensys_scanner/ViewRSSI.java | 155 +++++++++++++++++ examples/z1/sensys_scanner/project-conf.h | 46 +++++ examples/z1/sensys_scanner/rssi-scanner.c | 96 ++++++++++ platform/sky/contiki-conf.h | 3 +- platform/z1/contiki-conf.h | 10 +- 17 files changed, 864 insertions(+), 5 deletions(-) create mode 100644 examples/z1/sensys_scanner/.svn/all-wcprops create mode 100644 examples/z1/sensys_scanner/.svn/entries create mode 100644 examples/z1/sensys_scanner/.svn/prop-base/Makefile.svn-base create mode 100644 examples/z1/sensys_scanner/.svn/prop-base/ViewRSSI.java.svn-base create mode 100644 examples/z1/sensys_scanner/.svn/prop-base/project-conf.h.svn-base create mode 100644 examples/z1/sensys_scanner/.svn/prop-base/rssi-scanner.c.svn-base create mode 100644 examples/z1/sensys_scanner/.svn/text-base/Makefile.svn-base create mode 100644 examples/z1/sensys_scanner/.svn/text-base/ViewRSSI.java.svn-base create mode 100644 examples/z1/sensys_scanner/.svn/text-base/project-conf.h.svn-base create mode 100644 examples/z1/sensys_scanner/.svn/text-base/rssi-scanner.c.svn-base create mode 100755 examples/z1/sensys_scanner/Makefile create mode 100644 examples/z1/sensys_scanner/ViewRSSI.class create mode 100755 examples/z1/sensys_scanner/ViewRSSI.java create mode 100755 examples/z1/sensys_scanner/project-conf.h create mode 100755 examples/z1/sensys_scanner/rssi-scanner.c diff --git a/examples/z1/sensys_scanner/.svn/all-wcprops b/examples/z1/sensys_scanner/.svn/all-wcprops new file mode 100644 index 000000000..53b4847ee --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/all-wcprops @@ -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 diff --git a/examples/z1/sensys_scanner/.svn/entries b/examples/z1/sensys_scanner/.svn/entries new file mode 100644 index 000000000..a0f5ff520 --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/entries @@ -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 + diff --git a/examples/z1/sensys_scanner/.svn/prop-base/Makefile.svn-base b/examples/z1/sensys_scanner/.svn/prop-base/Makefile.svn-base new file mode 100644 index 000000000..869ac71cf --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/prop-base/Makefile.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/examples/z1/sensys_scanner/.svn/prop-base/ViewRSSI.java.svn-base b/examples/z1/sensys_scanner/.svn/prop-base/ViewRSSI.java.svn-base new file mode 100644 index 000000000..869ac71cf --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/prop-base/ViewRSSI.java.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/examples/z1/sensys_scanner/.svn/prop-base/project-conf.h.svn-base b/examples/z1/sensys_scanner/.svn/prop-base/project-conf.h.svn-base new file mode 100644 index 000000000..869ac71cf --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/prop-base/project-conf.h.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/examples/z1/sensys_scanner/.svn/prop-base/rssi-scanner.c.svn-base b/examples/z1/sensys_scanner/.svn/prop-base/rssi-scanner.c.svn-base new file mode 100644 index 000000000..869ac71cf --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/prop-base/rssi-scanner.c.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/examples/z1/sensys_scanner/.svn/text-base/Makefile.svn-base b/examples/z1/sensys_scanner/.svn/text-base/Makefile.svn-base new file mode 100644 index 000000000..8ff09587f --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/text-base/Makefile.svn-base @@ -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 diff --git a/examples/z1/sensys_scanner/.svn/text-base/ViewRSSI.java.svn-base b/examples/z1/sensys_scanner/.svn/text-base/ViewRSSI.java.svn-base new file mode 100644 index 000000000..e768594b6 --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/text-base/ViewRSSI.java.svn-base @@ -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 , Joakim Eriksson, + * + */ + +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 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(); + } + +} diff --git a/examples/z1/sensys_scanner/.svn/text-base/project-conf.h.svn-base b/examples/z1/sensys_scanner/.svn/text-base/project-conf.h.svn-base new file mode 100644 index 000000000..3f7a3e541 --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/text-base/project-conf.h.svn-base @@ -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__ */ diff --git a/examples/z1/sensys_scanner/.svn/text-base/rssi-scanner.c.svn-base b/examples/z1/sensys_scanner/.svn/text-base/rssi-scanner.c.svn-base new file mode 100644 index 000000000..1fd3c5cfe --- /dev/null +++ b/examples/z1/sensys_scanner/.svn/text-base/rssi-scanner.c.svn-base @@ -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 + +/*---------------------------------------------------------------------------*/ +/* 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(); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/z1/sensys_scanner/Makefile b/examples/z1/sensys_scanner/Makefile new file mode 100755 index 000000000..cb76f4a20 --- /dev/null +++ b/examples/z1/sensys_scanner/Makefile @@ -0,0 +1,26 @@ +DEFINES=PROJECT_CONF_H=\"project-conf.h\" + +# Define the target platform +ifndef TARGET +TARGET=z1 +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 +include $(CONTIKI)/Makefile.include diff --git a/examples/z1/sensys_scanner/ViewRSSI.class b/examples/z1/sensys_scanner/ViewRSSI.class new file mode 100644 index 0000000000000000000000000000000000000000..6bc4d11f9cb8658c36a7f49c02126d9ee9fd1064 GIT binary patch literal 4106 zcmb7H30Pd!75?umykU3)FB4uesX>WaC9DyXF_5?bVG@)j0)iweJeUVe7-q=K5R%x| z4NWu^>%LU2O>NWKO+klLVrpC4T5DUitKAp7@0-=Mn*R4a2Ep+4`^v|6&VA?Hd-ikg zo#)%Cq!f&LiFZjbCMmlm*dxK-Y+Q+VdGT(%M}n&qTrDZr zNN}wexwy^?H^wEnD(iyNse^y=;PrCH4Otg>GNdc9&x`%IQ8I6mvJQCgUP-xG?wn9? zix;b~Q-b$-aI3_(NpQQXrVvn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scanner/ViewRSSI.java b/examples/z1/sensys_scanner/ViewRSSI.java new file mode 100755 index 000000000..e768594b6 --- /dev/null +++ b/examples/z1/sensys_scanner/ViewRSSI.java @@ -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 , Joakim Eriksson, + * + */ + +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 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(); + } + +} diff --git a/examples/z1/sensys_scanner/project-conf.h b/examples/z1/sensys_scanner/project-conf.h new file mode 100755 index 000000000..3f7a3e541 --- /dev/null +++ b/examples/z1/sensys_scanner/project-conf.h @@ -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__ */ diff --git a/examples/z1/sensys_scanner/rssi-scanner.c b/examples/z1/sensys_scanner/rssi-scanner.c new file mode 100755 index 000000000..c7fdb463c --- /dev/null +++ b/examples/z1/sensys_scanner/rssi-scanner.c @@ -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 + +/*---------------------------------------------------------------------------*/ +/* 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); + setreg(CC2420_FSCTRL, f); + 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(); +} +/*---------------------------------------------------------------------------*/ diff --git a/platform/sky/contiki-conf.h b/platform/sky/contiki-conf.h index 8eeda6a22..e14458a05 100644 --- a/platform/sky/contiki-conf.h +++ b/platform/sky/contiki-conf.h @@ -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 diff --git a/platform/z1/contiki-conf.h b/platform/z1/contiki-conf.h index 729eef723..76ac245ce 100644 --- a/platform/z1/contiki-conf.h +++ b/platform/z1/contiki-conf.h @@ -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