Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki
This commit is contained in:
commit
6a1469aeb2
|
@ -33,10 +33,10 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* The Deluge protocol for data dissemination.
|
* An implementation of the Deluge protocol.
|
||||||
* (Hui and Culler: The dynamic behavior of a data
|
* (Hui and Culler: The dynamic behavior of a data
|
||||||
* dissemination protocol for network programming at scale,
|
* dissemination protocol for network programming at scale,
|
||||||
* SenSys 2004)
|
* ACM SenSys 2004)
|
||||||
* \author
|
* \author
|
||||||
* Nicolas Tsiftes <nvt@sics.se>
|
* Nicolas Tsiftes <nvt@sics.se>
|
||||||
*/
|
*/
|
||||||
|
@ -67,11 +67,6 @@
|
||||||
#define PRINTF(...)
|
#define PRINTF(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PROCESS(deluge_process, "Deluge process");
|
|
||||||
|
|
||||||
static void broadcast_recv(struct broadcast_conn *, const rimeaddr_t *);
|
|
||||||
static void unicast_recv(struct unicast_conn *, const rimeaddr_t *);
|
|
||||||
|
|
||||||
/* Implementation-specific variables. */
|
/* Implementation-specific variables. */
|
||||||
static struct broadcast_conn deluge_broadcast;
|
static struct broadcast_conn deluge_broadcast;
|
||||||
static struct unicast_conn deluge_uc;
|
static struct unicast_conn deluge_uc;
|
||||||
|
@ -86,32 +81,25 @@ static unsigned r_interval;
|
||||||
static unsigned recv_adv;
|
static unsigned recv_adv;
|
||||||
static int broadcast_profile;
|
static int broadcast_profile;
|
||||||
|
|
||||||
|
/* Deluge timers. */
|
||||||
static struct ctimer rx_timer;
|
static struct ctimer rx_timer;
|
||||||
static struct ctimer tx_timer;
|
static struct ctimer tx_timer;
|
||||||
static struct ctimer summary_timer;
|
static struct ctimer summary_timer;
|
||||||
static struct ctimer profile_timer;
|
static struct ctimer profile_timer;
|
||||||
|
|
||||||
static unsigned next_object_id;
|
/* Deluge objects will get an ID that defaults to the current value of
|
||||||
|
the next_object_id parameter. */
|
||||||
|
static deluge_object_id_t next_object_id;
|
||||||
|
|
||||||
|
/* Rime callbacks. */
|
||||||
|
static void broadcast_recv(struct broadcast_conn *, const rimeaddr_t *);
|
||||||
|
static void unicast_recv(struct unicast_conn *, const rimeaddr_t *);
|
||||||
|
|
||||||
static const struct broadcast_callbacks broadcast_call = {broadcast_recv, NULL};
|
static const struct broadcast_callbacks broadcast_call = {broadcast_recv, NULL};
|
||||||
static const struct unicast_callbacks unicast_call = {unicast_recv, NULL};
|
static const struct unicast_callbacks unicast_call = {unicast_recv, NULL};
|
||||||
|
|
||||||
#if NETSIM
|
/* The Deluge process manages the main Deluge timer. */
|
||||||
static char label[128];
|
PROCESS(deluge_process, "Deluge");
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint16_t
|
|
||||||
checksum(unsigned char *buf, unsigned len)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
uint16_t sum;
|
|
||||||
|
|
||||||
for(i = sum = 0; i < len; i++) {
|
|
||||||
sum = crc16_add(buf[i], sum);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
transition(int state)
|
transition(int state)
|
||||||
|
@ -136,15 +124,26 @@ transition(int state)
|
||||||
static int
|
static int
|
||||||
write_page(struct deluge_object *obj, unsigned pagenum, unsigned char *data)
|
write_page(struct deluge_object *obj, unsigned pagenum, unsigned char *data)
|
||||||
{
|
{
|
||||||
cfs_seek(obj->cfs_fd, pagenum * S_PAGE, CFS_SEEK_SET);
|
cfs_offset_t offset;
|
||||||
return cfs_write(obj->cfs_fd, (char *)data,
|
|
||||||
S_PAGE);
|
offset = pagenum * S_PAGE;
|
||||||
|
|
||||||
|
if(cfs_seek(obj->cfs_fd, offset, CFS_SEEK_SET) != offset) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return cfs_write(obj->cfs_fd, (char *)data, S_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
read_page(struct deluge_object *obj, unsigned pagenum, unsigned char *buf)
|
read_page(struct deluge_object *obj, unsigned pagenum, unsigned char *buf)
|
||||||
{
|
{
|
||||||
cfs_seek(obj->cfs_fd, pagenum * S_PAGE, CFS_SEEK_SET);
|
cfs_offset_t offset;
|
||||||
|
|
||||||
|
offset = pagenum * S_PAGE;
|
||||||
|
|
||||||
|
if(cfs_seek(obj->cfs_fd, offset, CFS_SEEK_SET) != offset) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return cfs_read(obj->cfs_fd, (char *)buf, S_PAGE);
|
return cfs_read(obj->cfs_fd, (char *)buf, S_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,26 +164,27 @@ init_page(struct deluge_object *obj, int pagenum, int have)
|
||||||
page->packet_set = ALL_PACKETS;
|
page->packet_set = ALL_PACKETS;
|
||||||
page->flags |= PAGE_COMPLETE;
|
page->flags |= PAGE_COMPLETE;
|
||||||
read_page(obj, pagenum, buf);
|
read_page(obj, pagenum, buf);
|
||||||
page->crc = checksum(buf, S_PAGE);
|
page->crc = crc16_data(buf, S_PAGE, 0);
|
||||||
} else {
|
} else {
|
||||||
page->version = 0;
|
page->version = 0;
|
||||||
page->packet_set = 0;
|
page->packet_set = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static cfs_offset_t
|
||||||
file_size(const char *file)
|
file_size(const char *file)
|
||||||
{
|
{
|
||||||
int fd, size;
|
int fd;
|
||||||
|
cfs_offset_t size;
|
||||||
|
|
||||||
fd = cfs_open(file, CFS_READ);
|
fd = cfs_open(file, CFS_READ);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
return -1;
|
return (cfs_offset_t)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = cfs_seek(fd, 0, CFS_SEEK_END);
|
size = cfs_seek(fd, 0, CFS_SEEK_END);
|
||||||
|
|
||||||
cfs_close(fd);
|
cfs_close(fd);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,6 +209,7 @@ init_object(struct deluge_object *obj, char *filename, unsigned version)
|
||||||
|
|
||||||
obj->pages = malloc(OBJECT_PAGE_COUNT(*obj) * sizeof(*obj->pages));
|
obj->pages = malloc(OBJECT_PAGE_COUNT(*obj) * sizeof(*obj->pages));
|
||||||
if(obj->pages == NULL) {
|
if(obj->pages == NULL) {
|
||||||
|
cfs_close(obj->cfs_fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +218,7 @@ init_object(struct deluge_object *obj, char *filename, unsigned version)
|
||||||
init_page(¤t_object, i, 1);
|
init_page(¤t_object, i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(obj->current_page, 0, sizeof (obj->current_page));
|
memset(obj->current_page, 0, sizeof(obj->current_page));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -244,15 +245,15 @@ send_request(void *arg)
|
||||||
|
|
||||||
obj = (struct deluge_object *)arg;
|
obj = (struct deluge_object *)arg;
|
||||||
|
|
||||||
request.object_id = obj->object_id;
|
|
||||||
request.cmd = DELUGE_CMD_REQUEST;
|
request.cmd = DELUGE_CMD_REQUEST;
|
||||||
request.pagenum = obj->current_rx_page;
|
request.pagenum = obj->current_rx_page;
|
||||||
request.version = obj->pages[request.pagenum].version;
|
request.version = obj->pages[request.pagenum].version;
|
||||||
request.request_set = ~obj->pages[obj->current_rx_page].packet_set;
|
request.request_set = ~obj->pages[obj->current_rx_page].packet_set;
|
||||||
|
request.object_id = obj->object_id;
|
||||||
|
|
||||||
PRINTF("Sending request for page %d, version %u, request_set %u\n",
|
PRINTF("Sending request for page %d, version %u, request_set %u\n",
|
||||||
request.pagenum, request.version, request.request_set);
|
request.pagenum, request.version, request.request_set);
|
||||||
packetbuf_copyfrom((uint8_t *)&request, sizeof (request));
|
packetbuf_copyfrom(&request, sizeof(request));
|
||||||
unicast_send(&deluge_uc, &obj->summary_from);
|
unicast_send(&deluge_uc, &obj->summary_from);
|
||||||
|
|
||||||
/* Deluge R.2 */
|
/* Deluge R.2 */
|
||||||
|
@ -276,14 +277,14 @@ advertise_summary(struct deluge_object *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
summary.cmd = DELUGE_CMD_SUMMARY;
|
summary.cmd = DELUGE_CMD_SUMMARY;
|
||||||
summary.object_id = obj->object_id;
|
|
||||||
summary.version = obj->update_version;
|
summary.version = obj->update_version;
|
||||||
summary.highest_available = highest_available_page(obj);
|
summary.highest_available = highest_available_page(obj);
|
||||||
|
summary.object_id = obj->object_id;
|
||||||
|
|
||||||
PRINTF("Advertising summary for object id %u: version=%u, available=%u\n",
|
PRINTF("Advertising summary for object id %u: version=%u, available=%u\n",
|
||||||
(unsigned) obj->object_id, summary.version, summary.highest_available);
|
(unsigned)obj->object_id, summary.version, summary.highest_available);
|
||||||
|
|
||||||
packetbuf_copyfrom((uint8_t *)&summary, sizeof (summary));
|
packetbuf_copyfrom(&summary, sizeof(summary));
|
||||||
broadcast_send(&deluge_broadcast);
|
broadcast_send(&deluge_broadcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,10 +352,10 @@ send_page(struct deluge_object *obj, unsigned pagenum)
|
||||||
unsigned char *cp;
|
unsigned char *cp;
|
||||||
|
|
||||||
pkt.cmd = DELUGE_CMD_PACKET;
|
pkt.cmd = DELUGE_CMD_PACKET;
|
||||||
pkt.object_id = obj->object_id;
|
|
||||||
pkt.pagenum = pagenum;
|
pkt.pagenum = pagenum;
|
||||||
pkt.version = obj->pages[pagenum].version;
|
pkt.version = obj->pages[pagenum].version;
|
||||||
pkt.packetnum = 0;
|
pkt.packetnum = 0;
|
||||||
|
pkt.object_id = obj->object_id;
|
||||||
pkt.crc = 0;
|
pkt.crc = 0;
|
||||||
|
|
||||||
read_page(obj, pagenum, buf);
|
read_page(obj, pagenum, buf);
|
||||||
|
@ -362,9 +363,9 @@ send_page(struct deluge_object *obj, unsigned pagenum)
|
||||||
/* Divide the page into packets and send them one at a time. */
|
/* Divide the page into packets and send them one at a time. */
|
||||||
for(cp = buf; cp + S_PKT <= (unsigned char *)&buf[S_PAGE]; cp += S_PKT) {
|
for(cp = buf; cp + S_PKT <= (unsigned char *)&buf[S_PAGE]; cp += S_PKT) {
|
||||||
if(obj->tx_set & (1 << pkt.packetnum)) {
|
if(obj->tx_set & (1 << pkt.packetnum)) {
|
||||||
pkt.crc = checksum(cp, S_PKT);
|
pkt.crc = crc16_data(cp, S_PKT, 0);
|
||||||
memcpy(pkt.payload, cp, S_PKT);
|
memcpy(pkt.payload, cp, S_PKT);
|
||||||
packetbuf_copyfrom((uint8_t *)&pkt, sizeof (pkt));
|
packetbuf_copyfrom(&pkt, sizeof(pkt));
|
||||||
broadcast_send(&deluge_broadcast);
|
broadcast_send(&deluge_broadcast);
|
||||||
}
|
}
|
||||||
pkt.packetnum++;
|
pkt.packetnum++;
|
||||||
|
@ -382,8 +383,12 @@ tx_callback(void *arg)
|
||||||
send_page(obj, obj->current_tx_page);
|
send_page(obj, obj->current_tx_page);
|
||||||
/* Deluge T.2. */
|
/* Deluge T.2. */
|
||||||
if(obj->tx_set) {
|
if(obj->tx_set) {
|
||||||
|
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,
|
||||||
|
PACKETBUF_ATTR_PACKET_TYPE_STREAM);
|
||||||
ctimer_reset(&tx_timer);
|
ctimer_reset(&tx_timer);
|
||||||
} else {
|
} else {
|
||||||
|
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,
|
||||||
|
PACKETBUF_ATTR_PACKET_TYPE_STREAM_END);
|
||||||
obj->current_tx_page = -1;
|
obj->current_tx_page = -1;
|
||||||
transition(DELUGE_STATE_MAINTAIN);
|
transition(DELUGE_STATE_MAINTAIN);
|
||||||
}
|
}
|
||||||
|
@ -449,7 +454,7 @@ handle_packet(struct deluge_msg_packet *msg)
|
||||||
memcpy(¤t_object.current_page[S_PKT * packet.packetnum],
|
memcpy(¤t_object.current_page[S_PKT * packet.packetnum],
|
||||||
packet.payload, S_PKT);
|
packet.payload, S_PKT);
|
||||||
|
|
||||||
crc = checksum(packet.payload, S_PKT);
|
crc = crc16_data(packet.payload, S_PKT, 0);
|
||||||
if(packet.crc != crc) {
|
if(packet.crc != crc) {
|
||||||
PRINTF("packet crc: %hu, calculated crc: %hu\n", packet.crc, crc);
|
PRINTF("packet crc: %hu, calculated crc: %hu\n", packet.crc, crc);
|
||||||
return;
|
return;
|
||||||
|
@ -459,6 +464,10 @@ handle_packet(struct deluge_msg_packet *msg)
|
||||||
page->packet_set |= (1 << packet.packetnum);
|
page->packet_set |= (1 << packet.packetnum);
|
||||||
|
|
||||||
if(page->packet_set == ALL_PACKETS) {
|
if(page->packet_set == ALL_PACKETS) {
|
||||||
|
/* This is the last packet of the requested page; stop streaming. */
|
||||||
|
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,
|
||||||
|
PACKETBUF_ATTR_PACKET_TYPE_STREAM_END);
|
||||||
|
|
||||||
write_page(¤t_object, packet.pagenum, current_object.current_page);
|
write_page(¤t_object, packet.pagenum, current_object.current_page);
|
||||||
page->version = packet.version;
|
page->version = packet.version;
|
||||||
page->flags = PAGE_COMPLETE;
|
page->flags = PAGE_COMPLETE;
|
||||||
|
@ -470,7 +479,7 @@ handle_packet(struct deluge_msg_packet *msg)
|
||||||
current_object.version = current_object.update_version;
|
current_object.version = current_object.update_version;
|
||||||
leds_on(LEDS_RED);
|
leds_on(LEDS_RED);
|
||||||
PRINTF("Update completed for object %u, version %u\n",
|
PRINTF("Update completed for object %u, version %u\n",
|
||||||
current_object.object_id, packet.version);
|
(unsigned)current_object.object_id, packet.version);
|
||||||
} else if(current_object.current_rx_page < OBJECT_PAGE_COUNT(current_object)) {
|
} else if(current_object.current_rx_page < OBJECT_PAGE_COUNT(current_object)) {
|
||||||
if(ctimer_expired(&rx_timer)) {
|
if(ctimer_expired(&rx_timer)) {
|
||||||
ctimer_set(&rx_timer,
|
ctimer_set(&rx_timer,
|
||||||
|
@ -480,36 +489,19 @@ handle_packet(struct deluge_msg_packet *msg)
|
||||||
}
|
}
|
||||||
/* Deluge R.3 */
|
/* Deluge R.3 */
|
||||||
transition(DELUGE_STATE_MAINTAIN);
|
transition(DELUGE_STATE_MAINTAIN);
|
||||||
|
} else {
|
||||||
|
/* More packets to come. Put lower layers in streaming mode. */
|
||||||
|
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,
|
||||||
|
PACKETBUF_ATTR_PACKET_TYPE_STREAM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
unicast_recv(struct unicast_conn *c, const rimeaddr_t *sender)
|
|
||||||
{
|
|
||||||
char *msg;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
msg = packetbuf_dataptr();
|
|
||||||
len = packetbuf_datalen();
|
|
||||||
if(len < 5)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch(msg[2]) {
|
|
||||||
case DELUGE_CMD_REQUEST:
|
|
||||||
if(len >= sizeof (struct deluge_msg_request))
|
|
||||||
handle_request((struct deluge_msg_request *)msg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PRINTF("Incoming packet with unknown command!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_profile(struct deluge_object *obj)
|
send_profile(struct deluge_object *obj)
|
||||||
{
|
{
|
||||||
struct deluge_msg_profile *msg;
|
struct deluge_msg_profile *msg;
|
||||||
unsigned char buf[sizeof (*msg) + OBJECT_PAGE_COUNT(*obj)];
|
unsigned char buf[sizeof(*msg) + OBJECT_PAGE_COUNT(*obj)];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(broadcast_profile && recv_adv < CONST_K) {
|
if(broadcast_profile && recv_adv < CONST_K) {
|
||||||
|
@ -517,14 +509,14 @@ send_profile(struct deluge_object *obj)
|
||||||
|
|
||||||
msg = (struct deluge_msg_profile *)buf;
|
msg = (struct deluge_msg_profile *)buf;
|
||||||
msg->cmd = DELUGE_CMD_PROFILE;
|
msg->cmd = DELUGE_CMD_PROFILE;
|
||||||
msg->object_id = obj->object_id;
|
|
||||||
msg->version = obj->version;
|
msg->version = obj->version;
|
||||||
msg->npages = OBJECT_PAGE_COUNT(*obj);
|
msg->npages = OBJECT_PAGE_COUNT(*obj);
|
||||||
|
msg->object_id = obj->object_id;
|
||||||
for(i = 0; i < msg->npages; i++) {
|
for(i = 0; i < msg->npages; i++) {
|
||||||
msg->version_vector[i] = obj->pages[i].version;
|
msg->version_vector[i] = obj->pages[i].version;
|
||||||
}
|
}
|
||||||
|
|
||||||
packetbuf_copyfrom(buf, sizeof (buf));
|
packetbuf_copyfrom(buf, sizeof(buf));
|
||||||
broadcast_send(&deluge_broadcast);
|
broadcast_send(&deluge_broadcast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,13 +543,13 @@ handle_profile(struct deluge_msg_profile *msg)
|
||||||
npages = OBJECT_PAGE_COUNT(*obj);
|
npages = OBJECT_PAGE_COUNT(*obj);
|
||||||
obj->size = msg->npages * S_PAGE;
|
obj->size = msg->npages * S_PAGE;
|
||||||
|
|
||||||
p = malloc(OBJECT_PAGE_COUNT(*obj) * sizeof (*obj->pages));
|
p = malloc(OBJECT_PAGE_COUNT(*obj) * sizeof(*obj->pages));
|
||||||
if(p == NULL) {
|
if(p == NULL) {
|
||||||
PRINTF("Failed to reallocate memory for pages!\n");
|
PRINTF("Failed to reallocate memory for pages!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(p, obj->pages, npages * sizeof (*obj->pages));
|
memcpy(p, obj->pages, npages * sizeof(*obj->pages));
|
||||||
free(obj->pages);
|
free(obj->pages);
|
||||||
obj->pages = (struct deluge_page *)p;
|
obj->pages = (struct deluge_page *)p;
|
||||||
|
|
||||||
|
@ -588,7 +580,7 @@ handle_profile(struct deluge_msg_profile *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *sender)
|
command_dispatcher(const rimeaddr_t *sender)
|
||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
int len;
|
int len;
|
||||||
|
@ -596,37 +588,50 @@ broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *sender)
|
||||||
|
|
||||||
msg = packetbuf_dataptr();
|
msg = packetbuf_dataptr();
|
||||||
len = packetbuf_datalen();
|
len = packetbuf_datalen();
|
||||||
if(len < 5)
|
if(len < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch(msg[2]) {
|
switch(msg[0]) {
|
||||||
case DELUGE_CMD_SUMMARY:
|
case DELUGE_CMD_SUMMARY:
|
||||||
if(len >= sizeof (struct deluge_msg_summary))
|
if(len >= sizeof(struct deluge_msg_summary))
|
||||||
handle_summary((struct deluge_msg_summary *)msg, sender);
|
handle_summary((struct deluge_msg_summary *)msg, sender);
|
||||||
break;
|
break;
|
||||||
case DELUGE_CMD_REQUEST:
|
case DELUGE_CMD_REQUEST:
|
||||||
if(len >= sizeof (struct deluge_msg_request))
|
if(len >= sizeof(struct deluge_msg_request))
|
||||||
handle_request((struct deluge_msg_request *)msg);
|
handle_request((struct deluge_msg_request *)msg);
|
||||||
break;
|
break;
|
||||||
case DELUGE_CMD_PACKET:
|
case DELUGE_CMD_PACKET:
|
||||||
if(len >= sizeof (struct deluge_msg_packet))
|
if(len >= sizeof(struct deluge_msg_packet))
|
||||||
handle_packet((struct deluge_msg_packet *)msg);
|
handle_packet((struct deluge_msg_packet *)msg);
|
||||||
break;
|
break;
|
||||||
case DELUGE_CMD_PROFILE:
|
case DELUGE_CMD_PROFILE:
|
||||||
profile = (struct deluge_msg_profile *)msg;
|
profile = (struct deluge_msg_profile *)msg;
|
||||||
if(len >= sizeof (*profile) &&
|
if(len >= sizeof(*profile) &&
|
||||||
len >= sizeof (*profile) + profile->npages * profile->version_vector[0])
|
len >= sizeof(*profile) + profile->npages * profile->version_vector[0])
|
||||||
handle_profile((struct deluge_msg_profile *)msg);
|
handle_profile((struct deluge_msg_profile *)msg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PRINTF("Incoming packet with unknown command!\n");
|
PRINTF("Incoming packet with unknown command: %d\n", msg[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unicast_recv(struct unicast_conn *c, const rimeaddr_t *sender)
|
||||||
|
{
|
||||||
|
command_dispatcher(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *sender)
|
||||||
|
{
|
||||||
|
command_dispatcher(sender);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
deluge_disseminate(char *file, unsigned version)
|
deluge_disseminate(char *file, unsigned version)
|
||||||
{
|
{
|
||||||
if(init_object(¤t_object, file, version) < 0) {
|
/* This implementation disseminates at most one object. */
|
||||||
|
if(next_object_id > 0 || init_object(¤t_object, file, version) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
process_start(&deluge_process, file);
|
process_start(&deluge_process, file);
|
||||||
|
|
|
@ -95,38 +95,40 @@ PROCESS_NAME(deluge_process);
|
||||||
#define CONST_OMEGA 8
|
#define CONST_OMEGA 8
|
||||||
#define ESTIMATED_TX_TIME (CLOCK_SECOND)
|
#define ESTIMATED_TX_TIME (CLOCK_SECOND)
|
||||||
|
|
||||||
|
typedef uint8_t deluge_object_id_t;
|
||||||
|
|
||||||
struct deluge_msg_summary {
|
struct deluge_msg_summary {
|
||||||
uint16_t object_id;
|
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint8_t highest_available;
|
uint8_t highest_available;
|
||||||
} __attribute__((packed));
|
deluge_object_id_t object_id;
|
||||||
|
};
|
||||||
|
|
||||||
struct deluge_msg_request {
|
struct deluge_msg_request {
|
||||||
uint16_t object_id;
|
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint8_t pagenum;
|
uint8_t pagenum;
|
||||||
uint8_t request_set;
|
uint8_t request_set;
|
||||||
} __attribute__((packed));
|
deluge_object_id_t object_id;
|
||||||
|
};
|
||||||
|
|
||||||
struct deluge_msg_packet {
|
struct deluge_msg_packet {
|
||||||
uint16_t object_id;
|
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint8_t pagenum;
|
uint8_t pagenum;
|
||||||
uint8_t packetnum;
|
uint8_t packetnum;
|
||||||
uint16_t crc;
|
uint16_t crc;
|
||||||
|
deluge_object_id_t object_id;
|
||||||
unsigned char payload[S_PKT];
|
unsigned char payload[S_PKT];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
struct deluge_msg_profile {
|
struct deluge_msg_profile {
|
||||||
uint16_t object_id;
|
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint8_t npages;
|
uint8_t npages;
|
||||||
|
deluge_object_id_t object_id;
|
||||||
uint8_t version_vector[];
|
uint8_t version_vector[];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
struct deluge_object {
|
struct deluge_object {
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
|
@ -799,7 +799,6 @@ create_log(struct file *file, struct file_header *hdr)
|
||||||
static int
|
static int
|
||||||
merge_log(coffee_page_t file_page, int extend)
|
merge_log(coffee_page_t file_page, int extend)
|
||||||
{
|
{
|
||||||
coffee_page_t log_page;
|
|
||||||
struct file_header hdr, hdr2;
|
struct file_header hdr, hdr2;
|
||||||
int fd, n;
|
int fd, n;
|
||||||
cfs_offset_t offset;
|
cfs_offset_t offset;
|
||||||
|
@ -808,7 +807,6 @@ merge_log(coffee_page_t file_page, int extend)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
read_header(&hdr, file_page);
|
read_header(&hdr, file_page);
|
||||||
log_page = hdr.log_page;
|
|
||||||
|
|
||||||
fd = cfs_open(hdr.name, CFS_READ);
|
fd = cfs_open(hdr.name, CFS_READ);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
#define PRINTF(...)
|
#define PRINTF(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SDA_0()
|
#ifndef SDA_0
|
||||||
#define SDA_0() (SHT11_PxDIR |= BV(SHT11_ARCH_SDA)) /* SDA Output=0 */
|
#define SDA_0() (SHT11_PxDIR |= BV(SHT11_ARCH_SDA)) /* SDA Output=0 */
|
||||||
#define SDA_1() (SHT11_PxDIR &= ~BV(SHT11_ARCH_SDA)) /* SDA Input */
|
#define SDA_1() (SHT11_PxDIR &= ~BV(SHT11_ARCH_SDA)) /* SDA Input */
|
||||||
#define SDA_IS_1 (SHT11_PxIN & BV(SHT11_ARCH_SDA))
|
#define SDA_IS_1 (SHT11_PxIN & BV(SHT11_ARCH_SDA))
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
#define RESET 0x1e /* 000 1111 0 */
|
#define RESET 0x1e /* 000 1111 0 */
|
||||||
|
|
||||||
/* This can probably be reduced to 250ns according to data sheet. */
|
/* This can probably be reduced to 250ns according to data sheet. */
|
||||||
#ifndef delay_400ns()
|
#ifndef delay_400ns
|
||||||
#define delay_400ns() _NOP()
|
#define delay_400ns() _NOP()
|
||||||
#endif
|
#endif
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -217,7 +217,7 @@ sht11_init(void)
|
||||||
* SDA 0: Output=0
|
* SDA 0: Output=0
|
||||||
* 1: Input and pull-up (Output=0)
|
* 1: Input and pull-up (Output=0)
|
||||||
*/
|
*/
|
||||||
#ifdef SHT11_INIT()
|
#ifdef SHT11_INIT
|
||||||
SHT11_INIT();
|
SHT11_INIT();
|
||||||
#else
|
#else
|
||||||
SHT11_PxOUT |= BV(SHT11_ARCH_PWR);
|
SHT11_PxOUT |= BV(SHT11_ARCH_PWR);
|
||||||
|
@ -232,7 +232,7 @@ sht11_init(void)
|
||||||
void
|
void
|
||||||
sht11_off(void)
|
sht11_off(void)
|
||||||
{
|
{
|
||||||
#ifdef SHT11_OFF()
|
#ifdef SHT11_OFF
|
||||||
SHT11_OFF();
|
SHT11_OFF();
|
||||||
#else
|
#else
|
||||||
SHT11_PxOUT &= ~BV(SHT11_ARCH_PWR);
|
SHT11_PxOUT &= ~BV(SHT11_ARCH_PWR);
|
||||||
|
|
|
@ -1452,6 +1452,7 @@ collect_send(struct collect_conn *tc, int rexmits)
|
||||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
|
||||||
printf("%d.%d: drop originated packet: no queuebuf\n",
|
printf("%d.%d: drop originated packet: no queuebuf\n",
|
||||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
|
||||||
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -267,4 +267,9 @@ unsigned long clock_seconds(void);
|
||||||
#define CCIF
|
#define CCIF
|
||||||
#define CLIF
|
#define CLIF
|
||||||
|
|
||||||
|
/* include the project config */
|
||||||
|
/* PROJECT_CONF_H might be defined in the project Makefile */
|
||||||
|
#ifdef PROJECT_CONF_H
|
||||||
|
#include PROJECT_CONF_H
|
||||||
|
#endif /* PROJECT_CONF_H */
|
||||||
#endif /* __CONTIKI_CONF_H__ */
|
#endif /* __CONTIKI_CONF_H__ */
|
||||||
|
|
|
@ -261,4 +261,10 @@ unsigned long clock_seconds(void);
|
||||||
#define CCIF
|
#define CCIF
|
||||||
#define CLIF
|
#define CLIF
|
||||||
|
|
||||||
|
/* include the project config */
|
||||||
|
/* PROJECT_CONF_H might be defined in the project Makefile */
|
||||||
|
#ifdef PROJECT_CONF_H
|
||||||
|
#include PROJECT_CONF_H
|
||||||
|
#endif /* PROJECT_CONF_H */
|
||||||
|
|
||||||
#endif /* __CONTIKI_CONF_H__ */
|
#endif /* __CONTIKI_CONF_H__ */
|
||||||
|
|
|
@ -384,8 +384,8 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len);
|
||||||
#define UIP_CONF_MAX_LISTENPORTS 2
|
#define UIP_CONF_MAX_LISTENPORTS 2
|
||||||
#define UIP_CONF_UDP_CONNS 6
|
#define UIP_CONF_UDP_CONNS 6
|
||||||
|
|
||||||
/* Optional, TCP needed to serve the RPL neighbor web page currently hard coded at bbbb::11 */
|
/* Optional, TCP needed to serve the RPL neighbor web page currently hard coded at bbbb::200 */
|
||||||
/* The RPL neighbors can also be viewed using the jack menu */
|
/* The RPL neighbors can also be viewed using the jackdaw menu */
|
||||||
/* A small MSS is adequate for the internal jackdaw webserver and RAM is very limited*/
|
/* A small MSS is adequate for the internal jackdaw webserver and RAM is very limited*/
|
||||||
#define RPL_HTTPD_SERVER 0
|
#define RPL_HTTPD_SERVER 0
|
||||||
#if RPL_HTTPD_SERVER
|
#if RPL_HTTPD_SERVER
|
||||||
|
|
|
@ -51,11 +51,11 @@ Berlin, 2007
|
||||||
* ScatterWeb Bootload and Contiki.
|
* ScatterWeb Bootload and Contiki.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "contiki.h"
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "dev/msb430-uart1.h"
|
#include "dev/msb430-uart1.h"
|
||||||
#include "msp430.h"
|
|
||||||
#include "dev/lpm.h"
|
#include "dev/lpm.h"
|
||||||
|
|
||||||
#ifndef U1ME
|
#ifndef U1ME
|
||||||
|
|
|
@ -46,6 +46,7 @@ import se.sics.cooja.mspmote.MspMoteTimeEvent;
|
||||||
import se.sics.mspsim.core.IOUnit;
|
import se.sics.mspsim.core.IOUnit;
|
||||||
import se.sics.mspsim.core.USART;
|
import se.sics.mspsim.core.USART;
|
||||||
import se.sics.mspsim.core.USARTListener;
|
import se.sics.mspsim.core.USARTListener;
|
||||||
|
import se.sics.mspsim.core.USARTSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
|
@ -73,13 +74,9 @@ public class MspSerial extends SerialUI implements SerialPort {
|
||||||
if (ioUnit instanceof USART) {
|
if (ioUnit instanceof USART) {
|
||||||
usart = (USART) ioUnit;
|
usart = (USART) ioUnit;
|
||||||
usart.setUSARTListener(new USARTListener() {
|
usart.setUSARTListener(new USARTListener() {
|
||||||
public void dataReceived(USART arg0, int arg1) {
|
@Override
|
||||||
MspSerial.this.dataReceived(arg1);
|
public void dataReceived(USARTSource source, int data) {
|
||||||
}
|
MspSerial.this.dataReceived(data);
|
||||||
public void stateChanged(int state) {
|
|
||||||
if (state == USARTListener.RXFLAG_CLEARED) {
|
|
||||||
/*tryWriteNextByte();*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,18 +31,8 @@
|
||||||
|
|
||||||
package se.sics.cooja.mspmote.interfaces;
|
package se.sics.cooja.mspmote.interfaces;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.GridLayout;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Observable;
|
|
||||||
import java.util.Observer;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
@ -62,6 +52,7 @@ import se.sics.cooja.mspmote.MspMoteTimeEvent;
|
||||||
import se.sics.mspsim.core.IOUnit;
|
import se.sics.mspsim.core.IOUnit;
|
||||||
import se.sics.mspsim.core.USART;
|
import se.sics.mspsim.core.USART;
|
||||||
import se.sics.mspsim.core.USARTListener;
|
import se.sics.mspsim.core.USARTListener;
|
||||||
|
import se.sics.mspsim.core.USARTSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TR1001 radio interface on ESB platform.
|
* TR1001 radio interface on ESB platform.
|
||||||
|
@ -200,7 +191,7 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USART listener support */
|
/* USART listener support */
|
||||||
public void dataReceived(USART source, int data) {
|
public void dataReceived(USARTSource source, int data) {
|
||||||
if (!isTransmitting()) {
|
if (!isTransmitting()) {
|
||||||
/* New transmission discovered */
|
/* New transmission discovered */
|
||||||
/*logger.info("----- NEW TR1001 TRANSMISSION DETECTED -----");*/
|
/*logger.info("----- NEW TR1001 TRANSMISSION DETECTED -----");*/
|
||||||
|
@ -253,9 +244,6 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stateChanged(int state) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/* General radio support */
|
/* General radio support */
|
||||||
public boolean isTransmitting() {
|
public boolean isTransmitting() {
|
||||||
return isTransmitting;
|
return isTransmitting;
|
||||||
|
|
Binary file not shown.
|
@ -8,7 +8,8 @@
|
||||||
# contikichecker
|
# contikichecker
|
||||||
|
|
||||||
#start the nodegui service
|
#start the nodegui service
|
||||||
service controlgui start
|
service -f controlgui start
|
||||||
service nodegui start
|
service -f nodegui start
|
||||||
#service stackchart start
|
service -f serialgui start
|
||||||
|
#service -f stackchart start
|
||||||
start
|
start
|
||||||
|
|
Loading…
Reference in a new issue