Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
- port rpl changes back into our branch
Browse files Browse the repository at this point in the history
 - fix tcp
 - all of John's RPL updates 


git-svn-id: http://tinyos-main.googlecode.com/svn/branches/blip-rpl-devel@5405 285f258d-8064-b571-fbc6-9656dc998e90
  • Loading branch information
sdhags committed Feb 3, 2011
0 parents commit 326d3ff
Show file tree
Hide file tree
Showing 5,041 changed files with 1,909,492 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
63 changes: 63 additions & 0 deletions README
@@ -0,0 +1,63 @@
This contains the TinyOS 2.0 source code as of

$Date: 2007-07-30 07:18:52 $

This tree includes the TinyOS 2.0 documentation in tinyos-2.x/doc;
you can also find the documentation online at:
http://www.tinyos.net/tinyos-2.x/doc/

Please note that RPM releases do not include the doc/ or tools/
directories. They do not include the former because of the above URL,
where corrections can be applied quickly. They do not include the
latter because that compiled versions of its code are installed in
the tinyos-tools RPM.

The basic directory structure is as follows:

apps: Sample TinyOS applications.
tests: Sample TinyOS applications which test a part of the system.

doc: Documentation
index.html: Index file to all documentation
txt: Text files (TEPs)
html: HTML files (TEPs, installation)
tutorial: Tutorials
pdf: PDFs of larger documents, such as the TinyOS Programming Manual

support: Non-nesC code for using TinyOS nodes
make: TinyOS make system
sdk: Standard developers kit: serial communication, etc.
c: C SDK (fully supported, but not exhaustively tested yet)
java: Java SDK (fully supported, heavily tested and used)
python: Python SDK (limited, not fully supported)

tools: TinyOS-specific tools and scripts
platforms: Platform-specific tools
release: Scripts and configurations for packaging release RPMs
tinyos: TinyOS scripts
java: Native support for TinyOS JNI libraries (serial and env)
misc: Assorted utility scripts, begininning with tos-
ncc: The scripts that invoke the nesC compiler: ncc, mig, ncg

tos: TinyOS source code (nesC, C)
chips: Chip-specific code
interfaces: Core system interfaces
lib: Extensions and larger common subsystems
byte_radio: General radio stack for byte-level radios
net: Network (multihop protocols)
ctp: Collection tree protocol
le: Link estimator
lqi: LQI-based collection for CC2420 platforms
power: Power management component library
printf: Printing small text messages to serial port
serial: Serial communication
timer: Timer component library
tossim: TOSSIM simulator
platforms: Platform-specific code
sensorboards: Sensorboard drivers
system: Core system components
types: Core system data types (header files)

You can find documentation for the 2.0.1 release online at:
http://www.tinyos.net/tinyos-2.x/doc/

71 changes: 71 additions & 0 deletions apps/AntiTheft/Nodes/AntiTheftAppC.nc
@@ -0,0 +1,71 @@
// $Id: AntiTheftAppC.nc,v 1.5 2008-04-24 21:15:50 mmaroti Exp $
/*
* Copyright (c) 2007 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* Top-level configuration for node code for the AntiTheft demo app.
* Instantiates the sensors, dissemination and collection services, and
* does all the necessary wiring.
*
* @author David Gay
*/
#include "antitheft.h"

