Made Block1 support dependent on resource handlers.\nAdded flags and target for minimal-net.

This commit is contained in:
Matthias Kovatsch 2012-03-17 15:32:51 +01:00
parent 3a3d457a57
commit e794088d19
3 changed files with 27 additions and 9 deletions

View file

@ -153,7 +153,14 @@ handle_incoming_data(void)
if (coap_error_code==NO_ERROR) if (coap_error_code==NO_ERROR)
{ {
/* Apply blockwise transfers. */ /* Apply blockwise transfers. */
if ( IS_OPTION(message, COAP_OPTION_BLOCK2) ) if ( IS_OPTION(message, COAP_OPTION_BLOCK1) && response->code<BAD_REQUEST_4_00 && !IS_OPTION(response, COAP_OPTION_BLOCK1) )
{
PRINTF("Block1 NOT IMPLEMENTED\n");
coap_error_code = NOT_IMPLEMENTED_5_01;
coap_error_message = "NoBlock1Support";
}
else if ( IS_OPTION(message, COAP_OPTION_BLOCK2) )
{ {
/* unchanged new_offset indicates that resource is unaware of blockwise transfer */ /* unchanged new_offset indicates that resource is unaware of blockwise transfer */
if (new_offset==block_offset) if (new_offset==block_offset)
@ -207,8 +214,8 @@ handle_incoming_data(void)
} /* if (service callback) */ } /* if (service callback) */
} else { } else {
coap_error_code = MEMORY_ALLOCATION_ERROR; coap_error_code = SERVICE_UNAVAILABLE_5_03;
coap_error_message = "Transaction buffer allocation failed"; coap_error_message = "NoFreeTraBuffer";
} /* if (transaction buffer) */ } /* if (transaction buffer) */
} }
else else

View file

@ -697,10 +697,12 @@ coap_parse_message(void *packet, uint8_t *data, uint16_t data_len)
PRINTF("Block2 [%lu%s (%u B/blk)]\n", coap_pkt->block2_num, coap_pkt->block2_more ? "+" : "", coap_pkt->block2_size); PRINTF("Block2 [%lu%s (%u B/blk)]\n", coap_pkt->block2_num, coap_pkt->block2_more ? "+" : "", coap_pkt->block2_size);
break; break;
case COAP_OPTION_BLOCK1: case COAP_OPTION_BLOCK1:
PRINTF("Block1 NOT IMPLEMENTED\n"); coap_pkt->block1_num = parse_int_option(current_option, option_len);
/*TODO implement */ coap_pkt->block1_more = (coap_pkt->block1_num & 0x08)>>3;
coap_error_message = "Blockwise POST/PUT not supported"; coap_pkt->block1_size = 16 << (coap_pkt->block1_num & 0x07);
return NOT_IMPLEMENTED_5_01; coap_pkt->block1_offset = (coap_pkt->block1_num & ~0x0000000F)<<(coap_pkt->block1_num & 0x07);
coap_pkt->block1_num >>= 4;
PRINTF("Block1 [%lu%s (%u B/blk)]\n", coap_pkt->block1_num, coap_pkt->block1_more ? "+" : "", coap_pkt->block1_size);
break; break;
case COAP_OPTION_IF_NONE_MATCH: case COAP_OPTION_IF_NONE_MATCH:
coap_pkt->if_none_match = 1; coap_pkt->if_none_match = 1;
@ -779,7 +781,11 @@ coap_set_status_code(void *packet, unsigned int code)
unsigned int unsigned int
coap_get_header_content_type(void *packet) coap_get_header_content_type(void *packet)
{ {
return ((coap_packet_t *)packet)->content_type; coap_packet_t *const coap_pkt = (coap_packet_t *) packet;
if (!IS_OPTION(coap_pkt, COAP_OPTION_CONTENT_TYPE)) return -1;
return coap_pkt->content_type;
} }
int int

View file

@ -1,4 +1,4 @@
all: rest-server-example coap-client-example all: rest-server-example coap-client-example plugtest-server
CONTIKI=../.. CONTIKI=../..
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
@ -25,6 +25,8 @@ else
${info INFO: compiling without RPL} ${info INFO: compiling without RPL}
UIP_CONF_RPL=0 UIP_CONF_RPL=0
CFLAGS += -DUIP_CONF_ND6_DEF_MAXDADNS=0 CFLAGS += -DUIP_CONF_ND6_DEF_MAXDADNS=0
CFLAGS += -DHARD_CODED_ADDRESS=\"fdfd::10\"
CFLAGS += -DUIP_CONF_BUFFER_SIZE=1280
endif endif
# linker optimizations # linker optimizations
@ -78,3 +80,6 @@ connect-router: $(CONTIKI)/tools/tunslip6
connect-router-cooja: $(CONTIKI)/tools/tunslip6 connect-router-cooja: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 aaaa::1/64 sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 aaaa::1/64
tap0up:
sudo ip address add fdfd::1/64 dev tap0