2012-12-18 17:28:42 +01:00
|
|
|
//include thy header!
|
|
|
|
#include <pingpong.h>
|
|
|
|
|
|
|
|
//standard stuff
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <vtimer.h>
|
|
|
|
#include <thread.h>
|
|
|
|
#include <msg.h>
|
|
|
|
|
|
|
|
//net stuff
|
|
|
|
#include <transceiver.h>
|
|
|
|
|
2013-02-13 14:56:46 +01:00
|
|
|
//debug stuff
|
|
|
|
//#define ENABLE_DEBUG
|
|
|
|
#ifdef ENABLE_DEBUG
|
|
|
|
#include <ps.h>
|
|
|
|
#endif
|
|
|
|
|
2012-12-18 17:28:42 +01:00
|
|
|
static uint16_t sequence = 0;
|
|
|
|
|
|
|
|
radio_packet_t p;
|
|
|
|
ping_packet_t ping_packet;
|
|
|
|
transceiver_command_t tcmd;
|
|
|
|
msg_t mesg;
|
|
|
|
|
|
|
|
// see header for documentation
|
|
|
|
void broadcast_without_ack(uint16_t duration) {
|
2013-01-28 12:39:44 +01:00
|
|
|
uint8_t counter = 0;
|
|
|
|
uint16_t seconds = 10;
|
2012-12-18 17:28:42 +01:00
|
|
|
|
2013-01-08 15:24:57 +01:00
|
|
|
puts("Setting up broadcast");
|
2013-01-28 12:39:44 +01:00
|
|
|
if (duration > 0) {
|
|
|
|
seconds = duration;
|
2012-12-18 17:28:42 +01:00
|
|
|
}
|
|
|
|
|
2013-01-28 12:39:44 +01:00
|
|
|
while(counter < seconds){
|
|
|
|
puts("Setting up packet");
|
2013-01-28 13:30:47 +01:00
|
|
|
counter = counter + 1;
|
2012-12-18 17:28:42 +01:00
|
|
|
send_broadcast();
|
2013-02-13 14:56:46 +01:00
|
|
|
#ifdef ENABLE_DEBUG
|
|
|
|
thread_print_all();
|
|
|
|
vtimer_print_short_queue();
|
|
|
|
vtimer_print_long_queue();
|
|
|
|
#endif
|
2013-01-08 15:24:57 +01:00
|
|
|
vtimer_usleep(1 * SECOND);
|
2012-12-18 17:28:42 +01:00
|
|
|
}
|
2013-01-30 18:56:23 +01:00
|
|
|
puts("stopping now");
|
2012-12-18 17:28:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// see header for documentation
|
|
|
|
void broadcast_incoming() {
|
|
|
|
puts("got some broadcasted stuff");
|
|
|
|
}
|
|
|
|
|
|
|
|
// see header for documentation
|
|
|
|
void send_broadcast() {
|
2013-01-08 15:24:57 +01:00
|
|
|
puts("Preparing broadcast ping");
|
2012-12-18 17:28:42 +01:00
|
|
|
mesg.type = SND_PKT;
|
|
|
|
mesg.content.ptr = (char*) &tcmd;
|
|
|
|
|
|
|
|
tcmd.transceivers = TRANSCEIVER_CC1100;
|
|
|
|
tcmd.data = &p;
|
|
|
|
p.length = sizeof(ping_packet_t);
|
|
|
|
p.dst = 0;
|
|
|
|
|
|
|
|
puts("creating packet..");
|
|
|
|
sequence++;
|
|
|
|
ping_packet.seq_nr = sequence;
|
|
|
|
ping_packet.type = PING_BCST;
|
|
|
|
|
|
|
|
puts("sending broadcast..");
|
|
|
|
p.data = (uint8_t *) &ping_packet;
|
|
|
|
msg_send(&mesg, transceiver_pid, 1);
|
|
|
|
puts("sent");
|
|
|
|
}
|