configuration AntiTheftAppC { }
implementation
{
/* First wire the low-level services (booting, serial port, radio).
There is no standard name for the actual radio component, so we use
#ifdef to get the right one for the current platform. */
components AntiTheftC, ActiveMessageC, MainC, LedsC,
new TimerMilliC() as MyTimer;
#if defined(PLATFORM_MICA2)
components CC1000CsmaRadioC as Radio;
#elif defined(PLATFORM_MICAZ)
components CC2420ActiveMessageC as Radio;
#elif defined(PLATFORM_IRIS)
components ActiveMessageC as Radio;
#else
#error "The AntiTheft application is only supported for mica2, micaz and iris nodes"
#endif

AntiTheftC.Boot -> MainC.Boot;
AntiTheftC.Check -> MyTimer;
AntiTheftC.Leds -> LedsC;
AntiTheftC.RadioControl -> ActiveMessageC;
AntiTheftC.LowPowerListening -> Radio;

/* Instaniate, wire MTS300 sensor board components. */
components new PhotoC(), new AccelXStreamC(), SounderC;

AntiTheftC.Read -> PhotoC;
AntiTheftC.ReadStream -> AccelXStreamC;
AntiTheftC.Mts300Sounder -> SounderC;

components DisseminationC;
AntiTheftC.DisseminationControl -> DisseminationC;

/* Instantiate and wire our settings dissemination service */
components new DisseminatorC(settings_t, DIS_SETTINGS);
AntiTheftC.SettingsValue -> DisseminatorC;

/* Instantiate and wire our collection service for theft alerts */
components CollectionC, new CollectionSenderC(COL_ALERTS) as AlertSender;

AntiTheftC.AlertRoot -> AlertSender;
AntiTheftC.CollectionControl -> CollectionC;

/* Instantiate and wire our local radio-broadcast theft alert and
reception services */
components new AMSenderC(AM_THEFT) as SendTheft,
new AMReceiverC(AM_THEFT) as ReceiveTheft;

AntiTheftC.TheftSend -> SendTheft;
AntiTheftC.TheftReceive -> ReceiveTheft;
}
224 changes: 224 additions & 0 deletions apps/AntiTheft/Nodes/AntiTheftC.nc
@@ -0,0 +1,224 @@
// $Id: AntiTheftC.nc,v 1.7 2009-10-28 19:11:15 razvanm Exp $
/*
* Copyright (c) 2007 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* Main code for the anti theft demo application.
*
* @author David Gay
*/
#include "antitheft.h"

