├── software └── ipv6_tunnel │ ├── Tupfile.ini │ ├── prefixes.dat │ ├── lib │ ├── ini │ │ ├── Tupfile │ │ └── ini.h │ └── jsmn │ │ ├── Tupfile │ │ └── jsmn.h │ ├── configs │ ├── local.config │ └── rpi.config │ ├── .gitignore │ ├── config-template.ini │ ├── Tuprules.tup │ ├── Tupfile │ ├── ipv6tunc │ ├── ipv6tuns │ ├── common.go │ ├── tunindex.go │ └── prefix.go ├── tinyos ├── apps │ ├── Node │ │ ├── .gitignore │ │ ├── readme.txt │ │ ├── NodeC.nc │ │ ├── Makefile │ │ └── NodeP.nc │ ├── RadioCountToLeds154 │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── RadioCountToLeds154C.nc │ │ ├── RadioCountToLeds154.h │ │ └── RadioCountToLeds154P.nc │ ├── RadioCountToLedsBlip │ │ ├── .gitignore │ │ ├── RadioCountToLedsBlipC.nc │ │ ├── Makefile │ │ ├── RadioCountToLedsBlip.h │ │ └── RadioCountToLedsBlipP.nc │ ├── tests │ │ ├── Uart │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── UartTestC.nc │ │ │ └── UartTestP.nc │ │ ├── BareReceive │ │ │ ├── README.md │ │ │ ├── Makefile │ │ │ ├── BareReceiveC.nc │ │ │ └── BareReceiveP.nc │ │ ├── Interrupt │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── InterruptC.nc │ │ │ └── InterruptP.nc │ │ ├── Interrupt2 │ │ │ ├── Makefile │ │ │ ├── Interrupt2P.nc │ │ │ └── Interrupt2C.nc │ │ ├── PolyPointHack │ │ │ ├── README.md │ │ │ ├── Makefile │ │ │ ├── PolyPointHackC.nc │ │ │ └── PolyPointHackP.nc │ │ └── BlipQuickPacket │ │ │ ├── README.md │ │ │ ├── Makefile │ │ │ ├── BlipQuickPacketC.nc │ │ │ └── BlipQuickPacketP.nc │ ├── SimpleSackTest │ │ ├── Makefile │ │ ├── SimpleSackTest.h │ │ ├── SimpleSackTestAppC.nc │ │ └── SimpleSackTestC.nc │ ├── ExtAddrTest │ │ ├── Makefile │ │ ├── README.md │ │ ├── ExtAddrTestC.nc │ │ └── ExtAddrTestP.nc │ ├── NodeCollect │ │ ├── README.md │ │ ├── Makefile │ │ ├── NodeCollectC.nc │ │ └── NodeCollectP.nc │ ├── BorderRouter │ │ ├── README.md │ │ ├── brconfig.ini │ │ ├── TunNameC.nc │ │ ├── BorderRouterP.nc │ │ ├── BorderRouterC.nc │ │ ├── TunNameP.nc │ │ ├── Makefile.failsafe │ │ └── Makefile │ ├── TSDemo2014BorderRouter │ │ ├── README.md │ │ ├── brconfig.ini │ │ ├── TunNameC.nc │ │ ├── BorderRouterP.nc │ │ ├── TSDemo2014BorderRouterC.nc │ │ ├── TunNameP.nc │ │ └── Makefile │ └── SpiLockDebug │ │ ├── README.md │ │ ├── SpiLockDebugC.nc │ │ ├── Makefile │ │ └── SpiLockDebugP.nc ├── support │ ├── make │ │ ├── arm-linux │ │ │ ├── debug.extra │ │ │ ├── install.extra │ │ │ ├── reinstall.extra │ │ │ ├── scp.extra │ │ │ └── arm-linux.rules │ │ ├── targets │ │ │ ├── gap.target │ │ │ └── rpi.target │ │ └── platforms │ │ │ ├── gap.platform │ │ │ └── rpi.platform │ └── sdk │ │ └── c │ │ ├── linux │ │ ├── file_helpers.h │ │ └── file_helpers.c │ │ └── ini │ │ └── ini.h ├── tos │ ├── chips │ │ ├── linux │ │ │ ├── PrintfC.nc │ │ │ ├── SerialStartC.nc │ │ │ ├── time │ │ │ │ ├── UnixTime.nc │ │ │ │ ├── UnixTimeC.nc │ │ │ │ └── UnixTimeP.nc │ │ │ ├── tun │ │ │ │ ├── TunName.nc │ │ │ │ ├── TunNameC.nc │ │ │ │ └── TunC.nc │ │ │ ├── BusyWaitMicroC.nc │ │ │ ├── BRConfigC.nc │ │ │ ├── CommandLineC.nc │ │ │ ├── McuSleepC.nc │ │ │ ├── socket │ │ │ │ ├── LinuxUdpSocketC.nc │ │ │ │ ├── TcpSocket.nc │ │ │ │ ├── PersistentTcpConnectionC.nc │ │ │ │ ├── LinuxUdpSocket.nc │ │ │ │ └── LinuxUdpSocketP.nc │ │ │ ├── RandomLinuxC.nc │ │ │ ├── timer │ │ │ │ ├── LocalTimeMilli32P.nc │ │ │ │ └── HilTimerMilliC.nc │ │ │ ├── BusyWaitMicroP.nc │ │ │ ├── McuSleepP.nc │ │ │ ├── uart │ │ │ │ ├── UartC.nc │ │ │ │ └── uart.h │ │ │ ├── RandomLinuxP.nc │ │ │ ├── LinuxLedP.nc │ │ │ ├── linux_atomic.h │ │ │ ├── BRConfigP.nc │ │ │ └── CommandLineP.nc │ │ ├── cc2520rpiAM │ │ │ ├── CC2520RpiAmPacketC.nc │ │ │ ├── README.md │ │ │ ├── CC2520RpiAm154DummyP.nc │ │ │ ├── CC2520RpiAmUniqueC.nc │ │ │ ├── CC2520RpiAmPacketMetadataC.nc │ │ │ ├── CC2520RpiAmUniqueP.nc │ │ │ ├── CC2520RpiAmPacketMetadataP.nc │ │ │ ├── CC2520RpiActiveMessageC.nc │ │ │ └── CC2520RpiAmPacketP.nc │ │ ├── cc2520linux │ │ │ ├── ReadLqiC.nc │ │ │ ├── Ieee154AddressC.nc │ │ │ ├── ReadLqiP.nc │ │ │ ├── CC2520LinuxLinkC.nc │ │ │ ├── CC2520LinuxSendC.nc │ │ │ ├── Ieee154BareC.nc │ │ │ ├── CC2520LinuxReceiveC.nc │ │ │ ├── RadioPacketMetadataC.nc │ │ │ ├── RadioPacketMetadataP.nc │ │ │ ├── CC2520LinuxRadioC.nc │ │ │ ├── CC2520LinuxDriver.h │ │ │ └── CC2520LinuxLinkP.nc │ │ ├── idrfid │ │ │ ├── IDrfidC.nc │ │ │ └── IDrfidP.nc │ │ └── bcm2835 │ │ │ ├── gpio │ │ │ ├── Bcm2835GpioC.nc │ │ │ ├── HplBcm2835GeneralIO.nc │ │ │ └── HplBcm2835GeneralIOC.nc │ │ │ ├── spi │ │ │ ├── RpiSpiC.nc │ │ │ ├── HilRpiSpiC.nc │ │ │ └── RpiSpiP.nc │ │ │ ├── gpio.h │ │ │ └── interrupt │ │ │ └── Bcm2835InterruptC.nc │ ├── platforms │ │ ├── armlinux │ │ │ ├── platform.h │ │ │ ├── border.h │ │ │ ├── platform_message.h │ │ │ ├── BorderC.nc │ │ │ ├── ActiveMessageC.nc │ │ │ ├── DumpHopHopP.nc │ │ │ └── debug_printf.h │ │ ├── gap │ │ │ ├── hardware.h │ │ │ ├── PlatformC.nc │ │ │ ├── LocalIeeeEui64C.nc │ │ │ ├── PlatformLedsC.nc │ │ │ ├── RadioSelectC.nc │ │ │ ├── PlatformP.nc │ │ │ └── chips │ │ │ │ └── cc2520linux │ │ │ │ └── RadioConfig.h │ │ └── rpi │ │ │ ├── chips │ │ │ ├── ds2411 │ │ │ │ ├── HplDs2411C.nc │ │ │ │ └── PlatformIeeeEui64.h │ │ │ └── cc2520linux │ │ │ │ └── RadioConfig.h │ │ │ ├── PlatformC.nc │ │ │ ├── RadioSelectC.nc │ │ │ ├── PlatformLedsC.nc │ │ │ ├── PlatformP.nc │ │ │ └── hardware.h │ ├── interfaces │ │ ├── BlockingIO.nc │ │ ├── UartBuffer.nc │ │ ├── UartConfig.nc │ │ ├── CommandLineArgs.nc │ │ ├── UnixTimeC.nc │ │ ├── BRConfig.nc │ │ ├── IO.nc │ │ ├── RadioAddress.nc │ │ └── PacketMetadata.nc │ ├── lib │ │ └── printf │ │ │ ├── generic_printf.h │ │ │ └── printf.h │ └── system │ │ ├── IOFileC.nc │ │ ├── IOManagerC.nc │ │ └── IOManagerP.nc └── Makefile.include ├── hardware ├── eagle │ ├── rpi-cc2520-interface │ │ ├── rev_a │ │ │ ├── interface_a.info │ │ │ ├── interface_a.pdf │ │ │ ├── interface_a_pcb.png │ │ │ ├── rpi-cc2520-interface_a_2012-10-29.zip │ │ │ ├── rpi-cc2520-interface_a_to_fab_2012-10-29.zip │ │ │ └── interface_a.centroid │ │ ├── rev_b │ │ │ ├── interface_b.info │ │ │ ├── interface_b.pdf │ │ │ ├── interface_b_pcb.png │ │ │ ├── rpi-cc2520-interface_b_bom.xls │ │ │ ├── rpi-cc2520-interface_b_2013-02-11.zip │ │ │ ├── rpi-cc2520-interface_b_to_fab_2013-02-11.zip │ │ │ └── interface_b.centroid │ │ └── README.md │ └── rpi-cc2520 │ │ ├── rev_a │ │ ├── rpi-cc2520_a.jpg │ │ ├── rpi-cc2520_a.pdf │ │ ├── rpi-cc2520_a_bom.xls │ │ ├── rpi-cc2520_a_pcb.png │ │ ├── rpi-cc2520_a_2013-04-19.zip │ │ ├── rpi-cc2520_a_2013-07-22.zip │ │ ├── rpi-cc2520_a_to_fab_2013-07-22.zip │ │ ├── rpi-cc2520_a_to_assembler_2013-07-22.zip │ │ ├── rpi-cc2520_a.info │ │ ├── rpi-cc2520_a_xy.csv │ │ ├── rpi-cc2520_a.centroid │ │ ├── rpi-cc2520_a_bom.csv │ │ └── rpi-cc2520_a_bom.txt │ │ └── README.md └── gerbmerge │ └── rev_b │ └── rev_b.def ├── media ├── blip.png ├── rpi-cc2520_2ndgen.jpg └── rpi-cc2520_2ndgen_500px.jpg ├── docs ├── cc2520.pdf ├── ds2411.pdf ├── cc2520em.zip ├── cc2520_errata.pdf ├── molex_sma_0732511350.pdf ├── ndk_nx2520sa_32mhz_crystal.pdf └── johanson_chip_balun_2450bm15a0002.pdf ├── torrents ├── raspbian_cc2520_2013-06-27.img.torrent └── raspbian_cc2520_2013-09-18.img.torrent ├── utils ├── recv_udp.py ├── identify_rpi.py └── mcast.py └── .gitignore /software/ipv6_tunnel/Tupfile.ini: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tinyos/apps/Node/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/prefixes.dat: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLeds154/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLedsBlip/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_a/interface_a.info: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_b/interface_b.info: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/lib/ini/Tupfile: -------------------------------------------------------------------------------- 1 | include_rules 2 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/lib/jsmn/Tupfile: -------------------------------------------------------------------------------- 1 | include_rules 2 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/configs/local.config: -------------------------------------------------------------------------------- 1 | CONFIG_GCC=gcc 2 | -------------------------------------------------------------------------------- /media/blip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/media/blip.png -------------------------------------------------------------------------------- /tinyos/apps/tests/Uart/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=UartTestC 2 | 3 | include $(MAKERULES) 4 | -------------------------------------------------------------------------------- /docs/cc2520.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/docs/cc2520.pdf -------------------------------------------------------------------------------- /docs/ds2411.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/docs/ds2411.pdf -------------------------------------------------------------------------------- /tinyos/support/make/arm-linux/debug.extra: -------------------------------------------------------------------------------- 1 | 2 | OPTFLAGS = -O1 -g -fnesc-no-inline -ggdb 3 | -------------------------------------------------------------------------------- /docs/cc2520em.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/docs/cc2520em.zip -------------------------------------------------------------------------------- /tinyos/apps/SimpleSackTest/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=SimpleSackTestAppC 2 | include $(MAKERULES) 3 | 4 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/PrintfC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration PrintfC { } 3 | implementation { } 4 | 5 | -------------------------------------------------------------------------------- /docs/cc2520_errata.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/docs/cc2520_errata.pdf -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/SerialStartC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration SerialStartC {} 3 | implementation { } 4 | 5 | -------------------------------------------------------------------------------- /docs/molex_sma_0732511350.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/docs/molex_sma_0732511350.pdf -------------------------------------------------------------------------------- /media/rpi-cc2520_2ndgen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/media/rpi-cc2520_2ndgen.jpg -------------------------------------------------------------------------------- /tinyos/tos/platforms/armlinux/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef IEEE802154_PANID 2 | #define IEEE802154_PANID 0x22 3 | #endif 4 | -------------------------------------------------------------------------------- /media/rpi-cc2520_2ndgen_500px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/media/rpi-cc2520_2ndgen_500px.jpg -------------------------------------------------------------------------------- /tinyos/apps/ExtAddrTest/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=ExtAddrTestC 2 | PFLAGS += -DCC2420_DEF_CHANNEL=23 3 | include $(MAKERULES) 4 | 5 | -------------------------------------------------------------------------------- /docs/ndk_nx2520sa_32mhz_crystal.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/docs/ndk_nx2520sa_32mhz_crystal.pdf -------------------------------------------------------------------------------- /tinyos/support/make/arm-linux/install.extra: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | 3 | BUILD_DEPS = program 4 | NODEID ?= $(INSTALL) 5 | -------------------------------------------------------------------------------- /tinyos/apps/NodeCollect/README.md: -------------------------------------------------------------------------------- 1 | NodeCollect 2 | =========== 3 | 4 | Simple app to periodically send data to a collection server. 5 | 6 | -------------------------------------------------------------------------------- /tinyos/apps/tests/BareReceive/README.md: -------------------------------------------------------------------------------- 1 | BareReceive 2 | =========== 3 | 4 | App for receiving any broadcast packets on a certain channel. 5 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Interrupt/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=InterruptC 2 | 3 | TINYOS_ROOT_DIR?=../.. 4 | include $(TINYOS_ROOT_DIR)/Makefile.include 5 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Interrupt2/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=Interrupt2C 2 | 3 | TINYOS_ROOT_DIR?=../.. 4 | include $(TINYOS_ROOT_DIR)/Makefile.include 5 | -------------------------------------------------------------------------------- /tinyos/tos/interfaces/BlockingIO.nc: -------------------------------------------------------------------------------- 1 | 2 | interface BlockingIO { 3 | // Block on all IO calls 4 | async command void waitForIO (); 5 | } 6 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/gap/hardware.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_hardware_h 2 | #define _H_hardware_h 3 | 4 | #undef atomic 5 | 6 | #endif // _H_hardware_h 7 | -------------------------------------------------------------------------------- /docs/johanson_chip_balun_2450bm15a0002.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/docs/johanson_chip_balun_2450bm15a0002.pdf -------------------------------------------------------------------------------- /tinyos/tos/interfaces/UartBuffer.nc: -------------------------------------------------------------------------------- 1 | 2 | interface UartBuffer { 3 | event void receive (uint8_t* buf, uint8_t len, uint64_t timestamp); 4 | } 5 | -------------------------------------------------------------------------------- /tinyos/tos/interfaces/UartConfig.nc: -------------------------------------------------------------------------------- 1 | #include "uart.h" 2 | 3 | interface UartConfig { 4 | command error_t setserial (uart_config_t* c); 5 | } 6 | -------------------------------------------------------------------------------- /tinyos/Makefile.include: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | 3 | TINYOS_ROOT_DIR?=/opt/tinyos-main 4 | include $(TINYOS_ROOT_DIR)/Makefile.include 5 | -------------------------------------------------------------------------------- /tinyos/tos/lib/printf/generic_printf.h: -------------------------------------------------------------------------------- 1 | #ifndef __M16C62P_PRINTF_H__ 2 | #define __M16C62P_PRINTF_H__ 3 | 4 | #endif // __M16C62P_PRINTF_H__ 5 | 6 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a.jpg -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a.pdf -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLeds154/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=RadioCountToLeds154C 2 | 3 | TINYOS_ROOT_DIR?=../.. 4 | include $(TINYOS_ROOT_DIR)/Makefile.include 5 | -------------------------------------------------------------------------------- /torrents/raspbian_cc2520_2013-06-27.img.torrent: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/torrents/raspbian_cc2520_2013-06-27.img.torrent -------------------------------------------------------------------------------- /torrents/raspbian_cc2520_2013-09-18.img.torrent: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/torrents/raspbian_cc2520_2013-09-18.img.torrent -------------------------------------------------------------------------------- /software/ipv6_tunnel/configs/rpi.config: -------------------------------------------------------------------------------- 1 | CONFIG_GCC=arm-linux-gnueabi-gcc 2 | 3 | CONFIG_GOOS=linux 4 | CONFIG_GOARCH=arm 5 | CONFIG_GOROOT=/home/bradjc/hg/go 6 | -------------------------------------------------------------------------------- /tinyos/tos/interfaces/CommandLineArgs.nc: -------------------------------------------------------------------------------- 1 | 2 | interface CommandLineArgs { 3 | command uint8_t count (); 4 | command char* getArg (uint8_t arg_idx); 5 | } 6 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_bom.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_bom.xls -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_pcb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_pcb.png -------------------------------------------------------------------------------- /tinyos/support/make/arm-linux/reinstall.extra: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | 3 | NODEID ?= $(REINSTALL) 4 | BUILD_DEPS = program 5 | TOSMAKE_DO_REINSTALL = y 6 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_a/interface_a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_a/interface_a.pdf -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_b/interface_b.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_b/interface_b.pdf -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_2013-04-19.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_2013-04-19.zip -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_2013-07-22.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_2013-07-22.zip -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_a/interface_a_pcb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_a/interface_a_pcb.png -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_b/interface_b_pcb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_b/interface_b_pcb.png -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_to_fab_2013-07-22.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_to_fab_2013-07-22.zip -------------------------------------------------------------------------------- /software/ipv6_tunnel/.gitignore: -------------------------------------------------------------------------------- 1 | config.ini 2 | build* 3 | 4 | ##### TUP GITIGNORE ##### 5 | ##### Lines below automatically generated by Tup. 6 | ##### Do not edit. 7 | .tup 8 | /.gitignore 9 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_b/rpi-cc2520-interface_b_bom.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_b/rpi-cc2520-interface_b_bom.xls -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_to_assembler_2013-07-22.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_to_assembler_2013-07-22.zip -------------------------------------------------------------------------------- /tinyos/apps/tests/PolyPointHack/README.md: -------------------------------------------------------------------------------- 1 | PolyPointHack 2 | ============= 3 | 4 | App for receiving any broadcast packets on a certain channel and printing them 5 | assuming they came from a polypoint tag. 6 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_a/rpi-cc2520-interface_a_2012-10-29.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_a/rpi-cc2520-interface_a_2012-10-29.zip -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_b/rpi-cc2520-interface_b_2013-02-11.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_b/rpi-cc2520-interface_b_2013-02-11.zip -------------------------------------------------------------------------------- /tinyos/apps/BorderRouter/README.md: -------------------------------------------------------------------------------- 1 | BorderRouter 2 | ============ 3 | 4 | This app is a generic border router for tunneling packets between the wireless 5 | sensor network side (802.15.4) and the Internet at large. 6 | -------------------------------------------------------------------------------- /tinyos/apps/BorderRouter/brconfig.ini: -------------------------------------------------------------------------------- 1 | # This file is used to configure the border router. 2 | # Place this in the same folder as the BorderRouterC executable. 3 | 4 | [network] 5 | prefix = 2001:470:1f11:131a:: 6 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Uart/README.md: -------------------------------------------------------------------------------- 1 | Uart Test 2 | ========= 3 | 4 | Very simple test that reads from the UART line and prints it to stdout. 5 | 6 | Also blinks an LED on a timer so that you know the app is running. 7 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/time/UnixTime.nc: -------------------------------------------------------------------------------- 1 | 2 | interface UnixTime { 3 | async command uint32_t getSeconds (); 4 | async command uint64_t getMilliseconds (); 5 | async command uint64_t getMicroseconds (); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tinyos/apps/TSDemo2014BorderRouter/README.md: -------------------------------------------------------------------------------- 1 | BorderRouter 2 | ============ 3 | 4 | This app is a generic border router for tunneling packets between the wireless 5 | sensor network side (802.15.4) and the Internet at large. 6 | -------------------------------------------------------------------------------- /tinyos/apps/TSDemo2014BorderRouter/brconfig.ini: -------------------------------------------------------------------------------- 1 | # This file is used to configure the border router. 2 | # Place this in the same folder as the BorderRouterC executable. 3 | 4 | [network] 5 | prefix = 2001:470:1f11:131a:: 6 | -------------------------------------------------------------------------------- /tinyos/tos/lib/printf/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @author: Brad Campbell 3 | */ 4 | 5 | #ifndef PRINTF_H 6 | #define PRINTF_H 7 | 8 | #include 9 | void printfflush () {} 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_a/rpi-cc2520-interface_a_to_fab_2012-10-29.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_a/rpi-cc2520-interface_a_to_fab_2012-10-29.zip -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_b/rpi-cc2520-interface_b_to_fab_2013-02-11.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab11/raspberrypi-cc2520/HEAD/hardware/eagle/rpi-cc2520-interface/rev_b/rpi-cc2520-interface_b_to_fab_2013-02-11.zip -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/README.md: -------------------------------------------------------------------------------- 1 | RPi - CC2520 Rev. A 2 | =================== 3 | 4 | This PCB contains the TI CC2520 and Maxim DS2411 and fits directly on to P1 5 | on the Raspberry Pi. 6 | 7 | This design is known to be working. 8 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/tun/TunName.nc: -------------------------------------------------------------------------------- 1 | /* Interface for retrieving the name a TUN device should use. 2 | * 3 | * @author Brad Campbell 4 | */ 5 | 6 | interface TunName { 7 | command char* getTunName (); 8 | } 9 | -------------------------------------------------------------------------------- /tinyos/tos/interfaces/UnixTimeC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration UnixTimeC { 3 | provides { 4 | interface UnixTime; 5 | } 6 | } 7 | 8 | implementation { 9 | components UnixTimeP; 10 | UnixTime = UnixTimeP.UnixTime; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /tinyos/tos/system/IOFileC.nc: -------------------------------------------------------------------------------- 1 | 2 | generic configuration IOFileC () { 3 | provides { 4 | interface IO; 5 | } 6 | } 7 | 8 | implementation { 9 | components IOManagerC; 10 | 11 | IO = IOManagerC.IO[unique("FILEID")]; 12 | } 13 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/config-template.ini: -------------------------------------------------------------------------------- 1 | [server] 2 | localhost = 127.0.0.1 3 | listenport = 10000 4 | prefixrange = 2001:1122:3344:0000::/48 5 | assignments = prefixes.dat 6 | 7 | [client] 8 | remotehost = 127.0.0.1 9 | remoteport = 10000 10 | -------------------------------------------------------------------------------- /tinyos/apps/ExtAddrTest/README.md: -------------------------------------------------------------------------------- 1 | ExtAddrTest 2 | =========== 3 | 4 | Very rough test app that sends 802.15.4 packets with an ext destination address. 5 | 6 | Run this with the read.c test for linux-cc2520-driver and see if it can receive 7 | packets. 8 | -------------------------------------------------------------------------------- /tinyos/support/sdk/c/linux/file_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef __FILE_HELPERS_H__ 2 | #define __FILE_HELPERS_H__ 3 | 4 | // Makes the given file descriptor non-blocking. 5 | // Returns 1 on success, 0 on failure. 6 | int make_nonblocking (int fd); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a.info: -------------------------------------------------------------------------------- 1 | title: RPi + CC2520 2 | author: Brad Campbell 3 | rev: A 4 | description: CC2520 shield for the Raspberry Pi. Includes three LEDs and the DS2411 ID chip. 5 | revision: a 6 | github: http://github.com/lab11/raspberrypi-cc2520 7 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/Tuprules.tup: -------------------------------------------------------------------------------- 1 | ifndef GCC 2 | error Define a variant. 3 | endif 4 | 5 | 6 | CFLAGS = -Wall -Wextra -Werror 7 | CFLAGS += -I$(TUP_CWD)/lib 8 | 9 | : foreach *.c |> @(GCC) %f $(CFLAGS) -c -o %o |> %B.o $(TUP_CWD)/ 10 | 11 | .gitignore 12 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/BusyWaitMicroC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration BusyWaitMicroC { 3 | provides { 4 | interface BusyWait; 5 | } 6 | } 7 | implementation { 8 | components BusyWaitMicroP; 9 | 10 | BusyWait = BusyWaitMicroP.BusyWait; 11 | } 12 | -------------------------------------------------------------------------------- /utils/recv_udp.py: -------------------------------------------------------------------------------- 1 | 2 | import socket 3 | 4 | me = '::0' 5 | 6 | mebind = socket.getaddrinfo(me, 2001)[0] 7 | 8 | s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) 9 | 10 | s.bind(mebind[-1]) 11 | 12 | while True: 13 | print s.recvfrom(100) 14 | 15 | 16 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/Tupfile: -------------------------------------------------------------------------------- 1 | include_rules 2 | 3 | : |> @(GCC) % $(LDFLAGS) -o %o |> ipv6tunnel-client 4 | 5 | export GOPATH 6 | : server.go common.go prefix.go tunindex.go |> GOOS=@(GOOS) GOARCH=@(GOARCH) GOROOT=@(GOROOT) go build -o %o %f |> ipv6tunnel-server 7 | -------------------------------------------------------------------------------- /tinyos/apps/SpiLockDebug/README.md: -------------------------------------------------------------------------------- 1 | SpiLockDebug 2 | ============ 3 | 4 | This app is designed to cause the SPI driver lock problems to occur as 5 | described in https://github.com/ab500/linux-cc2520-driver/issues/12. It does 6 | this by tuning off and on the radio periodically. 7 | 8 | -------------------------------------------------------------------------------- /tinyos/support/make/targets/gap.target: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | TARGET = gap 3 | 4 | PFLAGS += -DPRINTFUART_ENABLED=1 5 | 6 | $(call TOSMake_include_platform,gap) 7 | $(call TOSMake_include_make_platform,arm-linux) 8 | 9 | $(TARGET): $(BUILD_DEPS) 10 | @: 11 | -------------------------------------------------------------------------------- /tinyos/support/make/targets/rpi.target: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | TARGET = rpi 3 | 4 | PFLAGS += -DPRINTFUART_ENABLED=1 5 | 6 | $(call TOSMake_include_platform,rpi) 7 | $(call TOSMake_include_make_platform,arm-linux) 8 | 9 | $(TARGET): $(BUILD_DEPS) 10 | @: 11 | -------------------------------------------------------------------------------- /tinyos/apps/SimpleSackTest/SimpleSackTest.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMPLESACKTEST_H 2 | #define SIMPLESACKTEST_H 3 | 4 | enum { 5 | AM_BLINKTORADIO = 6, 6 | TIMER_PERIOD_MILLI = 250 7 | }; 8 | 9 | typedef nx_struct BlinkToRadioMsg { 10 | nx_uint16_t counter; 11 | } BlinkToRadioMsg; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/CC2520RpiAmPacketC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration CC2520RpiAmPacketC { 3 | provides { 4 | interface RadioPacket; 5 | } 6 | } 7 | 8 | implementation { 9 | 10 | components CC2520RpiAmPacketP as PacketP; 11 | 12 | RadioPacket = PacketP.RadioPacket; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/time/UnixTimeC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Simple interface to provide unix timestamps. 3 | */ 4 | 5 | configuration UnixTimeC { 6 | provides { 7 | interface UnixTime; 8 | } 9 | } 10 | 11 | implementation { 12 | components UnixTimeP; 13 | UnixTime = UnixTimeP.UnixTime; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tinyos/apps/Node/readme.txt: -------------------------------------------------------------------------------- 1 | You'll need to call make epic install.11 to run this, else it will share the 2 | same IPv6 address as the border router. 3 | 4 | I'm not too familar on how IPv6 addresses are supposed to be laid out on 5 | WSNs. Is there something special that should be done with subnets and 6 | broadcast addresses? 7 | -------------------------------------------------------------------------------- /tinyos/tos/interfaces/BRConfig.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Simple interface for loading and querying a border router config file. 3 | * 4 | * @author: Brad Campbell 5 | */ 6 | 7 | interface BRConfig { 8 | command error_t getPrefix (struct in6_addr* prefix); 9 | command struct in6_addr* getPrefixPtr (); 10 | } 11 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/ReadLqiC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration ReadLqiC { 3 | provides { 4 | interface ReadLqi; 5 | } 6 | } 7 | 8 | implementation { 9 | components ReadLqiP; 10 | components RadioSelectC; 11 | 12 | ReadLqiP.PacketMetadata -> RadioSelectC.PacketMetadata; 13 | 14 | ReadLqi = ReadLqiP.ReadLqi; 15 | } 16 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/armlinux/border.h: -------------------------------------------------------------------------------- 1 | #ifndef __BORDER_H__ 2 | #define __BORDER_H__ 3 | 4 | enum { 5 | ROUTE_IFACE_TUN = 3, 6 | }; 7 | 8 | // Might need to do this. 9 | // typedef uint8_t bool __attribute__((combine(rcombine))); 10 | 11 | // bool rcombine(bool a, bool b) { 12 | // return a & b; 13 | // } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /tinyos/apps/tests/BlipQuickPacket/README.md: -------------------------------------------------------------------------------- 1 | BlipQuickPacket 2 | =============== 3 | 4 | This app tests trying to send a UDP packet immediately after boot. This is 5 | necessary for monjolo type applications, but I don't think it works by default. 6 | I think it will take at least setting a default root as broadcast, but I'm not 7 | entirely sure. 8 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/README.md: -------------------------------------------------------------------------------- 1 | CC2520RpiAm 2 | =========== 3 | 4 | This stack is for Active Message applications. It provides the necessary 5 | interfaces for the rest of the TinyOS active message stack. It also uses 6 | the Send, Receive and Metadata interfaces from the normal CC2520rpi stack 7 | to remove the need for much duplication. 8 | 9 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/rpi/chips/ds2411/HplDs2411C.nc: -------------------------------------------------------------------------------- 1 | configuration HplDs2411C { 2 | provides { 3 | interface GeneralIO as Gpio; 4 | } 5 | } 6 | implementation { 7 | components HplBcm2835GeneralIOC as Hpl; 8 | components new Bcm2835GpioC() as BcmGpio; 9 | BcmGpio.IO -> Hpl.Port1_08; 10 | 11 | Gpio = BcmGpio.GeneralIO; 12 | } 13 | -------------------------------------------------------------------------------- /tinyos/tos/system/IOManagerC.nc: -------------------------------------------------------------------------------- 1 | 2 | // Handles all file descriptors 3 | 4 | configuration IOManagerC { 5 | provides { 6 | interface IO[uint8_t id]; 7 | interface BlockingIO; 8 | } 9 | } 10 | 11 | implementation { 12 | components IOManagerP; 13 | 14 | IO = IOManagerP.IO; 15 | BlockingIO = IOManagerP.BlockingIO; 16 | } 17 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/gap/PlatformC.nc: -------------------------------------------------------------------------------- 1 | /** 2 | * Initialization code 3 | * 4 | */ 5 | #include "hardware.h" 6 | 7 | configuration PlatformC { 8 | provides { 9 | interface Init; 10 | } 11 | } 12 | implementation { 13 | components PlatformP; 14 | components LedsC; 15 | 16 | PlatformP.Leds -> LedsC; 17 | 18 | Init = PlatformP; 19 | } 20 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/rpi/PlatformC.nc: -------------------------------------------------------------------------------- 1 | /** 2 | * Initialization code 3 | * 4 | */ 5 | #include "hardware.h" 6 | 7 | configuration PlatformC { 8 | provides { 9 | interface Init; 10 | } 11 | } 12 | implementation { 13 | components PlatformP; 14 | components LedsC; 15 | 16 | PlatformP.Leds -> LedsC; 17 | 18 | Init = PlatformP; 19 | } 20 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/BRConfigC.nc: -------------------------------------------------------------------------------- 1 | /* Component for loading and parsing a Border Router config file. 2 | * 3 | * @author: Brad Campbell 4 | */ 5 | 6 | configuration BRConfigC { 7 | provides { 8 | interface BRConfig; 9 | } 10 | } 11 | implementation { 12 | components BRConfigP; 13 | BRConfig = BRConfigP.BRConfig; 14 | } 15 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Interrupt/README.md: -------------------------------------------------------------------------------- 1 | Interrupt Test 2 | ============== 3 | 4 | This is a simple test to verify that interrupts are working on the RPi. 5 | 6 | 7 | To Use 8 | ------ 9 | 10 | Jumper pin `P1_7` to `P1_10`. LED0 will blink while the app is running. If the 11 | jumper is set correctly and interrupts are working LED1 will blink half as fast 12 | as LED0. 13 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/CC2520RpiAm154DummyP.nc: -------------------------------------------------------------------------------- 1 | 2 | module CC2520RpiAm154DummyP { 3 | uses { 4 | interface BareSend as Ieee154Send; 5 | interface BareReceive as Ieee154Receive; 6 | } 7 | } 8 | 9 | implementation { 10 | event message_t* Ieee154Receive.receive(message_t* msg) { return msg; } 11 | event void Ieee154Send.sendDone(message_t* msg, error_t error) { } 12 | } 13 | -------------------------------------------------------------------------------- /tinyos/apps/tests/BlipQuickPacket/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=BlipQuickPacketC 2 | 3 | CFLAGS += -DCC2520_DEF_CHANNEL=19 4 | CFLAGS += -DCC2420_DEF_CHANNEL=19 5 | CFLAGS += -DCC2420X_DEF_CHANNEL=19 6 | 7 | PFLAGS += -I$(TINYOS_ROOT_DIR)/tools/tinyos/c/blip/lib6lowpan 8 | 9 | PFLAGS += -DIN6_PREFIX="\"2001:470:1f11:131a::\"" 10 | 11 | TINYOS_ROOT_DIR?=../.. 12 | include $(TINYOS_ROOT_DIR)/Makefile.include 13 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/ipv6tunc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # USAGE: start|stop 3 | # 4 | case "$1" in 5 | start) 6 | echo "Starting IPv6 Tunnel Client." 7 | cd /home/bradjc 8 | sudo /home/bradjc/ipv6tunnel-client 9 | ;; 10 | stop) 11 | echo "Stopping IPv6 Tunnel Client." 12 | sudo pkill -9 ipv6server-client 13 | ;; 14 | 15 | *) 16 | echo “IPv6 Tunnel” 17 | echo $”Usage: $0 {start|stop}” 18 | exit 1 19 | esac 20 | exit 0 -------------------------------------------------------------------------------- /software/ipv6_tunnel/ipv6tuns: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # USAGE: start|stop 3 | # 4 | case "$1" in 5 | start) 6 | echo "Starting IPv6 Tunnel Server." 7 | cd /home/bradjc 8 | sudo /home/bradjc/ipv6tunnel-server 9 | ;; 10 | stop) 11 | echo "Stopping IPv6 Tunnel Server." 12 | sudo pkill -9 ipv6tunnel-server 13 | ;; 14 | 15 | *) 16 | echo “IPv6 Tunnel” 17 | echo $”Usage: $0 {start|stop}” 18 | exit 1 19 | esac 20 | exit 0 -------------------------------------------------------------------------------- /software/ipv6_tunnel/common.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type ClientIdentifier struct { 4 | Id string 5 | } 6 | 7 | type ClientPrefix struct { 8 | Prefix string 9 | } 10 | 11 | type ConfigIni struct { 12 | Server struct { 13 | Localhost string 14 | Listenport string 15 | Prefixrange string 16 | Assignments string 17 | } 18 | Client struct { 19 | Remotehost string 20 | Remoteport string 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Uart/UartTestC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration UartTestC { 3 | } 4 | 5 | implementation { 6 | components UartTestP as AppP; 7 | components MainC; 8 | components LedsC; 9 | components UartC; 10 | 11 | AppP.Boot -> MainC.Boot; 12 | AppP.Leds -> LedsC; 13 | 14 | components new TimerMilliC(); 15 | AppP.TimerMilliC -> TimerMilliC; 16 | 17 | AppP.UartBuffer -> UartC.UartBuffer; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /tinyos/tos/interfaces/IO.nc: -------------------------------------------------------------------------------- 1 | 2 | interface IO { 3 | // Add a file descriptor to the select() call 4 | command error_t registerFileDescriptor (int file_descriptor); 5 | // Remove the file descriptor from the select() call 6 | command error_t unregisterFileDescriptor (int file_descriptor); 7 | 8 | // Event that is triggered when data is ready on this io file 9 | async event void receiveReady (); 10 | } 11 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_a/interface_a.centroid: -------------------------------------------------------------------------------- 1 | # SMD component position file. 2 | # Created by centroid_smd.ulp 1.3.0. 3 | 4 | # Centroid Data for pc board: "interface_a.brd" as of: 12/30/13 1:10 AM 5 | # Measurements are in inches. 6 | # Comma delimited. 7 | # Only surface mount components included. 8 | 9 | RefDes,Layer,LocationX,LocationY,Rotation 10 | J1,Bottom,0.25000,0.86000,90 11 | J2,Top,0.25000,0.86000,90 12 | -------------------------------------------------------------------------------- /tinyos/apps/BorderRouter/TunNameC.nc: -------------------------------------------------------------------------------- 1 | /* Provide the name of the TUN interface. 2 | * 3 | * @author: Brad Campbell 4 | */ 5 | 6 | configuration TunNameC { 7 | provides { 8 | interface TunName; 9 | } 10 | } 11 | 12 | implementation { 13 | components TunNameP; 14 | components CommandLineC; 15 | 16 | TunNameP.CommandLineArgs -> CommandLineC.CommandLineArgs; 17 | 18 | TunName = TunNameP.TunName; 19 | } 20 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/CommandLineC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Provides an interface to retrieve the command line arguments from the 3 | * start of the application. Behaves very similarly to the argc/argv 4 | * arguments to int main(). 5 | */ 6 | 7 | configuration CommandLineC { 8 | provides { 9 | interface CommandLineArgs; 10 | } 11 | } 12 | 13 | implementation { 14 | components CommandLineP; 15 | CommandLineArgs = CommandLineP; 16 | } 17 | -------------------------------------------------------------------------------- /tinyos/apps/TSDemo2014BorderRouter/TunNameC.nc: -------------------------------------------------------------------------------- 1 | /* Provide the name of the TUN interface. 2 | * 3 | * @author: Brad Campbell 4 | */ 5 | 6 | configuration TunNameC { 7 | provides { 8 | interface TunName; 9 | } 10 | } 11 | 12 | implementation { 13 | components TunNameP; 14 | components CommandLineC; 15 | 16 | TunNameP.CommandLineArgs -> CommandLineC.CommandLineArgs; 17 | 18 | TunName = TunNameP.TunName; 19 | } 20 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/Ieee154AddressC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Dummy module that gives a constant name (Ieee154AddressC) to the component 3 | * that handles ieee15.4 addresses. 4 | * 5 | * @author: Brad Campbell 6 | */ 7 | 8 | configuration Ieee154AddressC { 9 | provides { 10 | interface Ieee154Address; 11 | } 12 | 13 | } implementation { 14 | components RadioSelectC; 15 | Ieee154Address = RadioSelectC.Ieee154Address; 16 | } 17 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/ReadLqiP.nc: -------------------------------------------------------------------------------- 1 | 2 | module ReadLqiP { 3 | provides { 4 | interface ReadLqi; 5 | } 6 | uses { 7 | interface PacketMetadata; 8 | } 9 | } 10 | 11 | implementation { 12 | 13 | command uint8_t ReadLqi.readLqi(message_t *msg) { 14 | return call PacketMetadata.getLqi(msg); 15 | } 16 | 17 | command uint8_t ReadLqi.readRssi(message_t *msg) { 18 | return call PacketMetadata.getRssi(msg); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/CC2520RpiAmUniqueC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration CC2520RpiAmUniqueC { 3 | provides { 4 | interface BareSend as Send; 5 | } 6 | uses { 7 | interface BareSend as SubSend; 8 | } 9 | } 10 | 11 | implementation { 12 | components CC2520RpiAmUniqueP; 13 | components MainC; 14 | 15 | MainC.SoftwareInit -> CC2520RpiAmUniqueP.Init; 16 | 17 | Send = CC2520RpiAmUniqueP.Send; 18 | SubSend = CC2520RpiAmUniqueP.SubSend; 19 | } 20 | -------------------------------------------------------------------------------- /tinyos/tos/chips/idrfid/IDrfidC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Wire to this module to use the ID Rfid Reader. 3 | * http://www.sparkfun.com/products/8419 4 | */ 5 | 6 | configuration IDrfidC { 7 | provides { 8 | interface Notify; 9 | } 10 | } 11 | 12 | implementation { 13 | components IDrfidP; 14 | 15 | components UartC; 16 | IDrfidP.UartBuffer -> UartC.UartBuffer; 17 | IDrfidP.UartConfig -> UartC.UartConfig; 18 | 19 | Notify = IDrfidP.Notify; 20 | } 21 | -------------------------------------------------------------------------------- /tinyos/apps/tests/BareReceive/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=BareReceiveC 2 | 3 | CHANNEL = 24 4 | 5 | CFLAGS += -DCC2420_DEF_CHANNEL=$(CHANNEL) 6 | CFLAGS += -DCC2420X_DEF_CHANNEL=$(CHANNEL) 7 | CFLAGS += -DCC2520_DEF_CHANNEL=$(CHANNEL) 8 | 9 | PFLAGS += -I$(TINYOS_ROOT_DIR)/tools/tinyos/c/blip/lib6lowpan 10 | PFLAGS += $(TINYOS_ROOT_DIR)/tools/tinyos/c/blip/lib6lowpan/ieee154_header.c 11 | 12 | CFLAGS += -DASSERT_NONE 13 | 14 | TINYOS_ROOT_DIR?=../.. 15 | include $(TINYOS_ROOT_DIR)/Makefile.include 16 | -------------------------------------------------------------------------------- /tinyos/apps/tests/PolyPointHack/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=PolyPointHackC 2 | 3 | CHANNEL = 24 4 | 5 | CFLAGS += -DCC2420_DEF_CHANNEL=$(CHANNEL) 6 | CFLAGS += -DCC2420X_DEF_CHANNEL=$(CHANNEL) 7 | CFLAGS += -DCC2520_DEF_CHANNEL=$(CHANNEL) 8 | 9 | PFLAGS += -I$(TINYOS_ROOT_DIR)/tools/tinyos/c/blip/lib6lowpan 10 | PFLAGS += $(TINYOS_ROOT_DIR)/tools/tinyos/c/blip/lib6lowpan/ieee154_header.c 11 | 12 | CFLAGS += -DASSERT_NONE 13 | 14 | TINYOS_ROOT_DIR?=../.. 15 | include $(TINYOS_ROOT_DIR)/Makefile.include 16 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/tun/TunNameC.nc: -------------------------------------------------------------------------------- 1 | /* Default implementation of a module that provides the TUN name to use when 2 | * creating a TUN device. This module is intended to be overwritten if the tun 3 | * name needs to be customized. 4 | * 5 | * @author Brad Campbell 6 | */ 7 | 8 | module TunNameC { 9 | provides { 10 | interface TunName; 11 | } 12 | } 13 | 14 | implementation { 15 | 16 | command char* TunName.getTunName () { 17 | return "\0"; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | 4 | # Libraries 5 | *.lib 6 | *.a 7 | 8 | # Shared objects (inc. Windows DLLs) 9 | *.dll 10 | *.so 11 | *.so.* 12 | *.dylib 13 | 14 | # Executables 15 | *.exe 16 | *.out 17 | *.app 18 | 19 | build 20 | 21 | *.b#* 22 | *.s#* 23 | *.l#* 24 | *.top 25 | *.bot 26 | *.bsk 27 | *.bsp 28 | *.drd 29 | *.dri 30 | *.gpi 31 | *.oln 32 | *.slk 33 | *.smb 34 | *.smt 35 | *.tsp 36 | *.fab 37 | *.sco 38 | merged.placement.txt 39 | merged.toollist.drl 40 | *.xls# 41 | docs/cc2520em 42 | 43 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/armlinux/platform_message.h: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_MESSAGE_H 2 | #define PLATFORM_MESSAGE_H 3 | 4 | #include "CC2520LinuxRadio.h" 5 | 6 | #define TOSH_DATA_LENGTH 128 7 | 8 | typedef union message_header { 9 | cc2520packet_header_t cc2520; 10 | } message_header_t; 11 | 12 | typedef union message_footer { 13 | cc2520packet_footer_t cc2520; 14 | } message_footer_t; 15 | 16 | typedef union message_metadata { 17 | cc2520packet_metadata_t cc2520; 18 | } message_metadata_t; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /tinyos/support/sdk/c/linux/file_helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "file_helpers.h" 5 | 6 | // Makes the given file descriptor non-blocking. 7 | // Returns 1 on success, 0 on failure. 8 | int make_nonblocking (int fd) { 9 | int flags, ret; 10 | 11 | flags = fcntl(fd, F_GETFL, 0); 12 | if (flags == -1) { 13 | return 0; 14 | } 15 | // Set the nonblocking flag. 16 | flags |= O_NONBLOCK; 17 | ret = fcntl(fd, F_SETFL, flags); 18 | 19 | return ret != -1; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/CC2520LinuxLinkC.nc: -------------------------------------------------------------------------------- 1 | 2 | generic configuration CC2520LinuxLinkC () { 3 | provides { 4 | interface BareSend as Send; 5 | } 6 | uses { 7 | interface BareSend as SubSend; 8 | interface PacketMetadata; 9 | } 10 | } 11 | 12 | implementation { 13 | components new CC2520LinuxLinkP() as LinkP; 14 | components new TimerMilliC(); 15 | 16 | LinkP.DelayTimer -> TimerMilliC; 17 | 18 | LinkP.SubSend = SubSend; 19 | LinkP.PacketMetadata = PacketMetadata; 20 | 21 | Send = LinkP.Send; 22 | } 23 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/README.md: -------------------------------------------------------------------------------- 1 | RPi - CC2520 Interface 2 | ====================== 3 | 4 | This board bridges the RPi and the TI CC2520EM evaluation module. 5 | 6 | Revision B is known to be working, but requires an expensive EVM. A newer 7 | design can be found in the rpi-cc2520 folder. 8 | 9 | 10 | Rev B 11 | ----- 12 | 13 | - Wired the radio GPIO lines directly on the PCB. 14 | - Added LEDs. 15 | 16 | Rev A 17 | ----- 18 | 19 | - Fits the CC2520EM. Requires jumper wires between the radio GPIOs and the RPi 20 | GPIOs. 21 | 22 | -------------------------------------------------------------------------------- /tinyos/apps/tests/BlipQuickPacket/BlipQuickPacketC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration BlipQuickPacketC {} 3 | implementation { 4 | 5 | components MainC; 6 | components BlipQuickPacketP as App; 7 | components LedsC; 8 | 9 | App.Boot -> MainC.Boot; 10 | App.Leds -> LedsC.Leds; 11 | 12 | // IPv6 Stack 13 | components IPStackC; 14 | App.BlipControl -> IPStackC.SplitControl; 15 | App.ForwardingTable -> IPStackC.ForwardingTable; 16 | components new UdpSocketC() as Udp; 17 | App.Udp -> Udp.UDP; 18 | 19 | components StaticIPAddressC; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Uart/UartTestP.nc: -------------------------------------------------------------------------------- 1 | 2 | module UartTestP { 3 | uses { 4 | interface Boot; 5 | interface Leds; 6 | interface Timer as TimerMilliC; 7 | interface UartBuffer; 8 | } 9 | } 10 | implementation { 11 | event void Boot.booted () { 12 | call TimerMilliC.startPeriodic(3000); 13 | } 14 | 15 | event void UartBuffer.receive (uint8_t* buf, uint8_t len) { 16 | printf("%s", buf); 17 | call Leds.led2Toggle(); 18 | } 19 | 20 | event void TimerMilliC.fired () { 21 | call Leds.led0Toggle(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/McuSleepC.nc: -------------------------------------------------------------------------------- 1 | #include "linux_atomic.h" 2 | 3 | configuration McuSleepC @safe() { 4 | provides { 5 | interface McuSleep; 6 | interface McuPowerState; 7 | } 8 | uses { 9 | interface McuPowerOverride; 10 | } 11 | } 12 | 13 | implementation { 14 | components McuSleepP; 15 | components IOManagerC; 16 | 17 | McuSleepP.BlockingIO -> IOManagerC.BlockingIO; 18 | 19 | McuSleep = McuSleepP.McuSleep; 20 | McuPowerState = McuSleepP.McuPowerState; 21 | McuPowerOverride = McuSleepP.McuPowerOverride; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tinyos/apps/tests/BareReceive/BareReceiveC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration BareReceiveC {} 3 | implementation { 4 | 5 | components MainC; 6 | components BareReceiveP as App; 7 | components LedsC; 8 | components Ieee154BareC; 9 | 10 | App.Boot -> MainC.Boot; 11 | App.Leds -> LedsC.Leds; 12 | 13 | // Radio 14 | // Uses a very bare radio interface. 15 | App.RadioControl -> Ieee154BareC.SplitControl; 16 | App.RadioSend -> Ieee154BareC.BareSend; 17 | App.RadioReceive -> Ieee154BareC.BareReceive; 18 | App.RadioPacket -> Ieee154BareC.BarePacket; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/CC2520LinuxSendC.nc: -------------------------------------------------------------------------------- 1 | 2 | generic configuration CC2520LinuxSendC (char char_dev_path[]) { 3 | provides { 4 | interface BareSend; 5 | } 6 | uses { 7 | interface PacketMetadata; 8 | } 9 | } 10 | 11 | implementation { 12 | components MainC; 13 | 14 | components new CC2520LinuxSendP(char_dev_path) as SendP; 15 | components new IOFileC(); 16 | 17 | MainC.SoftwareInit -> SendP.SoftwareInit; 18 | 19 | SendP.IO -> IOFileC.IO; 20 | SendP.PacketMetadata = PacketMetadata; 21 | 22 | BareSend = SendP.BareSend; 23 | } 24 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/socket/LinuxUdpSocketC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Instantiate this component to create a TCP socket that will reconnect itself 3 | * if the connection is lost. This component basically wraps the linux socket 4 | * utilities into a nice TinyOS form. 5 | * 6 | * @author: Pat Pannuto 7 | */ 8 | 9 | generic configuration LinuxUdpSocketC () { 10 | provides { 11 | interface LinuxUdpSocket; 12 | } 13 | } 14 | 15 | implementation { 16 | components new LinuxUdpSocketP(); 17 | LinuxUdpSocket = LinuxUdpSocketP.LinuxUdpSocket; 18 | } 19 | -------------------------------------------------------------------------------- /tinyos/apps/Node/NodeC.nc: -------------------------------------------------------------------------------- 1 | 2 | // generic app for a node in a wsn 3 | 4 | configuration NodeC {} 5 | implementation { 6 | components MainC, NodeP as App, LedsC; 7 | components new TimerMilliC(); 8 | 9 | App.Boot -> MainC.Boot; 10 | 11 | App.Leds -> LedsC; 12 | App.MilliTimer -> TimerMilliC; 13 | 14 | // Radio 15 | components IPStackC; 16 | components new UdpSocketC() as UDPService; 17 | App.RadioControl -> IPStackC.SplitControl; 18 | App.UDPService -> UDPService.UDP; 19 | 20 | #ifdef RPL_ROUTING 21 | components RPLRoutingC; 22 | #endif 23 | 24 | } 25 | -------------------------------------------------------------------------------- /tinyos/apps/tests/PolyPointHack/PolyPointHackC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration PolyPointHackC {} 3 | implementation { 4 | 5 | components MainC; 6 | components PolyPointHackP as App; 7 | components LedsC; 8 | components Ieee154BareC; 9 | 10 | App.Boot -> MainC.Boot; 11 | App.Leds -> LedsC.Leds; 12 | 13 | // Radio 14 | // Uses a very bare radio interface. 15 | App.RadioControl -> Ieee154BareC.SplitControl; 16 | App.RadioSend -> Ieee154BareC.BareSend; 17 | App.RadioReceive -> Ieee154BareC.BareReceive; 18 | App.RadioPacket -> Ieee154BareC.BarePacket; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Interrupt/InterruptC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Simple app to receive an interrupt and toggle an led. 3 | * 4 | * @author: Brad Campbell 5 | */ 6 | 7 | configuration InterruptC { 8 | } 9 | 10 | implementation { 11 | components InterruptP; 12 | components MainC; 13 | components LedsC; 14 | 15 | components Bcm2835InterruptC; 16 | components new TimerMilliC(); 17 | 18 | InterruptP.Int -> Bcm2835InterruptC.Port1_08; 19 | InterruptP.Boot -> MainC.Boot; 20 | InterruptP.TimerMilliC -> TimerMilliC; 21 | 22 | InterruptP.Leds -> LedsC; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /tinyos/tos/interfaces/RadioAddress.nc: -------------------------------------------------------------------------------- 1 | 2 | // Interface for getting and setting the hardware radio addresses 3 | 4 | // Should be a part of the rfxlink library 5 | 6 | interface RadioAddress { 7 | // Get the long address (64 bits) of the radio 8 | command ieee_eui64_t getExtAddr(); 9 | 10 | // Change the short address of the radio. 11 | async command uint16_t getShortAddr(); 12 | command void setShortAddr(uint16_t address); 13 | 14 | //Change the PAN address of the radio. 15 | async command uint16_t getPanAddr(); 16 | command void setPanAddr(uint16_t address); 17 | } 18 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/CC2520RpiAmPacketMetadataC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration CC2520RpiAmPacketMetadataC { 3 | provides { 4 | interface PacketField as PacketLinkQuality; 5 | interface PacketField as PacketRSSI; 6 | } 7 | } 8 | 9 | implementation { 10 | components CC2520RpiAmPacketMetadataP; 11 | components CC2520RpiRadioP as RadioP; 12 | 13 | CC2520RpiAmPacketMetadataP.PacketMetadata -> RadioP.PacketMetadata; 14 | 15 | PacketLinkQuality = CC2520RpiAmPacketMetadataP.PacketLinkQuality; 16 | PacketRSSI = CC2520RpiAmPacketMetadataP.PacketRSSI; 17 | } 18 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Interrupt/InterruptP.nc: -------------------------------------------------------------------------------- 1 | 2 | module InterruptP { 3 | uses { 4 | interface Boot; 5 | interface GpioInterrupt as Int; 6 | interface Timer as TimerMilliC; 7 | interface Leds; 8 | } 9 | } 10 | 11 | implementation { 12 | 13 | uint8_t p = 0; 14 | 15 | event void Boot.booted() { 16 | call Int.enableRisingEdge(); 17 | call TimerMilliC.startPeriodic(250); 18 | } 19 | 20 | async event void Int.fired () { 21 | call Leds.led1Toggle(); 22 | } 23 | 24 | event void TimerMilliC.fired () { 25 | call Leds.led0Toggle(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLedsBlip/RadioCountToLedsBlipC.nc: -------------------------------------------------------------------------------- 1 | #include "RadioCountToLedsBlip.h" 2 | 3 | configuration RadioCountToLedsBlipC {} 4 | implementation { 5 | components MainC, RadioCountToLedsBlipP as App, LedsC; 6 | components new TimerMilliC(); 7 | 8 | App.Boot -> MainC.Boot; 9 | 10 | App.Leds -> LedsC; 11 | App.MilliTimer -> TimerMilliC; 12 | 13 | components StaticIPAddressC; 14 | 15 | 16 | // Radio 17 | components IPStackC; 18 | components new UdpSocketC() as UDPService; 19 | App.RadioControl -> IPStackC; 20 | App.UDPService -> UDPService; 21 | 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /tinyos/apps/BorderRouter/BorderRouterP.nc: -------------------------------------------------------------------------------- 1 | 2 | module BorderRouterP @safe() { 3 | uses { 4 | interface Boot; 5 | 6 | interface SplitControl as RadioControl; 7 | interface RootControl; 8 | } 9 | } 10 | implementation { 11 | 12 | event void Boot.booted() { 13 | #if RPL_ROUTING 14 | call RootControl.setRoot(); 15 | #endif 16 | call RadioControl.start(); 17 | } 18 | 19 | event void RadioControl.startDone(error_t err) { 20 | if (err != SUCCESS) { 21 | call RadioControl.start(); 22 | } 23 | } 24 | 25 | event void RadioControl.stopDone (error_t e) { } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /tinyos/apps/SpiLockDebug/SpiLockDebugC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration SpiLockDebugC {} 3 | implementation { 4 | components MainC; 5 | components SpiLockDebugP as App; 6 | components LedsC; 7 | 8 | App.Boot -> MainC.Boot; 9 | App.Leds -> LedsC; 10 | 11 | // Radio/IP 12 | components IPStackC; 13 | App.RadioControl -> IPStackC; 14 | 15 | components BorderC; 16 | 17 | #ifdef RPL_ROUTING 18 | components RPLRoutingC; 19 | App.RootControl -> RPLRoutingC.RootControl; 20 | #endif 21 | 22 | components UDPShellC; 23 | 24 | components new TimerMilliC(); 25 | App.Timer -> TimerMilliC; 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /tinyos/apps/TSDemo2014BorderRouter/BorderRouterP.nc: -------------------------------------------------------------------------------- 1 | 2 | module BorderRouterP @safe() { 3 | uses { 4 | interface Boot; 5 | 6 | interface SplitControl as RadioControl; 7 | interface RootControl; 8 | } 9 | } 10 | implementation { 11 | 12 | event void Boot.booted() { 13 | #if RPL_ROUTING 14 | call RootControl.setRoot(); 15 | #endif 16 | call RadioControl.start(); 17 | } 18 | 19 | event void RadioControl.startDone(error_t err) { 20 | if (err != SUCCESS) { 21 | call RadioControl.start(); 22 | } 23 | } 24 | 25 | event void RadioControl.stopDone (error_t e) { } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520-interface/rev_b/interface_b.centroid: -------------------------------------------------------------------------------- 1 | # SMD component position file. 2 | # Created by centroid_smd.ulp 1.3.0. 3 | 4 | # Centroid Data for pc board: "interface_b.brd" as of: 12/30/13 1:11 AM 5 | # Measurements are in inches. 6 | # Comma delimited. 7 | # Only surface mount components included. 8 | 9 | RefDes,Layer,LocationX,LocationY,Rotation 10 | D1,Top,0.67000,0.04000,270 11 | D2,Top,0.87000,0.04000,270 12 | D3,Top,1.07000,0.04000,270 13 | J1,Bottom,0.20000,0.67000,90 14 | J2,Top,0.20000,0.67000,90 15 | R1,Bottom,0.67000,0.04500,180 16 | R2,Bottom,0.87000,0.04500,180 17 | R3,Bottom,1.07000,0.04500,180 18 | -------------------------------------------------------------------------------- /hardware/gerbmerge/rev_b/rev_b.def: -------------------------------------------------------------------------------- 1 | 2 | Row { 3 | Col { 4 | rpi-inter 5 | rpi-inter 6 | rpi-inter 7 | rpi-inter 8 | rpi-inter 9 | } 10 | Col { 11 | rpi-inter 12 | rpi-inter 13 | rpi-inter 14 | rpi-inter 15 | rpi-inter 16 | } 17 | Col { 18 | rpi-inter 19 | rpi-inter 20 | rpi-inter 21 | rpi-inter 22 | rpi-inter 23 | } 24 | Col { 25 | rpi-inter 26 | rpi-inter 27 | rpi-inter 28 | rpi-inter 29 | rpi-inter 30 | } 31 | Col { 32 | rpi-inter 33 | rpi-inter 34 | rpi-inter 35 | rpi-inter 36 | rpi-inter 37 | } 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/RandomLinuxC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* TinyOS interface for Random provided by the Linux random utilities. 3 | * Unfortunately the RandomC interface is wired to a particular random 4 | * number generator so if you want to use the Linux random you have to wire 5 | * to it explicitly. Boo TinyOS. 6 | */ 7 | 8 | configuration RandomLinuxC { 9 | provides { 10 | interface Init; 11 | interface ParameterInit as SeedInit; 12 | interface Random; 13 | } 14 | } 15 | 16 | implementation { 17 | components RandomLinuxP as Rand; 18 | 19 | Init = Rand.Init; 20 | SeedInit = Rand.SeedInit; 21 | Random = Rand.Random; 22 | } 23 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/timer/LocalTimeMilli32P.nc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Timer.h" 4 | 5 | module LocalTimeMilli32P { 6 | provides interface LocalTime as LocalTime; 7 | } 8 | implementation { 9 | 10 | async command uint32_t LocalTime.get() { 11 | struct timespec timer_val; 12 | int t_ret; 13 | uint32_t time_now = 0; 14 | 15 | t_ret = clock_gettime(CLOCK_MONOTONIC, &timer_val); 16 | 17 | if (t_ret == 0) { 18 | // get the time now in milliseconds 19 | time_now = (timer_val.tv_sec * 1000) + (timer_val.tv_nsec / 1000000); 20 | } 21 | 22 | return time_now; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /utils/identify_rpi.py: -------------------------------------------------------------------------------- 1 | import requests, time 2 | from uuid import getnode as get_mac 3 | import socket 4 | 5 | POST_URL = 'https://rpi-disc-gbns1w57rtvk.runscope.net' 6 | 7 | for i in range(0,10): 8 | 9 | macraw = get_mac() 10 | 11 | mactem = '{:0>12x}'.format(macraw) 12 | macfmt = ':'.join([mactem[i:i+2] for i in range(0, 12, 2)]) 13 | 14 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 15 | s.connect(('www.google.com', 0)) 16 | ipaddr = s.getsockname()[0] 17 | 18 | r = requests.post(POST_URL, 19 | data={"time":time.time(), "macaddr":macfmt, "ipaddr":ipaddr}) 20 | 21 | if r.status_code == 200: 22 | break 23 | 24 | time.sleep(10) 25 | 26 | -------------------------------------------------------------------------------- /tinyos/apps/ExtAddrTest/ExtAddrTestC.nc: -------------------------------------------------------------------------------- 1 | 2 | configuration ExtAddrTestC { } 3 | 4 | implementation { 5 | components ExtAddrTestP; 6 | components CC2420RadioC as MessageC; 7 | components MainC; 8 | components new TimerMilliC(); 9 | components LedsC; 10 | 11 | ExtAddrTestP.Boot -> MainC; 12 | ExtAddrTestP.Timer0 -> TimerMilliC; 13 | ExtAddrTestP.Leds -> LedsC; 14 | 15 | ExtAddrTestP.RadioControl -> MessageC.SplitControl; 16 | 17 | ExtAddrTestP.BarePacket -> MessageC.BarePacket; 18 | ExtAddrTestP.Ieee154Send -> MessageC.BareSend; 19 | ExtAddrTestP.Ieee154Receive -> MessageC.BareReceive; 20 | ExtAddrTestP.PacketLink -> MessageC.PacketLink; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tinyos/apps/tests/Interrupt2/Interrupt2P.nc: -------------------------------------------------------------------------------- 1 | 2 | module Interrupt2P { 3 | uses { 4 | interface Boot; 5 | interface GpioInterrupt as Int; 6 | interface Timer as TimerMilliC; 7 | interface Leds; 8 | interface HplBcm2835GeneralIO as Pin; 9 | } 10 | } 11 | 12 | implementation { 13 | 14 | uint8_t p = 0; 15 | 16 | event void Boot.booted() { 17 | call Pin.makeInput(); 18 | call Int.enableRisingEdge(); 19 | call TimerMilliC.startPeriodic(250); 20 | } 21 | 22 | async event void Int.fired () { 23 | call Leds.led1Toggle(); 24 | } 25 | 26 | event void TimerMilliC.fired () { 27 | call Leds.led0Toggle(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/BusyWaitMicroP.nc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | module BusyWaitMicroP { 4 | provides { 5 | interface BusyWait; 6 | } 7 | } 8 | 9 | implementation { 10 | 11 | async command void BusyWait.wait (uint16_t dt) { 12 | struct timeval now, pulse; 13 | int micros; 14 | 15 | gettimeofday(&pulse, NULL); 16 | micros = 0; 17 | 18 | while (micros < (int) dt) { 19 | gettimeofday(&now, NULL); 20 | if (now.tv_sec > pulse.tv_sec) { 21 | micros = 1000000L; 22 | } else { 23 | micros = 0; 24 | } 25 | micros = micros + (now.tv_usec - pulse.tv_usec); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/gap/LocalIeeeEui64C.nc: -------------------------------------------------------------------------------- 1 | 2 | module LocalIeeeEui64C { 3 | provides { 4 | interface LocalIeeeEui64; 5 | } 6 | } 7 | 8 | implementation { 9 | command ieee_eui64_t LocalIeeeEui64.getId () { 10 | int mac_addr_file; 11 | char buffer[17]; 12 | ieee_eui64_t eui; 13 | 14 | mac_addr_file = open("/sys/class/net/eth0/address", O_RDONLY); 15 | read(mac_addr_file, buffer, 17); 16 | 17 | sscanf(buffer, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", 18 | &eui.data[0], &eui.data[1], &eui.data[2], &eui.data[5], &eui.data[6], &eui.data[7]); 19 | eui.data[3] = 0xFF; 20 | eui.data[4] = 0xFE; 21 | eui.data[0] ^= 0x2; 22 | 23 | return eui; 24 | } 25 | } -------------------------------------------------------------------------------- /tinyos/apps/tests/Interrupt2/Interrupt2C.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Simple app to receive an interrupt and toggle an led. 3 | * 4 | * @author: Brad Campbell 5 | */ 6 | 7 | configuration Interrupt2C { 8 | } 9 | 10 | implementation { 11 | components Interrupt2P as InterruptP; 12 | components MainC; 13 | components LedsC; 14 | 15 | components Bcm2835InterruptC; 16 | components new TimerMilliC(); 17 | 18 | InterruptP.Int -> Bcm2835InterruptC.Port1_26; 19 | InterruptP.Boot -> MainC.Boot; 20 | InterruptP.TimerMilliC -> TimerMilliC; 21 | 22 | InterruptP.Leds -> LedsC; 23 | 24 | components HplBcm2835GeneralIOC as HplGpioC; 25 | InterruptP.Pin -> HplGpioC.Port1_26; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /tinyos/apps/SpiLockDebug/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=SpiLockDebugC 2 | 3 | PFLAGS += -DCC2520_DEF_CHANNEL=19 4 | 5 | # use rpl 6 | PFLAGS += -DRPL_ROUTING -DRPL_STORING_MODE -I$(LOWPAN_ROOT)/tos/lib/net/rpl 7 | # PFLAGS += -DRPL_OF_MRHOF 8 | 9 | # this works around fragmentation in the RX buffer pool 10 | PFLAGS += -DPPP_HDLC_RX_FRAME_LIMIT=1 -DPPP_HDLC_TX_FRAME_LIMIT=8 11 | 12 | # if you set this, the stack won't use dhcp to assign addresses -- it 13 | # will use this prefix combined with TOS_NODE_ID 14 | #PFLAGS += -DIN6_PREFIX=\"2607:f018:800a:bcde:f012:3456:7890::\" 15 | 16 | # derive short address from the dhcp address assignment, if possible 17 | #PFLAGS += -DBLIP_DERIVE_SHORTADDRS 18 | 19 | include $(MAKERULES) 20 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/gap/PlatformLedsC.nc: -------------------------------------------------------------------------------- 1 | #include "hardware.h" 2 | 3 | configuration PlatformLedsC { 4 | provides { 5 | interface GeneralIO as Led0; 6 | interface GeneralIO as Led1; 7 | interface GeneralIO as Led2; 8 | } 9 | uses { 10 | interface Init; 11 | } 12 | } 13 | implementation { 14 | // PlatformP will now specifically call the Init interface of PlatformLeds. 15 | components PlatformP; 16 | Init = PlatformP.LedsInit; 17 | 18 | components new LinuxLedP("gap:red:usr1") as l1; 19 | components new LinuxLedP("gap:green:usr0") as l0; 20 | components new LinuxLedP("gap:blue:usr2") as l2; 21 | 22 | Led0 = l0.GeneralIO; 23 | Led1 = l1.GeneralIO; 24 | Led2 = l2.GeneralIO; 25 | } 26 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/McuSleepP.nc: -------------------------------------------------------------------------------- 1 | #include "linux_atomic.h" 2 | 3 | module McuSleepP @safe() { 4 | provides { 5 | interface McuSleep; 6 | interface McuPowerState; 7 | } 8 | uses { 9 | interface McuPowerOverride; 10 | interface BlockingIO; 11 | } 12 | } 13 | 14 | implementation { 15 | 16 | mcu_power_t getPowerState() { 17 | return 0; 18 | } 19 | 20 | async command void McuSleep.sleep() { 21 | __nesc_enable_interrupt(); 22 | call BlockingIO.waitForIO(); 23 | __nesc_disable_interrupt(); 24 | } 25 | 26 | async command void McuPowerState.update() { 27 | } 28 | 29 | default async command mcu_power_t McuPowerOverride.lowestState() { 30 | return 1; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/socket/TcpSocket.nc: -------------------------------------------------------------------------------- 1 | 2 | /* This is a simple TinyOS interface for a TCP socket. 3 | * 4 | * @author: Brad Campbell 5 | */ 6 | 7 | interface TcpSocket { 8 | 9 | // Open a socket to a remote server. host can be an ip address or a hostname. 10 | command error_t connect (const char* host, uint16_t port); 11 | 12 | // Send a buffer to the remove host. This function will loop until all of the 13 | // data is sent. 14 | command error_t send (uint8_t* buf, uint16_t len); 15 | 16 | // Close the connection to the server. 17 | command error_t close (); 18 | 19 | // Callback when data comes in on the socket. 20 | event void receive(uint8_t* msg, int msglen); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /tinyos/apps/NodeCollect/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=NodeCollectC 2 | 3 | PFLAGS += -DCC2420_DEF_CHANNEL=19 4 | PFLAGS += -DCC2520_DEF_CHANNEL=19 5 | # use rpl 6 | PFLAGS += -DRPL_ROUTING -DRPL_STORING_MODE -I$(LOWPAN_ROOT)/tos/lib/net/rpl 7 | # PFLAGS += -DRPL_OF_MRHOF 8 | 9 | # this works around fragmentation in the RX buffer pool 10 | PFLAGS += -DPPP_HDLC_RX_FRAME_LIMIT=1 -DPPP_HDLC_TX_FRAME_LIMIT=8 11 | 12 | # if you set this, the stack won't use dhcp to assign addresses -- it 13 | # will use this prefix combined with TOS_NODE_ID 14 | #PFLAGS += -DIN6_PREFIX=\"2607:f018:800a:bcde:f012:3456:7890::\" 15 | 16 | # derive short address from the dhcp address assignment, if possible 17 | #PFLAGS += -DBLIP_DERIVE_SHORTADDRS 18 | 19 | include $(MAKERULES) 20 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/socket/PersistentTcpConnectionC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Instantiate this component to create a TCP socket that will reconnect itself 3 | * if the connection is lost. This component basically wraps the linux socket 4 | * utilities into a nice TinyOS form. 5 | * 6 | * @author: Brad Campbell 7 | */ 8 | 9 | generic configuration PersistentTcpConnectionC () { 10 | provides { 11 | interface TcpSocket; 12 | } 13 | } 14 | 15 | implementation { 16 | components new PersistentTcpConnectionP() as TcpConnP; 17 | components new TimerMilliC() as ReconnectTimer; 18 | components new IOFileC() as IOF; 19 | 20 | TcpConnP.ReconnectTimer -> ReconnectTimer.Timer; 21 | TcpConnP.IO -> IOF.IO; 22 | 23 | TcpSocket = TcpConnP.TcpSocket; 24 | } 25 | -------------------------------------------------------------------------------- /tinyos/apps/BorderRouter/BorderRouterC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Basic component includes for a general purpose border router. 3 | * 4 | * @author Brad Campbell 5 | */ 6 | 7 | configuration BorderRouterC {} 8 | implementation { 9 | components MainC; 10 | components BorderRouterP as App; 11 | 12 | App.Boot -> MainC.Boot; 13 | 14 | // Radio/IP 15 | components IPStackC; 16 | App.RadioControl -> IPStackC; 17 | 18 | components BorderC; 19 | 20 | // If we want to use static addressing 21 | // components StaticIPAddressC; 22 | 23 | // Uncomment to use DHCP 24 | // components Dhcp6C; 25 | 26 | 27 | #ifdef RPL_ROUTING 28 | components RPLRoutingC; 29 | App.RootControl -> RPLRoutingC.RootControl; 30 | #endif 31 | 32 | components UDPShellC; 33 | } 34 | -------------------------------------------------------------------------------- /tinyos/apps/NodeCollect/NodeCollectC.nc: -------------------------------------------------------------------------------- 1 | 2 | // app for a data collection node in a wsn 3 | 4 | configuration NodeCollectC {} 5 | implementation { 6 | components MainC, NodeCollectP as App, LedsC; 7 | components new TimerMilliC(); 8 | 9 | App.Boot -> MainC.Boot; 10 | 11 | App.Leds -> LedsC; 12 | App.MilliTimer -> TimerMilliC; 13 | 14 | // Radio 15 | components IPStackC; 16 | components new UdpSocketC() as UDPService; 17 | App.RadioControl -> IPStackC.SplitControl; 18 | App.UDPService -> UDPService.UDP; 19 | // App.ForwardingTable -> IPStackC.ForwardingTable; 20 | 21 | #ifdef RPL_ROUTING 22 | components RPLRoutingC; 23 | #endif 24 | 25 | #ifdef PRINTFUART_ENABLED 26 | components PrintfC; 27 | components SerialStartC; 28 | #endif 29 | 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/Ieee154BareC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Provides an abstraction layer for complete access to an 802.15.4 packet 3 | * buffer. Packets provided to this module will be interpreted as 802.15.4 4 | * frames and will have the sequence number set. All other fields must be set 5 | * by upper layers. 6 | */ 7 | 8 | configuration Ieee154BareC { 9 | provides { 10 | interface SplitControl; 11 | 12 | interface Packet as BarePacket; 13 | interface Send as BareSend; 14 | interface Receive as BareReceive; 15 | } 16 | } 17 | 18 | implementation { 19 | components RadioSelectC; 20 | 21 | SplitControl = RadioSelectC.SplitControl; 22 | 23 | BarePacket = RadioSelectC.Packet; 24 | BareSend = RadioSelectC.Send; 25 | BareReceive = RadioSelectC.Receive; 26 | } 27 | -------------------------------------------------------------------------------- /tinyos/apps/TSDemo2014BorderRouter/TSDemo2014BorderRouterC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Basic component includes for a general purpose border router. 3 | * 4 | * @author Brad Campbell 5 | */ 6 | 7 | configuration BorderRouterC {} 8 | implementation { 9 | components MainC; 10 | components BorderRouterP as App; 11 | 12 | App.Boot -> MainC.Boot; 13 | 14 | // Radio/IP 15 | components IPStackC; 16 | App.RadioControl -> IPStackC; 17 | 18 | components BorderC; 19 | 20 | // If we want to use static addressing 21 | components StaticIPAddressC; 22 | 23 | 24 | // Uncomment to use DHCP 25 | // components Dhcp6C; 26 | 27 | 28 | #ifdef RPL_ROUTING 29 | components RPLRoutingC; 30 | App.RootControl -> RPLRoutingC.RootControl; 31 | #endif 32 | 33 | components UDPShellC; 34 | } 35 | -------------------------------------------------------------------------------- /tinyos/apps/SimpleSackTest/SimpleSackTestAppC.nc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SimpleSackTest.h" 3 | 4 | configuration SimpleSackTestAppC { 5 | } 6 | implementation { 7 | components MainC; 8 | components LedsC; 9 | components SimpleSackTestC as App; 10 | components new TimerMilliC() as Timer0; 11 | 12 | components CC2420Ieee154MessageC as RadioC; 13 | 14 | App.Ieee154Send -> RadioC.Ieee154Send; 15 | App.Ieee154Receive -> RadioC.Ieee154Receive; 16 | App.Ieee154Packet -> RadioC.Ieee154Packet; 17 | App.RadioControl -> RadioC.SplitControl; 18 | App.Packet -> RadioC.Packet; 19 | App.PacketAcknowledgements -> RadioC.PacketAcknowledgements; 20 | App.CC2420Config -> RadioC.CC2420Config; 21 | 22 | App.Boot -> MainC; 23 | App.Leds -> LedsC; 24 | App.Timer0 -> Timer0; 25 | } 26 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/CC2520LinuxReceiveC.nc: -------------------------------------------------------------------------------- 1 | /* 2 | * Packet receive path for the CC2520 3 | * 4 | * @author: Brad Campbell 5 | */ 6 | 7 | generic configuration CC2520LinuxReceiveC (char char_dev_path[]) { 8 | provides { 9 | interface BareReceive; 10 | } 11 | uses { 12 | interface PacketMetadata; 13 | } 14 | } 15 | 16 | implementation { 17 | 18 | components MainC; 19 | 20 | components new CC2520LinuxReceiveP(char_dev_path) as ReceiveP; 21 | components new IOFileC(); 22 | components UnixTimeC; 23 | 24 | MainC.SoftwareInit -> ReceiveP.SoftwareInit; 25 | 26 | ReceiveP.IO -> IOFileC.IO; 27 | ReceiveP.UnixTime -> UnixTimeC.UnixTime; 28 | 29 | ReceiveP.PacketMetadata = PacketMetadata; 30 | 31 | BareReceive = ReceiveP.BareReceive; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/uart/UartC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Provides an easy way to read from the serial port /dev/ttyAMA0 on the RPi. 3 | * Be sure to check that the serial port isn't being used by the kernel, etc. 4 | * if you get errors. 5 | */ 6 | 7 | configuration UartC { 8 | provides { 9 | interface UartBuffer; 10 | interface UartConfig; 11 | } 12 | } 13 | 14 | implementation { 15 | components UartP; 16 | components MainC; 17 | components new IOFileC(); 18 | components UnixTimeC; 19 | components HplBcm2835GeneralIOC; 20 | 21 | MainC.SoftwareInit -> UartP.SoftwareInit; 22 | 23 | UartP.IO -> IOFileC.IO; 24 | UartP.UnixTime -> UnixTimeC.UnixTime; 25 | UartP.RXPin -> HplBcm2835GeneralIOC.Port1_10; 26 | 27 | UartBuffer = UartP.UartBuffer; 28 | UartConfig = UartP.UartConfig; 29 | } 30 | -------------------------------------------------------------------------------- /tinyos/support/make/arm-linux/scp.extra: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | # Adding 'install scp' to the command line will automatically scp the exe to an 3 | # rpi 4 | 5 | ifndef SCP 6 | $(warning $(shell echo -e '$(WARN_STRING) No RPi target given. Cannot install.')) 7 | BUILD_DEPS = tinyos_image 8 | else 9 | BUILD_DEPS = program 10 | endif 11 | 12 | # Check if a number was given or something else 13 | NUMBER_CHECK := $(shell python -c "import sys; int(sys.argv[1]); print('number')" $(SCP) 2>&1) 14 | 15 | # Set the rpi hostname 16 | ifeq ($(NUMBER_CHECK), number) 17 | RPI_ID = rpi$(SCP) 18 | else 19 | RPI_ID = $(SCP) 20 | endif 21 | 22 | program: setid FORCE 23 | @echo -e '$(INFO_STRING) Installing rpi binary to $(RPI_ID)' 24 | @scp $(TOSMAKE_BUILD_DIR)/main.exe $(RPI_ID):~/$(notdir $(COMPONENT)) 25 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/rpi/RadioSelectC.nc: -------------------------------------------------------------------------------- 1 | /* Use this module to choose which radio on RPi to use. 2 | */ 3 | configuration RadioSelectC { 4 | provides { 5 | interface SplitControl; 6 | 7 | interface Send; 8 | interface Receive; 9 | interface Packet; 10 | interface LowPowerListening; 11 | interface PacketMetadata; 12 | interface Ieee154Address; 13 | } 14 | } 15 | 16 | implementation { 17 | 18 | components new CC2520LinuxRadioC("/dev/radio") as RadioC; 19 | 20 | SplitControl = RadioC.SplitControl; 21 | Send = RadioC.Send; 22 | Receive = RadioC.Receive; 23 | Packet = RadioC.Packet; 24 | LowPowerListening = RadioC.LowPowerListening; 25 | PacketMetadata = RadioC.PacketMetadata; 26 | Ieee154Address = RadioC.Ieee154Address; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLedsBlip/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=RadioCountToLedsBlipC 2 | 3 | 4 | CFLAGS += -DCC2420_DEF_CHANNEL=18 5 | CFLAGS += -DCC2420X_DEF_CHANNEL=18 6 | CFLAGS += -DCC2520_DEF_CHANNEL=18 7 | 8 | # use rpl 9 | PFLAGS += -DRPL_ROUTING -DRPL_STORING_MODE -I$(LOWPAN_ROOT)/tos/lib/net/rpl 10 | # PFLAGS += -DRPL_OF_MRHOF 11 | 12 | # this works around fragmentation in the RX buffer pool 13 | PFLAGS += -DPPP_HDLC_RX_FRAME_LIMIT=1 -DPPP_HDLC_TX_FRAME_LIMIT=8 14 | 15 | # if you set this, the stack won't use dhcp to assign addresses -- it 16 | # will use this prefix combined with TOS_NODE_ID 17 | PFLAGS += -DIN6_PREFIX=\"2001:638:709:1234::fffe:\" 18 | 19 | # derive short address from the dhcp address assignment, if possible 20 | PFLAGS += -DBLIP_DERIVE_SHORTADDRS 21 | 22 | TINYOS_ROOT_DIR?=../.. 23 | include $(TINYOS_ROOT_DIR)/Makefile.include 24 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_xy.csv: -------------------------------------------------------------------------------- 1 | # Centroid Data for pc board: "rpi-cc2520_a.brd" as of: 7/19/13 11:33 PM 2 | # Measurements are in inches. Comma delimited 3 | # Only surface mount components included 4 | 5 | RefDes,Layer,LocationX,LocationY,Rotation 6 | B1,Top,0.650,0.705,0 7 | C1,Top,0.330,0.540,270 8 | C2,Top,0.615,0.595,0 9 | C3,Top,0.550,0.870,270 10 | C4,Top,0.330,0.870,180 11 | C5,Top,0.465,0.270,270 12 | C6,Top,0.435,0.495,0 13 | C7,Top,0.535,0.495,180 14 | D1,Top,0.405,0.050,270 15 | D2,Top,0.555,0.050,270 16 | D3,Top,0.705,0.050,270 17 | L1,Top,0.380,0.270,270 18 | P1,Top,0.485,1.125,45 19 | R1,Top,0.405,0.100,0 20 | R2,Top,0.555,0.100,0 21 | R3,Top,0.705,0.100,0 22 | R4,Top,0.300,0.970,270 23 | R5,Top,0.485,0.870,270 24 | R6,Top,0.600,0.190,90 25 | U1,Top,0.435,0.705,0 26 | U2,Top,0.700,0.205,180 27 | X1,Top,0.485,0.405,180 28 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/CC2520RpiAmUniqueP.nc: -------------------------------------------------------------------------------- 1 | 2 | // Sets the sequence number 3 | 4 | module CC2520RpiAmUniqueP { 5 | provides { 6 | interface BareSend as Send; 7 | interface Init; 8 | } 9 | uses { 10 | interface BareSend as SubSend; 11 | } 12 | } 13 | 14 | implementation { 15 | 16 | uint8_t seq_no; 17 | 18 | command error_t Init.init () { 19 | seq_no = TOS_NODE_ID << 4; 20 | return SUCCESS; 21 | } 22 | 23 | command error_t Send.send (message_t* msg) { 24 | uint8_t* msg_ptr = (uint8_t*) msg; 25 | msg_ptr[3] = seq_no++; 26 | return call SubSend.send(msg); 27 | } 28 | 29 | command error_t Send.cancel (message_t* msg) { 30 | return call SubSend.cancel(msg); 31 | } 32 | 33 | event void SubSend.sendDone (message_t* msg, error_t error) { 34 | signal Send.sendDone(msg, error); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/rpi/PlatformLedsC.nc: -------------------------------------------------------------------------------- 1 | #include "hardware.h" 2 | 3 | configuration PlatformLedsC { 4 | provides { 5 | interface GeneralIO as Led0; 6 | interface GeneralIO as Led1; 7 | interface GeneralIO as Led2; 8 | } 9 | uses { 10 | interface Init; 11 | } 12 | } 13 | implementation { 14 | // PlatformP will now specifically 15 | // call the Init interface of PlatformLeds. 16 | components PlatformP; 17 | components HplBcm2835GeneralIOC as GeneralIOC; 18 | 19 | components new Bcm2835GpioC() as Led0Impl; 20 | components new Bcm2835GpioC() as Led1Impl; 21 | components new Bcm2835GpioC() as Led2Impl; 22 | 23 | Init = PlatformP.LedsInit; 24 | 25 | Led0Impl.IO -> GeneralIOC.Port1_07; 26 | Led1Impl.IO -> GeneralIOC.Port1_12; 27 | Led2Impl.IO -> GeneralIOC.Port1_13; 28 | 29 | Led0 = Led0Impl; 30 | Led1 = Led1Impl; 31 | Led2 = Led2Impl; 32 | } 33 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/RadioPacketMetadataC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Wrapper config for interfaces that operate on the metadata level of a packet. 3 | * This is designed for BLIP, and any radio that wishes to support BLIP needs 4 | * to create this configuration and provide these interfaces. 5 | * 6 | * @author Brad Campbell 7 | */ 8 | 9 | configuration RadioPacketMetadataC { 10 | provides { 11 | interface LowPowerListening; 12 | interface PacketLink; 13 | interface PacketAcknowledgements; 14 | } 15 | } 16 | 17 | implementation { 18 | components RadioSelectC; 19 | components RadioPacketMetadataP; 20 | 21 | RadioPacketMetadataP.PacketMetadata -> RadioSelectC.PacketMetadata; 22 | 23 | LowPowerListening = RadioSelectC.LowPowerListening; 24 | PacketLink = RadioPacketMetadataP.PacketLink; 25 | PacketAcknowledgements = RadioPacketMetadataP.PacketAcknowledgements; 26 | } 27 | -------------------------------------------------------------------------------- /tinyos/apps/BorderRouter/TunNameP.nc: -------------------------------------------------------------------------------- 1 | /* Get the TUN name from the command line options 2 | * 3 | * @author Brad Campbell 4 | */ 5 | 6 | module TunNameP { 7 | provides { 8 | interface TunName; 9 | } 10 | uses { 11 | interface CommandLineArgs; 12 | } 13 | } 14 | 15 | implementation { 16 | 17 | command char* TunName.getTunName () { 18 | uint8_t argc; 19 | uint8_t i; 20 | 21 | argc = call CommandLineArgs.count(); 22 | 23 | // Iterate through the arguments, skipping the name of the executable 24 | for (i=1; i i+1) { 30 | return call CommandLineArgs.getArg(i+1); 31 | } 32 | } 33 | } 34 | 35 | return "\0"; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/RandomLinuxP.nc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | module RandomLinuxP @safe() { 6 | provides { 7 | interface Init; 8 | interface ParameterInit as SeedInit; 9 | interface Random; 10 | } 11 | } 12 | implementation { 13 | 14 | command error_t Init.init () { 15 | unsigned int iseed; 16 | 17 | iseed = (unsigned int) time(NULL); 18 | srand(iseed); 19 | 20 | return SUCCESS; 21 | } 22 | 23 | command error_t SeedInit.init (uint16_t s) { 24 | srand((unsigned int) s); 25 | 26 | return SUCCESS; 27 | } 28 | 29 | // Return the next 32 bit random number 30 | async command uint32_t Random.rand32 () { 31 | return (uint32_t) rand(); 32 | } 33 | 34 | // Return low 16 bits of next 32 bit random number 35 | async command uint16_t Random.rand16 () { 36 | return (uint16_t) rand(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /tinyos/apps/TSDemo2014BorderRouter/TunNameP.nc: -------------------------------------------------------------------------------- 1 | /* Get the TUN name from the command line options 2 | * 3 | * @author Brad Campbell 4 | */ 5 | 6 | module TunNameP { 7 | provides { 8 | interface TunName; 9 | } 10 | uses { 11 | interface CommandLineArgs; 12 | } 13 | } 14 | 15 | implementation { 16 | 17 | command char* TunName.getTunName () { 18 | uint8_t argc; 19 | uint8_t i; 20 | 21 | argc = call CommandLineArgs.count(); 22 | 23 | // Iterate through the arguments, skipping the name of the executable 24 | for (i=1; i i+1) { 30 | return call CommandLineArgs.getArg(i+1); 31 | } 32 | } 33 | } 34 | 35 | return "\0"; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /tinyos/tos/chips/bcm2835/gpio/Bcm2835GpioC.nc: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Implementation of the general-purpose I/O abstraction 4 | * for the Raspberry Pi 5 | * 6 | * @author Brad Campbell 7 | */ 8 | 9 | generic module Bcm2835GpioC() @safe() { 10 | provides interface GeneralIO; 11 | uses interface HplBcm2835GeneralIO as IO; 12 | } 13 | 14 | implementation { 15 | async command void GeneralIO.set() { call IO.set(); } 16 | async command void GeneralIO.clr() { call IO.clr(); } 17 | async command void GeneralIO.toggle() { call IO.toggle(); } 18 | async command bool GeneralIO.get() { return call IO.get(); } 19 | async command void GeneralIO.makeInput() { call IO.makeInput(); } 20 | async command bool GeneralIO.isInput() { return call IO.isInput(); } 21 | async command void GeneralIO.makeOutput() { call IO.makeOutput(); } 22 | async command bool GeneralIO.isOutput() { return call IO.isOutput(); } 23 | } 24 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/gap/RadioSelectC.nc: -------------------------------------------------------------------------------- 1 | /* Use this module to choose which radio on GAP to use. 2 | */ 3 | configuration RadioSelectC { 4 | provides { 5 | interface SplitControl; 6 | 7 | interface Send; 8 | interface Receive; 9 | interface Packet; 10 | interface LowPowerListening; 11 | interface PacketMetadata; 12 | interface Ieee154Address; 13 | } 14 | } 15 | 16 | implementation { 17 | 18 | #if GAP_RADIO_SELECT == 0 19 | components new CC2520LinuxRadioC("/dev/cc2520_0") as RadioC; 20 | #elif GAP_RADIO_SELECT == 1 21 | components new CC2520LinuxRadioC("/dev/cc2520_1") as RadioC; 22 | #endif 23 | 24 | SplitControl = RadioC.SplitControl; 25 | Send = RadioC.Send; 26 | Receive = RadioC.Receive; 27 | Packet = RadioC.Packet; 28 | LowPowerListening = RadioC.LowPowerListening; 29 | PacketMetadata = RadioC.PacketMetadata; 30 | Ieee154Address = RadioC.Ieee154Address; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/time/UnixTimeP.nc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | module UnixTimeP { 4 | provides { 5 | interface UnixTime; 6 | } 7 | } 8 | 9 | implementation { 10 | async command uint32_t UnixTime.getSeconds () { 11 | return (uint32_t) time(NULL); 12 | } 13 | 14 | async command uint64_t UnixTime.getMilliseconds () { 15 | int ret; 16 | struct timeval tv; 17 | uint64_t unix_time = 0; 18 | 19 | ret = gettimeofday(&tv, NULL); 20 | if (ret == 0) { 21 | unix_time = (((uint64_t) tv.tv_sec) * 1000) + 22 | (((uint64_t) tv.tv_usec) / 1000); 23 | } 24 | return unix_time; 25 | } 26 | 27 | async command uint64_t UnixTime.getMicroseconds () { 28 | int ret; 29 | struct timeval tv; 30 | uint64_t unix_time = 0; 31 | 32 | ret = gettimeofday(&tv, NULL); 33 | if (ret == 0) { 34 | unix_time = (((uint64_t) tv.tv_sec) * 1000000) + ((uint64_t) tv.tv_usec); 35 | } 36 | return unix_time; 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /tinyos/apps/SpiLockDebug/SpiLockDebugP.nc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | module SpiLockDebugP @safe() { 7 | uses { 8 | interface Boot; 9 | interface Leds; 10 | 11 | interface SplitControl as RadioControl; 12 | 13 | interface RootControl; 14 | 15 | interface Timer as Timer; 16 | } 17 | } 18 | implementation { 19 | 20 | event void Boot.booted() { 21 | #ifdef RPL_ROUTING 22 | call RootControl.setRoot(); 23 | #endif 24 | call RadioControl.start(); 25 | } 26 | 27 | event void RadioControl.startDone(error_t err) { 28 | if (err != SUCCESS) { 29 | call RadioControl.start(); 30 | } else { 31 | call Timer.startOneShot(10000u); 32 | } 33 | } 34 | 35 | event void Timer.fired () { 36 | printf("DEBUG: stopping radio.\b"); 37 | call RadioControl.stop(); 38 | } 39 | 40 | event void RadioControl.stopDone (error_t e) { 41 | call RadioControl.start(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /tinyos/apps/Node/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=NodeC 2 | 3 | PFLAGS += -DCC2420_DEF_CHANNEL=21 4 | PFLAGS += -DCC2520_DEF_CHANNEL=21 5 | 6 | ### 7 | ### Set the addressing scheme 8 | ### 9 | # Use IN6_PREFIX with static addressing modes 10 | #PFLAGS += -DIN6_PREFIX="\"::\"" 11 | PFLAGS += -DBLIP_ADDR_AUTOCONF=1 12 | PFLAGS += -DRPL_ADDR_AUTOCONF=0 13 | 14 | ### 15 | ### Configure BLIP 16 | ### 17 | PFLAGS += -DBLIP_SEND_ROUTER_SOLICITATIONS=1 18 | PFLAGS += -DBLIP_SEND_ROUTER_ADVERTISEMENTS=0 19 | 20 | # derive short address from the dhcp address assignment, if possible 21 | #PFLAGS += -DBLIP_DERIVE_SHORTADDRS 22 | 23 | ### 24 | ### Configure RPL 25 | ### 26 | #PFLAGS += -DRPL_ROUTING=0 27 | PFLAGS += -DRPL_STORING_MODE=1 -I%T/lib/net/rpl 28 | PFLAGS += -DRPL_OF_0=1 29 | PFLAGS += -DRPL_OF_MRHOF=0 30 | 31 | # this works around fragmentation in the RX buffer pool 32 | PFLAGS += -DPPP_HDLC_RX_FRAME_LIMIT=1 -DPPP_HDLC_TX_FRAME_LIMIT=8 33 | 34 | GOALS += blip 35 | 36 | TINYOS_ROOT_DIR?=../.. 37 | include $(TINYOS_ROOT_DIR)/Makefile.include 38 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/tunindex.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "strconv" 5 | "strings" 6 | "sync" 7 | ) 8 | 9 | const TUN_ID_MIN = 0 10 | const TUN_ID_MAX = 15 11 | 12 | type TunManager struct { 13 | tunset map[int]bool 14 | lock sync.Mutex 15 | 16 | } 17 | 18 | // Returns tunX 19 | func (t *TunManager) getNewTunName () (tunid string) { 20 | t.lock.Lock() 21 | 22 | var tunidint int 23 | 24 | for i:=TUN_ID_MIN; i<=TUN_ID_MAX; i++ { 25 | if !t.tunset[i] { 26 | t.tunset[i] = true 27 | tunidint = i 28 | break 29 | } 30 | } 31 | 32 | tunid = "tun" + strconv.Itoa(tunidint) 33 | 34 | t.lock.Unlock() 35 | return 36 | } 37 | 38 | func (t *TunManager) unsetTunName (tunid string) { 39 | t.lock.Lock() 40 | 41 | tunidstr := strings.TrimLeft(tunid, "tun") 42 | tunidint, _ := strconv.Atoi(tunidstr) 43 | t.tunset[tunidint] = false 44 | 45 | t.lock.Unlock() 46 | } 47 | 48 | // Manages which TUN ids are free and not 49 | func CreateTunIds () (*TunManager) { 50 | var t TunManager 51 | t.tunset = make(map[int]bool) 52 | 53 | return &t 54 | } 55 | -------------------------------------------------------------------------------- /tinyos/apps/tests/BareReceive/BareReceiveP.nc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | module BareReceiveP { 5 | uses { 6 | interface Leds; 7 | interface Boot; 8 | 9 | interface SplitControl as RadioControl; 10 | interface Packet as RadioPacket; 11 | interface Send as RadioSend; 12 | interface Receive as RadioReceive; 13 | } 14 | } 15 | implementation { 16 | 17 | uint32_t count = 0; 18 | 19 | event void Boot.booted() { 20 | call RadioControl.start(); 21 | } 22 | 23 | event void RadioControl.startDone (error_t error) { 24 | } 25 | 26 | event void RadioSend.sendDone (message_t* message, error_t error) { 27 | } 28 | 29 | event message_t* RadioReceive.receive(message_t* packet, 30 | void* payload, uint8_t len) { 31 | 32 | int i; 33 | printf("%05i got packet (%i): 0x", count++, len); 34 | for (i=0; i 12 | */ 13 | 14 | configuration TunC { 15 | provides { 16 | interface IPForward; 17 | } 18 | } 19 | 20 | implementation { 21 | components TunP; 22 | components MainC; 23 | components new IOFileC(); 24 | components IPAddressC; 25 | components TunNameC; 26 | 27 | TunP.IO -> IOFileC.IO; 28 | 29 | // Anytime the IP address of the border router changes we need to know. 30 | // This will let us update the route to and ipv6 address of the TUN device. 31 | TunP.IPAddress -> IPAddressC.IPAddress; 32 | 33 | TunP.TunName -> TunNameC.TunName; 34 | 35 | MainC.SoftwareInit -> TunP.SoftwareInit; 36 | 37 | IPForward = TunP.IPForward; 38 | } 39 | -------------------------------------------------------------------------------- /tinyos/tos/chips/bcm2835/spi/RpiSpiC.nc: -------------------------------------------------------------------------------- 1 | 2 | 3 | //#include 4 | 5 | generic configuration RpiSpiC(uint8_t chip_enable) 6 | { 7 | provides 8 | { 9 | interface Resource; 10 | interface SpiByte; 11 | interface FastSpiByte; 12 | interface SpiPacket; 13 | interface HplRpiSpiChipSelConfig; 14 | } 15 | uses { 16 | interface Init as SpiInit; 17 | interface ResourceConfigure; 18 | } 19 | } 20 | implementation 21 | { 22 | enum { 23 | CLIENT_ID = unique(RPI_SPI_BUS), 24 | }; 25 | 26 | components HilRpiSpiC as SpiC; 27 | SpiC.SpiChipInit = SpiInit; 28 | Resource = SpiC.Resource[CLIENT_ID]; 29 | SpiByte = SpiC.SpiByte[CLIENT_ID]; 30 | FastSpiByte = SpiC.FastSpiByte[CLIENT_ID]; 31 | SpiPacket = SpiC.SpiPacket[CLIENT_ID]; 32 | HplRpiSpiChipSelConfig = SpiC.HplRpiSpiChipSelConfig[chip_enable]; 33 | 34 | components new RpiSpiP(chip_enable); 35 | ResourceConfigure = RpiSpiP.ResourceConfigure; 36 | RpiSpiP.SubResourceConfigure <- SpiC.ResourceConfigure[CLIENT_ID]; 37 | RpiSpiP.HplRpiSpiConfig -> SpiC.HplRpiSpiConfig; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a.centroid: -------------------------------------------------------------------------------- 1 | # SMD component position file. 2 | # Created by centroid_smd.ulp 1.3.0. 3 | 4 | <<<<<<< HEAD 5 | # Centroid Data for pc board: "rpi-cc2520_a.brd" as of: 1/9/14 12:16 AM 6 | ======= 7 | # Centroid Data for pc board: "rpi-cc2520_a.brd" as of: 12/30/13 1:04 AM 8 | >>>>>>> 2446e36909c50613084ff1ce758806e6b2feee4e 9 | # Measurements are in inches. 10 | # Comma delimited. 11 | # Only surface mount components included. 12 | 13 | RefDes,Layer,LocationX,LocationY,Rotation 14 | B1,Top,0.65000,0.70500,0 15 | C1,Top,0.33000,0.54000,270 16 | C2,Top,0.61500,0.59500,0 17 | C3,Top,0.55000,0.87000,270 18 | C4,Top,0.33000,0.87000,180 19 | C5,Top,0.46500,0.27000,270 20 | C6,Top,0.43500,0.49500,0 21 | C7,Top,0.53500,0.49500,180 22 | D1,Top,0.40500,0.05000,270 23 | D2,Top,0.55500,0.05000,270 24 | D3,Top,0.70500,0.05000,270 25 | L1,Top,0.38000,0.27000,270 26 | P1,Top,0.48500,1.12500,45 27 | R1,Top,0.40500,0.10000,0 28 | R2,Top,0.55500,0.10000,0 29 | R3,Top,0.70500,0.10000,0 30 | R4,Top,0.30000,0.97000,270 31 | R5,Top,0.48500,0.87000,270 32 | R6,Top,0.60000,0.19000,90 33 | U1,Top,0.43500,0.70500,0 34 | U2,Top,0.70000,0.20500,180 35 | X1,Top,0.48500,0.40500,180 36 | -------------------------------------------------------------------------------- /tinyos/support/make/platforms/gap.platform: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | 3 | PFLAGS += -I%T/platforms/armlinux 4 | PFLAGS += -I%T/platforms/gap 5 | PFLAGS += -I%T/platforms/gap/chips/cc2520linux 6 | PFLAGS += -I%T/chips/cc2520linux 7 | PFLAGS += -I%T/chips/linux 8 | PFLAGS += -I%T/chips/linux/socket 9 | PFLAGS += -I%T/chips/linux/time 10 | PFLAGS += -I%T/chips/linux/timer 11 | PFLAGS += -I%T/chips/linux/tun 12 | PFLAGS += -I%T/chips/linux/uart 13 | PFLAGS += -I%T/interfaces 14 | PFLAGS += -I%T/lib/net/blip 15 | 16 | PFLAGS += -I%T/../support/sdk/c/linux 17 | PFLAGS += %T/../support/sdk/c/linux/file_helpers.c 18 | 19 | PFLAGS += -I%T/../support/sdk/c/ini 20 | PFLAGS += %T/../support/sdk/c/ini/ini.c 21 | 22 | PFLAGS += -I%T/lib/timer 23 | PFLAGS += -I%T/lib/serial 24 | PFLAGS += -I%T/lib/power 25 | PFLAGS += -I%T/lib/rfxlink/layers 26 | PFLAGS += -I%T/lib/rfxlink/util 27 | PFLAGS += -I%T/lib/onewire 28 | PFLAGS += -I%T/lib/printf 29 | 30 | PFLAGS += -mcpu=arm1176jzf-s 31 | PFLAGS += -fnesc-target=env 32 | 33 | export NESC_MACHINE = structure_size_boundary=32, pointer=4,4 float=4,4 double=8,4 long_double=8,4 short=2,2 int=4,4 long=4,4 long_long=8,4 int1248_align=1,2,4,4 wchar_size_size=4,4 char_wchar_signed=false,true 34 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/gap/PlatformP.nc: -------------------------------------------------------------------------------- 1 | #include "hardware.h" 2 | #include "debug_printf.h" 3 | #include 4 | 5 | module PlatformP { 6 | provides { 7 | interface Init; 8 | } 9 | uses { 10 | //interface Init as GpioInit; 11 | interface Init as LedsInit; 12 | interface Init as InterruptInit; 13 | interface Leds; 14 | } 15 | } 16 | implementation { 17 | 18 | void sigint_handler (int sig) { 19 | RPI_PRINTF("Shuting down.\n"); 20 | call Leds.led0Off(); 21 | call Leds.led1Off(); 22 | call Leds.led2Off(); 23 | 24 | exit(0); 25 | } 26 | 27 | command error_t Init.init() { 28 | 29 | setvbuf(stdout, NULL, _IONBF, 0); 30 | 31 | RPI_PRINTF("Bringing system online.\n"); 32 | //call GpioInit.init(); 33 | call LedsInit.init(); 34 | call InterruptInit.init(); 35 | 36 | RPI_PRINTF("Setting SIGINT signal handler.\n"); 37 | __nesc_keyword_signal(SIGINT, sigint_handler); 38 | 39 | return SUCCESS; 40 | } 41 | 42 | // Fallback interface for LEDs if LedsC is not 43 | // used. 44 | default command error_t LedsInit.init() { 45 | return SUCCESS; 46 | } 47 | 48 | default command error_t InterruptInit.init() { 49 | return SUCCESS; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/rpi/PlatformP.nc: -------------------------------------------------------------------------------- 1 | #include "hardware.h" 2 | #include "debug_printf.h" 3 | #include 4 | 5 | module PlatformP { 6 | provides { 7 | interface Init; 8 | } 9 | uses { 10 | interface Init as GpioInit; 11 | interface Init as LedsInit; 12 | interface Init as InterruptInit; 13 | interface Leds; 14 | } 15 | } 16 | implementation { 17 | 18 | void sigint_handler (int sig) { 19 | RPI_PRINTF("Shuting down.\n"); 20 | call Leds.led0Off(); 21 | call Leds.led1Off(); 22 | call Leds.led2Off(); 23 | 24 | exit(0); 25 | } 26 | 27 | command error_t Init.init() { 28 | 29 | setvbuf(stdout, NULL, _IONBF, 0); 30 | 31 | RPI_PRINTF("Bringing system online.\n"); 32 | call GpioInit.init(); 33 | call LedsInit.init(); 34 | call InterruptInit.init(); 35 | 36 | RPI_PRINTF("Setting SIGINT signal handler.\n"); 37 | __nesc_keyword_signal(SIGINT, sigint_handler); 38 | 39 | return SUCCESS; 40 | } 41 | 42 | // Fallback interface for LEDs if LedsC is not 43 | // used. 44 | default command error_t LedsInit.init() { 45 | return SUCCESS; 46 | } 47 | 48 | default command error_t InterruptInit.init() { 49 | return SUCCESS; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLeds154/RadioCountToLeds154C.nc: -------------------------------------------------------------------------------- 1 | #include "RadioCountToLeds154.h" 2 | 3 | /** 4 | * Configuration for the RadioCountToLeds application. RadioCountToLeds 5 | * maintains a 4Hz counter, broadcasting its value in an AM packet 6 | * every time it gets updated. A RadioCountToLeds node that hears a counter 7 | * displays the bottom three bits on its LEDs. This application is a useful 8 | * test to show that basic AM communication and timers work. 9 | * 10 | * @author Philip Levis 11 | * @author Brad Campbell (change to use Ieee154 interfaces) 12 | * @date June 6 2005 13 | */ 14 | 15 | configuration RadioCountToLeds154C {} 16 | implementation { 17 | components MainC, RadioCountToLeds154P as App, LedsC; 18 | // components new AMSenderC(AM_RADIO_COUNT_MSG); 19 | // components new AMReceiverC(AM_RADIO_COUNT_MSG); 20 | components Ieee154MessageC; 21 | components new TimerMilliC(); 22 | // components ActiveMessageC; 23 | 24 | App.Boot -> MainC.Boot; 25 | 26 | App.Receive -> Ieee154MessageC.Ieee154Receive; 27 | App.Ieee154Send -> Ieee154MessageC.Ieee154Send; 28 | App.RadioControl -> Ieee154MessageC.SplitControl; 29 | App.Leds -> LedsC; 30 | App.MilliTimer -> TimerMilliC; 31 | App.Ieee154Packet -> Ieee154MessageC.Packet; 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /tinyos/support/make/arm-linux/arm-linux.rules: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | define RPI_HELP 3 | 4 | RPI extras: 5 | None available at the moment. 6 | 7 | endef 8 | 9 | HELP += $(RPI_HELP) 10 | 11 | SHELL=/bin/bash 12 | 13 | ARM_COMPILER_PREFIX=$(shell if `hash arm-linux-gnueabi-gcc >& /dev/null`; then echo arm-linux-gnueabi; elif `hash arm-unknown-linux-gnueabi-gcc >& /dev/null`; then echo arm-unknown-linux-gnueabi; elif `hash arm-none-linux-gnueabi-gcc >& /dev/null`; then echo arm-none-linux-gnueabi; elif `hash arm-none-eabi-gcc >& /dev/null`; then echo arm-none-eabi; else echo -n ""; fi) 14 | 15 | ifeq (,$(ARM_COMPILER_PREFIX)) 16 | $(error "No cross compiler found. Have you installed an ARM toolchain?") 17 | endif 18 | 19 | GCC = $(ARM_COMPILER_PREFIX)-gcc 20 | OBJCOPY = $(ARM_COMPILER_PREFIX)-objcopy 21 | OBJDUMP = $(ARM_COMPILER_PREFIX)-objdump 22 | SET_ID = tos-set-symbols 23 | SIZE = $(ARM_COMPILER_PREFIX)-size 24 | NM = $(ARM_COMPILER_PREFIX)-nm 25 | LIBS = -lm -lrt -lc 26 | 27 | INSTALL_BIN = $(MAIN_BIN).out$(if $(NODEID),-$(NODEID),) 28 | 29 | OPTFLAGS ?= -Os 30 | 31 | PFLAGS += -Wall -Wshadow 32 | PFLAGS += -finline-limit=100000 33 | 34 | TOSMAKE_BINARY_FORMAT = bin 35 | TOSMAKE_BINARY_IN = $(MAIN_BIN) 36 | TOSMAKE_BINARY_OUT = $(INSTALL_BIN) 37 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/CC2520RpiAmPacketMetadataP.nc: -------------------------------------------------------------------------------- 1 | 2 | module CC2520RpiAmPacketMetadataP { 3 | provides { 4 | interface PacketField as PacketLinkQuality; 5 | interface PacketField as PacketRSSI; 6 | } 7 | uses { 8 | interface PacketMetadata; 9 | } 10 | } 11 | 12 | implementation { 13 | 14 | 15 | //----------------- PacketLinkQuality ----------------- 16 | async command bool PacketLinkQuality.isSet(message_t* msg) { 17 | return TRUE; 18 | } 19 | 20 | async command uint8_t PacketLinkQuality.get(message_t* msg) { 21 | return call PacketMetadata.getLqi(msg); 22 | } 23 | 24 | async command void PacketLinkQuality.clear(message_t* msg) { 25 | } 26 | 27 | async command void PacketLinkQuality.set(message_t* msg, uint8_t value) { 28 | call PacketMetadata.setLqi(msg, value); 29 | } 30 | 31 | 32 | //----------------- PacketRSSI ----------------- 33 | async command bool PacketRSSI.isSet(message_t* msg) { 34 | return TRUE; 35 | } 36 | 37 | async command uint8_t PacketRSSI.get(message_t* msg) { 38 | return call PacketMetadata.getRssi(msg); 39 | } 40 | 41 | async command void PacketRSSI.clear(message_t* msg) { 42 | } 43 | 44 | async command void PacketRSSI.set(message_t* msg, uint8_t value) { 45 | call PacketMetadata.setRssi(msg, value); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /tinyos/apps/tests/PolyPointHack/PolyPointHackP.nc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | module PolyPointHackP { 5 | uses { 6 | interface Leds; 7 | interface Boot; 8 | 9 | interface SplitControl as RadioControl; 10 | interface Packet as RadioPacket; 11 | interface Send as RadioSend; 12 | interface Receive as RadioReceive; 13 | } 14 | } 15 | implementation { 16 | 17 | uint32_t count = 0; 18 | 19 | event void Boot.booted() { 20 | call RadioControl.start(); 21 | } 22 | 23 | event void RadioControl.startDone (error_t error) { 24 | } 25 | 26 | event void RadioSend.sendDone (message_t* message, error_t error) { 27 | } 28 | 29 | event message_t* RadioReceive.receive(message_t* packet, 30 | void* payload, uint8_t len) { 31 | 32 | char* msg; 33 | int i; 34 | /* 35 | printf("%05i got packet (%i): 0x", count++, len); 36 | for (i=0; i 4 | #include 5 | 6 | 7 | module NodeP @safe() { 8 | uses { 9 | interface Boot; 10 | interface Leds; 11 | interface Timer as MilliTimer; 12 | 13 | interface SplitControl as RadioControl; 14 | interface UDP as UDPService; 15 | } 16 | } 17 | implementation { 18 | 19 | bool locked; 20 | uint16_t counter = 0; 21 | 22 | struct sockaddr_in6 dest; 23 | 24 | event void Boot.booted() { 25 | inet_pton6("2001:638:709:1235::1", &dest.sin6_addr); 26 | dest.sin6_port = htons(2001); 27 | 28 | call RadioControl.start(); 29 | } 30 | 31 | event void RadioControl.startDone(error_t err) { 32 | 33 | if (err == SUCCESS) { 34 | call UDPService.bind(2001); 35 | call MilliTimer.startPeriodic(10000); 36 | } else { 37 | call RadioControl.start(); 38 | } 39 | } 40 | 41 | event void MilliTimer.fired() { 42 | counter++; 43 | 44 | call UDPService.sendto(&dest, &counter, 2); 45 | } 46 | 47 | event void UDPService.recvfrom (struct sockaddr_in6 *from, 48 | void *payload, 49 | uint16_t len, 50 | struct ip6_metadata *meta) { 51 | } 52 | 53 | event void RadioControl.stopDone (error_t e) { } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/RadioPacketMetadataP.nc: -------------------------------------------------------------------------------- 1 | 2 | module RadioPacketMetadataP { 3 | provides { 4 | interface PacketAcknowledgements; 5 | interface PacketLink; 6 | } 7 | uses { 8 | interface PacketMetadata; 9 | } 10 | } 11 | 12 | implementation { 13 | 14 | async command error_t PacketAcknowledgements.requestAck(message_t* msg) { 15 | return call PacketMetadata.requestAck(msg); 16 | } 17 | 18 | async command error_t PacketAcknowledgements.noAck(message_t* msg) { 19 | return call PacketMetadata.noAck(msg); 20 | } 21 | 22 | async command bool PacketAcknowledgements.wasAcked(message_t* msg) { 23 | return call PacketMetadata.wasAcked(msg); 24 | } 25 | 26 | command void PacketLink.setRetries(message_t *msg, uint16_t maxRetries) { 27 | return call PacketMetadata.setRetries(msg, maxRetries); 28 | } 29 | 30 | command void PacketLink.setRetryDelay(message_t *msg, uint16_t retryDelay) { 31 | return call PacketMetadata.setRetryDelay(msg, retryDelay); 32 | } 33 | 34 | command uint16_t PacketLink.getRetries(message_t *msg) { 35 | return call PacketMetadata.getRetries(msg); 36 | } 37 | 38 | command uint16_t PacketLink.getRetryDelay(message_t *msg) { 39 | return call PacketMetadata.getRetryDelay(msg); 40 | } 41 | 42 | command bool PacketLink.wasDelivered(message_t *msg) { 43 | return call PacketMetadata.wasAcked(msg); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/armlinux/BorderC.nc: -------------------------------------------------------------------------------- 1 | /* Wire together the components needed to create a border router style packet 2 | * exit and entry point. 3 | * 4 | * @author: Brad Campbell 5 | */ 6 | 7 | #include "border.h" 8 | 9 | configuration BorderC { 10 | } 11 | 12 | implementation { 13 | components BorderP; 14 | components TunC; 15 | 16 | components MainC; 17 | MainC.SoftwareInit -> BorderP.SoftwareInit; 18 | 19 | components IPForwardingEngineP; 20 | IPForwardingEngineP.IPForward[ROUTE_IFACE_TUN] -> TunC.IPForward; 21 | 22 | components IPStackC; 23 | BorderP.ForwardingTable -> IPStackC.ForwardingTable; 24 | // BorderP.ForwardingNoLoop -> IPStackC.ForwardingEvents[ROUTE_IFACE_TUN]; 25 | 26 | // components IPNeighborDiscoveryC; 27 | // BorderP.NeighborDiscovery -> IPNeighborDiscoveryC.NeighborDiscovery; 28 | 29 | #if RPL_ROUTING 30 | components RplBorderRouterP, IPPacketC, IPNeighborDiscoveryC; 31 | RplBorderRouterP.NeighborDiscovery -> IPNeighborDiscoveryC.NeighborDiscovery; 32 | RplBorderRouterP.ForwardingEvents -> IPStackC.ForwardingEvents[ROUTE_IFACE_TUN]; 33 | RplBorderRouterP.IPPacket -> IPPacketC.IPPacket; 34 | #endif 35 | 36 | components DumpHopHopP; 37 | DumpHopHopP.NeighborDiscovery -> IPNeighborDiscoveryC.NeighborDiscovery; 38 | DumpHopHopP.ForwardingEvents -> IPStackC.ForwardingEvents[ROUTE_IFACE_154]; 39 | DumpHopHopP.IPPacket -> IPPacketC.IPPacket; 40 | } 41 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/socket/LinuxUdpSocket.nc: -------------------------------------------------------------------------------- 1 | 2 | /* This is a simple TinyOS interface for a UDP socket. It exposes some 3 | * Linux-specific features, such as CORK'ing, that are useful. 4 | * 5 | * @author: Pat Pannuto 6 | */ 7 | 8 | interface LinuxUdpSocket { 9 | 10 | // Open a socket to a remote server. host can be an ip address or a hostname. 11 | command error_t init (const char* host, uint16_t port); 12 | 13 | // Release any resources held by this socket. If the flush_buffer argument is 14 | // true, any partially constructed packet will be sent before closing the 15 | // socket, otherwise the data will be discarded. Any errors raised in sending 16 | // the final packet are silently discarded; if catching these are necessary, 17 | // callers should first sendData() instead. 18 | command error_t close (bool flush_buffer); 19 | 20 | // Build a single packet by appending data to each call of this function. No 21 | // data is actually sent until sendData() is called 22 | command error_t build_packet (uint8_t* buf, uint16_t len); 23 | 24 | // Send a packet. Any buffer provided here will be appended to the 25 | // buildPacket() buffer and then sent. buf may be NULL iff len is 0. 26 | // Sending a 0-length packet is not considered an error and will return 27 | // success. 28 | command error_t send_data (uint8_t* buf, uint16_t len); 29 | 30 | // No RX interface is currently provided. 31 | } 32 | -------------------------------------------------------------------------------- /tinyos/tos/chips/bcm2835/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef __GPIO_H__ 2 | #define __GPIO_H__ 3 | 4 | // RPi Version 2 5 | enum { 6 | RPI_V2_GPIO_P1_03 = 2, // Version 2, Pin P1-03 7 | RPI_V2_GPIO_P1_05 = 3, // Version 2, Pin P1-05 8 | RPI_V2_GPIO_P1_07 = 4, // Version 2, Pin P1-07 9 | RPI_V2_GPIO_P1_08 = 14, // Version 2, Pin P1-08, defaults to alt function 0 UART0_TXD 10 | RPI_V2_GPIO_P1_10 = 15, // Version 2, Pin P1-10, defaults to alt function 0 UART0_RXD 11 | RPI_V2_GPIO_P1_11 = 17, // Version 2, Pin P1-11 12 | RPI_V2_GPIO_P1_12 = 18, // Version 2, Pin P1-12 13 | RPI_V2_GPIO_P1_13 = 27, // Version 2, Pin P1-13 14 | RPI_V2_GPIO_P1_15 = 22, // Version 2, Pin P1-15 15 | RPI_V2_GPIO_P1_16 = 23, // Version 2, Pin P1-16 16 | RPI_V2_GPIO_P1_18 = 24, // Version 2, Pin P1-18 17 | RPI_V2_GPIO_P1_19 = 10, // Version 2, Pin P1-19, MOSI when SPI0 in use 18 | RPI_V2_GPIO_P1_21 = 9, // Version 2, Pin P1-21, MISO when SPI0 in use 19 | RPI_V2_GPIO_P1_22 = 25, // Version 2, Pin P1-22 20 | RPI_V2_GPIO_P1_23 = 11, // Version 2, Pin P1-23, CLK when SPI0 in use 21 | RPI_V2_GPIO_P1_24 = 8, // Version 2, Pin P1-24, CE0 when SPI0 in use 22 | RPI_V2_GPIO_P1_26 = 7, // Version 2, Pin P1-26, CE1 when SPI0 in use 23 | 24 | RPI_V2_GPIO_P5_03 = 28, // Version 2, Pin P5-03 25 | RPI_V2_GPIO_P5_04 = 29, // Version 2, Pin P5-04 26 | RPI_V2_GPIO_P5_05 = 30, // Version 2, Pin P5-05 27 | RPI_V2_GPIO_P5_06 = 31 // Version 2, Pin P5-06 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /utils/mcast.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Send/receive UDP multicast packets. 4 | # Requires that your OS kernel supports IP multicast. 5 | # 6 | # Usage: 7 | # mcast -s (sender, IPv4) 8 | # mcast -s -6 (sender, IPv6) 9 | # mcast (receivers, IPv4) 10 | # mcast -6 (receivers, IPv6) 11 | 12 | MYPORT = 2001 13 | MYGROUP_4 = '225.0.0.250' 14 | MYGROUP_6 = 'fe80::fffe:12' 15 | MYGROUP_6 = '2001:638:709:1234::fffe:1' 16 | #me='fe80::2e41:38ff:fe89:9a2' 17 | me='::1' 18 | MYTTL = 10 # Increase to reach other networks 19 | 20 | import time 21 | import struct 22 | import socket 23 | import sys 24 | 25 | def main(): 26 | group = MYGROUP_6 27 | 28 | sender(group) 29 | 30 | 31 | 32 | def sender(group): 33 | addrinfo = socket.getaddrinfo(group, None)[0] 34 | print addrinfo 35 | 36 | s = socket.socket(addrinfo[0], socket.SOCK_DGRAM) 37 | 38 | # Set Time-to-live (optional) 39 | ttl_bin = struct.pack('@i', MYTTL) 40 | if addrinfo[0] == socket.AF_INET: # IPv4 41 | s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl_bin) 42 | else: 43 | s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_MULTICAST_HOPS, ttl_bin) 44 | 45 | # mebind = socket.getaddrinfo(me, 2004)[0] 46 | # print mebind 47 | # s.bind(mebind[-1]) 48 | 49 | while True: 50 | data = repr(time.time()) 51 | s.sendto(data + '\0', (addrinfo[4][0], MYPORT)) 52 | time.sleep(1) 53 | 54 | 55 | if __name__ == '__main__': 56 | main() 57 | -------------------------------------------------------------------------------- /tinyos/support/make/platforms/rpi.platform: -------------------------------------------------------------------------------- 1 | #-*-Makefile-*- vim:syntax=make 2 | 3 | PFLAGS += -I%T/platforms/armlinux 4 | PFLAGS += -I%T/platforms/rpi 5 | PFLAGS += -I%T/platforms/rpi/chips/cc2520linux 6 | PFLAGS += -I%T/platforms/rpi/chips/ds2411 7 | PFLAGS += -I%T/chips/cc2520linux 8 | PFLAGS += -I%T/chips/cc2520rpiAM 9 | PFLAGS += -I%T/chips/bcm2835 10 | PFLAGS += -I%T/chips/bcm2835/gpio 11 | PFLAGS += -I%T/chips/bcm2835/interrupt 12 | PFLAGS += -I%T/chips/idrfid 13 | PFLAGS += -I%T/chips/linux 14 | PFLAGS += -I%T/chips/linux/socket 15 | PFLAGS += -I%T/chips/linux/time 16 | PFLAGS += -I%T/chips/linux/timer 17 | PFLAGS += -I%T/chips/linux/tun 18 | PFLAGS += -I%T/chips/linux/uart 19 | PFLAGS += -I%T/interfaces 20 | PFLAGS += -I%T/lib/net/blip 21 | 22 | PFLAGS += -I%T/../support/sdk/c/linux 23 | PFLAGS += %T/../support/sdk/c/linux/file_helpers.c 24 | 25 | PFLAGS += -I%T/../support/sdk/c/ini 26 | PFLAGS += %T/../support/sdk/c/ini/ini.c 27 | 28 | PFLAGS += -I%T/chips/ds2411 29 | PFLAGS += -I%T/lib/timer 30 | PFLAGS += -I%T/lib/serial 31 | PFLAGS += -I%T/lib/power 32 | PFLAGS += -I%T/lib/rfxlink/layers 33 | PFLAGS += -I%T/lib/rfxlink/util 34 | PFLAGS += -I%T/lib/onewire 35 | PFLAGS += -I%T/lib/printf 36 | 37 | PFLAGS += -mcpu=arm1176jzf-s 38 | PFLAGS += -fnesc-target=env 39 | 40 | 41 | export NESC_MACHINE = structure_size_boundary=32, pointer=4,4 float=4,4 double=8,4 long_double=8,4 short=2,2 int=4,4 long=4,4 long_long=8,4 int1248_align=1,2,4,4 wchar_size_size=4,4 char_wchar_signed=false,true 42 | -------------------------------------------------------------------------------- /tinyos/apps/tests/BlipQuickPacket/BlipQuickPacketP.nc: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | #include 3 | #include 4 | 5 | module BlipQuickPacketP { 6 | uses { 7 | interface Leds; 8 | interface Boot; 9 | 10 | interface SplitControl as BlipControl; 11 | interface UDP as Udp; 12 | interface ForwardingTable; 13 | } 14 | } 15 | implementation { 16 | 17 | #define RECEIVER "2001:470:1f10:1320::2" 18 | #define PORT 4001 19 | //uint16_t PORT = 0xf0AA; 20 | 21 | #define ALL_ROUTERS "ff02::2" 22 | 23 | struct sockaddr_in6 dest; // Where to send the packet 24 | struct in6_addr next_hop; 25 | 26 | event void Boot.booted() { 27 | inet_pton6(RECEIVER, &dest.sin6_addr); 28 | dest.sin6_port = htons(PORT); 29 | 30 | call BlipControl.start(); 31 | } 32 | 33 | event void BlipControl.startDone (error_t error) { 34 | error_t err; 35 | uint32_t data; 36 | 37 | inet_pton6(ALL_ROUTERS, &next_hop); 38 | call ForwardingTable.addRoute(dest.sin6_addr.s6_addr, 128, &next_hop, 39 | ROUTE_IFACE_154); 40 | 41 | // Set the payload as the pkt data 42 | data = 0xCABEBEED; 43 | 44 | err = call Udp.sendto(&dest, &data, 3); 45 | if (err != SUCCESS) { 46 | } 47 | } 48 | 49 | event void BlipControl.stopDone (error_t error) { 50 | } 51 | 52 | event void Udp.recvfrom (struct sockaddr_in6 *from, 53 | void *data, 54 | uint16_t len, 55 | struct ip6_metadata *meta) { } 56 | } 57 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/LinuxLedP.nc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | generic module LinuxLedP (char led_name[]) { 6 | provides { 7 | interface GeneralIO; 8 | } 9 | } 10 | 11 | implementation { 12 | 13 | char filename[256]; 14 | 15 | // We use makeOutput as the init function. 16 | // Using GeneralIO for a linux led is dumb as it is. 17 | async command void GeneralIO.makeOutput () { 18 | snprintf(filename, 256, "/sys/class/leds/%s/brightness", led_name); 19 | } 20 | 21 | async command void GeneralIO.set () { 22 | int led_file = open(filename, O_RDWR); 23 | write(led_file, "1", 1); 24 | } 25 | 26 | async command void GeneralIO.clr () { 27 | int led_file = open(filename, O_RDWR); 28 | write(led_file, "0", 1); 29 | } 30 | 31 | async command void GeneralIO.toggle () { 32 | int led_file = open(filename, O_RDWR); 33 | if (call GeneralIO.get()) { 34 | write(led_file, "0", 1); 35 | } else { 36 | write(led_file, "1", 1); 37 | } 38 | } 39 | 40 | async command bool GeneralIO.get () { 41 | char buffer[10]; 42 | int led_file = open(filename, O_RDWR); 43 | 44 | read(led_file, buffer, 1); 45 | if (strncmp(buffer, "1", 1) == 0) { 46 | return TRUE; 47 | } 48 | return FALSE; 49 | } 50 | 51 | async command void GeneralIO.makeInput () { 52 | } 53 | 54 | async command bool GeneralIO.isInput () { 55 | return FALSE; 56 | } 57 | 58 | async command bool GeneralIO.isOutput () { 59 | return TRUE; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /tinyos/tos/chips/bcm2835/interrupt/Bcm2835InterruptC.nc: -------------------------------------------------------------------------------- 1 | #include "gpio.h" 2 | 3 | /* File based implementation of Linux userspace interrupts. 4 | * Unfortunately because this module works by letting the kernel module write 5 | * to a file with information about interrupts, there is about a 2ms delay 6 | * between the interrupt being triggered and the TinyOS app registering it. 7 | * This means this module cannot be used for anything that requires tight 8 | * timing. 9 | */ 10 | 11 | configuration Bcm2835InterruptC { 12 | provides { 13 | interface GpioInterrupt as Port1_03; 14 | interface GpioInterrupt as Port1_08; 15 | interface GpioInterrupt as Port1_10; 16 | interface GpioInterrupt as Port1_12; 17 | interface GpioInterrupt as Port1_13; 18 | interface GpioInterrupt as Port1_19; 19 | interface GpioInterrupt as Port1_21; 20 | interface GpioInterrupt as Port1_23; 21 | interface GpioInterrupt as Port1_24; 22 | interface GpioInterrupt as Port1_26; 23 | } 24 | } 25 | 26 | implementation { 27 | components Bcm2835InterruptP as IntP; 28 | components PlatformP; 29 | 30 | PlatformP.InterruptInit -> IntP.Init; 31 | 32 | Port1_03 = IntP.Port1[RPI_V2_GPIO_P1_03]; 33 | Port1_08 = IntP.Port1[RPI_V2_GPIO_P1_08]; 34 | Port1_10 = IntP.Port1[RPI_V2_GPIO_P1_10]; 35 | Port1_12 = IntP.Port1[RPI_V2_GPIO_P1_12]; 36 | Port1_13 = IntP.Port1[RPI_V2_GPIO_P1_13]; 37 | Port1_19 = IntP.Port1[RPI_V2_GPIO_P1_19]; 38 | Port1_21 = IntP.Port1[RPI_V2_GPIO_P1_21]; 39 | Port1_23 = IntP.Port1[RPI_V2_GPIO_P1_23]; 40 | Port1_24 = IntP.Port1[RPI_V2_GPIO_P1_24]; 41 | Port1_26 = IntP.Port1[RPI_V2_GPIO_P1_26]; 42 | } 43 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/rpi/chips/ds2411/PlatformIeeeEui64.h: -------------------------------------------------------------------------------- 1 | // $Id: PlatformIeeeEui64.h,v 1.1 2010/02/23 06:45:38 sdhsdh Exp $ 2 | /* 3 | * Copyright (c) 2007, Vanderbilt University 4 | * All rights reserved. 5 | * 6 | * Permission to use, copy, modify, and distribute this software and its 7 | * documentation for any purpose, without fee, and without written agreement is 8 | * hereby granted, provided that the above copyright notice, the following 9 | * two paragraphs and the author appear in all copies of this software. 10 | * 11 | * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR 12 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 13 | * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT 14 | * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15 | * 16 | * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, 17 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 18 | * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 19 | * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO 20 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 21 | * 22 | * Author: Janos Sallai 23 | * changes for Epic 24 | */ 25 | 26 | #ifndef PLATFORMIEEEEUI64_H 27 | #define PLATFORMIEEEEUI64_H 28 | 29 | enum { 30 | IEEE_EUI64_COMPANY_ID_0 = 0xc0, // University of Michigan 31 | IEEE_EUI64_COMPANY_ID_1 = 0x98, 32 | IEEE_EUI64_COMPANY_ID_2 = 0xe5, 33 | IEEE_EUI64_SERIAL_ID_0 = 'R', 34 | IEEE_EUI64_SERIAL_ID_1 = 'P', 35 | }; 36 | 37 | #endif // PLATFORMIEEEEUI64_H 38 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/rpi/hardware.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Hardware definition for the Raspberry Pi platform. 3 | * 4 | * @author Brad Campbell 5 | */ 6 | #ifndef _H_hardware_h 7 | #define _H_hardware_h 8 | 9 | //#include "msp430hardware.h" 10 | 11 | // enum so components can override power saving, 12 | // as per TEP 112. 13 | //enum { 14 | // TOS_SLEEP_NONE = MSP430_POWER_ACTIVE, 15 | //}; 16 | /* 17 | // LEDS 18 | TOSH_ASSIGN_PIN(RED_LED, 4, 0); 19 | TOSH_ASSIGN_PIN(GREEN_LED, 4, 3); 20 | TOSH_ASSIGN_PIN(YELLOW_LED, 4, 7); 21 | 22 | // CC2420 RADIO 23 | TOSH_ASSIGN_PIN(RADIO_CSN, 4, 2); 24 | TOSH_ASSIGN_PIN(RADIO_VREF, 4, 5); 25 | TOSH_ASSIGN_PIN(RADIO_RESET, 4, 6); 26 | TOSH_ASSIGN_PIN(RADIO_FIFOP, 1, 0); 27 | TOSH_ASSIGN_PIN(RADIO_SFD, 4, 1); 28 | TOSH_ASSIGN_PIN(RADIO_GIO0, 1, 3); 29 | TOSH_ASSIGN_PIN(RADIO_FIFO, 1, 3); 30 | TOSH_ASSIGN_PIN(RADIO_GIO1, 1, 4); 31 | TOSH_ASSIGN_PIN(RADIO_CCA, 1, 4); 32 | 33 | TOSH_ASSIGN_PIN(CC_FIFOP, 1, 0); 34 | TOSH_ASSIGN_PIN(CC_FIFO, 1, 3); 35 | TOSH_ASSIGN_PIN(CC_SFD, 4, 1); 36 | TOSH_ASSIGN_PIN(CC_VREN, 4, 5); 37 | TOSH_ASSIGN_PIN(CC_RSTN, 4, 6); 38 | 39 | // USART0 40 | TOSH_ASSIGN_PIN(SIMO0, 3, 1); 41 | TOSH_ASSIGN_PIN(SOMI0, 3, 2); 42 | TOSH_ASSIGN_PIN(UCLK0, 3, 3); 43 | 44 | // USART1 45 | TOSH_ASSIGN_PIN(SIMO1, 5, 1); 46 | TOSH_ASSIGN_PIN(SOMI1, 5, 2); 47 | TOSH_ASSIGN_PIN(UCLK1, 5, 3); 48 | 49 | // UART1 50 | TOSH_ASSIGN_PIN(UTXD0, 3, 4); 51 | TOSH_ASSIGN_PIN(URXD0, 3, 5); 52 | TOSH_ASSIGN_PIN(UTXD1, 3, 6); 53 | TOSH_ASSIGN_PIN(URXD1, 3, 7); 54 | 55 | // 1-Wire 56 | TOSH_ASSIGN_PIN(ONEWIRE, 2, 4); 57 | */ 58 | // need to undef atomic inside header files or nesC ignores the directive 59 | #undef atomic 60 | 61 | #endif // _H_hardware_h 62 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_bom.csv: -------------------------------------------------------------------------------- 1 | # Bill of Materials 2 | # Converted from rpi-cc2520_a_bom.xls 3 | # Generated by bom_to_text.py 4 | 5 | Qty,Value,Device,Package,Parts,Description,DIGIKEY,DIGIREEL 6 | 1,,2450BM15A0002,2450BM,B1,BALUN JTI MATCHED ZIGBEE,712-1536-1-ND,712-1536-6-ND 7 | 4,100nF,C-EUC0402,C0402,"C1, C2, C3, C4","CAPACITOR, European symbol",490-1318-1-ND,490-1318-6-ND 8 | 1,1uF,C-EUC0603,C0603,C5,"CAPACITOR, European symbol",490-1550-1-ND,490-1550-6-ND 9 | 2,27pF,C-EUC0402,C0402,"C6, C7","CAPACITOR, European symbol",490-5869-1-ND,490-5869-6-ND 10 | 1,,LED0603,LED-0603,D1,Green LED,160-1834-1-ND,160-1834-6-ND 11 | 1,,LED0603,LED-0603,D2,Red LED,160-1835-1-ND,160-1835-6-ND 12 | 1,,LED0603,LED-0603,D3,Blue LED,160-1837-1-ND,160-1837-6-ND 13 | 1,,PINHD-2X13,2X13,J1,PIN HEADER,SAM1204-13-ND,SAM1204-13-ND 14 | 1,,INDUCTOR0603,L0603,L1,Inductors,490-1015-1-ND,490-1015-6-ND 15 | 1,,MOLEX_73251-135X,SMA-J/PCB,P1,SMA JACK SMT 50 OHM,WM9357-ND,WM9357-ND 16 | 3,470,R-US_R0603,R0402,"R1, R2, R3","RESISTOR, American symbol",RHM470JCT-ND,RHM470JTR-ND 17 | 1,1M 1%,R-US_R0402,R0402,R4,"RESISTOR, American symbol",RHM1.00MCDCT-ND,RHM1.00MCDDKR-ND 18 | 1,56k 1%,R-US_R0402,R0402,R5,"RESISTOR, American symbol",P56.0KLCT-ND,P56.0KLDKR-ND 19 | 1,2.2k,R-US_R0402,R0402,R6,"RESISTOR, American symbol",RHM2.2KCECT-ND,RHM2.2KCEDKR-ND 20 | 1,,CC2520,S-PVQFN-N28,U1,2.4 GHZ IEEE 802.15.4/ZIGBEE® RF TRANSCEIVER,296-22996-1-ND,296-22996-6-ND 21 | 1,,DS2411,SOT-23,U2,IC SILICON SERIAL NUMBER SOT-23,DS2411R+CT-ND,DS2411R+DKR-ND 22 | 1,,NX2520SA,NX2520SA,X1,CRYSTAL 32MHZ 10PF SMD,644-1065-1-ND,644-1065-6-ND 23 | 1,,ANTENNA,,,ANTENNA 2.45GHZ 1/4 WAVE SMA,ANT-2.4-CW-RH-SMA-ND,ANT-2.4-CW-RH-SMA-ND 24 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/timer/HilTimerMilliC.nc: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * HilTimerMilliC provides a parameterized interface to a virtualized 4 | * millisecond timer. TimerMilliC in tos/system/ uses this component to 5 | * allocate new timers. 6 | * 7 | * @author Cory Sharp 8 | * @see Please refer to TEP 102 for more information about this component and its 9 | * intended use. 10 | */ 11 | 12 | configuration HilTimerMilliC 13 | { 14 | provides interface Init; 15 | provides interface Timer as TimerMilli[ uint8_t num ]; 16 | provides interface LocalTime; 17 | } 18 | implementation 19 | { 20 | components new AlarmMilli32P(); 21 | components new AlarmToTimerC(TMilli); 22 | components new VirtualizeTimerC(TMilli,uniqueCount(UQ_TIMER_MILLI)); 23 | components new CounterToLocalTimeC(TMilli); 24 | components LocalTimeMilli32P; 25 | 26 | Init = AlarmMilli32P; 27 | TimerMilli = VirtualizeTimerC; 28 | LocalTime = LocalTimeMilli32P; 29 | 30 | VirtualizeTimerC.TimerFrom -> AlarmToTimerC; 31 | AlarmToTimerC.Alarm -> AlarmMilli32P; 32 | 33 | // CounterToLocalTimeC.Counter -> CounterMilli32C; 34 | 35 | /* 36 | components new AlarmMilli32C(); 37 | components new AlarmToTimerC(TMilli); 38 | components new VirtualizeTimerC(TMilli,uniqueCount(UQ_TIMER_MILLI)); 39 | components new CounterToLocalTimeC(TMilli); 40 | components CounterMilli32C; 41 | 42 | Init = AlarmMilli32C; 43 | TimerMilli = VirtualizeTimerC; 44 | LocalTime = CounterToLocalTimeC; 45 | 46 | VirtualizeTimerC.TimerFrom -> AlarmToTimerC; 47 | AlarmToTimerC.Alarm -> AlarmMilli32C; 48 | CounterToLocalTimeC.Counter -> CounterMilli32C; 49 | */ 50 | } 51 | -------------------------------------------------------------------------------- /tinyos/apps/NodeCollect/NodeCollectP.nc: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #define COLLECTION_SERVER "2001:470:1f10:131c::2" 9 | #define WSN_ROOT "2607:f018:800a:bcde:f012:3456:7891:1" 10 | 11 | module NodeCollectP @safe() { 12 | uses { 13 | interface Boot; 14 | interface Leds; 15 | interface Timer as MilliTimer; 16 | 17 | interface SplitControl as RadioControl; 18 | interface UDP as UDPService; 19 | } 20 | } 21 | implementation { 22 | 23 | uint16_t counter = 0; 24 | 25 | struct sockaddr_in6 server; 26 | struct sockaddr_in6 root; 27 | 28 | event void Boot.booted() { 29 | inet_pton6(COLLECTION_SERVER, &server.sin6_addr); 30 | server.sin6_port = htons(2001); 31 | inet_pton6(WSN_ROOT, &root.sin6_addr); 32 | root.sin6_port = htons(2001); 33 | 34 | call RadioControl.start(); 35 | } 36 | 37 | event void RadioControl.startDone(error_t err) { 38 | if (err == SUCCESS) { 39 | call UDPService.bind(2001); 40 | call MilliTimer.startPeriodic(1000); 41 | 42 | } else { 43 | call RadioControl.start(); 44 | } 45 | } 46 | 47 | event void MilliTimer.fired() { 48 | counter++; 49 | if (counter % 2) { 50 | call Leds.led0Toggle(); 51 | call UDPService.sendto(&server, &counter, 2); 52 | } else { 53 | // call Leds.led1Toggle(); 54 | // call UDPService.sendto(&root, &counter, 2); 55 | } 56 | } 57 | 58 | event void UDPService.recvfrom (struct sockaddr_in6 *from, 59 | void *payload, 60 | uint16_t len, 61 | struct ip6_metadata *meta) { 62 | call Leds.led2Toggle(); 63 | } 64 | 65 | event void RadioControl.stopDone (error_t e) { } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/armlinux/ActiveMessageC.nc: -------------------------------------------------------------------------------- 1 | 2 | //#include 3 | 4 | configuration ActiveMessageC 5 | { 6 | provides 7 | { 8 | interface SplitControl; 9 | 10 | interface AMSend[uint8_t id]; 11 | interface Receive[uint8_t id]; 12 | // interface Receive as Snoop[uint8_t id]; 13 | // not sure if sendnotifier is needed 14 | // interface SendNotifier[am_id_t id]; 15 | 16 | interface Packet; 17 | interface AMPacket; 18 | 19 | interface PacketAcknowledgements; 20 | // interface LowPowerListening; 21 | 22 | // not required (aka telosa + cc2420 driver doesnt have them) 23 | // interface PacketLink; 24 | // interface RadioChannel; 25 | 26 | // interface PacketTimeStamp as PacketTimeStampMicro; 27 | // interface PacketTimeStamp as PacketTimeStampMilli; 28 | } 29 | } 30 | 31 | implementation 32 | { 33 | components CC2520RpiActiveMessageC as MessageC; 34 | 35 | // components RadioControlP, HplSam3TCC; 36 | 37 | SplitControl = MessageC.SplitControl; 38 | //SplitControl = RadioControlP; 39 | //RadioControlP.LowRadioControl -> MessageC; 40 | //RadioControlP.TC -> HplSam3TCC.TC0; // We use TIOA1 which is channel 1 on TC0 41 | 42 | AMSend = MessageC.AMSend; 43 | Receive = MessageC.Receive; 44 | // not doing snoop right now 45 | // Snoop = MessageC.Snoop; 46 | //SendNotifier = MessageC; 47 | 48 | Packet = MessageC.Packet; 49 | AMPacket = MessageC.AMPacket; 50 | 51 | 52 | PacketAcknowledgements = MessageC.PacketAcknowledgements; 53 | /* LowPowerListening = MessageC.LowPowerListening; 54 | PacketLink = MessageC.PacketLink; 55 | RadioChannel = MessageC.RadioChannel; 56 | 57 | PacketTimeStampMilli = MessageC.PacketTimeStampMilli; 58 | PacketTimeStampMicro = MessageC.PacketTimeStampRadio; 59 | */ 60 | } 61 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/CC2520RpiActiveMessageC.nc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #ifdef IEEE154FRAMES_ENABLED 5 | #error "You cannot use ActiveMessageC with IEEE154FRAMES_ENABLED defined" 6 | #endif 7 | 8 | configuration CC2520RpiActiveMessageC { 9 | provides { 10 | interface SplitControl; 11 | 12 | interface AMSend[am_id_t id]; 13 | interface Receive[am_id_t id]; 14 | // interface Receive as Snoop[am_id_t id]; 15 | // interface SendNotifier[am_id_t id]; 16 | 17 | interface Packet; 18 | interface AMPacket; 19 | 20 | interface PacketAcknowledgements; 21 | /* interface LowPowerListening; 22 | interface PacketLink; 23 | interface RadioChannel; 24 | 25 | interface PacketField as PacketLinkQuality; 26 | interface PacketField as PacketTransmitPower; 27 | interface PacketField as PacketRSSI; 28 | 29 | interface LocalTime as LocalTimeRadio; 30 | interface PacketTimeStamp as PacketTimeStampRadio; 31 | interface PacketTimeStamp as PacketTimeStampMilli; 32 | */ 33 | } 34 | } 35 | 36 | implementation 37 | { 38 | components CC2520RpiAmRadioC as RadioC; 39 | 40 | SplitControl = RadioC.SplitControl; 41 | 42 | AMSend = RadioC.AMSend; 43 | Receive = RadioC.Receive; 44 | // Snoop = RadioC.Snoop; 45 | // SendNotifier = RadioC; 46 | 47 | Packet = RadioC.PacketForActiveMessage; 48 | AMPacket = RadioC; 49 | 50 | 51 | PacketAcknowledgements = RadioC; 52 | /* LowPowerListening = RadioC; 53 | PacketLink = RadioC; 54 | RadioChannel = RadioC; 55 | 56 | PacketLinkQuality = RadioC.PacketLinkQuality; 57 | PacketTransmitPower = RadioC.PacketTransmitPower; 58 | PacketRSSI = RadioC.PacketRSSI; 59 | 60 | LocalTimeRadio = RadioC; 61 | PacketTimeStampMilli = RadioC; 62 | PacketTimeStampRadio = RadioC; 63 | */ 64 | } 65 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/linux_atomic.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_ATOMIC_H__ 2 | #define __LINUX_ATOMIC_H__ 3 | 4 | #include 5 | 6 | typedef uint8_t mcu_power_t; 7 | typedef bool __nesc_atomic_t; 8 | 9 | // We can safely use norace with these variables. There are only accessed when 10 | // interrupts are disabled, but the nesc compiler doesn't know that. 11 | norace bool interupts_enabled = TRUE; 12 | norace sigset_t global_sigmask; 13 | 14 | __nesc_atomic_t __nesc_atomic_start(void); 15 | void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts); 16 | 17 | void __nesc_disable_interrupt(void) @safe() { 18 | sigset_t all; 19 | sigset_t temp_sigmask; 20 | 21 | // Unconditionally block all signals when this function is called. This 22 | // simulates a microcontroller where you can disable and re-disable global 23 | // interrupts anytime. 24 | sigfillset(&all); 25 | sigprocmask(SIG_BLOCK, &all, &temp_sigmask); 26 | 27 | // Now that interrupts are disabled, check to see if they were already 28 | // disabled or, if not, we need to save the previous mask in order to use 29 | // it to re-enable interrupts. 30 | if (interupts_enabled) { 31 | global_sigmask = temp_sigmask; 32 | interupts_enabled = FALSE; 33 | } 34 | } 35 | 36 | void __nesc_enable_interrupt(void) @safe() { 37 | // To re-enable interrupts, just apply the old sigmask we had before we 38 | // disabled interrupts. 39 | interupts_enabled = TRUE; 40 | sigprocmask(SIG_SETMASK, &global_sigmask, NULL); 41 | } 42 | 43 | __nesc_atomic_t __nesc_atomic_start(void) @spontaneous() @safe() { 44 | __nesc_atomic_t prev_state = interupts_enabled; 45 | __nesc_disable_interrupt(); 46 | return prev_state; 47 | } 48 | 49 | void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts) @spontaneous() @safe() { 50 | if (reenable_interrupts) { 51 | __nesc_enable_interrupt(); 52 | } 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/lib/jsmn/jsmn.h: -------------------------------------------------------------------------------- 1 | #ifndef __JSMN_H_ 2 | #define __JSMN_H_ 3 | 4 | /** 5 | * JSON type identifier. Basic types are: 6 | * o Object 7 | * o Array 8 | * o String 9 | * o Other primitive: number, boolean (true/false) or null 10 | */ 11 | typedef enum { 12 | JSMN_PRIMITIVE = 0, 13 | JSMN_OBJECT = 1, 14 | JSMN_ARRAY = 2, 15 | JSMN_STRING = 3 16 | } jsmntype_t; 17 | 18 | typedef enum { 19 | /* Not enough tokens were provided */ 20 | JSMN_ERROR_NOMEM = -1, 21 | /* Invalid character inside JSON string */ 22 | JSMN_ERROR_INVAL = -2, 23 | /* The string is not a full JSON packet, more bytes expected */ 24 | JSMN_ERROR_PART = -3, 25 | /* Everything was fine */ 26 | JSMN_SUCCESS = 0 27 | } jsmnerr_t; 28 | 29 | /** 30 | * JSON token description. 31 | * @param type type (object, array, string etc.) 32 | * @param start start position in JSON data string 33 | * @param end end position in JSON data string 34 | */ 35 | typedef struct { 36 | jsmntype_t type; 37 | int start; 38 | int end; 39 | int size; 40 | #ifdef JSMN_PARENT_LINKS 41 | int parent; 42 | #endif 43 | } jsmntok_t; 44 | 45 | /** 46 | * JSON parser. Contains an array of token blocks available. Also stores 47 | * the string being parsed now and current position in that string 48 | */ 49 | typedef struct { 50 | unsigned int pos; /* offset in the JSON string */ 51 | uint toknext; /* next token to allocate */ 52 | int toksuper; /* superior token node, e.g parent object or array */ 53 | } jsmn_parser; 54 | 55 | /** 56 | * Create JSON parser over an array of tokens 57 | */ 58 | void jsmn_init(jsmn_parser *parser); 59 | 60 | /** 61 | * Run JSON parser. It parses a JSON data string into and array of tokens, each describing 62 | * a single JSON object. 63 | */ 64 | jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, 65 | jsmntok_t *tokens, unsigned int num_tokens); 66 | 67 | #endif /* __JSMN_H_ */ 68 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/BRConfigP.nc: -------------------------------------------------------------------------------- 1 | #include "ini.h" 2 | 3 | /* Supports the following configuration options: 4 | * 5 | * [network] 6 | * prefix = 7 | * 8 | * @author: Brad Campbell 9 | */ 10 | 11 | module BRConfigP { 12 | provides { 13 | interface BRConfig; 14 | } 15 | } 16 | implementation { 17 | 18 | typedef struct { 19 | struct in6_addr prefix; // IPv6 prefix for the network 20 | } border_router_config_t; 21 | 22 | bool inited = FALSE; 23 | const char* filename = "brconfig.ini"; 24 | border_router_config_t brc; 25 | 26 | int handler (void* user, const char* section, const char* name, const char* value) { 27 | border_router_config_t* brc_ptr = (border_router_config_t*) user; 28 | 29 | #define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0 30 | if (MATCH("network", "prefix")) { 31 | // Save the address as binary data 32 | inet_pton6(value, &brc_ptr->prefix); 33 | } else { 34 | return 0; // unknown section/name, error 35 | } 36 | return 1; 37 | } 38 | 39 | // Open an .ini file to configure the border router 40 | error_t init() { 41 | int result; 42 | 43 | if (inited) return EALREADY; 44 | 45 | result = ini_parse(filename, handler, &brc); 46 | if (result < 0) { 47 | ERROR("Could not load %s.\n", filename); 48 | ERROR("You must provide an .ini file for configuration.\n"); 49 | exit(1); 50 | } 51 | 52 | inited = TRUE; 53 | 54 | return SUCCESS; 55 | } 56 | 57 | // Copies the prefix into the address you provide 58 | command error_t BRConfig.getPrefix (struct in6_addr* prefix) { 59 | init(); 60 | 61 | memcpy(&prefix->s6_addr, &brc.prefix.s6_addr, sizeof(struct in6_addr)); 62 | return SUCCESS; 63 | } 64 | 65 | command struct in6_addr* BRConfig.getPrefixPtr () { 66 | init(); 67 | return &brc.prefix; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /tinyos/apps/ExtAddrTest/ExtAddrTestP.nc: -------------------------------------------------------------------------------- 1 | module ExtAddrTestP { 2 | uses { 3 | interface Boot; 4 | interface Leds; 5 | interface Timer as Timer0; 6 | 7 | interface SplitControl as RadioControl; 8 | interface Packet as BarePacket; 9 | interface Send as Ieee154Send; 10 | interface Receive as Ieee154Receive; 11 | interface PacketLink; 12 | } 13 | } 14 | 15 | implementation { 16 | 17 | uint16_t counter = 0; 18 | uint8_t pkt[128]; 19 | 20 | message_t* msg = (message_t*) pkt; 21 | 22 | event void Boot.booted() { 23 | // setup packet 24 | pkt[0] = 19; // length 25 | pkt[1] = 0x41; // no ack 26 | pkt[2] = 0x8C; // dest ext addr, src short 27 | pkt[3] = 0x00; // seq 28 | pkt[4] = 0x22; // pan id 29 | pkt[5] = 0x00; 30 | pkt[6] = 0x08; // dst ext addr 31 | pkt[7] = 0x00; 32 | pkt[8] = 0x00; 33 | pkt[9] = 0x00; 34 | pkt[10] = 0x00; 35 | pkt[11] = 0x00; 36 | pkt[12] = 0x00; 37 | pkt[13] = 0x00; 38 | pkt[14] = 0x01; // src sht addr 39 | pkt[15] = 0x00; 40 | pkt[16] = (counter & 0xFF); 41 | pkt[17] = (counter >> 8); 42 | 43 | call RadioControl.start(); 44 | } 45 | 46 | event void RadioControl.startDone (error_t e) { 47 | if (e == SUCCESS) { 48 | call Timer0.startPeriodic(1000); 49 | } else { 50 | call RadioControl.start(); 51 | } 52 | } 53 | 54 | event void Timer0.fired () { 55 | counter++; 56 | 57 | pkt[16] = (counter & 0xFF); 58 | pkt[17] = (counter >> 8); 59 | 60 | call Ieee154Send.send(msg, call BarePacket.payloadLength(msg)); 61 | call Leds.led2Toggle(); 62 | } 63 | 64 | event void Ieee154Send.sendDone (message_t *msgl, error_t error) { } 65 | 66 | event message_t* Ieee154Receive.receive (message_t *msgl, 67 | void *msg_payload, 68 | uint8_t len) { 69 | } 70 | 71 | event void RadioControl.stopDone (error_t error) { 72 | 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520rpiAM/CC2520RpiAmPacketP.nc: -------------------------------------------------------------------------------- 1 | 2 | // This layer is responsible for the "raw" data from the 3 | // the radio driver. Here, the header is a one byte length field 4 | // and the payload is everything in the packet except for the 5 | // length field and the two byte checksum at the end. The checksum 6 | // is verified by the lower driver. 7 | 8 | module CC2520RpiAmPacketP { 9 | provides { 10 | interface RadioPacket; 11 | } 12 | } 13 | 14 | implementation { 15 | 16 | async command uint8_t RadioPacket.headerLength (message_t* msg) { 17 | // sizeof (ieee154_simple_header_t) + sizeof(len) + 2 18 | // return 12; 19 | // At this layer we have a 1 byte header: the length field 20 | return sizeof(cc2520_header_t); 21 | } 22 | 23 | async command uint8_t RadioPacket.payloadLength(message_t* msg) { 24 | // The "payload" length at this point is the entire packet 25 | // except for the length field and the crc at the end. 26 | // The length byte at the start of the packet does not count 27 | // itself. 28 | uint8_t len = ((cc2520packet_header_t*) msg->header)->cc2520.length; 29 | //return len - sizeof(crc_packet); 30 | return len - 2; 31 | } 32 | 33 | 34 | async command void RadioPacket.setPayloadLength(message_t* msg, 35 | uint8_t length) { 36 | // This is the end call of a series of "setPayloadLength" calls. 37 | // Each layer adds its content or header to the total "payload" 38 | // length. At this point we add the crc check length to the total 39 | // before sending it to the driver. 40 | ((cc2520packet_header_t*) msg->header)->cc2520.length = length + 2; 41 | //*(((uint8_t*) msg->data) - 1) = length + 2; 42 | } 43 | 44 | async command uint8_t RadioPacket.maxPayloadLength() { 45 | // Max length in 802.15.4 is 128 minus 1 for the length field 46 | // and minus 2 for the crc field 47 | return 128 - sizeof(cc2520_header_t) - 2; 48 | } 49 | 50 | async command uint8_t RadioPacket.metadataLength(message_t* msg) { 51 | return 0; 52 | } 53 | 54 | async command void RadioPacket.clear(message_t* msg) { 55 | memset(msg, 0, sizeof(message_t)); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /tinyos/tos/chips/bcm2835/gpio/HplBcm2835GeneralIO.nc: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * HPL for the TI MSP430 family of microprocessors. This provides an 4 | * abstraction for general-purpose I/O. 5 | * 6 | * @author Cory Sharp 7 | * @author Peter Bigot 8 | */ 9 | 10 | #include "TinyError.h" 11 | 12 | interface HplBcm2835GeneralIO 13 | { 14 | /** 15 | * Set pin to high. 16 | */ 17 | async command void set(); 18 | 19 | /** 20 | * Set pin to low. 21 | */ 22 | async command void clr(); 23 | 24 | /** 25 | * Toggle pin status. 26 | */ 27 | async command void toggle(); 28 | 29 | /** 30 | * Get the port status that contains the pin. 31 | * 32 | * @return Status of the port that contains the given pin. The x'th 33 | * pin on the port will be represented in the x'th bit. 34 | */ 35 | async command uint8_t getRaw(); 36 | 37 | /** 38 | * Read pin value. 39 | * 40 | * @return TRUE if pin is high, FALSE otherwise. 41 | */ 42 | async command bool get(); 43 | 44 | /** 45 | * Set pin direction to input. 46 | */ 47 | async command void makeInput(); 48 | 49 | async command bool isInput(); 50 | 51 | /** 52 | * Set pin direction to output. 53 | */ 54 | async command void makeOutput(); 55 | 56 | async command bool isOutput(); 57 | 58 | /** 59 | * Set pin for module specific functionality. 60 | */ 61 | async command void selectModuleFunc(); 62 | 63 | async command bool isModuleFunc(); 64 | 65 | /** 66 | * Set pin for I/O functionality. 67 | */ 68 | // async command void selectIOFunc(); 69 | 70 | // async command bool isIOFunc(); 71 | 72 | /** 73 | * Set pin pullup / pull down resistor mode. 74 | * @param mode One of the MSP430_PORT_RESISTOR_* values 75 | * @return EINVAL if invalid mode or pin does not support resistor configuration; 76 | * FAIL if pin is not an input; 77 | * SUCCESS if pin supports resistor configuration, is an input, and mode is valid 78 | */ 79 | // async command error_t setResistor(uint8_t mode); 80 | 81 | /** 82 | * Get the pin pullup / pulldown resistor mode. 83 | * 84 | * @return one of the MSP430_PORT_RESISTOR_* values 85 | */ 86 | // async command uint8_t getResistor(); 87 | 88 | } 89 | 90 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/armlinux/DumpHopHopP.nc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | module DumpHopHopP { 6 | uses { 7 | interface ForwardingEvents; 8 | interface IPPacket; 9 | interface NeighborDiscovery; 10 | } 11 | } 12 | 13 | implementation { 14 | 15 | event bool ForwardingEvents.initiate(struct ip6_packet *pkt, 16 | struct in6_addr *next_hop) { 17 | return TRUE; 18 | } 19 | 20 | event bool ForwardingEvents.approve(struct ip6_packet *pkt, 21 | struct in6_addr *next_hop) { 22 | int off; 23 | uint8_t nxt = IPV6_HOP; 24 | 25 | printf("DUMP HOP HOP HOP\n"); 26 | 27 | /* dont want hop hop headers */ 28 | off = call IPPacket.findHeader(pkt->ip6_data, pkt->ip6_hdr.ip6_nxt, &nxt); 29 | if (off < 0) { 30 | return TRUE; 31 | } else if (off == 0) { 32 | uint8_t length_in_bytes = 0; 33 | 34 | printf("Removing the hop by hop header\n"); 35 | 36 | // Need to get rid of this header 37 | 38 | // Start by copying the next header value to the main packet 39 | pkt->ip6_hdr.ip6_nxt = pkt->ip6_data->iov_base[0]; 40 | 41 | // Now figure out the length of the header to be skipped 42 | length_in_bytes = (pkt->ip6_data->iov_base[1] + 1) * 8; 43 | 44 | // Move this iov to skip that header 45 | pkt->ip6_data->iov_base += length_in_bytes; 46 | pkt->ip6_data->iov_len -= length_in_bytes; 47 | 48 | // Update the main pkt len 49 | pkt->ip6_hdr.ip6_plen = htons(ntohs(pkt->ip6_hdr.ip6_plen) - (uint16_t) length_in_bytes); 50 | 51 | // Update UDP checksum, if needed 52 | if (pkt->ip6_hdr.ip6_nxt == IANA_UDP) { 53 | uint16_t udp_check; 54 | pkt->ip6_data->iov_base[6] = 0; 55 | pkt->ip6_data->iov_base[7] = 0; 56 | udp_check = htons(msg_cksum(&pkt->ip6_hdr, pkt->ip6_data, IANA_UDP)); 57 | pkt->ip6_data->iov_base[6] = (udp_check & 0xFF); 58 | pkt->ip6_data->iov_base[7] = ((udp_check >> 8) & 0xFF); 59 | } 60 | 61 | } 62 | 63 | return TRUE; 64 | } 65 | 66 | event void ForwardingEvents.linkResult(struct in6_addr *dest, 67 | struct send_info *info) { 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /tinyos/tos/chips/bcm2835/spi/HilRpiSpiC.nc: -------------------------------------------------------------------------------- 1 | 2 | 3 | //#include 4 | 5 | configuration HilRpiSpiC 6 | { 7 | provides 8 | { 9 | interface Resource[uint8_t]; 10 | interface SpiByte[uint8_t]; 11 | // interface FastSpiByte[uint8_t]; 12 | interface SpiPacket[uint8_t]; 13 | interface HplSam3SpiChipSelConfig[uint8_t]; 14 | interface HplSam3SpiConfig; 15 | } 16 | uses { 17 | interface Init as SpiChipInit; 18 | interface ResourceConfigure[uint8_t]; 19 | } 20 | } 21 | implementation 22 | { 23 | components RealMainP; 24 | RealMainP.PlatformInit -> HilRpiSpiP.Init; 25 | 26 | components HplRpiSpiC; 27 | HplRpiSpiConfig = HplRpiSpiC; 28 | HilRpiSpiP.SpiChipInit = SpiChipInit; 29 | HilRpiSpiP.HplRpiSpiConfig -> HplRpiSpiC; 30 | HilRpiSpiP.HplRpiSpiControl -> HplRpiSpiC; 31 | HilRpiSpiP.HplRpiSpiStatus -> HplRpiSpiC; 32 | HilRpiSpiP.HplRpiSpiInterrupts -> HplRpiSpiC; 33 | HplRpiSpiChipSelConfig[0] = HplRpiSpiC.HplSam3SpiChipSelConfig0; 34 | HplRpiSpiChipSelConfig[1] = HplRpiSpiC.HplSam3SpiChipSelConfig1; 35 | // HplRpiSpiChipSelConfig[2] = HplRpiSpiC.HplSam3SpiChipSelConfig2; 36 | // HplRpiSpiChipSelConfig[3] = HplRpiSpiC.HplSam3SpiChipSelConfig3; 37 | 38 | components new FcfsArbiterC(RPI_SPI_BUS) as ArbiterC; 39 | Resource = ArbiterC; 40 | ResourceConfigure = ArbiterC; 41 | HilRpiSpiP.ArbiterInfo -> ArbiterC; 42 | 43 | components new AsyncStdControlPowerManagerC() as PM; 44 | PM.AsyncStdControl -> HplRpiSpiC; 45 | PM.ArbiterInfo -> ArbiterC.ArbiterInfo; 46 | PM.ResourceDefaultOwner -> ArbiterC.ResourceDefaultOwner; 47 | 48 | components HilRpiSpiP; 49 | SpiByte = HilRpiSpiP.SpiByte; 50 | SpiPacket = HilRpiSpiP.SpiPacket; 51 | 52 | // components new FastSpiSam3C(SAM3_SPI_BUS); 53 | // FastSpiSam3C.SpiByte -> HilRpiSpiP.SpiByte; 54 | // FastSpiByte = FastSpiSam3C; 55 | 56 | // components HplSam3sGeneralIOC; 57 | // HilRpiSpiP.SpiPinMiso -> HplSam3sGeneralIOC.HplPioA12; 58 | // HilRpiSpiP.SpiPinMosi -> HplSam3sGeneralIOC.HplPioA13; 59 | // HilRpiSpiP.SpiPinSpck -> HplSam3sGeneralIOC.HplPioA14; 60 | 61 | components HplNVICC; 62 | HilRpiSpiP.SpiIrqControl -> HplNVICC.SPIInterrupt; 63 | } 64 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/armlinux/debug_printf.h: -------------------------------------------------------------------------------- 1 | #ifndef __DEBUG_PRINTF_H__ 2 | #define __DEBUG_PRINTF_H__ 3 | 4 | #include 5 | 6 | #define RPI_DEBUG 1 7 | //#define CC2520RPI_DEBUG 1 8 | //#define CC2520RPI_KERNEL_DRIVER_DEBUG 1 9 | #define TUN_DEBUG 1 10 | //#define IOMANAGER_DEBUG 1 11 | //#define RPI_INTERRUPT_DEBUG 1 12 | #define UART_DEBUG 1 13 | #define EUI64_DEBUG 1 14 | #define CMDLINE_DEBUG 1 15 | #define PERSISTENT_TCP_DEBUG 1 16 | 17 | 18 | #define DBG(...)\ 19 | do {\ 20 | flockfile(stdout);\ 21 | printf("%s:%d:\t", __FILE__, __LINE__);\ 22 | printf(__VA_ARGS__);\ 23 | funlockfile(stdout);\ 24 | } while (0) 25 | 26 | 27 | // fprintf(stderr, "%s:%d\t%s:\t", __FILE__, __LINE__, __func__); 28 | 29 | #define ERROR(...)\ 30 | do {\ 31 | flockfile(stderr);\ 32 | fprintf(stderr, "%s:%d\t", __FILE__, __LINE__);\ 33 | fprintf(stderr, __VA_ARGS__);\ 34 | funlockfile(stderr);\ 35 | } while (0) 36 | 37 | 38 | #ifdef RPI_DEBUG 39 | #define RPI_PRINTF(...) DBG(__VA_ARGS__) 40 | #else 41 | #define RPI_PRINTF(...) 42 | #endif 43 | 44 | #ifdef CC2520RPI_DEBUG 45 | #define RADIO_PRINTF(...) DBG(__VA_ARGS__) 46 | #else 47 | #define RADIO_PRINTF(...) 48 | #endif 49 | 50 | #ifdef TUN_DEBUG 51 | #define TUN_PRINTF(...) DBG(__VA_ARGS__) 52 | #define TUN_PRINTF_IN6ADDR(...) printf_in6addr(__VA_ARGS__) 53 | #define TUN_PRINTF_NEWL() printf("\n") 54 | #else 55 | #define TUN_PRINTF(...) 56 | #define TUN_PRINTF_IN6ADDR(...) 57 | #define TUN_PRINTF_NEWL() 58 | #endif 59 | 60 | #ifdef IOMANAGER_DEBUG 61 | #define IOMANAGER_PRINTF(...) DBG(__VA_ARGS__) 62 | #else 63 | #define IOMANAGER_PRINTF(...) 64 | #endif 65 | 66 | #ifdef RPI_INTERRUPT_DEBUG 67 | #define INT_PRINTF(...) DBG(__VA_ARGS__) 68 | #else 69 | #define INT_PRINTF(...) 70 | #endif 71 | 72 | #ifdef UART_DEBUG 73 | #define UART_PRINTF(...) DBG(__VA_ARGS__) 74 | #else 75 | #define UART_PRINTF(...) 76 | #endif 77 | 78 | #ifdef EUI64_DEBUG 79 | #define EUI64_PRINTF(...) DBG(__VA_ARGS__) 80 | #else 81 | #define EUI64_PRINTF(...) 82 | #endif 83 | 84 | #ifdef CMDLINE_DEBUG 85 | #define CMDLINE_PRINTF(...) DBG(__VA_ARGS__) 86 | #else 87 | #define CMDLINE_PRINTF(...) 88 | #endif 89 | 90 | #ifdef PERSISTENT_TCP_DEBUG 91 | #define PERSISTENT_TCP_PRINTF(...) DBG(__VA_ARGS__) 92 | #else 93 | #define PERSISTENT_TCP_PRINTF(...) 94 | #endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /tinyos/tos/chips/bcm2835/spi/RpiSpiP.nc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 University of California, Los Angeles 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the 13 | * distribution. 14 | * - Neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * HOLDER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 28 | * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | generic module RpiSpiP(uint8_t chip_id) 33 | { 34 | provides 35 | { 36 | interface ResourceConfigure as SubResourceConfigure; 37 | } 38 | uses { 39 | interface ResourceConfigure; 40 | interface HplRpiSpiConfig; 41 | } 42 | } 43 | implementation { 44 | 45 | async command void SubResourceConfigure.configure() { 46 | call HplRpiSpiConfig.selectChip(chip_id); 47 | call ResourceConfigure.configure(); 48 | } 49 | 50 | async command void SubResourceConfigure.unconfigure() { 51 | call ResourceConfigure.unconfigure(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/CC2520LinuxRadioC.nc: -------------------------------------------------------------------------------- 1 | 2 | /* Top level radio driver module for a very bare radio interface for the CC2520 3 | * radio running on Linux. This driver expects nearly fully formed 802.15.4 4 | * packets including the physical layer length byte. This driver will set the 5 | * sequence number and handle packet retries on the send side, and add metadata 6 | * on the receive side. 7 | * 8 | * This driver provides interfaces compatible with the BLIP IPv6/6LoWPAN stack. 9 | * See http://docs.tinyos.net/tinywiki/index.php/BLIP_2.0_Platform_Support_Guide 10 | * for a little more information on how these interfaces act. 11 | * 12 | * CC2520RpiRadioC stack: 13 | * RadioP 14 | * / \ 15 | * V \ 16 | * LinkP \ 17 | * | \ 18 | * V V 19 | * SendP ReceiveP 20 | */ 21 | 22 | generic configuration CC2520LinuxRadioC (char char_dev_path[]) { 23 | provides { 24 | interface SplitControl; 25 | 26 | interface Send; 27 | interface Receive; 28 | interface Packet; 29 | interface LowPowerListening; 30 | interface PacketMetadata; 31 | interface Ieee154Address; 32 | } 33 | } 34 | 35 | implementation { 36 | components new CC2520LinuxRadioP(char_dev_path); 37 | components new CC2520LinuxLinkC(); 38 | components new CC2520LinuxReceiveC(char_dev_path); 39 | components new CC2520LinuxSendC(char_dev_path); 40 | components LocalIeeeEui64C; 41 | 42 | CC2520LinuxRadioP.LocalIeeeEui64 -> LocalIeeeEui64C.LocalIeeeEui64; 43 | 44 | CC2520LinuxRadioP.SubSend -> CC2520LinuxLinkC.Send; 45 | CC2520LinuxLinkC.SubSend -> CC2520LinuxSendC.BareSend; 46 | 47 | CC2520LinuxRadioP.SubReceive -> CC2520LinuxReceiveC.BareReceive; 48 | 49 | CC2520LinuxReceiveC.PacketMetadata -> CC2520LinuxRadioP.PacketMetadata; 50 | CC2520LinuxLinkC.PacketMetadata -> CC2520LinuxRadioP.PacketMetadata; 51 | CC2520LinuxSendC.PacketMetadata -> CC2520LinuxRadioP.PacketMetadata; 52 | 53 | SplitControl = CC2520LinuxRadioP.SplitControl; 54 | Send = CC2520LinuxRadioP.Send; 55 | Receive = CC2520LinuxRadioP.Receive; 56 | Packet = CC2520LinuxRadioP.Packet; 57 | LowPowerListening = CC2520LinuxRadioP.LowPowerListening; 58 | PacketMetadata = CC2520LinuxRadioP.PacketMetadata; 59 | Ieee154Address = CC2520LinuxRadioP.Ieee154Address; 60 | } 61 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLeds154/RadioCountToLeds154.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005 The Regents of the University of California. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the 14 | * distribution. 15 | * - Neither the name of the University of California nor the names of 16 | * its contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | * OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * Copyright (c) 2002-2003 Intel Corporation 33 | * All rights reserved. 34 | * 35 | * This file is distributed under the terms in the attached INTEL-LICENSE 36 | * file. If you do not find these files, copies can be found by writing to 37 | * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 38 | * 94704. Attention: Intel License Inquiry. 39 | */ 40 | 41 | #ifndef RADIO_COUNT_TO_LEDS_H 42 | #define RADIO_COUNT_TO_LEDS_H 43 | 44 | typedef nx_struct radio_count_msg { 45 | nx_uint16_t counter; 46 | } radio_count_msg_t; 47 | 48 | enum { 49 | AM_RADIO_COUNT_MSG = 6, 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLedsBlip/RadioCountToLedsBlip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005 The Regents of the University of California. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the 14 | * distribution. 15 | * - Neither the name of the University of California nor the names of 16 | * its contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | * OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * Copyright (c) 2002-2003 Intel Corporation 33 | * All rights reserved. 34 | * 35 | * This file is distributed under the terms in the attached INTEL-LICENSE 36 | * file. If you do not find these files, copies can be found by writing to 37 | * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 38 | * 94704. Attention: Intel License Inquiry. 39 | */ 40 | 41 | #ifndef RADIO_COUNT_TO_LEDS_H 42 | #define RADIO_COUNT_TO_LEDS_H 43 | 44 | typedef nx_struct radio_count_msg { 45 | nx_uint16_t counter; 46 | } radio_count_msg_t; 47 | 48 | enum { 49 | AM_RADIO_COUNT_MSG = 6, 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /tinyos/tos/chips/idrfid/IDrfidP.nc: -------------------------------------------------------------------------------- 1 | #include "uart.h" 2 | 3 | /** 4 | * Module for reading the ID series of RFID readers. 5 | * 6 | * @author Brad Campbell 7 | * @version $Revision: 1.1 8 | */ 9 | 10 | module IDrfidP { 11 | provides { 12 | interface Notify; 13 | } 14 | uses { 15 | interface UartBuffer; 16 | interface UartConfig; 17 | } 18 | } 19 | implementation { 20 | 21 | bool active = FALSE; 22 | uint8_t rfid_code[5]; 23 | 24 | uart_config_t rfid_uart_conf = {9600, 16}; 25 | 26 | command error_t Notify.enable() { 27 | active = TRUE; 28 | return call UartConfig.setserial(&rfid_uart_conf); 29 | } 30 | 31 | command error_t Notify.disable() { 32 | active = FALSE; 33 | return SUCCESS; 34 | } 35 | 36 | uint8_t ahex2b (uint8_t ascii) { 37 | if (ascii > 0x2f && ascii < 0x3a) { 38 | // is numeral 39 | return ascii - 0x30; 40 | } else if (ascii > 0x40 && ascii < 0x47) { 41 | // is uppercase hex letter 42 | return ascii - 0x37; 43 | } else if (ascii > 0x60 && ascii < 0x67) { 44 | // is lowercase hex letter 45 | return ascii - 0x57; 46 | } 47 | // error - is not hex character in ascii 48 | return 0x0; 49 | } 50 | 51 | void convert_rfid (uint8_t* buf, uint8_t* code) { 52 | int i; 53 | uint8_t char1, char2; 54 | for (i=0; i<5; i++) { 55 | char1 = ahex2b(buf[i<<1]); 56 | char2 = ahex2b(buf[(i<<1)+1]); 57 | code[i] = (char1<<4) | char2; 58 | } 59 | } 60 | 61 | bool verify_checksum (uint8_t* code, uint8_t* chksum_buf) { 62 | int i; 63 | uint8_t chksum = 0; 64 | uint8_t zero_checker = 0; // makes sure the code is not all zeros 65 | uint8_t real_chksum = (ahex2b(chksum_buf[0])<<4) | ahex2b(chksum_buf[1]); 66 | 67 | for (i=0; i<5; i++) { 68 | chksum ^= code[i]; 69 | zero_checker |= code[i]; 70 | } 71 | 72 | return chksum == real_chksum && zero_checker; 73 | } 74 | 75 | event void UartBuffer.receive (uint8_t* buf, 76 | uint8_t len, 77 | uint64_t timestamp) { 78 | bool chksum; 79 | 80 | if (!active) { 81 | return; 82 | } 83 | 84 | if (len != 16) { 85 | return; 86 | } 87 | 88 | convert_rfid(buf + 1, rfid_code); 89 | chksum = verify_checksum(rfid_code, buf+11); 90 | if (chksum) signal Notify.notify(rfid_code); 91 | } 92 | 93 | } 94 | 95 | -------------------------------------------------------------------------------- /tinyos/tos/system/IOManagerP.nc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "debug_printf.h" 9 | 10 | module IOManagerP { 11 | provides { 12 | interface IO[uint8_t id]; 13 | interface BlockingIO; 14 | } 15 | } 16 | 17 | implementation { 18 | 19 | enum { 20 | N_FDS = uniqueCount("FILEID"), 21 | }; 22 | 23 | uint8_t map[N_FDS]; 24 | fd_set rfds; 25 | bool is_init = FALSE; 26 | 27 | 28 | command error_t IO.registerFileDescriptor[uint8_t id] (int file_descriptor) { 29 | IOMANAGER_PRINTF("registering file descriptor %i for %i.\n", id, 30 | file_descriptor); 31 | if (!is_init) { 32 | memset(map, 0x01, sizeof(uint8_t) * N_FDS); 33 | is_init = TRUE; 34 | } 35 | atomic map[id] = file_descriptor; 36 | return SUCCESS; 37 | } 38 | 39 | command error_t IO.unregisterFileDescriptor[uint8_t id] (int fd) { 40 | IOMANAGER_PRINTF("unregistering file descriptor %i for %i.\n", id, fd); 41 | if (!is_init) return EOFF; 42 | // Set the file descriptor back to 1 to remove it 43 | atomic map[id] = 1; 44 | return SUCCESS; 45 | } 46 | 47 | async command void BlockingIO.waitForIO () { 48 | int ret; 49 | int i; 50 | uint8_t nfds = 0; 51 | 52 | // Clear the struct and set all fd that aren't 1 53 | FD_ZERO(&rfds); 54 | for (i=0; i nfds) { 58 | nfds = map[i] + 1; 59 | } 60 | } 61 | } 62 | 63 | // This blocks and is how we sleep! 64 | ret = select(nfds, &rfds, NULL, NULL, NULL); 65 | 66 | if (ret < 0) { 67 | if (errno == EINTR) { 68 | // suppress 69 | } else { 70 | // error 71 | ERROR("select return error: %i\n", ret); 72 | } 73 | 74 | } else if (ret == 0) { 75 | ERROR("select return 0.\n"); 76 | 77 | } else { 78 | // some file is ready 79 | int j; 80 | 81 | if (ret > 1) { 82 | IOMANAGER_PRINTF("select finds %i file descriptors ready\n", ret); 83 | } 84 | for (j=0; j 5 | #include 6 | #include 7 | 8 | #define BASE 0xCC 9 | 10 | struct cc2520_set_channel_data { 11 | uint8_t channel; 12 | }; 13 | 14 | struct cc2520_set_address_data { 15 | uint16_t short_addr; 16 | uint64_t extended_addr; 17 | uint16_t pan_id; 18 | }; 19 | 20 | struct cc2520_set_ack_data { 21 | uint32_t timeout; 22 | }; 23 | 24 | struct cc2520_set_lpl_data { 25 | uint32_t window; 26 | uint32_t interval; 27 | bool enabled; 28 | }; 29 | 30 | struct cc2520_set_csma_data { 31 | uint32_t min_backoff; 32 | uint32_t init_backoff; 33 | uint32_t cong_backoff; 34 | bool enabled; 35 | }; 36 | 37 | struct cc2520_set_print_messages_data { 38 | uint8_t debug_level; 39 | }; 40 | 41 | struct cc2520_set_txpower_data { 42 | uint8_t txpower; 43 | }; 44 | 45 | // Define different levels of debug printing 46 | // print nothing 47 | #define DEBUG_PRINT_OFF 0 48 | // print only when something goes wrong 49 | #define DEBUG_PRINT_ERR 1 50 | // print occasional messages about interesting things 51 | #define DEBUG_PRINT_INFO 2 52 | // print a good amount of debuging output 53 | #define DEBUG_PRINT_DBG 3 54 | 55 | // Possible TX Powers: 56 | #define CC2520_TXPOWER_5DBM 0xF7 57 | #define CC2520_TXPOWER_3DBM 0xF2 58 | #define CC2520_TXPOWER_2DBM 0xAB 59 | #define CC2520_TXPOWER_1DBM 0x13 60 | #define CC2520_TXPOWER_0DBM 0x32 61 | #define CC2520_TXPOWER_N2DBM 0x81 62 | #define CC2520_TXPOWER_N4DBM 0x88 63 | #define CC2520_TXPOWER_N7DBM 0x2C 64 | #define CC2520_TXPOWER_N18DBM 0x03 65 | 66 | #define CC2520_IO_RADIO_INIT _IO(BASE, 0) 67 | #define CC2520_IO_RADIO_ON _IO(BASE, 1) 68 | #define CC2520_IO_RADIO_OFF _IO(BASE, 2) 69 | #define CC2520_IO_RADIO_SET_CHANNEL _IOW(BASE, 3, struct cc2520_set_channel_data) 70 | #define CC2520_IO_RADIO_SET_ADDRESS _IOW(BASE, 4, struct cc2520_set_address_data) 71 | #define CC2520_IO_RADIO_SET_TXPOWER _IOW(BASE, 5, struct cc2520_set_txpower_data) 72 | #define CC2520_IO_RADIO_SET_ACK _IOW(BASE, 6, struct cc2520_set_ack_data) 73 | #define CC2520_IO_RADIO_SET_LPL _IOW(BASE, 7, struct cc2520_set_lpl_data) 74 | #define CC2520_IO_RADIO_SET_CSMA _IOW(BASE, 8, struct cc2520_set_csma_data) 75 | #define CC2520_IO_RADIO_SET_PRINT _IOW(BASE, 9, struct cc2520_set_print_messages_data) 76 | 77 | // Transmit error codes 78 | #define CC2520_TX_SUCCESS 0 79 | #define CC2520_TX_BUSY 255 80 | #define CC2520_TX_LENGTH 254 81 | #define CC2520_TX_ACK_TIMEOUT 253 82 | #define CC2520_TX_FAILED 252 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/lib/ini/ini.h: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | inih is released under the New BSD license (see LICENSE.txt). Go to the project 4 | home page for more info: 5 | 6 | http://code.google.com/p/inih/ 7 | 8 | */ 9 | 10 | #ifndef __INI_H__ 11 | #define __INI_H__ 12 | 13 | /* Make this header file easier to include in C++ code */ 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | 20 | /* Parse given INI-style file. May have [section]s, name=value pairs 21 | (whitespace stripped), and comments starting with ';' (semicolon). Section 22 | is "" if name=value pair parsed before any section heading. name:value 23 | pairs are also supported as a concession to Python's ConfigParser. 24 | 25 | For each name=value pair parsed, call handler function with given user 26 | pointer as well as section, name, and value (data only valid for duration 27 | of handler call). Handler should return nonzero on success, zero on error. 28 | 29 | Returns 0 on success, line number of first error on parse error (doesn't 30 | stop on first error), -1 on file open error, or -2 on memory allocation 31 | error (only when INI_USE_STACK is zero). 32 | */ 33 | int ini_parse(const char* filename, 34 | int (*handler)(void* user, const char* section, 35 | const char* name, const char* value), 36 | void* user); 37 | 38 | /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't 39 | close the file when it's finished -- the caller must do that. */ 40 | int ini_parse_file(FILE* file, 41 | int (*handler)(void* user, const char* section, 42 | const char* name, const char* value), 43 | void* user); 44 | 45 | /* Nonzero to allow multi-line value parsing, in the style of Python's 46 | ConfigParser. If allowed, ini_parse() will call the handler with the same 47 | name for each subsequent line parsed. */ 48 | #ifndef INI_ALLOW_MULTILINE 49 | #define INI_ALLOW_MULTILINE 1 50 | #endif 51 | 52 | /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of 53 | the file. See http://code.google.com/p/inih/issues/detail?id=21 */ 54 | #ifndef INI_ALLOW_BOM 55 | #define INI_ALLOW_BOM 1 56 | #endif 57 | 58 | /* Nonzero to use stack, zero to use heap (malloc/free). */ 59 | #ifndef INI_USE_STACK 60 | #define INI_USE_STACK 1 61 | #endif 62 | 63 | /* Maximum line length for any line in INI file. */ 64 | #ifndef INI_MAX_LINE 65 | #define INI_MAX_LINE 200 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __INI_H__ */ 73 | -------------------------------------------------------------------------------- /tinyos/support/sdk/c/ini/ini.h: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | inih is released under the New BSD license (see LICENSE.txt). Go to the project 4 | home page for more info: 5 | 6 | http://code.google.com/p/inih/ 7 | 8 | */ 9 | 10 | #ifndef __INI_H__ 11 | #define __INI_H__ 12 | 13 | /* Make this header file easier to include in C++ code */ 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | 20 | /* Parse given INI-style file. May have [section]s, name=value pairs 21 | (whitespace stripped), and comments starting with ';' (semicolon). Section 22 | is "" if name=value pair parsed before any section heading. name:value 23 | pairs are also supported as a concession to Python's ConfigParser. 24 | 25 | For each name=value pair parsed, call handler function with given user 26 | pointer as well as section, name, and value (data only valid for duration 27 | of handler call). Handler should return nonzero on success, zero on error. 28 | 29 | Returns 0 on success, line number of first error on parse error (doesn't 30 | stop on first error), -1 on file open error, or -2 on memory allocation 31 | error (only when INI_USE_STACK is zero). 32 | */ 33 | int ini_parse(const char* filename, 34 | int (*handler)(void* user, const char* section, 35 | const char* name, const char* value), 36 | void* user); 37 | 38 | /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't 39 | close the file when it's finished -- the caller must do that. */ 40 | int ini_parse_file(FILE* file, 41 | int (*handler)(void* user, const char* section, 42 | const char* name, const char* value), 43 | void* user); 44 | 45 | /* Nonzero to allow multi-line value parsing, in the style of Python's 46 | ConfigParser. If allowed, ini_parse() will call the handler with the same 47 | name for each subsequent line parsed. */ 48 | #ifndef INI_ALLOW_MULTILINE 49 | #define INI_ALLOW_MULTILINE 1 50 | #endif 51 | 52 | /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of 53 | the file. See http://code.google.com/p/inih/issues/detail?id=21 */ 54 | #ifndef INI_ALLOW_BOM 55 | #define INI_ALLOW_BOM 1 56 | #endif 57 | 58 | /* Nonzero to use stack, zero to use heap (malloc/free). */ 59 | #ifndef INI_USE_STACK 60 | #define INI_USE_STACK 1 61 | #endif 62 | 63 | /* Maximum line length for any line in INI file. */ 64 | #ifndef INI_MAX_LINE 65 | #define INI_MAX_LINE 200 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __INI_H__ */ 73 | -------------------------------------------------------------------------------- /tinyos/tos/chips/bcm2835/gpio/HplBcm2835GeneralIOC.nc: -------------------------------------------------------------------------------- 1 | #include "gpio.h" 2 | 3 | configuration HplBcm2835GeneralIOC { 4 | 5 | // provides all the ports as raw ports 6 | provides interface HplBcm2835GeneralIO as Port1_03; // GPIO 2 7 | provides interface HplBcm2835GeneralIO as Port1_05; // GPIO 3 8 | provides interface HplBcm2835GeneralIO as Port1_07; // GPIO 4 9 | provides interface HplBcm2835GeneralIO as Port1_08; // GPIO 14 10 | provides interface HplBcm2835GeneralIO as Port1_10; // GPIO 15 11 | provides interface HplBcm2835GeneralIO as Port1_11; // GPIO 17 12 | provides interface HplBcm2835GeneralIO as Port1_12; // GPIO 18 13 | provides interface HplBcm2835GeneralIO as Port1_13; // GPIO 27 14 | provides interface HplBcm2835GeneralIO as Port1_15; // GPIO 22 15 | provides interface HplBcm2835GeneralIO as Port1_16; // GPIO 23 16 | provides interface HplBcm2835GeneralIO as Port1_18; // GPIO 24 17 | provides interface HplBcm2835GeneralIO as Port1_19; // GPIO 10 18 | provides interface HplBcm2835GeneralIO as Port1_21; // GPIO 9 19 | provides interface HplBcm2835GeneralIO as Port1_22; // GPIO 25 20 | provides interface HplBcm2835GeneralIO as Port1_23; // GPIO 11 21 | provides interface HplBcm2835GeneralIO as Port1_24; // GPIO 8 22 | provides interface HplBcm2835GeneralIO as Port1_26; // GPIO 7 23 | 24 | provides interface HplBcm2835GeneralIO as Port5_03; // GPIO 28 25 | provides interface HplBcm2835GeneralIO as Port5_04; // GPIO 29 26 | provides interface HplBcm2835GeneralIO as Port5_05; // GPIO 30 27 | provides interface HplBcm2835GeneralIO as Port5_06; // GPIO 31 28 | 29 | } 30 | 31 | implementation { 32 | 33 | components HplBcm2835GeneralIOP as IoP; 34 | components PlatformP; 35 | 36 | PlatformP.GpioInit -> IoP.Init; 37 | 38 | Port1_03 = IoP.Gpio[RPI_V2_GPIO_P1_03]; 39 | Port1_05 = IoP.Gpio[RPI_V2_GPIO_P1_05]; 40 | Port1_07 = IoP.Gpio[RPI_V2_GPIO_P1_07]; 41 | Port1_08 = IoP.Gpio[RPI_V2_GPIO_P1_08]; 42 | Port1_10 = IoP.Gpio[RPI_V2_GPIO_P1_10]; 43 | Port1_11 = IoP.Gpio[RPI_V2_GPIO_P1_11]; 44 | Port1_12 = IoP.Gpio[RPI_V2_GPIO_P1_12]; 45 | Port1_13 = IoP.Gpio[RPI_V2_GPIO_P1_13]; 46 | Port1_15 = IoP.Gpio[RPI_V2_GPIO_P1_15]; 47 | Port1_16 = IoP.Gpio[RPI_V2_GPIO_P1_16]; 48 | Port1_18 = IoP.Gpio[RPI_V2_GPIO_P1_18]; 49 | Port1_19 = IoP.Gpio[RPI_V2_GPIO_P1_19]; 50 | Port1_21 = IoP.Gpio[RPI_V2_GPIO_P1_21]; 51 | Port1_22 = IoP.Gpio[RPI_V2_GPIO_P1_22]; 52 | Port1_23 = IoP.Gpio[RPI_V2_GPIO_P1_23]; 53 | Port1_24 = IoP.Gpio[RPI_V2_GPIO_P1_24]; 54 | Port1_26 = IoP.Gpio[RPI_V2_GPIO_P1_26]; 55 | 56 | Port5_03 = IoP.Gpio[RPI_V2_GPIO_P5_03]; 57 | Port5_04 = IoP.Gpio[RPI_V2_GPIO_P5_04]; 58 | Port5_05 = IoP.Gpio[RPI_V2_GPIO_P5_05]; 59 | Port5_06 = IoP.Gpio[RPI_V2_GPIO_P5_06]; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /tinyos/apps/SimpleSackTest/SimpleSackTestC.nc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SimpleSackTest.h" 3 | #include "Ieee154.h" 4 | 5 | module SimpleSackTestC { 6 | uses interface Boot; 7 | uses interface Leds; 8 | uses interface Timer as Timer0; 9 | 10 | uses interface Ieee154Send; 11 | uses interface Ieee154Packet; 12 | uses interface Packet; 13 | uses interface Receive as Ieee154Receive; 14 | uses interface SplitControl as RadioControl; 15 | 16 | uses interface CC2420Config; 17 | 18 | uses interface PacketAcknowledgements; 19 | 20 | } 21 | implementation { 22 | 23 | ieee154_saddr_t addr = 0x01; 24 | uint16_t counter; 25 | message_t pkt; 26 | bool busy = FALSE; 27 | 28 | void setLeds(uint16_t val) { 29 | if (val & 0x01) 30 | call Leds.led0On(); 31 | else 32 | call Leds.led0Off(); 33 | } 34 | 35 | event void Boot.booted() { 36 | call RadioControl.start(); 37 | } 38 | 39 | event void Ieee154Send.sendDone(message_t* msg, error_t err) { 40 | if (&pkt == msg) { 41 | call Leds.led1Toggle(); 42 | if (call PacketAcknowledgements.wasAcked(msg)) { 43 | call Leds.led2Toggle(); 44 | } 45 | busy = FALSE; 46 | } 47 | } 48 | 49 | event message_t* Ieee154Receive.receive(message_t* msg, void* payload, uint8_t len) { 50 | if (len == sizeof(BlinkToRadioMsg)) { 51 | BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload; 52 | setLeds(btrpkt->counter); 53 | } 54 | return msg; 55 | } 56 | 57 | event void RadioControl.startDone(error_t err) { 58 | if (err == SUCCESS) { 59 | call CC2420Config.setAutoAck(1,0); 60 | call CC2420Config.sync(); 61 | } 62 | else { 63 | call RadioControl.start(); 64 | } 65 | } 66 | 67 | event void CC2420Config.syncDone(error_t error){ 68 | if (error == SUCCESS){ 69 | call Timer0.startPeriodic(TIMER_PERIOD_MILLI); 70 | } 71 | else{ 72 | call CC2420Config.setAutoAck(1,0); //enable auto-sw-acks 73 | call CC2420Config.sync(); 74 | } 75 | } 76 | 77 | event void RadioControl.stopDone(error_t err) { 78 | 79 | } 80 | 81 | event void Timer0.fired() { 82 | counter++; 83 | if (!busy) { 84 | BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*) 85 | (call Packet.getPayload(&pkt, sizeof(BlinkToRadioMsg))); 86 | 87 | if (btrpkt == NULL) { 88 | return; 89 | } 90 | 91 | btrpkt->counter = counter; 92 | 93 | call PacketAcknowledgements.requestAck(&pkt); 94 | 95 | if (call Ieee154Send.send(addr, 96 | &pkt, sizeof(BlinkToRadioMsg)) == SUCCESS) { 97 | busy = TRUE; 98 | } 99 | } 100 | } 101 | } 102 | 103 | -------------------------------------------------------------------------------- /tinyos/apps/TSDemo2014BorderRouter/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=TSDemo2014BorderRouterC 2 | 3 | PFLAGS += -DCC2520_DEF_CHANNEL=18 4 | 5 | ################################################################################ 6 | ### Set the addressing scheme 7 | ################################################################################ 8 | 9 | # Use IN6_PREFIX with static addressing modes 10 | PFLAGS += -DIN6_PREFIX=\"fec0::\" 11 | # Use BLIP Neighbor Discovery to autoconfigure an address 12 | PFLAGS += -DBLIP_ADDR_AUTOCONF=0 13 | # Use RPL and prefix information in DIO messages to autoconfigure an address 14 | PFLAGS += -DRPL_ADDR_AUTOCONF=0 15 | 16 | ################################################################################ 17 | ### Configure BLIP 18 | ################################################################################ 19 | 20 | # Configure the Neighbor Discovery mechanism 21 | PFLAGS += -DBLIP_SEND_ROUTER_SOLICITATIONS=0 22 | PFLAGS += -DBLIP_SEND_ROUTER_ADVERTISEMENTS=0 23 | 24 | # Configure the number of times BLIP tries to send a packet and how long it 25 | # waits between attempts 26 | #PFLAGS += -DBLIP_L2_RETRIES=5 27 | #PFLAGS += -DBLIP_L2_DELAY=103 28 | 29 | # Configure how many of the 6LoWPAN headers we support 30 | #PFLAGS += -DLIB6LOWPAN_FULL=1 31 | 32 | # Configure the header compression for 6LoWPAN 33 | PFLAGS += -DLIB6LOWPAN_HC_VERSION=6 34 | 35 | # Keep statistics about various BLIP/IPv6 parameters. See BlipStatistics.h 36 | #PFLAGS += -DBLIP_STATS 37 | #PFLAGS += -DBLIP_STATS_IP_MEM 38 | 39 | ################################################################################ 40 | ### Configure RPL 41 | ################################################################################ 42 | 43 | # Include the RPL layer if set to 1 44 | PFLAGS += -DRPL_ROUTING=1 45 | 46 | # If set keep routing information in each node. If not the root must keep all 47 | # routing information. 48 | PFLAGS += -DRPL_STORING_MODE=1 49 | PFLAGS += -DROUTE_TABLE_SZ=100 50 | 51 | # Choose the objective function RPL should use 52 | PFLAGS += -DRPL_OF_0=1 53 | PFLAGS += -DRPL_OF_MRHOF=0 54 | 55 | ################################################################################ 56 | ### Configure LPL 57 | ################################################################################ 58 | 59 | #PFLAGS += -DLOW_POWER_LISTENING 60 | #PFLAGS += -DLPL_SLEEP_INTERVAL=512 61 | #PFLAGS += -DLPL_DEF_LOCAL_WAKEUP=512 62 | #PFLAGS += -DLPL_DEF_REMOTE_WAKEUP=512 63 | 64 | ################################################################################ 65 | ### Configure printf() output 66 | ################################################################################ 67 | 68 | #PFLAGS += -DPRINTFUART_ENABLED 69 | 70 | GOALS += blip rpl 71 | 72 | TINYOS_ROOT_DIR?=../.. 73 | include $(TINYOS_ROOT_DIR)/Makefile.include 74 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/gap/chips/cc2520linux/RadioConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Vanderbilt University 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the 14 | * distribution. 15 | * - Neither the name of the copyright holder nor the names of 16 | * its contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | * OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * Author: Janos Sallai, Miklos Maroti 33 | * Author: Thomas Schmid (adapted for CC2520) 34 | * Author: Brad Campbell (adapted for CC2520Rpi) 35 | */ 36 | 37 | #ifndef __RADIOCONFIG_H__ 38 | #define __RADIOCONFIG_H__ 39 | 40 | #include 41 | #include 42 | 43 | // This is the default value of the PA_POWER field of the TXCTL register. 44 | #ifndef CC2520_DEF_RFPOWER 45 | #define CC2520_DEF_RFPOWER CC2520_TXPOWER_0DBM 46 | #endif 47 | 48 | // This is the default value of the CHANNEL field of the FSCTRL register. 49 | #ifndef CC2520_DEF_CHANNEL 50 | #define CC2520_DEF_CHANNEL 11 51 | #endif 52 | 53 | // The number of microseconds a sending mote will wait for an acknowledgement 54 | #ifndef SOFTWAREACK_TIMEOUT 55 | #define SOFTWAREACK_TIMEOUT 2500 56 | #endif 57 | 58 | #ifndef LPL_WINDOW 59 | #define LPL_WINDOW 320 60 | #endif 61 | 62 | 63 | /** 64 | * Make PACKET_LINK automaticaly enabled for Ieee154MessageC 65 | */ 66 | #if !defined(TFRAMES_ENABLED) && !defined(PACKET_LINK) 67 | #define PACKET_LINK 68 | #endif 69 | 70 | #endif 71 | 72 | //__RADIOCONFIG_H__ 73 | -------------------------------------------------------------------------------- /tinyos/tos/platforms/rpi/chips/cc2520linux/RadioConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Vanderbilt University 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the 14 | * distribution. 15 | * - Neither the name of the copyright holder nor the names of 16 | * its contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | * OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * Author: Janos Sallai, Miklos Maroti 33 | * Author: Thomas Schmid (adapted for CC2520) 34 | * Author: Brad Campbell (adapted for CC2520Rpi) 35 | */ 36 | 37 | #ifndef __RADIOCONFIG_H__ 38 | #define __RADIOCONFIG_H__ 39 | 40 | #include 41 | #include 42 | 43 | // This is the default value of the PA_POWER field of the TXCTL register. 44 | #ifndef CC2520_DEF_RFPOWER 45 | #define CC2520_DEF_RFPOWER CC2520_TXPOWER_0DBM 46 | #endif 47 | 48 | // This is the default value of the CHANNEL field of the FSCTRL register. 49 | #ifndef CC2520_DEF_CHANNEL 50 | #define CC2520_DEF_CHANNEL 11 51 | #endif 52 | 53 | // The number of microseconds a sending mote will wait for an acknowledgement 54 | #ifndef SOFTWAREACK_TIMEOUT 55 | #define SOFTWAREACK_TIMEOUT 2500 56 | #endif 57 | 58 | #ifndef LPL_WINDOW 59 | #define LPL_WINDOW 320 60 | #endif 61 | 62 | 63 | /** 64 | * Make PACKET_LINK automaticaly enabled for Ieee154MessageC 65 | */ 66 | #if !defined(TFRAMES_ENABLED) && !defined(PACKET_LINK) 67 | #define PACKET_LINK 68 | #endif 69 | 70 | #endif 71 | 72 | //__RADIOCONFIG_H__ 73 | -------------------------------------------------------------------------------- /tinyos/apps/BorderRouter/Makefile.failsafe: -------------------------------------------------------------------------------- 1 | COMPONENT=BorderRouterC 2 | 3 | PFLAGS += -DCC2520_DEF_CHANNEL=19 4 | 5 | PFLAGS += -DIEEE802154_PANID=0x15bb 6 | 7 | ################################################################################ 8 | ### Set the addressing scheme 9 | ################################################################################ 10 | 11 | # Use IN6_PREFIX with static addressing modes 12 | #PFLAGS += -DIN6_PREFIX=\"fec0::\" 13 | # Use BLIP Neighbor Discovery to autoconfigure an address 14 | PFLAGS += -DBLIP_ADDR_AUTOCONF=1 15 | # Use RPL and prefix information in DIO messages to autoconfigure an address 16 | PFLAGS += -DRPL_ADDR_AUTOCONF=0 17 | 18 | ################################################################################ 19 | ### Configure BLIP 20 | ################################################################################ 21 | 22 | # Configure the Neighbor Discovery mechanism 23 | PFLAGS += -DBLIP_SEND_ROUTER_SOLICITATIONS=1 24 | PFLAGS += -DBLIP_SEND_ROUTER_ADVERTISEMENTS=1 25 | 26 | # Configure the number of times BLIP tries to send a packet and how long it 27 | # waits between attempts 28 | #PFLAGS += -DBLIP_L2_RETRIES=5 29 | #PFLAGS += -DBLIP_L2_DELAY=103 30 | 31 | # Configure how many of the 6LoWPAN headers we support 32 | #PFLAGS += -DLIB6LOWPAN_FULL=1 33 | 34 | # Configure the header compression for 6LoWPAN 35 | PFLAGS += -DLIB6LOWPAN_HC_VERSION=6 36 | 37 | # Keep statistics about various BLIP/IPv6 parameters. See BlipStatistics.h 38 | #PFLAGS += -DBLIP_STATS 39 | #PFLAGS += -DBLIP_STATS_IP_MEM 40 | 41 | ################################################################################ 42 | ### Configure RPL 43 | ################################################################################ 44 | 45 | # Include the RPL layer if set to 1 46 | PFLAGS += -DRPL_ROUTING=1 47 | 48 | # If set keep routing information in each node. If not the root must keep all 49 | # routing information. 50 | PFLAGS += -DRPL_STORING_MODE=1 51 | PFLAGS += -DROUTE_TABLE_SZ=100 52 | 53 | # Choose the objective function RPL should use 54 | PFLAGS += -DRPL_OF_0=0 55 | PFLAGS += -DRPL_OF_MRHOF=1 56 | 57 | ################################################################################ 58 | ### Configure LPL 59 | ################################################################################ 60 | 61 | #PFLAGS += -DLOW_POWER_LISTENING 62 | #PFLAGS += -DLPL_SLEEP_INTERVAL=512 63 | #PFLAGS += -DLPL_DEF_LOCAL_WAKEUP=512 64 | #PFLAGS += -DLPL_DEF_REMOTE_WAKEUP=512 65 | 66 | ################################################################################ 67 | ### Configure printf() output 68 | ################################################################################ 69 | 70 | #PFLAGS += -DPRINTFUART_ENABLED 71 | 72 | GOALS += blip rpl 73 | 74 | TINYOS_ROOT_DIR?=../.. 75 | include $(TINYOS_ROOT_DIR)/Makefile.include 76 | -------------------------------------------------------------------------------- /hardware/eagle/rpi-cc2520/rev_a/rpi-cc2520_a_bom.txt: -------------------------------------------------------------------------------- 1 | # Bill of Materials 2 | # Converted from rpi-cc2520_a_bom.xls 3 | # Generated by bom_to_text.py 4 | 5 | Qty Value Device Package Parts Description DIGIKEY DIGIREEL 6 | 1 2450BM15A0002 2450BM B1 BALUN JTI MATCHED ZIGBEE 712-1536-1-ND 712-1536-6-ND 7 | 4 100nF C-EUC0402 C0402 C1, C2, C3, C4 CAPACITOR, European symbol 490-1318-1-ND 490-1318-6-ND 8 | 1 1uF C-EUC0603 C0603 C5 CAPACITOR, European symbol 490-1550-1-ND 490-1550-6-ND 9 | 2 27pF C-EUC0402 C0402 C6, C7 CAPACITOR, European symbol 490-5869-1-ND 490-5869-6-ND 10 | 1 LED0603 LED-0603 D1 Green LED 160-1834-1-ND 160-1834-6-ND 11 | 1 LED0603 LED-0603 D2 Red LED 160-1835-1-ND 160-1835-6-ND 12 | 1 LED0603 LED-0603 D3 Blue LED 160-1837-1-ND 160-1837-6-ND 13 | 1 PINHD-2X13 2X13 J1 PIN HEADER SAM1204-13-ND SAM1204-13-ND 14 | 1 INDUCTOR0603 L0603 L1 Inductors 490-1015-1-ND 490-1015-6-ND 15 | 1 MOLEX_73251-135X SMA-J/PCB P1 SMA JACK SMT 50 OHM WM9357-ND WM9357-ND 16 | 3 470 R-US_R0603 R0402 R1, R2, R3 RESISTOR, American symbol RHM470JCT-ND RHM470JTR-ND 17 | 1 1M 1% R-US_R0402 R0402 R4 RESISTOR, American symbol RHM1.00MCDCT-ND RHM1.00MCDDKR-ND 18 | 1 56k 1% R-US_R0402 R0402 R5 RESISTOR, American symbol P56.0KLCT-ND P56.0KLDKR-ND 19 | 1 2.2k R-US_R0402 R0402 R6 RESISTOR, American symbol RHM2.2KCECT-ND RHM2.2KCEDKR-ND 20 | 1 CC2520 S-PVQFN-N28 U1 2.4 GHZ IEEE 802.15.4/ZIGBEE® RF TRANSCEIVER 296-22996-1-ND 296-22996-6-ND 21 | 1 DS2411 SOT-23 U2 IC SILICON SERIAL NUMBER SOT-23 DS2411R+CT-ND DS2411R+DKR-ND 22 | 1 NX2520SA NX2520SA X1 CRYSTAL 32MHZ 10PF SMD 644-1065-1-ND 644-1065-6-ND 23 | 1 ANTENNA ANTENNA 2.45GHZ 1/4 WAVE SMA ANT-2.4-CW-RH-SMA-ND ANT-2.4-CW-RH-SMA-ND 24 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/socket/LinuxUdpSocketP.nc: -------------------------------------------------------------------------------- 1 | 2 | /* The component provides a linux UDP socket interface. It leverages some 3 | * Linux-specific features to provide a slightly easier interface. 4 | * 5 | * @author: Pat Pannuto 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | generic module LinuxUdpSocketP () { 20 | provides { 21 | interface LinuxUdpSocket; 22 | } 23 | } 24 | 25 | implementation { 26 | 27 | int sockfd = -1; 28 | struct sockaddr_in server; 29 | struct hostent *hp; 30 | 31 | command error_t LinuxUdpSocket.init (const char* host, uint16_t port) { 32 | sockfd = socket(PF_INET, SOCK_DGRAM, 0); 33 | if (sockfd < 0) { 34 | perror("cannot create socket"); 35 | return FAIL; 36 | } 37 | 38 | server.sin_family = PF_INET; 39 | if ( (hp = gethostbyname(host)) == NULL) { 40 | perror("Invalid or unknown host"); 41 | goto init_fail_sock; 42 | } 43 | 44 | memcpy(&server.sin_addr.s_addr, hp->h_addr, hp->h_length); 45 | 46 | server.sin_port = htons(port); // Can/should this use magic TOS endian type? 47 | 48 | return SUCCESS; 49 | 50 | init_fail_sock: 51 | close(sockfd); 52 | sockfd = -1; 53 | 54 | return FAIL; 55 | } 56 | 57 | command error_t LinuxUdpSocket.close (bool flush_buffer) { 58 | if (flush_buffer) { 59 | call LinuxUdpSocket.send_data(NULL, 0); 60 | } 61 | 62 | if (close(sockfd) < 0) { 63 | perror("Failed to close socket"); 64 | return FAIL; 65 | } 66 | 67 | sockfd = -1; 68 | return SUCCESS; 69 | } 70 | 71 | command error_t LinuxUdpSocket.build_packet (uint8_t* buf, uint16_t len) { 72 | uint16_t sent = 0; 73 | 74 | if (sockfd == -1) { 75 | fprintf(stderr, "LinuxUdpSocket::build_packet\tInvalid sockfd (init not called?\n"); 76 | return FAIL; 77 | } 78 | 79 | while (sent < len) { 80 | ssize_t ret; 81 | 82 | ret = sendto(sockfd, buf+sent, len-sent, MSG_MORE, 83 | (struct sockaddr*) &server, sizeof(server)); 84 | if (ret < 0) { 85 | perror("Error building UDP packet"); 86 | return FAIL; 87 | } 88 | sent += ret; 89 | } 90 | 91 | return SUCCESS; 92 | } 93 | 94 | command error_t LinuxUdpSocket.send_data (uint8_t* buf, uint16_t len) { 95 | if (call LinuxUdpSocket.build_packet(buf, len) == FAIL) { 96 | return FAIL; 97 | } 98 | 99 | if (sendto(sockfd, NULL, 0, 0, 100 | (struct sockaddr*) &server, sizeof(server)) < 0) { 101 | perror("Error sending UDP packet"); 102 | return FAIL; 103 | } 104 | 105 | return SUCCESS; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/uart/uart.h: -------------------------------------------------------------------------------- 1 | #ifndef __RPI_UART_H__ 2 | #define __RPI_UART_H__ 3 | 4 | /* 5 | * Definitions for async_struct (and serial_struct) flags field 6 | */ 7 | #define ASYNC_HUP_NOTIFY 0x0001 // Notify getty on hangups and closes 8 | // on the callout port 9 | #define ASYNC_FOURPORT 0x0002 // Set OU1, OUT2 per AST Fourport settings 10 | #define ASYNC_SAK 0x0004 // Secure Attention Key (Orange book) 11 | #define ASYNC_SPLIT_TERMIOS 0x0008 // Separate termios for dialin/callout 12 | #define ASYNC_SPD_MASK 0x1030 13 | #define ASYNC_SPD_HI 0x0010 // Use 56000 instead of 38400 bps 14 | #define ASYNC_SPD_VHI 0x0020 // Use 115200 instead of 38400 bps 15 | #define ASYNC_SPD_CUST 0x0030 // Use user-specified divisor 16 | #define ASYNC_SKIP_TEST 0x0040 // Skip UART test during autoconfiguration 17 | #define ASYNC_AUTO_IRQ 0x0080 // Do automatic IRQ during autoconfig 18 | #define ASYNC_SESSION_LOCKOUT 0x0100 // Lock out cua opens based on session 19 | #define ASYNC_PGRP_LOCKOUT 0x0200 // Lock out cua opens based on pgrp 20 | #define ASYNC_CALLOUT_NOHUP 0x0400 // Don't do hangups for cua device 21 | #define ASYNC_HARDPPS_CD 0x0800 // Call hardpps when CD goes high 22 | #define ASYNC_SPD_SHI 0x1000 // Use 230400 instead of 38400 bps 23 | #define ASYNC_SPD_WARP 0x1010 // Use 460800 instead of 38400 bps 24 | #define ASYNC_LOW_LATENCY 0x2000 // Request low latency behaviour 25 | #define ASYNC_FLAGS 0x3FFF // Possible legal async flags 26 | #define ASYNC_USR_MASK 0x3430 // Legal flags that non-privileged 27 | // users can set or reset 28 | 29 | // Internal flags used only by kernel/chr_drv/serial.c 30 | #define ASYNC_INITIALIZED 0x80000000 // Serial port was initialized 31 | #define ASYNC_CALLOUT_ACTIVE 0x40000000 // Call out device is active 32 | #define ASYNC_NORMAL_ACTIVE 0x20000000 // Normal device is active 33 | #define ASYNC_BOOT_AUTOCONF 0x10000000 // Autoconfigure port on bootup 34 | #define ASYNC_CLOSING 0x08000000 // Serial port is closing 35 | #define ASYNC_CTS_FLOW 0x04000000 // Do CTS flow control 36 | #define ASYNC_CHECK_CD 0x02000000 // i.e., CLOCAL 37 | #define ASYNC_SHARE_IRQ 0x01000000 // for multifunction cards 38 | #define ASYNC_INTERNAL_FLAGS 0xFF000000 // Internal flags 39 | 40 | struct serial_struct { 41 | int type; 42 | int line; 43 | int port; 44 | int irq; 45 | int flags; 46 | int xmit_fifo_size; 47 | int custom_divisor; 48 | int baud_base; 49 | unsigned short close_delay; 50 | char io_type; 51 | char reserved_char[1]; 52 | int hub6; 53 | unsigned short closing_wait; /* time to wait before closing */ 54 | unsigned short closing_wait2; /* no longer used... */ 55 | unsigned char *iomem_base; 56 | unsigned short iomem_reg_shift; 57 | int reserved[2]; 58 | }; 59 | 60 | typedef struct { 61 | int baud_rate; 62 | int min_return; 63 | } uart_config_t; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /software/ipv6_tunnel/prefix.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/binary" 5 | "encoding/json" 6 | "errors" 7 | "log" 8 | "net" 9 | "os" 10 | "strconv" 11 | "strings" 12 | "sync" 13 | ) 14 | 15 | type PrefixManager struct { 16 | prefixfile *os.File // the file to store the prefix assignments in 17 | prefixes map[string]string // map of id -> prefix 18 | inuse map[string]bool // map of prefix -> bool; marks prefixes as used 19 | prefixcidr *net.IPNet // the range of available prefixes 20 | prefixstart uint64 // first prefix in integer form 21 | lock sync.Mutex // only one client can get a prefix at a time 22 | } 23 | 24 | // When a client connects retrieve the prefix they should use. 25 | // First tries to find if they have already connected and uses the previous 26 | // prefix. 27 | func (pm *PrefixManager) getPrefix (id string) (prefix string, err error) { 28 | pm.lock.Lock() 29 | 30 | prefix, in := pm.prefixes[id] 31 | 32 | if !in { 33 | var i uint64 = pm.prefixstart 34 | ipb := make([]byte, 16) 35 | 36 | for { 37 | binary.BigEndian.PutUint64(ipb[0:8], i) 38 | binary.BigEndian.PutUint64(ipb[8:16], 0) 39 | possible_prefix := net.IP(ipb).String() + "/64" 40 | 41 | if pm.prefixcidr.Contains(ipb) { 42 | taken, in := pm.inuse[possible_prefix] 43 | if !in || !taken { 44 | pm.prefixes[id] = possible_prefix 45 | pm.inuse[possible_prefix] = true 46 | prefix = possible_prefix 47 | break 48 | } 49 | } else { 50 | pm.lock.Unlock() 51 | return "", errors.New("Out of prefixes") 52 | } 53 | i++ 54 | } 55 | } 56 | 57 | // Write the result to the file 58 | pm.prefixfile.Seek(0, 0) 59 | b, _ := json.Marshal(pm.prefixes) 60 | pm.prefixfile.Write(b) 61 | 62 | pm.lock.Unlock() 63 | return prefix, nil 64 | } 65 | 66 | func Create (filename string, prefixrange string) (*PrefixManager) { 67 | var err error 68 | 69 | var pm PrefixManager 70 | pm.prefixes = make(map[string]string) 71 | pm.inuse = make(map[string]bool) 72 | 73 | // Read in all the existing assignments 74 | assignbuf := make([]byte, 12000) 75 | pm.prefixfile, err = os.OpenFile(filename, os.O_RDWR, 0) 76 | rlen, err := pm.prefixfile.Read(assignbuf) 77 | err = json.Unmarshal(assignbuf[0:rlen], &pm.prefixes) 78 | 79 | // Put all of the assigned prefixes in the used set 80 | for k, _ := range pm.prefixes { 81 | pm.inuse[pm.prefixes[k]] = true 82 | } 83 | 84 | // Get the prefix block to select prefixes from 85 | _, pm.prefixcidr, err = net.ParseCIDR(prefixrange) 86 | if err != nil { log.Fatal(err) } 87 | 88 | // Figure out the first IP address in the prefix range 89 | prefixstrings := strings.Split(prefixrange, "/") 90 | prefixip := net.ParseIP(prefixstrings[0]) 91 | pm.prefixstart = binary.BigEndian.Uint64(prefixip) 92 | // Now mask only those bits in the prefix 93 | prefixlen, _ := strconv.Atoi(prefixstrings[1]) 94 | prefixlenu64 := uint64(prefixlen) 95 | pm.prefixstart = ((pm.prefixstart >> (64 - prefixlenu64)) << (64 - prefixlenu64)) 96 | 97 | 98 | return &pm 99 | } 100 | 101 | 102 | -------------------------------------------------------------------------------- /tinyos/apps/BorderRouter/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENT=BorderRouterC 2 | 3 | PFLAGS += -DCC2520_DEF_CHANNEL=19 4 | #PFLAGS += -DIEEE802154_PANID=0x689a 5 | PFLAGS += -DIEEE802154_PANID=0x0022 6 | #PFLAGS += -DIEEE802154_PANID=0xbbb1 7 | 8 | ################################################################################ 9 | ### Set the addressing scheme 10 | ################################################################################ 11 | 12 | # Use IN6_PREFIX with static addressing modes 13 | #PFLAGS += -DIN6_PREFIX=\"fec0::\" 14 | # Use BLIP Neighbor Discovery to autoconfigure an address 15 | PFLAGS += -DBLIP_ADDR_AUTOCONF=1 16 | # Use RPL and prefix information in DIO messages to autoconfigure an address 17 | PFLAGS += -DRPL_ADDR_AUTOCONF=0 18 | 19 | ################################################################################ 20 | ### Configure BLIP 21 | ################################################################################ 22 | 23 | # Configure the Neighbor Discovery mechanism 24 | PFLAGS += -DBLIP_SEND_ROUTER_SOLICITATIONS=1 25 | PFLAGS += -DBLIP_SEND_ROUTER_ADVERTISEMENTS=1 26 | 27 | # Configure the number of times BLIP tries to send a packet and how long it 28 | # waits between attempts 29 | #PFLAGS += -DBLIP_L2_RETRIES=5 30 | #PFLAGS += -DBLIP_L2_DELAY=103 31 | 32 | # Configure how many of the 6LoWPAN headers we support 33 | #PFLAGS += -DLIB6LOWPAN_FULL=1 34 | 35 | # Configure the header compression for 6LoWPAN 36 | PFLAGS += -DLIB6LOWPAN_HC_VERSION=6 37 | 38 | # Keep statistics about various BLIP/IPv6 parameters. See BlipStatistics.h 39 | #PFLAGS += -DBLIP_STATS 40 | #PFLAGS += -DBLIP_STATS_IP_MEM 41 | 42 | ################################################################################ 43 | ### Configure RPL 44 | ################################################################################ 45 | 46 | # Include the RPL layer if set to 1 47 | PFLAGS += -DRPL_ROUTING=1 48 | 49 | # If set keep routing information in each node. If not the root must keep all 50 | # routing information. 51 | PFLAGS += -DRPL_STORING_MODE=1 52 | PFLAGS += -DROUTE_TABLE_SZ=100 53 | 54 | # Choose the objective function RPL should use 55 | PFLAGS += -DRPL_OF_0=1 56 | PFLAGS += -DRPL_OF_MRHOF=0 57 | 58 | ################################################################################ 59 | ### Configure LPL 60 | ################################################################################ 61 | 62 | #PFLAGS += -DLOW_POWER_LISTENING 63 | #PFLAGS += -DLPL_SLEEP_INTERVAL=512 64 | #PFLAGS += -DLPL_DEF_LOCAL_WAKEUP=512 65 | #PFLAGS += -DLPL_DEF_REMOTE_WAKEUP=512 66 | 67 | ################################################################################ 68 | ### Configure printf() output 69 | ################################################################################ 70 | 71 | #PFLAGS += -DPRINTFUART_ENABLED 72 | 73 | ################################################################################ 74 | ### Configure GAP Radios 75 | ################################################################################ 76 | 77 | PFLAGS += -DGAP_RADIO_SELECT=1 78 | 79 | GOALS += blip rpl 80 | 81 | TINYOS_ROOT_DIR?=../.. 82 | include $(TINYOS_ROOT_DIR)/Makefile.include 83 | -------------------------------------------------------------------------------- /tinyos/tos/chips/linux/CommandLineP.nc: -------------------------------------------------------------------------------- 1 | 2 | module CommandLineP { 3 | provides { 4 | interface CommandLineArgs; 5 | } 6 | } 7 | 8 | implementation { 9 | 10 | #define MAX_ARGS 20 11 | #define MAX_ARG_LEN 100 12 | 13 | // 2D array of all of the arguments (white space separated) 14 | char args[MAX_ARGS][MAX_ARG_LEN]; 15 | 16 | uint8_t num_args = 0; 17 | 18 | bool inited = FALSE; 19 | 20 | error_t init() { 21 | int cmdline_fd; 22 | char fn_buf[100]; 23 | pid_t process_id; 24 | int ret; 25 | uint8_t arg_buf[(MAX_ARGS*MAX_ARG_LEN) + 1]; 26 | int i; 27 | 28 | if (inited) return SUCCESS; 29 | 30 | // Get the filename to the cmdline file that contains the arguments 31 | process_id = getpid(); 32 | ret = snprintf(fn_buf, 100, "/proc/%i/cmdline", process_id); 33 | 34 | cmdline_fd = open(fn_buf, O_RDONLY); 35 | if (cmdline_fd == -1) { 36 | ERROR("Unabled to open file of command line arguments.\n"); 37 | return FAIL; 38 | } 39 | 40 | ret = read(cmdline_fd, arg_buf, MAX_ARGS*MAX_ARG_LEN); 41 | if (ret == -1) { 42 | ERROR("Unable to read from command line file.\n"); 43 | return FAIL; 44 | } 45 | 46 | // Add a null character at the end of the file contents just in case. 47 | // This ensures that the last argument will be null terminated when it is 48 | // saved in the array. 49 | arg_buf[ret] = '\0'; 50 | 51 | { 52 | // Copy all arguments into our nice 2d array 53 | // All whitespace has been converted to '\0' by linux 54 | bool arg_started = FALSE; 55 | int arg_idx = -1; 56 | int arg_char_idx = 0; 57 | 58 | for (i=0; i<=ret; i++) { 59 | if (arg_buf[i] == 0) { 60 | // Skip whitespace 61 | if (arg_started && arg_char_idx < MAX_ARG_LEN) { 62 | // add the null byte 63 | args[arg_idx][arg_char_idx++] = '\0'; 64 | } 65 | arg_started = FALSE; 66 | continue; 67 | } 68 | 69 | if (!arg_started) { 70 | // start a new argument 71 | arg_idx++; 72 | arg_started = TRUE; 73 | arg_char_idx = 0; 74 | } 75 | 76 | if (arg_char_idx >= (MAX_ARG_LEN-1)) { 77 | // Skip the remainder of the argument after MAX_ARG_LEN 78 | // Save 1 byte for the null terminator 79 | continue; 80 | } 81 | if (arg_idx >= MAX_ARGS) { 82 | break; 83 | } 84 | 85 | args[arg_idx][arg_char_idx++] = arg_buf[i]; 86 | 87 | } 88 | 89 | num_args = arg_idx + 1; 90 | } 91 | 92 | CMDLINE_PRINTF("Number of args: %i\n", num_args); 93 | for (i=0; i= num_args) { 112 | return NULL; 113 | } 114 | return args[arg_idx]; 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /tinyos/tos/interfaces/PacketMetadata.nc: -------------------------------------------------------------------------------- 1 | 2 | // Retreive interesting auxillary info about a packet 3 | 4 | interface PacketMetadata { 5 | command uint8_t getLqi (message_t* msg); 6 | command uint8_t getRssi (message_t* msg); 7 | command void setLqi (message_t *msg, uint8_t lqi); 8 | command void setRssi (message_t *msg, uint8_t rssi); 9 | 10 | // Returns the timestamp of when the packet was received, in microseconds 11 | // from the unix epoch. 12 | command uint64_t getTimestamp (message_t* msg); 13 | command void setTimestamp (message_t* msg, uint64_t timestamp); 14 | 15 | 16 | /** 17 | * Set the maximum number of times attempt message delivery 18 | * Default is 0 19 | * @param 'message_t* ONE msg' 20 | * @param maxRetries the maximum number of attempts to deliver 21 | * the message 22 | */ 23 | command void setRetries(message_t *msg, uint16_t maxRetries); 24 | 25 | /** 26 | * Set a delay between each retry attempt 27 | * @param msg 28 | * @param retryDelay the delay betweeen retry attempts, in milliseconds 29 | */ 30 | command void setRetryDelay(message_t *msg, uint16_t retryDelay); 31 | 32 | /** 33 | * @param 'message_t* ONE msg' 34 | * @return the maximum number of retry attempts for this message 35 | */ 36 | command uint16_t getRetries(message_t *msg); 37 | 38 | /** 39 | * @param 'message_t* ONE msg' 40 | * @return the delay between retry attempts in ms for this message 41 | */ 42 | command uint16_t getRetryDelay(message_t *msg); 43 | 44 | /** 45 | * Tell a protocol that when it sends this packet, it should use synchronous 46 | * acknowledgments. 47 | * The acknowledgment is synchronous as the caller can check whether the 48 | * ack was received through the wasAcked() command as soon as a send operation 49 | * completes. 50 | * 51 | * @param 'message_t* ONE msg' - A message which should be acknowledged when transmitted. 52 | * @return SUCCESS if acknowledgements are enabled, EBUSY 53 | * if the communication layer cannot enable them at this time, FAIL 54 | * if it does not support them. 55 | */ 56 | 57 | async command error_t requestAck(message_t* msg); 58 | 59 | /** 60 | * Tell a protocol that when it sends this packet, it should not use 61 | * synchronous acknowledgments. 62 | * 63 | * @param 'message_t* ONE msg' - A message which should not be acknowledged when transmitted. 64 | * @return SUCCESS if acknowledgements are disabled, EBUSY 65 | * if the communication layer cannot disable them at this time, FAIL 66 | * if it cannot support unacknowledged communication. 67 | */ 68 | 69 | async command error_t noAck(message_t* msg); 70 | 71 | /** 72 | * Tell a caller whether or not a transmitted packet was acknowledged. 73 | * If acknowledgments on the packet had been disabled through noAck(), 74 | * then the return value is undefined. If a packet 75 | * layer does not support acknowledgements, this command must return always 76 | * return FALSE. 77 | * 78 | * @param 'message_t* ONE msg' - A transmitted message. 79 | * @return Whether the packet was acknowledged. 80 | * 81 | */ 82 | 83 | async command bool wasAcked(message_t* msg); 84 | 85 | command void setWasAcked (message_t* msg, bool ack); 86 | 87 | } 88 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLeds154/RadioCountToLeds154P.nc: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | #include "RadioCountToLeds154.h" 3 | 4 | #include 5 | 6 | /** 7 | * Implementation of the RadioCountToLeds application. RadioCountToLeds 8 | * maintains a 4Hz counter, broadcasting its value in an AM packet 9 | * every time it gets updated. A RadioCountToLeds node that hears a counter 10 | * displays the bottom three bits on its LEDs. This application is a useful 11 | * test to show that basic AM communication and timers work. 12 | * 13 | * @author Philip Levis 14 | * @date June 6 2005 15 | */ 16 | 17 | module RadioCountToLeds154P @safe() { 18 | uses { 19 | interface Leds; 20 | interface Boot; 21 | interface Receive; 22 | interface Ieee154Send; 23 | interface Timer as MilliTimer; 24 | interface SplitControl as RadioControl; 25 | interface Packet as Ieee154Packet; 26 | } 27 | } 28 | implementation { 29 | 30 | message_t packet; 31 | 32 | bool locked; 33 | uint16_t counter = 0; 34 | 35 | event void Boot.booted() { 36 | call RadioControl.start(); 37 | } 38 | 39 | event void RadioControl.startDone(error_t err) { 40 | if (err == SUCCESS) { 41 | call MilliTimer.startPeriodic(250); 42 | } 43 | else { 44 | call RadioControl.start(); 45 | } 46 | } 47 | 48 | event void RadioControl.stopDone(error_t err) { 49 | // do nothing 50 | } 51 | 52 | event void MilliTimer.fired() { 53 | error_t e; 54 | counter++; 55 | dbg("RadioCountToLedsC", "RadioCountToLedsC: timer fired, counter is %hu.\n", counter); 56 | if (locked) { 57 | return; 58 | } else { 59 | radio_count_msg_t* rcm = (radio_count_msg_t*) 60 | call Ieee154Packet.getPayload(&packet, sizeof(radio_count_msg_t)); 61 | if (rcm == NULL) { 62 | return; 63 | } 64 | 65 | rcm->counter = counter; 66 | e = call Ieee154Send.send(IEEE154_BROADCAST_ADDR, 67 | &packet, 68 | sizeof(radio_count_msg_t)); 69 | if (e == SUCCESS) { 70 | dbg("RadioCountToLedsC", "RadioCountToLedsC: packet sent.\n", counter); 71 | locked = TRUE; 72 | } 73 | } 74 | } 75 | 76 | event message_t* Receive.receive(message_t* bufPtr, 77 | void* payload, 78 | uint8_t len) { 79 | // printf("RadioCountToLedsC", "Received packet of length %hhu.\n", len); 80 | if (len != sizeof(radio_count_msg_t)) {return bufPtr;} 81 | else { 82 | radio_count_msg_t* rcm = (radio_count_msg_t*)payload; 83 | if (rcm->counter & 0x1) { 84 | call Leds.led0On(); 85 | } 86 | else { 87 | call Leds.led0Off(); 88 | } 89 | if (rcm->counter & 0x2) { 90 | call Leds.led1On(); 91 | } 92 | else { 93 | call Leds.led1Off(); 94 | } 95 | if (rcm->counter & 0x4) { 96 | call Leds.led2On(); 97 | } 98 | else { 99 | call Leds.led2Off(); 100 | } 101 | return bufPtr; 102 | } 103 | } 104 | 105 | event void Ieee154Send.sendDone(message_t* bufPtr, error_t error) { 106 | if (&packet == bufPtr) { 107 | locked = FALSE; 108 | } 109 | } 110 | 111 | } 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /tinyos/tos/chips/cc2520linux/CC2520LinuxLinkP.nc: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Miklos Maroti, 3 | * Author: Morten Tranberg Hansen 4 | * Author: Brad Campbell 5 | */ 6 | 7 | generic module CC2520LinuxLinkP () { 8 | provides { 9 | interface BareSend as Send; 10 | } 11 | uses { 12 | interface BareSend as SubSend; 13 | interface PacketMetadata; 14 | interface Timer as DelayTimer; 15 | } 16 | } 17 | 18 | implementation { 19 | enum { 20 | STATE_READY = 0, 21 | STATE_SENDING = 1, 22 | STATE_SENDDONE = 2, 23 | STATE_SIGNAL = 4, // add error code 24 | }; 25 | 26 | uint8_t state = STATE_READY; 27 | message_t *currentMsg; 28 | uint16_t totalRetries; 29 | 30 | 31 | // We do everything from a single task in order to call SubSend.send 32 | // and Send.sendDone only once. This helps inlining the code and 33 | // reduces the code size. 34 | // 35 | task void send() { 36 | uint16_t retries; 37 | 38 | retries = call PacketMetadata.getRetries(currentMsg); 39 | 40 | if (state == STATE_SENDDONE) { 41 | if (retries == 0 || call PacketMetadata.wasAcked(currentMsg)) { 42 | state = STATE_SIGNAL + SUCCESS; 43 | 44 | } else if (++totalRetries < retries) { 45 | uint16_t delay; 46 | 47 | state = STATE_SENDING; 48 | delay = call PacketMetadata.getRetryDelay(currentMsg); 49 | 50 | if (delay > 0) { 51 | call DelayTimer.startOneShot(delay); 52 | return; 53 | } 54 | 55 | } else { 56 | state = STATE_SIGNAL + FAIL; 57 | } 58 | } 59 | 60 | if (state == STATE_SENDING) { 61 | state = STATE_SENDDONE; 62 | 63 | if (call SubSend.send(currentMsg) != SUCCESS) { 64 | post send(); 65 | } 66 | 67 | return; 68 | } 69 | 70 | if (state >= STATE_SIGNAL) { 71 | error_t error = state - STATE_SIGNAL; 72 | 73 | // do not update the retries count for non packet link messages 74 | if (retries > 0) { 75 | call PacketMetadata.setRetries(currentMsg, totalRetries); 76 | } 77 | 78 | state = STATE_READY; 79 | signal Send.sendDone(currentMsg, error); 80 | } 81 | } 82 | 83 | event void SubSend.sendDone(message_t* msg, error_t error) { 84 | if (error != SUCCESS) { 85 | state = STATE_SIGNAL + error; 86 | } 87 | 88 | post send(); 89 | } 90 | 91 | event void DelayTimer.fired() { 92 | post send(); 93 | } 94 | 95 | command error_t Send.send(message_t *msg) { 96 | if (state != STATE_READY) return EBUSY; 97 | 98 | // it is enough to set it only once 99 | if (call PacketMetadata.getRetries(msg) > 0) { 100 | call PacketMetadata.requestAck(msg); 101 | } 102 | 103 | currentMsg = msg; 104 | totalRetries = 0; 105 | state = STATE_SENDING; 106 | post send(); 107 | 108 | return SUCCESS; 109 | } 110 | 111 | command error_t Send.cancel(message_t *msg) { 112 | if (currentMsg != msg || state == STATE_READY) { 113 | return FAIL; 114 | } 115 | 116 | // if a send is in progress 117 | if (state == STATE_SENDDONE) { 118 | call SubSend.cancel(msg); 119 | } else { 120 | post send(); 121 | } 122 | 123 | call DelayTimer.stop(); 124 | state = STATE_SIGNAL + ECANCEL; 125 | 126 | return SUCCESS; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /tinyos/apps/RadioCountToLedsBlip/RadioCountToLedsBlipP.nc: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | #include "RadioCountToLedsBlip.h" 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include "blip_printf.h" 10 | #include "neighbor_discovery.h" 11 | 12 | /** 13 | * Implementation of the RadioCountToLeds application. RadioCountToLeds 14 | * maintains a 4Hz counter, broadcasting its value in an AM packet 15 | * every time it gets updated. A RadioCountToLeds node that hears a counter 16 | * displays the bottom three bits on its LEDs. This application is a useful 17 | * test to show that basic AM communication and timers work. 18 | * 19 | * @author Philip Levis 20 | * @date June 6 2005 21 | */ 22 | 23 | module RadioCountToLedsBlipP @safe() { 24 | uses { 25 | interface Boot; 26 | interface Leds; 27 | interface Timer as MilliTimer; 28 | 29 | interface SplitControl as RadioControl; 30 | interface UDP as UDPService; 31 | } 32 | } 33 | implementation { 34 | 35 | // message_t packet; 36 | 37 | bool locked; 38 | uint16_t counter = 0; 39 | 40 | radio_count_msg_t rcm; 41 | radio_count_msg_t* rcm_ptr; 42 | 43 | event void Boot.booted() { 44 | call RadioControl.start(); 45 | } 46 | 47 | event void RadioControl.startDone(error_t err) { 48 | if (err == SUCCESS) { 49 | call UDPService.bind(2001); 50 | call MilliTimer.startPeriodic(1000); 51 | } 52 | else { 53 | call RadioControl.start(); 54 | } 55 | } 56 | 57 | event void MilliTimer.fired() { 58 | error_t e; 59 | struct sockaddr_in6 dest; 60 | counter++; 61 | dbg("RadioCountToLedsC", "RadioCountToLedsC: timer fired, counter is %hu.\n", counter); 62 | // if (locked) { 63 | // return; 64 | // } else { 65 | 66 | 67 | // link-local multicast 68 | inet_pton6("ff02::1", &dest.sin6_addr); 69 | 70 | // some other random address 71 | // inet_pton6("2001::1", &dest.sin6_addr); 72 | dest.sin6_port = htons(2001); 73 | 74 | rcm.counter = counter; 75 | call UDPService.sendto(&dest, &rcm, sizeof(radio_count_msg_t)); 76 | 77 | // if (e == SUCCESS) { 78 | // dbg("RadioCountToLedsC", "RadioCountToLedsC: packet sent.\n", counter); 79 | // locked = TRUE; 80 | // } 81 | // } 82 | } 83 | 84 | event void UDPService.recvfrom (struct sockaddr_in6 *from, 85 | void *payload, 86 | uint16_t len, 87 | struct ip6_metadata *meta) { 88 | 89 | if (len != sizeof(radio_count_msg_t)) { 90 | // printf("RCTLB: bad len\n"); 91 | return; 92 | } else { 93 | rcm_ptr = (radio_count_msg_t*)payload; 94 | if (rcm_ptr->counter & 0x1) { 95 | call Leds.led0On(); 96 | } 97 | else { 98 | call Leds.led0Off(); 99 | } 100 | if (rcm_ptr->counter & 0x2) { 101 | call Leds.led1On(); 102 | } 103 | else { 104 | call Leds.led1Off(); 105 | } 106 | if (rcm_ptr->counter & 0x4) { 107 | call Leds.led2On(); 108 | } 109 | else { 110 | call Leds.led2Off(); 111 | } 112 | return; 113 | } 114 | } 115 | 116 | 117 | 118 | event void RadioControl.stopDone (error_t e) { } 119 | 120 | } 121 | 122 | 123 | 124 | 125 | --------------------------------------------------------------------------------