get s/button ->show button status 0/1

This commit is contained in:
harald 2014-04-30 15:20:25 +02:00
parent 40bd9950d1
commit 5fcac26e80
2 changed files with 12 additions and 4 deletions

View file

@ -293,10 +293,17 @@ EVENT_RESOURCE(event, METHOD_GET, "s/button", "title=\"Event demo\";obs");
void
event_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
char message[100];
int index = 0;
int length = 0; /* |<-------->| */
int button = button_sensor.value(0);
index += sprintf(message + index,"%d",button);
length = strlen(message);
memcpy(buffer, message,length );
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
/* Usually, a CoAP server would response with the current resource representation. */
const char *msg = "It's eventful!";
REST.set_response_payload(response, (uint8_t *)msg, strlen(msg));
REST.set_response_payload(response, buffer, length);
/* A post_handler that handles subscriptions/observing will be called for periodic resources by the framework. */
}

View file

@ -39,7 +39,8 @@ ISR(INT4_vect)
static int
value(int type)
{
return (PORTE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer);
return (PINE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer);
//return 0;
}