module AntiTheftC
{
uses {
interface Timer<TMilli> as Check;
interface Read<uint16_t>;
interface ReadStream<uint16_t>;
interface Leds;
interface Boot;
interface Mts300Sounder;
interface DisseminationValue<settings_t> as SettingsValue;
interface Send as AlertRoot;
interface StdControl as CollectionControl;
interface StdControl as DisseminationControl;
interface SplitControl as RadioControl;
interface LowPowerListening;
interface AMSend as TheftSend;
interface Receive as TheftReceive;
}
}
implementation
{
enum {
/* Threshold for considering mote in a dark place */
DARK_THRESHOLD = 600,

/* Amount of time warning leds should stay on (in checkInterval counts) */
WARNING_TIME = 3,

/* Number of acceleration samples to collect */
ACCEL_SAMPLES = 10,

/* Interval between acceleration samples (us) */
ACCEL_INTERVAL = 10000
};

settings_t settings;
message_t alertMsg, theftMsg;
uint16_t ledTime; /* Time left until leds switched off */
uint16_t accelSamples[ACCEL_SAMPLES];

/********* LED handling **********/

/* Warn that some error occurred */
void errorLed() {
ledTime = WARNING_TIME;
call Leds.led2On();
}

/* Notify user that settings changed */
void settingsLed() {
ledTime = WARNING_TIME;
call Leds.led1On();
}

/* Turn on bright red light! (LED) */
void theftLed() {
ledTime = WARNING_TIME;
call Leds.led0On();
}

/* Time-out leds. Called every checkInterval */
void updateLeds() {
if (ledTime && !--ledTime)
{
call Leds.led0Off();
call Leds.led1Off();
call Leds.led2Off();
}
}

/* Check result code and report error if a problem occurred */
void check(error_t ok) {
if (ok != SUCCESS)
errorLed();
}

/* Report theft, based on current settings */
void theft() {
if (settings.alert & ALERT_LEDS)
theftLed();
if (settings.alert & ALERT_SOUND)
call Mts300Sounder.beep(100);
if (settings.alert & ALERT_RADIO)
/* A local broadcast with no payload */
check(call TheftSend.send(AM_BROADCAST_ADDR, &theftMsg, 0));
if (settings.alert & ALERT_ROOT)
{
/* Report the identity of this node, using the collection protocol */

/* Get the payload part of alertMsg and fill in our data */
alert_t *newAlert = call AlertRoot.getPayload(&alertMsg, sizeof(alert_t));
if (newAlert != NULL) {
newAlert->stolenId = TOS_NODE_ID;
/* and send it... */
check(call AlertRoot.send(&alertMsg, sizeof *newAlert));
}
}
}

/* We have nothing to do after messages are sent */
event void AlertRoot.sendDone(message_t *msg, error_t ok) { }
event void TheftSend.sendDone(message_t *msg, error_t ok) { }

/* We've received a theft alert from a neighbour. Turn on the theft warning
light! */
event message_t *TheftReceive.receive(message_t* msg, void* payload, uint8_t len) {
theftLed();
/* We don't need to hold on to the message buffer, so just return the
received buffer */
return msg;
}

/* At boot time, start the periodic timer and the radio */
event void Boot.booted() {
errorLed();
settings.alert = DEFAULT_ALERT;
settings.detect = DEFAULT_DETECT;

call Check.startPeriodic(DEFAULT_CHECK_INTERVAL);
call RadioControl.start();
}

/* Radio started. Now start the collection protocol and set the
wakeup interval for low-power-listening wakeup to half a second. */
event void RadioControl.startDone(error_t ok) {
if (ok == SUCCESS)
{
call DisseminationControl.start();
call CollectionControl.start();
call LowPowerListening.setLocalWakeupInterval(512);
}
else
errorLed();
}

event void RadioControl.stopDone(error_t ok) { }

/* New settings received, update our local copy */
event void SettingsValue.changed() {
const settings_t *newSettings = call SettingsValue.get();

settingsLed();
settings = *newSettings;
/* Switch to the new check interval */
call Check.startPeriodic(newSettings->checkInterval);
}

/* Every check interval: update leds, check for theft based on current
settings */
event void Check.fired() {
updateLeds();

if (settings.detect & DETECT_DARK)
call Read.read(); /* Initiate light sensor read */
if (settings.detect & DETECT_ACCEL)
{
/* To sample acceleration, we first register our buffer
(postBuffer). Then we trigger sampling at the desired
interval (read) */
call ReadStream.postBuffer(accelSamples, ACCEL_SAMPLES);
call ReadStream.read(ACCEL_INTERVAL);
}
}

/* Light sample completed. Check if it indicates theft */
event void Read.readDone(error_t ok, uint16_t val) {
if (ok == SUCCESS && val < DARK_THRESHOLD)
theft(); /* ALERT! ALERT! */
}

/* A deferred task to check the acceleration data and detect theft. */
task void checkAcceleration() {
uint8_t i;
uint16_t avg;
uint32_t var;

/* We check for theft by checking whether the variance of the sample
(in mysterious acceleration units) is > 4 */

for (avg = 0, i = 0; i < ACCEL_SAMPLES; i++)
avg += accelSamples[i];
avg /= ACCEL_SAMPLES;

for (var = 0, i = 0; i < ACCEL_SAMPLES; i++)
{
int16_t diff = accelSamples[i] - avg;
var += diff * diff;
}

if (var > 4 * ACCEL_SAMPLES)
theft(); /* ALERT! ALERT! */
}

/* The acceleration read completed. Post the task that will check for
theft. We defer this somewhat cpu-intensive computation to avoid
having the current task run for too long. */
event void ReadStream.readDone(error_t ok, uint32_t usActualPeriod) {
if (ok == SUCCESS)
post checkAcceleration();
else
errorLed();
}

/* The current sampling buffer is full. If we were using several buffers,
we would switch between them here. */
event void ReadStream.bufferDone(error_t ok, uint16_t *buf, uint16_t count) { }
}
11 changes: 11 additions & 0 deletions apps/AntiTheft/Nodes/Makefile
@@ -0,0 +1,11 @@
SENSORBOARD=mts300
PFLAGS += -I%T/lib/net/ctp -I%T/lib/net -I%T/lib/net/4bitle -I%T/lib/net/drip
COMPONENT=AntiTheftAppC

#CFLAGS += -DLOW_POWER_LISTENING
#CFLAGS += -DLPL_DEF_LOCAL_WAKEUP=512
#CFLAGS += -DLPL_DEF_REMOTE_WAKEUP=512
#CFLAGS += -DDELAY_AFTER_RECEIVE=20

include $(MAKERULES)

0 comments on commit 326d3ff

Please sign in to comment.