A set of simple example programs for the ESB platform
This commit is contained in:
parent
3552d70176
commit
0e2a28da94
84
platform/esb/apps/beeper.c
Normal file
84
platform/esb/apps/beeper.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: beeper.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*/
|
||||
#include "contiki-esb.h"
|
||||
|
||||
PROCESS(beeper_process, "Beeper");
|
||||
|
||||
static struct etimer etimer;
|
||||
|
||||
static struct pt beeper_pt;
|
||||
|
||||
static
|
||||
PT_THREAD(beeper_thread(struct pt *pt))
|
||||
{
|
||||
PT_BEGIN(pt);
|
||||
|
||||
while(1) {
|
||||
PT_WAIT_UNTIL(pt, etimer_expired(&etimer));
|
||||
etimer_reset(&etimer);
|
||||
leds_invert(LEDS_RED);
|
||||
beep();
|
||||
|
||||
PT_WAIT_UNTIL(pt, etimer_expired(&etimer));
|
||||
etimer_reset(&etimer);
|
||||
leds_invert(LEDS_RED);
|
||||
}
|
||||
|
||||
PT_END(pt);
|
||||
}
|
||||
|
||||
PROCESS_THREAD(beeper_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
etimer_set(&etimer, CLOCK_SECOND / 2);
|
||||
PT_INIT(&beeper_pt);
|
||||
|
||||
button_sensor.activate();
|
||||
|
||||
while(1) {
|
||||
|
||||
beeper_thread(&beeper_pt);
|
||||
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if(ev == codeprop_event_quit) {
|
||||
break;
|
||||
} else if(ev == sensors_event &&
|
||||
data == &button_sensor) {
|
||||
leds_invert(LEDS_YELLOW);
|
||||
}
|
||||
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
137
platform/esb/apps/fader.c
Normal file
137
platform/esb/apps/fader.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: fader.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-esb.h"
|
||||
|
||||
PROCESS(fader_process, "LED fader");
|
||||
AUTOSTART_PROCESSES(&fader_process);
|
||||
|
||||
#define ON 1
|
||||
#define OFF 0
|
||||
|
||||
static unsigned char onoroff;
|
||||
static struct etimer etimer;
|
||||
static struct pt fade_pt, fade_in_pt, fade_out_pt;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(fade_in(struct pt *pt))
|
||||
{
|
||||
static int delay;
|
||||
|
||||
PT_BEGIN(pt);
|
||||
|
||||
for(delay = 3980; delay > 20; delay -= 20) {
|
||||
leds_on(LEDS_ALL);
|
||||
clock_delay(4000 - delay);
|
||||
leds_off(LEDS_ALL);
|
||||
clock_delay(delay);
|
||||
PT_YIELD(pt);
|
||||
}
|
||||
|
||||
PT_END(pt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(fade_out(struct pt *pt))
|
||||
{
|
||||
static int delay;
|
||||
|
||||
PT_BEGIN(pt);
|
||||
|
||||
for(delay = 20; delay < 3980; delay += 20) {
|
||||
leds_on(LEDS_ALL);
|
||||
clock_delay(4000 - delay);
|
||||
leds_off(LEDS_ALL);
|
||||
clock_delay(delay);
|
||||
PT_YIELD(pt);
|
||||
}
|
||||
|
||||
PT_END(pt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(fade(struct pt *pt))
|
||||
{
|
||||
PT_BEGIN(pt);
|
||||
|
||||
PT_SPAWN(pt, &fade_in_pt, fade_in(&fade_in_pt));
|
||||
PT_SPAWN(pt, &fade_out_pt, fade_out(&fade_out_pt));
|
||||
|
||||
etimer_set(&etimer, CLOCK_SECOND * 10);
|
||||
PT_WAIT_UNTIL(pt, etimer_expired(&etimer));
|
||||
|
||||
PT_END(pt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(fader_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
PT_INIT(&fade_pt);
|
||||
PT_INIT(&fade_in_pt);
|
||||
PT_INIT(&fade_out_pt);
|
||||
onoroff = ON;
|
||||
etimer_set(&etimer, CLOCK_SECOND * 32);
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER) {
|
||||
etimer_reset(&etimer);
|
||||
PT_INIT(&fade_pt);
|
||||
process_poll(&fader_process);
|
||||
}
|
||||
|
||||
if(onoroff == ON &&
|
||||
PT_SCHEDULE(fade(&fade_pt))) {
|
||||
process_poll(&fader_process);
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
fader_on(void)
|
||||
{
|
||||
onoroff = ON;
|
||||
process_poll(&fader_process);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
fader_off(void)
|
||||
{
|
||||
onoroff = OFF;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
45
platform/esb/apps/fader.h
Normal file
45
platform/esb/apps/fader.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: fader.h,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __FADER_H__
|
||||
#define __FADER_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(fader_process);
|
||||
|
||||
void fader_on(void);
|
||||
void fader_off(void);
|
||||
|
||||
#endif /* __FADER_H__ */
|
67
platform/esb/apps/helloworld.c
Normal file
67
platform/esb/apps/helloworld.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* This file is part of the Configurable Sensor Network Application
|
||||
* Architecture for sensor nodes running the Contiki operating system.
|
||||
*
|
||||
* $Id: helloworld.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2006-03-07
|
||||
* Updated : $Date: 2006/06/18 07:48:48 $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include "contiki-esb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
PROCESS(helloworld_process, "Helloworld");
|
||||
|
||||
AUTOSTART_PROCESSES(&helloworld_process);
|
||||
|
||||
static struct etimer timer;
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(helloworld_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
etimer_set(&timer, CLOCK_SECOND * 2);
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
|
||||
|
||||
etimer_reset(&timer);
|
||||
leds_invert(LEDS_YELLOW);
|
||||
printf("Hello world!\n");
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
201
platform/esb/apps/pinger.c
Normal file
201
platform/esb/apps/pinger.c
Normal file
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: pinger.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-esb.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
PROCESS(pinger, "Pinger");
|
||||
|
||||
static struct uip_udp_conn *conn;
|
||||
|
||||
struct data {
|
||||
u8_t dummy_data[20];
|
||||
u16_t id;
|
||||
u16_t seqno;
|
||||
u8_t pingpong;
|
||||
#define PING 0
|
||||
#define PONG 1
|
||||
};
|
||||
|
||||
static unsigned char pingeron;
|
||||
static struct etimer etimer;
|
||||
|
||||
static unsigned short sent_seqno, last_seqno;
|
||||
|
||||
#define PORT 9145
|
||||
|
||||
static int place_id = 0, packet_count = 0;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
quit(void)
|
||||
{
|
||||
process_exit(&pinger);
|
||||
LOADER_UNLOAD();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
udp_appcall(void *arg)
|
||||
{
|
||||
struct data *d;
|
||||
/* char buf[50];*/
|
||||
d = (struct data *)uip_appdata;
|
||||
|
||||
if(uip_newdata()) {
|
||||
leds_toggle(LEDS_YELLOW);
|
||||
/* beep();*/
|
||||
|
||||
/* if(htons(d->seqno) != last_seqno + 1) {
|
||||
leds_toggle(LEDS_RED);
|
||||
beep_quick(2);
|
||||
}*/
|
||||
/* last_seqno = htons(d->seqno);*/
|
||||
/* uip_udp_send(sizeof(struct data));*/
|
||||
/* snprintf(buf, sizeof(buf), "Packet received id %d signal %u\n",
|
||||
d->id, tr1001_sstrength());
|
||||
|
||||
rs232_print(buf);*/
|
||||
/* if(d->pingpong == PING) {
|
||||
d->pingpong = PONG;
|
||||
} else {
|
||||
d->pingpong = PING;
|
||||
d->seqno = htons(htons(d->seqno) + 1);
|
||||
}*/
|
||||
/* uip_udp_send(sizeof(struct data));
|
||||
timer_restart(&timer);*/
|
||||
} else if(uip_poll()) {
|
||||
if(pingeron && etimer_expired(&etimer) && packet_count > 0) {
|
||||
--packet_count;
|
||||
d->id = place_id;
|
||||
d->pingpong = PING;
|
||||
d->seqno = htons(sent_seqno);
|
||||
++sent_seqno;
|
||||
uip_udp_send(sizeof(struct data));
|
||||
etimer_reset(&etimer);
|
||||
leds_toggle(LEDS_GREEN);
|
||||
}
|
||||
|
||||
if(packet_count == 0) {
|
||||
pingeron = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(config_thread(struct pt *pt, process_event_t ev, process_data_t data))
|
||||
{
|
||||
static struct etimer pushtimer;
|
||||
static int counter;
|
||||
|
||||
PT_BEGIN(pt);
|
||||
|
||||
|
||||
while(1) {
|
||||
|
||||
PT_WAIT_UNTIL(pt, ev == sensors_event &&
|
||||
(struct sensors_sensor *)data == &button_sensor);
|
||||
|
||||
beep();
|
||||
|
||||
leds_on(LEDS_YELLOW);
|
||||
|
||||
etimer_set(&pushtimer, CLOCK_SECOND);
|
||||
for(counter = 0; !etimer_expired(&pushtimer); ++counter) {
|
||||
etimer_restart(&pushtimer);
|
||||
PT_YIELD_UNTIL(pt, (ev == sensors_event &&
|
||||
(struct sensors_sensor *)data == &button_sensor) ||
|
||||
etimer_expired(&pushtimer));
|
||||
}
|
||||
|
||||
place_id = counter;
|
||||
|
||||
beep_quick(place_id);
|
||||
|
||||
pingeron = 1;
|
||||
|
||||
packet_count = 20;
|
||||
|
||||
etimer_set(&etimer, CLOCK_SECOND / 2);
|
||||
|
||||
leds_off(LEDS_YELLOW);
|
||||
|
||||
leds_on(LEDS_RED);
|
||||
PT_WAIT_UNTIL(pt, packet_count == 0);
|
||||
|
||||
pingeron = 0;
|
||||
leds_off(LEDS_RED);
|
||||
}
|
||||
|
||||
PT_END(pt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(pinger, ev, data)
|
||||
{
|
||||
static struct pt config_pt;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
pingeron = 0;
|
||||
|
||||
conn = udp_broadcast_new(HTONS(PORT), NULL);
|
||||
|
||||
PT_INIT(&config_pt);
|
||||
|
||||
button_sensor.activate();
|
||||
|
||||
|
||||
while(1) {
|
||||
|
||||
config_thread(&config_pt, ev, data);
|
||||
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
printf("Event %d\n", ev);
|
||||
|
||||
beep();
|
||||
|
||||
if(ev == tcpip_event) {
|
||||
udp_appcall(data);
|
||||
}
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER && etimer_expired(&etimer)) {
|
||||
tcpip_poll_udp(conn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
40
platform/esb/apps/pinger.h
Normal file
40
platform/esb/apps/pinger.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: pinger.h,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __PINGER_H__
|
||||
#define __PINGER_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(pinger);
|
||||
|
||||
#endif /* __PINGER_H__ */
|
155
platform/esb/apps/radio-test.c
Normal file
155
platform/esb/apps/radio-test.c
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* 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: radio-test.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2006-03-07
|
||||
* Updated : $Date: 2006/06/18 07:48:48 $
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* Simple application to indicate connectivity between two nodes:
|
||||
*
|
||||
* - Red led indicates a packet sent via radio (one packet sent each second)
|
||||
* - Yellow led indicates that this node can hear the other node but not
|
||||
* necessary vice versa (unidirectional communication).
|
||||
* - Green led indicates that both nodes can communicate with each
|
||||
* other (bidirectional communication)
|
||||
*/
|
||||
|
||||
#include "contiki-esb.h"
|
||||
#include <string.h>
|
||||
|
||||
PROCESS(radio_test_process, "Radio test");
|
||||
AUTOSTART_PROCESSES(&radio_test_process);
|
||||
|
||||
#define ON 1
|
||||
#define OFF 0
|
||||
|
||||
#define HEADER "RTST"
|
||||
#define PACKET_SIZE 20
|
||||
#define PORT 2345
|
||||
|
||||
struct indicator {
|
||||
int onoff;
|
||||
int led;
|
||||
clock_time_t interval;
|
||||
struct etimer timer;
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void
|
||||
set(struct indicator *indicator, int onoff) {
|
||||
if(indicator->onoff ^ onoff) {
|
||||
indicator->onoff = onoff;
|
||||
if(onoff) {
|
||||
leds_on(indicator->led);
|
||||
} else {
|
||||
leds_off(indicator->led);
|
||||
}
|
||||
}
|
||||
if(onoff) {
|
||||
etimer_set(&indicator->timer, indicator->interval);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(radio_test_process, ev, data)
|
||||
{
|
||||
static struct etimer send_timer;
|
||||
static struct uip_udp_conn *conn;
|
||||
static struct indicator recv, other, flash;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
/* Initialize the indicators */
|
||||
recv.onoff = other.onoff = flash.onoff = OFF;
|
||||
recv.interval = other.interval = CLOCK_SECOND;
|
||||
flash.interval = 1;
|
||||
recv.led = LEDS_YELLOW;
|
||||
other.led = LEDS_GREEN;
|
||||
flash.led = LEDS_RED;
|
||||
|
||||
conn = udp_broadcast_new(HTONS(PORT), NULL);
|
||||
etimer_set(&send_timer, CLOCK_SECOND);
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER) {
|
||||
if(data == &send_timer) {
|
||||
etimer_reset(&send_timer);
|
||||
tcpip_poll_udp(conn);
|
||||
|
||||
} else if(data == &other.timer) {
|
||||
set(&other, OFF);
|
||||
|
||||
} else if(data == &recv.timer) {
|
||||
set(&recv, OFF);
|
||||
|
||||
} else if(data == &flash.timer) {
|
||||
set(&flash, OFF);
|
||||
}
|
||||
|
||||
} else if(ev == tcpip_event) {
|
||||
|
||||
if(uip_poll()) {
|
||||
/* send packet */
|
||||
memcpy(uip_sappdata, HEADER, sizeof(HEADER));
|
||||
((char *)uip_sappdata)[sizeof(HEADER)] = recv.onoff;
|
||||
/* send arbitrary data to fill the packet size */
|
||||
uip_send(uip_sappdata, PACKET_SIZE);
|
||||
|
||||
set(&flash, ON);
|
||||
}
|
||||
|
||||
if(uip_newdata()) {
|
||||
/* packet received */
|
||||
if(uip_datalen() < PACKET_SIZE
|
||||
|| strncmp((char *)uip_appdata, HEADER, sizeof(HEADER))) {
|
||||
/* invalid message */
|
||||
leds_blink();
|
||||
|
||||
} else {
|
||||
set(&recv, ON);
|
||||
set(&other, ((char *)uip_appdata)[sizeof(HEADER)] ? ON : OFF);
|
||||
|
||||
/* synchronize the sending to keep the nodes from sending
|
||||
simultaneously */
|
||||
etimer_set(&send_timer, CLOCK_SECOND);
|
||||
etimer_adjust(&send_timer, - (int) (CLOCK_SECOND >> 1));
|
||||
|
||||
beep();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
57
platform/esb/apps/sensor-output.c
Normal file
57
platform/esb/apps/sensor-output.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: sensor-output.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*/
|
||||
#include "contiki.h"
|
||||
#include "scatterweb.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
PROCESS(sensor_output_process, "Sensor output");
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(sensor_output_process, ev, data)
|
||||
{
|
||||
struct sensors_sensor *s;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);
|
||||
|
||||
s = (struct sensors_sensor *)data;
|
||||
|
||||
printf("%s %d\n", s->type, s->value());
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
40
platform/esb/apps/sensor-output.h
Normal file
40
platform/esb/apps/sensor-output.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: sensor-output.h,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __SENSOR_OUTPUT_H__
|
||||
#define __SENSOR_OUTPUT_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(sensor_output_process);
|
||||
|
||||
#endif /* __SENSOR_OUTPUT_H__ */
|
66
platform/esb/apps/test-receiver.c
Normal file
66
platform/esb/apps/test-receiver.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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: test-receiver.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2006-03-07
|
||||
* Updated : $Date: 2006/06/18 07:48:48 $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include "contiki-esb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
PROCESS(test_receiver_process, "Test - Receiver");
|
||||
AUTOSTART_PROCESSES(&test_receiver_process);
|
||||
|
||||
#define PORT 1234
|
||||
|
||||
PROCESS_THREAD(test_receiver_process, ev, data)
|
||||
{
|
||||
static struct uip_udp_conn *conn;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
conn = udp_broadcast_new(HTONS(PORT), NULL);
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event && uip_newdata());
|
||||
leds_invert(LEDS_YELLOW);
|
||||
|
||||
/* Make sure the message is null terminated */
|
||||
((char *) uip_appdata)[uip_datalen()] = 0;
|
||||
printf("RECV: %s\n", (char *) uip_appdata);
|
||||
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
68
platform/esb/apps/test-sender.c
Normal file
68
platform/esb/apps/test-sender.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* 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: test-sender.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
|
||||
* Created : 2006-03-07
|
||||
* Updated : $Date: 2006/06/18 07:48:48 $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include "contiki-esb.h"
|
||||
|
||||
PROCESS(test_sender_process, "Test - Sender");
|
||||
AUTOSTART_PROCESSES(&test_sender_process);
|
||||
|
||||
#define PORT 1234
|
||||
|
||||
PROCESS_THREAD(test_sender_process, ev, data)
|
||||
{
|
||||
static struct etimer timer;
|
||||
static struct uip_udp_conn *conn;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
conn = udp_broadcast_new(HTONS(PORT), NULL);
|
||||
etimer_set(&timer, CLOCK_SECOND * 2);
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
|
||||
etimer_reset(&timer);
|
||||
|
||||
/* Send packet */
|
||||
tcpip_poll_udp(conn);
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event && uip_poll());
|
||||
leds_invert(LEDS_YELLOW);
|
||||
uip_send("Hello world", sizeof("Hello world"));
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
Loading…
Reference in a new issue