moved test applications from platform root to separate directory
This commit is contained in:
parent
6f862c4506
commit
014c6c82e1
10 changed files with 274 additions and 237 deletions
|
@ -26,44 +26,33 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testbutton.c,v 1.3 2007/04/02 16:31:28 fros4943 Exp $
|
||||
* $Id: testbutton.c,v 1.1 2007/11/25 22:46:14 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "sys/loader.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/list.h"
|
||||
#include "lib/random.h"
|
||||
|
||||
#include "net/uip.h"
|
||||
|
||||
#include "lib/sensors.h"
|
||||
#include "sys/log.h"
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "printf2log.h" /* COOJA specific: Transforms printf() to log_message() */
|
||||
|
||||
PROCESS(button_test_process, "Button test process");
|
||||
PROCESS(test_button_process, "Test button process");
|
||||
AUTOSTART_PROCESSES(&test_button_process);
|
||||
|
||||
PROCESS_THREAD(button_test_process, ev, data)
|
||||
PROCESS_THREAD(test_button_process, ev, data)
|
||||
{
|
||||
static int custom_counter = 0;
|
||||
static char logMess[100];
|
||||
static int counter = 0;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
sprintf(logMess, "Starting Button test process (counter=%i)\n", custom_counter);
|
||||
log_message(logMess, "");
|
||||
printf("Starting Button test process (counter=%i)\n", counter);
|
||||
button_sensor.activate();
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if (ev == sensors_event && data == &button_sensor && button_sensor.value(0)) {
|
||||
custom_counter++;
|
||||
|
||||
sprintf(logMess, "Button pressed (counter=%i)\n", custom_counter);
|
||||
log_message(logMess, "");
|
||||
counter++;
|
||||
printf("Button pressed (counter=%i)\n", counter);
|
||||
}
|
||||
}
|
||||
|
|
@ -26,51 +26,55 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testcfs.c,v 1.1 2006/10/11 14:15:16 fros4943 Exp $
|
||||
* $Id: testcfs.c,v 1.1 2007/11/25 22:46:14 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "contiki.h"
|
||||
#include "sys/etimer.h"
|
||||
#include "sys/clock.h"
|
||||
#include "sys/log.h"
|
||||
#include "cfs/cfs.h"
|
||||
|
||||
PROCESS(cfs_test_process, "CFS test process");
|
||||
#include <stdio.h>
|
||||
#include "printf2log.h" /* COOJA specific: Transforms printf() to log_message() */
|
||||
|
||||
PROCESS_THREAD(cfs_test_process, ev, data)
|
||||
PROCESS(test_cfs_process, "Test CFS process");
|
||||
AUTOSTART_PROCESSES(&test_cfs_process);
|
||||
|
||||
PROCESS_THREAD(test_cfs_process, ev, data)
|
||||
{
|
||||
static struct etimer mytimer;
|
||||
static char wroteLastTime = 0;
|
||||
static struct etimer et;
|
||||
static int fd;
|
||||
static u16_t counter;
|
||||
static char buf[30];
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
etimer_set(&mytimer, CLOCK_SECOND);
|
||||
fd = cfs_open("ignored_name", CFS_READ | CFS_WRITE);
|
||||
|
||||
log_message("Starting CFS test process\n", "");
|
||||
printf("Starting CFS test process\n");
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
|
||||
/* Write to filesystem */
|
||||
sprintf(buf, "filedata%04ifiledata%04i", counter, counter);
|
||||
fd = cfs_open("filename", CFS_READ | CFS_WRITE);
|
||||
cfs_seek(fd, 0);
|
||||
cfs_write(fd, buf, 24);
|
||||
cfs_close(fd);
|
||||
printf("Wrote to filesystem: '%s'\n", buf);
|
||||
counter++;
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
|
||||
/* Read from filesystem */
|
||||
fd = cfs_open("file1", CFS_READ | CFS_WRITE);
|
||||
cfs_seek(fd, 4);
|
||||
cfs_read(fd, buf, 12);
|
||||
cfs_close(fd);
|
||||
buf[12] = '\0';
|
||||
printf("Read from filesystem: '%s'\n", buf);
|
||||
|
||||
if (etimer_expired(&mytimer)) {
|
||||
if (wroteLastTime) {
|
||||
wroteLastTime = !wroteLastTime;
|
||||
cfs_seek(fd, 5);
|
||||
cfs_read(fd, &buf[0], 9);
|
||||
buf[10] = '\0';
|
||||
log_message("Read from filesystem:", buf);
|
||||
log_message("\n", "");
|
||||
} else {
|
||||
wroteLastTime = !wroteLastTime;
|
||||
cfs_seek(fd, 0);
|
||||
cfs_write(fd, "tjobaloba labadobahoba", 22);
|
||||
log_message("Wrote to filesystem\n", "");
|
||||
}
|
||||
etimer_restart(&mytimer);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
|
@ -26,14 +26,36 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testcfs.h,v 1.1 2006/10/11 14:15:16 fros4943 Exp $
|
||||
* $Id: testctimer.c,v 1.1 2007/11/25 22:46:14 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CFS_TEST_H__
|
||||
#define __CFS_TEST_H__
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rime/ctimer.h"
|
||||
|
||||
PROCESS_NAME(cfs_test_process);
|
||||
#include <stdio.h>
|
||||
#include "printf2log.h" /* COOJA specific: Transforms printf() to log_message() */
|
||||
|
||||
#endif /* __CFS_TEST_H__ */
|
||||
PROCESS(test_ctimer_process, "Callback timer test process");
|
||||
AUTOSTART_PROCESSES(&test_ctimer_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct ctimer ct;
|
||||
static u16_t counter = 0;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
callback(void *ptr)
|
||||
{
|
||||
counter++;
|
||||
printf("Callback function called at time %lu (counter=%i)\n", clock_time(), counter);
|
||||
ctimer_set(&ct, CLOCK_SECOND/2, callback, NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(test_ctimer_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Starting callback timer test process (counter=%i)\n", counter);
|
||||
|
||||
ctimer_set(&ct, CLOCK_SECOND/2, callback, NULL);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
|
@ -26,14 +26,34 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testbutton.h,v 1.1 2006/08/21 12:11:18 fros4943 Exp $
|
||||
* $Id: testetimer.c,v 1.1 2007/11/25 22:46:14 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#ifndef __BUTTON_TEST_H__
|
||||
#define __BUTTON_TEST_H__
|
||||
|
||||
#include "contiki.h"
|
||||
#include "sys/etimer.h"
|
||||
|
||||
PROCESS_NAME(button_test_process);
|
||||
#include <stdio.h>
|
||||
#include "printf2log.h" /* COOJA specific: Transforms printf() to log_message() */
|
||||
|
||||
#endif /* __BUTTON_TEST_H__ */
|
||||
PROCESS(test_etimer_process, "Event timer test process");
|
||||
AUTOSTART_PROCESSES(&test_etimer_process);
|
||||
|
||||
PROCESS_THREAD(test_etimer_process, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
static u16_t counter = 0;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Starting event timer test process (counter=%i)\n", counter);
|
||||
|
||||
while(1) {
|
||||
etimer_set(&et, CLOCK_SECOND/2);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
|
||||
counter++;
|
||||
printf("Event timer triggered event at time %lu (counter=%i)\n", clock_time(), counter);
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
|
@ -26,52 +26,48 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testetimer.c,v 1.2 2007/04/02 16:31:28 fros4943 Exp $
|
||||
* $Id: testsensors.c,v 1.1 2007/11/25 22:46:14 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/pir-sensor.h"
|
||||
#include "dev/vib-sensor.h"
|
||||
#include "dev/radio-sensor.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "contiki.h"
|
||||
#include "sys/loader.h"
|
||||
#include "printf2log.h" /* COOJA specific: Transforms printf() to log_message() */
|
||||
|
||||
#include "lib/list.h"
|
||||
#include "lib/random.h"
|
||||
PROCESS(test_sensors_process, "Test sensors process");
|
||||
AUTOSTART_PROCESSES(&test_sensors_process);
|
||||
|
||||
#include "net/uip.h"
|
||||
|
||||
#include "sys/etimer.h"
|
||||
#include "sys/clock.h"
|
||||
|
||||
#include "lib/sensors.h"
|
||||
#include "sys/log.h"
|
||||
|
||||
|
||||
PROCESS(etimer_test_process, "ETimer test process");
|
||||
|
||||
PROCESS_THREAD(etimer_test_process, ev, data)
|
||||
PROCESS_THREAD(test_sensors_process, ev, data)
|
||||
{
|
||||
static struct etimer mytimer;
|
||||
|
||||
static int custom_counter = 0;
|
||||
static char logMess[100];
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
etimer_set(&mytimer, 1111);
|
||||
|
||||
sprintf(logMess, "Starting event timer test process (counter=%i)\n", custom_counter);
|
||||
log_message(logMess, "");
|
||||
|
||||
printf("Starting sensors test process\n");
|
||||
button_sensor.activate();
|
||||
pir_sensor.activate();
|
||||
vib_sensor.activate();
|
||||
radio_sensor.activate();
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if (etimer_expired(&mytimer)) {
|
||||
custom_counter++;
|
||||
sprintf(logMess, "Timed out (counter=%i)\n", custom_counter);
|
||||
log_message(logMess, "");
|
||||
|
||||
etimer_restart(&mytimer);
|
||||
if (ev == sensors_event) {
|
||||
if (data == &button_sensor) {
|
||||
printf("Button\n");
|
||||
} else if (data == &vib_sensor) {
|
||||
printf("Vibration sensor\n");
|
||||
} else if (data == &pir_sensor) {
|
||||
printf("Passive IR sensor\n");
|
||||
} else {
|
||||
printf("Unknown sensor\n");
|
||||
}
|
||||
} else {
|
||||
printf("Non-sensor event triggered\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PROCESS_END();
|
|
@ -26,54 +26,43 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testserial.c,v 1.2 2007/04/02 16:31:28 fros4943 Exp $
|
||||
* $Id: testserial.c,v 1.1 2007/11/25 22:46:14 fros4943 Exp $
|
||||
*/
|
||||
|
||||
|
||||
#include "contiki.h"
|
||||
#include "sys/loader.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/list.h"
|
||||
#include "lib/random.h"
|
||||
|
||||
#include "net/uip.h"
|
||||
|
||||
#include "lib/sensors.h"
|
||||
#include "sys/log.h"
|
||||
#include "dev/serial.h"
|
||||
#include "dev/rs232.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "printf2log.h" /* COOJA specific: Transforms printf() to log_message() */
|
||||
|
||||
PROCESS(serial_test_process, "Serial test process");
|
||||
PROCESS(test_serial_process, "Serial test process");
|
||||
AUTOSTART_PROCESSES(&test_serial_process);
|
||||
|
||||
AUTOSTART_PROCESSES(&serial_test_process);
|
||||
|
||||
PROCESS_THREAD(serial_test_process, ev, data)
|
||||
PROCESS_THREAD(test_serial_process, ev, data)
|
||||
{
|
||||
static struct etimer mytimer;
|
||||
static struct etimer et;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
etimer_set(&mytimer, CLOCK_SECOND);
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
||||
/* Starts the serial process among other */
|
||||
/* Start serial process */
|
||||
serial_init();
|
||||
|
||||
log_message("Starting serial test process\n", "");
|
||||
printf("Starting serial test process\n");
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if (etimer_expired(&mytimer)) {
|
||||
log_message("Sending serial data now\n", "");
|
||||
etimer_restart(&mytimer);
|
||||
if (etimer_expired(&et)) {
|
||||
printf("Sending serial data now\n");
|
||||
rs232_print("GNU's not Unix\n");
|
||||
etimer_restart(&et);
|
||||
}
|
||||
|
||||
if(ev == serial_event_message) {
|
||||
log_message("Message received: ", data);
|
||||
printf("Message received: '%s'\n", data);
|
||||
}
|
||||
}
|
||||
|
98
platform/cooja/testapps/testuaodv.c
Normal file
98
platform/cooja/testapps/testuaodv.c
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testuaodv.c,v 1.1 2007/11/25 22:46:14 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "net/uip.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include "net/uaodv.h"
|
||||
#include "net/uaodv-rt.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "printf2log.h" /* COOJA specific: Transforms printf() to log_message() */
|
||||
|
||||
#define COOJA_PORT 1234
|
||||
|
||||
PROCESS(test_uaodv_process, "uIP uAODV test process");
|
||||
AUTOSTART_PROCESSES(&uaodv_process, &test_uaodv_process);
|
||||
|
||||
static struct uip_udp_conn *out_conn;
|
||||
static struct uip_udp_conn *in_conn;
|
||||
/*---------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(test_uaodv_process, ev, data)
|
||||
{
|
||||
static uip_ipaddr_t addr;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("uIP uAODV test process started\n");
|
||||
|
||||
uip_ipaddr(&addr, 0,0,0,0);
|
||||
in_conn = udp_new(&addr, HTONS(0), NULL);
|
||||
uip_udp_bind(in_conn, HTONS(COOJA_PORT));
|
||||
|
||||
uip_ipaddr(&addr, 10,10,10,4);
|
||||
out_conn = udp_new(&addr, HTONS(COOJA_PORT), NULL);
|
||||
|
||||
button_sensor.activate();
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if(ev == sensors_event && data == &button_sensor && button_sensor.value(0)) {
|
||||
struct uaodv_rt_entry *route;
|
||||
|
||||
uip_ipaddr(&addr, 10,10,10,4);
|
||||
route = uaodv_rt_lookup_any(&addr);
|
||||
if (route == NULL || route->is_bad) {
|
||||
printf("%d.%d.%d.%d: lookup %d.%d.%d.%d\n", uip_ipaddr_to_quad(&uip_hostaddr), uip_ipaddr_to_quad(&addr));
|
||||
uaodv_request_route_to(&addr);
|
||||
} else {
|
||||
printf("%d.%d.%d.%d: send to %d.%d.%d.%d\n", uip_ipaddr_to_quad(&uip_hostaddr), uip_ipaddr_to_quad(&addr));
|
||||
tcpip_poll_udp(out_conn);
|
||||
PROCESS_WAIT_UNTIL(ev == tcpip_event && uip_poll());
|
||||
uip_send("cooyah COOJA", 12);
|
||||
}
|
||||
}
|
||||
|
||||
if(ev == tcpip_event && uip_newdata()) {
|
||||
((char*) uip_appdata)[uip_datalen()] = 0;
|
||||
printf("data received from %d.%d.%d.%d: %s\n",
|
||||
uip_ipaddr_to_quad(&((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])->srcipaddr),
|
||||
(char *)uip_appdata);
|
||||
leds_toggle(LEDS_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
|
@ -26,64 +26,61 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testcooja.c,v 1.1 2007/03/22 10:04:47 fros4943 Exp $
|
||||
* $Id: testuip.c,v 1.1 2007/11/25 22:46:14 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "net/uip.h"
|
||||
#include "lib/sensors.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "sys/log.h"
|
||||
#include "node-id.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "printf2log.h" /* COOJA specific: Transforms printf() to log_message() */
|
||||
|
||||
#define COOJA_PORT 1234
|
||||
|
||||
PROCESS(cooja_test_process, "Example process for COOJA");
|
||||
AUTOSTART_PROCESSES(&cooja_test_process);
|
||||
PROCESS(test_uip_process, "uIP test process");
|
||||
AUTOSTART_PROCESSES(&test_uip_process);
|
||||
|
||||
static struct uip_udp_conn *broadcast_conn;
|
||||
/*---------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(cooja_test_process, ev, data)
|
||||
PROCESS_THREAD(test_uip_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
PROCESS_BEGIN();
|
||||
|
||||
log_message("Example process started", "");
|
||||
|
||||
broadcast_conn = udp_broadcast_new(COOJA_PORT , NULL);
|
||||
printf("uIP test process started\n");
|
||||
|
||||
button_sensor.activate();
|
||||
broadcast_conn = udp_broadcast_new(COOJA_PORT, NULL);
|
||||
button_sensor.activate();
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
log_message("An event occured: ", "");
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
printf("An event occured: ");
|
||||
|
||||
if(ev == PROCESS_EVENT_EXIT) {
|
||||
log_message("shutting down\n", "");
|
||||
break;
|
||||
}
|
||||
if(ev == PROCESS_EVENT_EXIT) {
|
||||
printf("shutting down\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(ev == sensors_event && data == &button_sensor && button_sensor.value(0)) {
|
||||
log_message("the button is pressed, sending packet\n", "");
|
||||
if(ev == sensors_event && data == &button_sensor && button_sensor.value(0)) {
|
||||
printf("button clicked, sending packet\n");
|
||||
|
||||
tcpip_poll_udp(broadcast_conn);
|
||||
PROCESS_WAIT_UNTIL(ev == tcpip_event && uip_poll());
|
||||
uip_send("cooyah COOJA", 12);
|
||||
}
|
||||
|
||||
if(ev == sensors_event && data == &button_sensor && !button_sensor.value(0)) {
|
||||
log_message("the button was released again, doing nothing\n", "");
|
||||
}
|
||||
tcpip_poll_udp(broadcast_conn);
|
||||
PROCESS_WAIT_UNTIL(ev == tcpip_event && uip_poll());
|
||||
uip_send("cooyah COOJA", 12);
|
||||
}
|
||||
|
||||
if(ev == tcpip_event && uip_newdata()) {
|
||||
log_message("a packet was received, turning on leds\n", "");
|
||||
log_message("PACKET DATA: ", uip_appdata);
|
||||
leds_on(LEDS_ALL);
|
||||
}
|
||||
|
||||
}
|
||||
if(ev == sensors_event && data == &button_sensor && !button_sensor.value(0)) {
|
||||
printf("button released, ignoring event\n");
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
if(ev == tcpip_event && uip_newdata()) {
|
||||
printf("a packet was received, toggling leds\n");
|
||||
printf("packet data: '%s'\n", (char*) uip_appdata);
|
||||
leds_toggle(LEDS_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testetimer.h,v 1.1 2006/08/21 12:11:17 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#ifndef __ETIMER_TEST_H__
|
||||
#define __ETIMER_TEST_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(etimer_test_process);
|
||||
|
||||
#endif /* __ETIMER_TEST_H__ */
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: testserial.h,v 1.1 2006/08/21 12:11:18 fros4943 Exp $
|
||||
*/
|
||||
|
||||
#ifndef __BUTTON_TEST_H__
|
||||
#define __BUTTON_TEST_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(button_test_process);
|
||||
|
||||
#endif /* __BUTTON_TEST_H__ */
|
Loading…
Reference in a new issue