Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki
This commit is contained in:
commit
d711887a1b
|
@ -44,7 +44,7 @@
|
|||
|
||||
#include "er-coap-07-engine.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#define PRINT6ADDR(addr) PRINTF("[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]", ((u8_t *)addr)[0], ((u8_t *)addr)[1], ((u8_t *)addr)[2], ((u8_t *)addr)[3], ((u8_t *)addr)[4], ((u8_t *)addr)[5], ((u8_t *)addr)[6], ((u8_t *)addr)[7], ((u8_t *)addr)[8], ((u8_t *)addr)[9], ((u8_t *)addr)[10], ((u8_t *)addr)[11], ((u8_t *)addr)[12], ((u8_t *)addr)[13], ((u8_t *)addr)[14], ((u8_t *)addr)[15])
|
||||
|
@ -169,7 +169,7 @@ handle_incoming_data(void)
|
|||
PRINTF("handle_incoming_data(): block_offset >= response->payload_len\n");
|
||||
|
||||
response->code = BAD_OPTION_4_02;
|
||||
coap_set_payload(response, (uint8_t*)"Block out of scope", 18);
|
||||
coap_set_payload(response, (uint8_t*)"BlockOutOfScope", 15);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -308,55 +308,79 @@ RESOURCE(well_known_core, METHOD_GET, ".well-known/core", "");
|
|||
void
|
||||
well_known_core_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
{
|
||||
/* Response might be NULL for non-confirmable requests. */
|
||||
if (response)
|
||||
{
|
||||
size_t strpos = 0;
|
||||
size_t bufpos = 0;
|
||||
size_t tmplen = 0;
|
||||
resource_t* resource = NULL;
|
||||
|
||||
for (resource = (resource_t*)list_head(rest_get_resources()); resource; resource = resource->next)
|
||||
{
|
||||
strpos += snprintf((char *) buffer + bufpos, REST_MAX_CHUNK_SIZE - bufpos + 1,
|
||||
"</%s>%s%s%s",
|
||||
resource->url,
|
||||
resource->attributes[0] ? ";" : "",
|
||||
resource->attributes,
|
||||
resource->next ? "," : "" );
|
||||
PRINTF("res: /%s (%p)\npos: s%d, o%d, b%d\n", resource->url, resource, strpos, *offset, bufpos);
|
||||
|
||||
PRINTF("discover: %s\n", resource->url);
|
||||
|
||||
if (strpos <= *offset)
|
||||
if (strpos >= *offset && bufpos < preferred_size)
|
||||
{
|
||||
/* Discard output before current block */
|
||||
PRINTF(" if %d <= %ld B\n", strpos, *offset);
|
||||
PRINTF(" %s\n", buffer);
|
||||
bufpos = 0;
|
||||
buffer[bufpos++] = '<';
|
||||
}
|
||||
else /* (strpos > *offset) */
|
||||
++strpos;
|
||||
|
||||
if (strpos >= *offset && bufpos < preferred_size)
|
||||
{
|
||||
/* output partly in block */
|
||||
size_t len = MIN(strpos - *offset, preferred_size);
|
||||
buffer[bufpos++] = '/';
|
||||
}
|
||||
++strpos;
|
||||
|
||||
PRINTF(" el %d/%d @ %ld B\n", len, preferred_size, *offset);
|
||||
tmplen = strlen(resource->url);
|
||||
if (strpos+tmplen > *offset)
|
||||
{
|
||||
bufpos += snprintf((char *) buffer + bufpos, preferred_size - bufpos + 1,
|
||||
"%s", resource->url + ((*offset-(int32_t)strpos > 0) ? (*offset-(int32_t)strpos) : 0));
|
||||
/* minimal-net requires these casts */
|
||||
}
|
||||
strpos += tmplen;
|
||||
|
||||
/* Block might start in the middle of the output; align with buffer start. */
|
||||
if (bufpos == 0)
|
||||
if (strpos >= *offset && bufpos < preferred_size)
|
||||
{
|
||||
buffer[bufpos++] = '>';
|
||||
}
|
||||
++strpos;
|
||||
|
||||
if (resource->attributes[0])
|
||||
{
|
||||
if (strpos >= *offset && bufpos < preferred_size)
|
||||
{
|
||||
memmove(buffer, buffer+strlen((char *)buffer)-strpos+*offset, len);
|
||||
buffer[bufpos++] = ';';
|
||||
}
|
||||
++strpos;
|
||||
|
||||
bufpos = len;
|
||||
PRINTF(" %s\n", buffer);
|
||||
|
||||
if (bufpos >= preferred_size)
|
||||
tmplen = strlen(resource->attributes);
|
||||
if (strpos+tmplen > *offset)
|
||||
{
|
||||
break;
|
||||
bufpos += snprintf((char *) buffer + bufpos, preferred_size - bufpos + 1,
|
||||
"%s", resource->attributes + (*offset-(int32_t)strpos > 0 ? *offset-(int32_t)strpos : 0));
|
||||
}
|
||||
strpos += tmplen;
|
||||
}
|
||||
|
||||
if (resource->next)
|
||||
{
|
||||
if (strpos >= *offset && bufpos < preferred_size)
|
||||
{
|
||||
buffer[bufpos++] = ',';
|
||||
}
|
||||
++strpos;
|
||||
}
|
||||
|
||||
/* buffer full, but resource not completed yet; or: do not break if resource exactly fills buffer. */
|
||||
if (bufpos >= preferred_size && strpos-bufpos > *offset)
|
||||
{
|
||||
PRINTF("res: BREAK at %s (%p)\n", resource->url, resource);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bufpos>0) {
|
||||
PRINTF("BUF %d: %.*s\n", bufpos, bufpos, (char *) buffer);
|
||||
|
||||
coap_set_payload(response, buffer, bufpos );
|
||||
coap_set_header_content_type(response, APPLICATION_LINK_FORMAT);
|
||||
}
|
||||
|
@ -365,17 +389,18 @@ well_known_core_handler(void* request, void* response, uint8_t *buffer, uint16_t
|
|||
PRINTF("well_known_core_handler(): bufpos<=0\n");
|
||||
|
||||
coap_set_rest_status(response, BAD_OPTION_4_02);
|
||||
coap_set_payload(response, (uint8_t*)"Block out of scope", 18);
|
||||
coap_set_payload(response, (uint8_t*)"BlockOutOfScope", 15);
|
||||
}
|
||||
|
||||
if (resource==NULL) {
|
||||
PRINTF("res: DONE\n");
|
||||
*offset = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINTF("res: MORE at %s (%p)\n", resource->url, resource);
|
||||
*offset += bufpos;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(coap_receiver, ev, data)
|
||||
|
|
|
@ -524,14 +524,14 @@ static unsigned short
|
|||
generate_sensor_readings(void *arg)
|
||||
{
|
||||
uint16_t numprinted;
|
||||
uint16_t h,m,s;
|
||||
uint16_t days,h,m,s;
|
||||
unsigned long seconds=clock_seconds();
|
||||
// uint8_t p1;
|
||||
static const char httpd_cgi_sensor0[] HTTPD_STRING_ATTR = "[Updated %d seconds ago]<br><br>";
|
||||
static const char httpd_cgi_sensor1[] HTTPD_STRING_ATTR = "<em>Temperature:</em> %s<br>";
|
||||
static const char httpd_cgi_sensor2[] HTTPD_STRING_ATTR = "<em>Battery:</em> %s<br>";
|
||||
// static const char httpd_cgi_sensr12[] HTTPD_STRING_ATTR = "<em>Temperature:</em> %s <em>Battery:</em> %s<br>";
|
||||
static const char httpd_cgi_sensor3[] HTTPD_STRING_ATTR = "<em>Elapsed timer :</em> %02d:%02d:%02d<br>";
|
||||
static const char httpd_cgi_sensor3[] HTTPD_STRING_ATTR = "<em>Uptime :</em> %02d:%02d:%02d<br>";
|
||||
static const char httpd_cgi_sensor3d[] HTTPD_STRING_ATTR = "<em>Uptime :</em> %u days %02u:%02u:%02u<br>";
|
||||
// static const char httpd_cgi_sensor4[] HTTPD_STRING_ATTR = "<em>Sleeping time :</em> %02d:%02d:%02d (%d%%)<br>";
|
||||
|
||||
numprinted=0;
|
||||
|
@ -554,33 +554,97 @@ generate_sensor_readings(void *arg)
|
|||
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor2, sensor_extvoltage);
|
||||
// numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensr12, sensor_temperature,sensor_extvoltage);
|
||||
|
||||
#if RADIOSTATS
|
||||
/* Remember radioontime for display below - slow connection might make it report longer than cpu ontime! */
|
||||
savedradioontime = radioontime;
|
||||
#endif
|
||||
h=seconds/3600;
|
||||
s=seconds-h*3600;
|
||||
m=s/60;
|
||||
s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor3, h,m,s);
|
||||
|
||||
/* TODO: some gcc's have a bug with %02d format that adds a zero byte and extra chars to the end of the string.
|
||||
h=seconds/3600;s=seconds-h*3600;m=s/60;s=s-m*60;
|
||||
days=h/24;
|
||||
if (days == 0) {
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor3, h,m,s);
|
||||
} else {
|
||||
h=h-days*24;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor3d, days,h,m,s);
|
||||
}
|
||||
/* TODO: some gcc's have a bug with %02d format that adds an extra char after the string terminator.
|
||||
* Seen with arm-none-eabi-gcc.exe (Sourcery G++ Lite 2008q3-66) 4.3.2
|
||||
* Quick cosmetic fix to strip that off: */
|
||||
if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||
|
||||
if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||
|
||||
#if 0
|
||||
if (sleepseconds) {
|
||||
p1=100UL*sleepseconds/seconds;
|
||||
h=sleepseconds/3600;
|
||||
s=sleepseconds-h*3600;
|
||||
m=s/60;
|
||||
s=s-m*60;
|
||||
uint8_t p1;
|
||||
p1=100UL*sleepseconds/seconds;h=sleepseconds/3600;s=sleepseconds-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor4, h,m,s,p1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENERGEST_CONF_ON
|
||||
{uint8_t p1,p2;
|
||||
#if 0
|
||||
/* Update all the timers to get current values */
|
||||
for (p1=1;p1<ENERGEST_TYPE_MAX;p1++) {
|
||||
if (energest_current_mode[p1]) {
|
||||
ENERGEST_OFF(p1);
|
||||
ENERGEST_ON(p1);
|
||||
}
|
||||
}
|
||||
#else
|
||||
energest_flush();
|
||||
#endif
|
||||
static const char httpd_cgi_sensor10[] HTTPD_STRING_ATTR = "<em>Radio (ENERGEST) :</em> Tx %02u:%02u:%02u (%u.%02u%%) ";
|
||||
static const char httpd_cgi_sensor11[] HTTPD_STRING_ATTR = "Tx %02u:%02u:%02u (%u.%02u%%)<br>";
|
||||
s=energest_total_time[ENERGEST_TYPE_LISTEN].current/RTIMER_ARCH_SECOND;
|
||||
h=s*10000/seconds;p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor10, h,m,s,p1,p2);
|
||||
if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;}
|
||||
else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||
s=energest_total_time[ENERGEST_TYPE_TRANSMIT].current/RTIMER_ARCH_SECOND;
|
||||
h=s*10000/seconds;p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor11, h,m,s,p1,p2);
|
||||
if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;}
|
||||
else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||
}
|
||||
#endif /* ENERGEST_CONF_ON */
|
||||
|
||||
#if RIMESTATS_CONF_ON
|
||||
#include "net/rime/rimestats.h"
|
||||
static const char httpd_cgi_sensor21[] HTTPD_STRING_ATTR = "<em>Packets (RIMESTATS) :</em> Tx=%5lu Rx=%5lu TxL=%5lu RxL=%5lu<br>";
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor21,
|
||||
rimestats.tx,rimestats.rx,rimestats.lltx-rimestats.tx,rimestats.llrx-rimestats.rx);
|
||||
#endif
|
||||
|
||||
#if CONTIKIMAC_CONF_COMPOWER
|
||||
#include "sys/compower.h"
|
||||
{uint8_t p1,p2;
|
||||
extern struct compower_activity current_packet;
|
||||
static const char httpd_cgi_sensor31[] HTTPD_STRING_ATTR = "<em>ContikiMAC (COMPOWER):</em> Idle Rx %02u:%02u:%02u (%u.%02u%%) ";
|
||||
static const char httpd_cgi_sensor32[] HTTPD_STRING_ATTR = "Tx %02u:%02u:%02u (%u.%0u%%)<br>";
|
||||
|
||||
s=100UL*compower_idle_activity.listen/RTIMER_ARCH_SECOND;
|
||||
h=s*100/seconds;p1=h/100;p2=h-p1*100;s/=100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor31, h,m,s,p1,p2);
|
||||
if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;}
|
||||
else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||
s=100UL*compower_idle_activity.transmit/RTIMER_ARCH_SECOND;
|
||||
h=s*100/seconds;p1=h/100;p2=h-p1*100;s/=100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor32, h,m,s,p1,p2);
|
||||
if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;}
|
||||
else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||
}
|
||||
#endif
|
||||
|
||||
return numprinted;
|
||||
|
||||
}
|
||||
|
|
|
@ -548,7 +548,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
|
|||
#if WITH_PHASE_OPTIMIZATION
|
||||
ret = phase_wait(&phase_list, packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||
CYCLE_TIME, GUARD_TIME,
|
||||
mac_callback, mac_callback_ptr, buf_list, 0);
|
||||
mac_callback, mac_callback_ptr, buf_list);
|
||||
if(ret == PHASE_DEFERRED) {
|
||||
return MAC_TX_DEFERRED;
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ qsend_packet(mac_callback_t sent, void *ptr)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
static void
|
||||
qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
||||
{
|
||||
struct rdc_buf_list *curr = buf_list;
|
||||
|
@ -748,14 +748,8 @@ qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
|||
}
|
||||
/* Do not send during reception of a burst */
|
||||
if(we_are_receiving_burst) {
|
||||
queuebuf_to_packetbuf(curr->buf);
|
||||
/* We try to defer, and return an error this wasn't possible */
|
||||
int ret = phase_wait(&phase_list, packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||
CYCLE_TIME, GUARD_TIME,
|
||||
sent, ptr, curr, 2);
|
||||
if(ret != PHASE_DEFERRED) {
|
||||
mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 1);
|
||||
}
|
||||
/* Return COLLISION so the MAC may try again later */
|
||||
mac_call_sent_callback(sent, ptr, MAC_TX_COLLISION, 1);
|
||||
return;
|
||||
}
|
||||
/* The receiver needs to be awoken before we send */
|
||||
|
|
|
@ -699,7 +699,7 @@ qsend_packet(mac_callback_t sent, void *ptr)
|
|||
mac_call_sent_callback(sent, ptr, ret, 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
static void
|
||||
qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
||||
{
|
||||
if(buf_list != NULL) {
|
||||
|
|
|
@ -726,7 +726,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
static void
|
||||
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
||||
{
|
||||
if(buf_list != NULL) {
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "net/mac/nullrdc-noframer.h"
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/netstack.h"
|
||||
#include <string.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
|
@ -55,7 +56,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||
mac_call_sent_callback(sent, ptr, ret, 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
static void
|
||||
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
||||
{
|
||||
if(buf_list != NULL) {
|
||||
|
|
|
@ -201,7 +201,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||
mac_call_sent_callback(sent, ptr, ret, 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
static void
|
||||
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
||||
{
|
||||
if(buf_list != NULL) {
|
||||
|
|
|
@ -167,7 +167,7 @@ phase_wait(struct phase_list *list,
|
|||
const rimeaddr_t *neighbor, rtimer_clock_t cycle_time,
|
||||
rtimer_clock_t guard_time,
|
||||
mac_callback_t mac_callback, void *mac_callback_ptr,
|
||||
struct rdc_buf_list *buf_list, int extra_deferment)
|
||||
struct rdc_buf_list *buf_list)
|
||||
{
|
||||
struct phase *e;
|
||||
// const rimeaddr_t *neighbor = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
|
||||
|
@ -176,7 +176,7 @@ phase_wait(struct phase_list *list,
|
|||
time for the next expected phase and setup a ctimer to switch on
|
||||
the radio just before the phase. */
|
||||
e = find_neighbor(list, neighbor);
|
||||
if((e != NULL) | extra_deferment) {
|
||||
if(e != NULL) {
|
||||
rtimer_clock_t wait, now, expected, sync;
|
||||
clock_time_t ctimewait;
|
||||
|
||||
|
@ -202,14 +202,10 @@ phase_wait(struct phase_list *list,
|
|||
if(wait < guard_time) {
|
||||
wait += cycle_time;
|
||||
}
|
||||
if(extra_deferment) {
|
||||
wait += extra_deferment * cycle_time;
|
||||
}
|
||||
|
||||
|
||||
ctimewait = (CLOCK_SECOND * (wait - guard_time)) / RTIMER_ARCH_SECOND;
|
||||
|
||||
if((ctimewait > PHASE_DEFER_THRESHOLD) | extra_deferment) {
|
||||
if(ctimewait > PHASE_DEFER_THRESHOLD) {
|
||||
struct phase_queueitem *p;
|
||||
|
||||
p = memb_alloc(&queued_packets_memb);
|
||||
|
|
|
@ -76,7 +76,7 @@ void phase_init(struct phase_list *list);
|
|||
phase_status_t phase_wait(struct phase_list *list, const rimeaddr_t *neighbor,
|
||||
rtimer_clock_t cycle_time, rtimer_clock_t wait_before,
|
||||
mac_callback_t mac_callback, void *mac_callback_ptr,
|
||||
struct rdc_buf_list *buf_list, int extra_deferment);
|
||||
struct rdc_buf_list *buf_list);
|
||||
void phase_update(const struct phase_list *list, const rimeaddr_t *neighbor,
|
||||
rtimer_clock_t time, int mac_status);
|
||||
|
||||
|
|
|
@ -763,7 +763,7 @@ qsend_packet(mac_callback_t sent, void *ptr)
|
|||
mac_call_sent_callback(sent, ptr, ret, 1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
static void
|
||||
qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
||||
{
|
||||
if(buf_list != NULL) {
|
||||
|
|
|
@ -24,8 +24,7 @@ CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
|||
endif
|
||||
|
||||
# linker optimizations
|
||||
CFLAGS += -ffunction-sections
|
||||
LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__
|
||||
SMALL=1
|
||||
|
||||
# REST framework, requires WITH_COAP
|
||||
ifeq ($(WITH_COAP), 7)
|
||||
|
|
|
@ -34,9 +34,11 @@
|
|||
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
|
||||
#ifndef QUEUEBUF_CONF_NUM
|
||||
#define QUEUEBUF_CONF_NUM 6
|
||||
#endif
|
||||
/* Save some memory for the sky platform */
|
||||
#undef UIP_CONF_DS6_NBR_NBU
|
||||
#define UIP_CONF_DS6_NBR_NBU 10
|
||||
#undef UIP_CONF_DS6_ROUTE_NBU
|
||||
#define UIP_CONF_DS6_ROUTE_NBU 10
|
||||
|
||||
/* Increase rpl-border-router IP-buffer when using 128 */
|
||||
#ifndef REST_MAX_CHUNK_SIZE
|
||||
|
@ -45,7 +47,7 @@
|
|||
|
||||
/* Decrease to 2 if no space left for stack when using 128-byte chunks */
|
||||
#ifndef COAP_MAX_OPEN_TRANSACTIONS
|
||||
#define COAP_MAX_OPEN_TRANSACTIONS 4
|
||||
#define COAP_MAX_OPEN_TRANSACTIONS 4
|
||||
#endif
|
||||
|
||||
/* Must be <= open transaction number */
|
||||
|
@ -62,4 +64,6 @@
|
|||
#define WEBSERVER_CONF_CFS_CONNS 2
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* __PROJECT_RPL_WEB_CONF_H__ */
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
* Resources are defined by the RESOURCE macro.
|
||||
* Signature: resource name, the RESTful methods it handles, and its URI path (omitting the leading slash).
|
||||
*/
|
||||
RESOURCE(helloworld, METHOD_GET, "hello", "title=\"Hello world (set length with ?len query)\";rt=\"Text\"");
|
||||
RESOURCE(helloworld, METHOD_GET, "hello", "title=\"Hello world: ?len=0..\";rt=\"Text\"");
|
||||
|
||||
/*
|
||||
* A handler function named [resource name]_handler must be implemented for each RESOURCE.
|
||||
|
@ -105,8 +105,9 @@ void
|
|||
helloworld_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
{
|
||||
const char *len = NULL;
|
||||
int length = 12; /* ------->| */
|
||||
char *message = "Hello World! ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789?!at 86 now+2+4at 99 now100..105..110..115..120..125..130..135..140..145..150..155..160";
|
||||
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
|
||||
char const * const message = "Hello World! ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy";
|
||||
int length = 12; /* |<-------->| */
|
||||
|
||||
/* The query string can be retrieved by rest_get_query() or parsed for its key-value pairs. */
|
||||
if (REST.get_query_variable(request, "len", &len)) {
|
||||
|
@ -124,7 +125,7 @@ helloworld_handler(void* request, void* response, uint8_t *buffer, uint16_t pref
|
|||
}
|
||||
|
||||
/* This resource mirrors the incoming request. It shows how to access the options and how to set them for the response. */
|
||||
RESOURCE(mirror, METHOD_GET | METHOD_POST | METHOD_PUT | METHOD_DELETE | HAS_SUB_RESOURCES, "mirror", "title=\"Returns your decoded message\";rt=\"Debug\"");
|
||||
RESOURCE(mirror, METHOD_GET | METHOD_POST | METHOD_PUT | METHOD_DELETE, "mirror", "title=\"Returns your decoded message\";rt=\"Debug\"");
|
||||
|
||||
void
|
||||
mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
|
@ -283,7 +284,7 @@ mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
|
|||
*/
|
||||
RESOURCE(chunks, METHOD_GET, "chunks", "title=\"Blockwise demo\";rt=\"Data\"");
|
||||
|
||||
#define CHUNKS_TOTAL 1030
|
||||
#define CHUNKS_TOTAL 2050
|
||||
|
||||
void
|
||||
chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
|
@ -294,26 +295,35 @@ chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
|
|||
if (*offset>=CHUNKS_TOTAL)
|
||||
{
|
||||
REST.set_response_status(response, REST.status.BAD_OPTION);
|
||||
REST.set_response_payload(response, (uint8_t*)"Block out of scope", 18);
|
||||
/* A block error message should not exceed the minimum block size (16). */
|
||||
REST.set_response_payload(response, (uint8_t*)"BlockOutOfScope", 15);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Generate data until reaching CHUNKS_TOTAL. */
|
||||
while (strpos<REST_MAX_CHUNK_SIZE) {
|
||||
strpos += snprintf((char *)buffer+strpos, REST_MAX_CHUNK_SIZE-strpos+1, "|%ld|", *offset);
|
||||
while (strpos<preferred_size)
|
||||
{
|
||||
strpos += snprintf((char *)buffer+strpos, preferred_size-strpos+1, "|%ld|", *offset);
|
||||
}
|
||||
/* Truncate if above. */
|
||||
if (*offset+strpos > CHUNKS_TOTAL)
|
||||
|
||||
/* snprintf() does not adjust return value if truncated by size. */
|
||||
if (strpos > preferred_size)
|
||||
{
|
||||
strpos = preferred_size;
|
||||
}
|
||||
|
||||
/* Truncate if above total size. */
|
||||
if (*offset+(int32_t)strpos > CHUNKS_TOTAL)
|
||||
{
|
||||
strpos = CHUNKS_TOTAL - *offset;
|
||||
}
|
||||
|
||||
REST.set_response_payload(response, buffer, strpos);
|
||||
|
||||
/* Signal chunk awareness of resource to framework. */
|
||||
/* IMPORTANT for chunk-wise resources: Signal chunk awareness to REST engine. */
|
||||
*offset += strpos;
|
||||
|
||||
/* Signal end of resource. */
|
||||
/* Signal end of resource representation. */
|
||||
if (*offset>=CHUNKS_TOTAL)
|
||||
{
|
||||
*offset = -1;
|
||||
|
@ -395,7 +405,7 @@ event_event_handler(resource_t *r)
|
|||
|
||||
#if defined (PLATFORM_HAS_LEDS)
|
||||
/*A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated*/
|
||||
RESOURCE(led, METHOD_POST | METHOD_PUT , "leds", "title=\"Led control (use ?color=red|green|blue and POST/PUT mode=on|off)\";rt=\"Control\"");
|
||||
RESOURCE(led, METHOD_POST | METHOD_PUT , "leds", "title=\"LEDs: ?color=r|g|b, POST/PUT mode=on|off\";rt=\"Control\"");
|
||||
|
||||
void
|
||||
led_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
|
@ -409,11 +419,11 @@ led_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_s
|
|||
if ((len=REST.get_query_variable(request, "color", &color))) {
|
||||
PRINTF("color %.*s\n", len, color);
|
||||
|
||||
if (strncmp(color, "red", len)==0) {
|
||||
if (strncmp(color, "r", len)==0) {
|
||||
led = LEDS_RED;
|
||||
} else if(strncmp(color,"green", len)==0) {
|
||||
} else if(strncmp(color,"g", len)==0) {
|
||||
led = LEDS_GREEN;
|
||||
} else if (strncmp(color,"blue", len)==0) {
|
||||
} else if (strncmp(color,"b", len)==0) {
|
||||
led = LEDS_BLUE;
|
||||
} else {
|
||||
success = 0;
|
||||
|
@ -524,7 +534,6 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
|
|||
}
|
||||
#endif /* PLATFORM_HAS_BATTERY */
|
||||
|
||||
|
||||
PROCESS(rest_server_example, "Rest Server Example");
|
||||
AUTOSTART_PROCESSES(&rest_server_example);
|
||||
|
||||
|
@ -569,6 +578,7 @@ PROCESS_THREAD(rest_server_example, ev, data)
|
|||
rest_activate_resource(&resource_led);
|
||||
rest_activate_resource(&resource_toggle);
|
||||
#endif /* PLATFORM_HAS_LEDS */
|
||||
|
||||
#if defined (PLATFORM_HAS_LIGHT)
|
||||
SENSORS_ACTIVATE(light_sensor);
|
||||
rest_activate_resource(&resource_light);
|
||||
|
|
|
@ -47,9 +47,9 @@
|
|||
se.sics.cooja.mspmote.SkyMoteType
|
||||
<identifier>skyweb</identifier>
|
||||
<description>Rest</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/rest-example/rest-server-example.c</source>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/er-rest-example/rest-server-example.c</source>
|
||||
<commands EXPORT="discard">make rest-server-example.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/rest-example/rest-server-example.sky</firmware>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/er-rest-example/rest-server-example.sky</firmware>
|
||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
||||
|
@ -98,7 +98,7 @@
|
|||
<plugin>
|
||||
se.sics.cooja.plugins.SimControl
|
||||
<width>259</width>
|
||||
<z>1</z>
|
||||
<z>5</z>
|
||||
<height>179</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>0</location_y>
|
||||
|
@ -115,21 +115,22 @@
|
|||
<viewport>7.9849281638410705 0.0 0.0 7.9849281638410705 -133.27812697619663 -225.04752569190535</viewport>
|
||||
</plugin_config>
|
||||
<width>300</width>
|
||||
<z>0</z>
|
||||
<z>4</z>
|
||||
<height>175</height>
|
||||
<location_x>371</location_x>
|
||||
<location_y>2</location_y>
|
||||
<location_x>263</location_x>
|
||||
<location_y>3</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>762</width>
|
||||
<z>3</z>
|
||||
<width>560</width>
|
||||
<z>1</z>
|
||||
<height>326</height>
|
||||
<location_x>12</location_x>
|
||||
<location_y>294</location_y>
|
||||
<location_x>1</location_x>
|
||||
<location_y>293</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.RadioLogger
|
||||
|
@ -148,10 +149,10 @@
|
|||
SerialSocketServer
|
||||
<mote_arg>0</mote_arg>
|
||||
<width>422</width>
|
||||
<z>5</z>
|
||||
<z>2</z>
|
||||
<height>74</height>
|
||||
<location_x>1234</location_x>
|
||||
<location_y>93</location_y>
|
||||
<location_x>39</location_x>
|
||||
<location_y>199</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.TimeLine
|
||||
|
@ -166,10 +167,10 @@
|
|||
<zoomfactor>25.49079397896416</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>1624</width>
|
||||
<z>4</z>
|
||||
<z>3</z>
|
||||
<height>252</height>
|
||||
<location_x>166</location_x>
|
||||
<location_y>699</location_y>
|
||||
<location_x>4</location_x>
|
||||
<location_y>622</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
||||
|
@ -178,11 +179,11 @@
|
|||
<interface>Serial port</interface>
|
||||
<scrollpos>0,0</scrollpos>
|
||||
</plugin_config>
|
||||
<width>662</width>
|
||||
<z>2</z>
|
||||
<height>362</height>
|
||||
<location_x>7</location_x>
|
||||
<location_y>221</location_y>
|
||||
<width>702</width>
|
||||
<z>0</z>
|
||||
<height>646</height>
|
||||
<location_x>564</location_x>
|
||||
<location_y>2</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ WITH_UIP6=1
|
|||
UIP_CONF_IPV6=1
|
||||
CFLAGS+= -DUIP_CONF_IPV6_RPL
|
||||
|
||||
#linker optimizations
|
||||
SMALL=1
|
||||
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
PROJECT_SOURCEFILES += slip-bridge.c
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ typedef unsigned short uip_stats_t;
|
|||
#define UIP_CONF_TCP_SPLIT 0
|
||||
#define UIP_CONF_IP_FORWARD 0
|
||||
#define UIP_CONF_LOGGING 0
|
||||
#define UIP_CONF_UDP_CHECKSUMS 0
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
|
||||
/* Not used but avoids compile errors while sicslowpan.c is being developed */
|
||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||
|
|
Loading…
Reference in a new issue