From cfca07489d2d3375c22fc47906c98cafe5e55e16 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Tue, 27 Sep 2016 18:13:03 +0200 Subject: [PATCH] coap client test --- examples/osd/triggerbaord/project-conf.h | 2 +- examples/osd/triggerbaord/sketch.pde | 35 +++++++++++++++--------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/examples/osd/triggerbaord/project-conf.h b/examples/osd/triggerbaord/project-conf.h index 230f9ba0b..445f3a95e 100644 --- a/examples/osd/triggerbaord/project-conf.h +++ b/examples/osd/triggerbaord/project-conf.h @@ -36,7 +36,7 @@ #define PLATFORM_HAS_BUTTON 1 #define PLATFORM_HAS_BATTERY 1 -#define LOOP_INTERVAL (10 * CLOCK_SECOND) +#define LOOP_INTERVAL (CLOCK_SECOND/10) /* Seeping nodes are host nodes without routing features */ #define UIP_CONF_ROUTER 0 diff --git a/examples/osd/triggerbaord/sketch.pde b/examples/osd/triggerbaord/sketch.pde index ba8700eaf..1b4570dbd 100755 --- a/examples/osd/triggerbaord/sketch.pde +++ b/examples/osd/triggerbaord/sketch.pde @@ -37,12 +37,12 @@ uint8_t bled_status; // should be the same :-) #define UIP_NTOHS(x) UIP_HTONS(x) #define SERVER_NODE(ip) \ - uip_ip6addr(ip,0xfe80,0,0,0,0,0,0,0x01) + uip_ip6addr(ip,0xaaaa,0,0,0,0,0,0,0x01) uip_ipaddr_t server_ipaddr, tmp_addr; char server_resource [20] = "button"; -extern int32_t event_counter; +static int32_t levent_counter; #define NUM_LEDS 1 @@ -81,10 +81,11 @@ void setup (void) int coap_server_post(void) { static coap_packet_t request [1]; /* Array: treat as pointer */ - char buf [9]; + char buf [25]; + printf("post\n"); coap_transaction_t *transaction; int buttonstate = button_sensor.value(0); - sprintf (buf, "state=%d&event=%lu",buttonstate,event_counter); + sprintf (buf, "state=%d&event=%lu",buttonstate,levent_counter++); // printf ("%s\n", buf); coap_init_message (request, COAP_TYPE_NON, COAP_PUT, 0); coap_set_header_uri_path (request, server_resource); @@ -101,14 +102,22 @@ int coap_server_post(void) void loop (void) { +// test caop srever post + + static int buttonstate = 1; + + if(buttonstate != button_sensor.value(0)){ + coap_server_post(); + buttonstate=button_sensor.value(0); + } // test chainable led - static byte power=0; - for (byte i=0; i