#include "contiki.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
#if CONTIKI_TARGET_NETSIM
#include "ether.h"
#include "node.h"
#endif
#define FILESIZE 40000
static unsigned long bytecount;
static clock_time_t start_time;
extern int profile_max_queuelen;
PROCESS(example_rucb_process,
"Rucb example");
AUTOSTART_PROCESSES(&example_rucb_process);
static void
write_chunk(struct rucb_conn *c, int offset, int flag,
char *data, int datalen)
{
#if CONTIKI_TARGET_NETSIM
{
char buf[100];
printf("received %d; %d\n", offset, datalen);
sprintf(buf, "%d%%", (100 * (offset + datalen)) / FILESIZE);
ether_set_text(buf);
}
#endif
}
static int
read_chunk(struct rucb_conn *c, int offset, char *to, int maxsize)
{
int size;
size = maxsize;
if(bytecount + maxsize >= FILESIZE) {
size = FILESIZE - bytecount;
}
bytecount += size;
if(bytecount == FILESIZE) {
print_stats();
}
return size;
}
const static struct rucb_callbacks rucb_call = {write_chunk, read_chunk,
static struct rucb_conn rucb;
#include "node-id.h"
{
rucb_open(&rucb, 137, &rucb_call);
SENSORS_ACTIVATE(button_sensor);
rimeaddr_t recv;
recv.u8[0] = 52;
recv.u8[1] = 0;
rucb_send(&rucb, &recv);
#if CONTIKI_TARGET_NETSIM
ether_send_done();
#endif
}
while(1) {
data == &button_sensor);
}
}