mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
77 lines
1.5 KiB
C
77 lines
1.5 KiB
C
//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>
|
|
|
|
//debug stuff
|
|
//#define ENABLE_DEBUG
|
|
#ifdef ENABLE_DEBUG
|
|
#include <ps.h>
|
|
#endif
|
|
|
|
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) {
|
|
uint8_t counter = 0;
|
|
uint16_t seconds = 10;
|
|
|
|
puts("Setting up broadcast");
|
|
if (duration > 0) {
|
|
seconds = duration;
|
|
}
|
|
|
|
while(counter < seconds){
|
|
puts("Setting up packet");
|
|
counter = counter + 1;
|
|
send_broadcast();
|
|
#ifdef ENABLE_DEBUG
|
|
thread_print_all();
|
|
vtimer_print_short_queue();
|
|
vtimer_print_long_queue();
|
|
#endif
|
|
vtimer_usleep(1 * SECOND);
|
|
}
|
|
puts("stopping now");
|
|
}
|
|
|
|
// see header for documentation
|
|
void broadcast_incoming() {
|
|
puts("got some broadcasted stuff");
|
|
}
|
|
|
|
// see header for documentation
|
|
void send_broadcast() {
|
|
puts("Preparing broadcast ping");
|
|
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");
|
|
}
|