#include "contiki.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
#define FILESIZE 200
PROCESS(example_rudolph0_process,
"Rudolph0 example");
AUTOSTART_PROCESSES(&example_rudolph0_process);
static void
write_chunk(struct rudolph0_conn *c, int offset, int flag,
uint8_t *data, int datalen)
{
int fd;
if(flag == RUDOLPH0_FLAG_NEWFILE) {
leds_on(LEDS_RED);
} else {
}
if(datalen > 0) {
int ret;
ret = cfs_write(fd, data, datalen);
}
if(flag == RUDOLPH0_FLAG_LASTCHUNK) {
int i;
leds_off(LEDS_RED);
leds_on(LEDS_YELLOW);
for(i = 0; i < FILESIZE; ++i) {
unsigned char buf;
cfs_read(fd, &buf, 1);
if(buf != (unsigned char)i) {
printf("error: diff at %d, %d != %d\n", i, i, buf);
break;
}
}
}
}
static int
read_chunk(struct rudolph0_conn *c, int offset, uint8_t *to, int maxsize)
{
int fd;
int ret;
ret = cfs_read(fd, to, maxsize);
return ret;
}
const static struct rudolph0_callbacks rudolph0_call = {write_chunk,
read_chunk};
static struct rudolph0_conn rudolph0;
{
static int fd;
rudolph0_open(&rudolph0, 138, &rudolph0_call);
SENSORS_ACTIVATE(button_sensor);
while(1) {
data == &button_sensor);
{
int i;
for(i = 0; i < FILESIZE; i++) {
unsigned char buf = i;
cfs_write(fd, &buf, 1);
}
}
data == &button_sensor);
rudolph0_stop(&rudolph0);
}
}