diff --git a/apps/er-coap-07/er-coap-07-engine.c b/apps/er-coap-07/er-coap-07-engine.c index 47bbccd90..a6a1dc573 100644 --- a/apps/er-coap-07/er-coap-07-engine.c +++ b/apps/er-coap-07/er-coap-07-engine.c @@ -153,7 +153,14 @@ handle_incoming_data(void) if (coap_error_code==NO_ERROR) { /* Apply blockwise transfers. */ - if ( IS_OPTION(message, COAP_OPTION_BLOCK2) ) + if ( IS_OPTION(message, COAP_OPTION_BLOCK1) && response->codeblock2_num, coap_pkt->block2_more ? "+" : "", coap_pkt->block2_size); break; case COAP_OPTION_BLOCK1: - PRINTF("Block1 NOT IMPLEMENTED\n"); - /*TODO implement */ - coap_error_message = "Blockwise POST/PUT not supported"; - return NOT_IMPLEMENTED_5_01; + coap_pkt->block1_num = parse_int_option(current_option, option_len); + coap_pkt->block1_more = (coap_pkt->block1_num & 0x08)>>3; + coap_pkt->block1_size = 16 << (coap_pkt->block1_num & 0x07); + 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; case COAP_OPTION_IF_NONE_MATCH: coap_pkt->if_none_match = 1; @@ -779,7 +781,11 @@ coap_set_status_code(void *packet, unsigned int code) unsigned int 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 diff --git a/examples/er-rest-example/Makefile b/examples/er-rest-example/Makefile index c10d11482..1cdae1b5e 100644 --- a/examples/er-rest-example/Makefile +++ b/examples/er-rest-example/Makefile @@ -1,4 +1,4 @@ -all: rest-server-example coap-client-example +all: rest-server-example coap-client-example plugtest-server CONTIKI=../.. CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" @@ -25,6 +25,8 @@ else ${info INFO: compiling without RPL} UIP_CONF_RPL=0 CFLAGS += -DUIP_CONF_ND6_DEF_MAXDADNS=0 +CFLAGS += -DHARD_CODED_ADDRESS=\"fdfd::10\" +CFLAGS += -DUIP_CONF_BUFFER_SIZE=1280 endif # linker optimizations @@ -78,3 +80,6 @@ connect-router: $(CONTIKI)/tools/tunslip6 connect-router-cooja: $(CONTIKI)/tools/tunslip6 sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 aaaa::1/64 + +tap0up: + sudo ip address add fdfd::1/64 dev tap0