get s/button ->show button status 0/1
This commit is contained in:
parent
c106898d2b
commit
d90e0d622d
2 changed files with 12 additions and 4 deletions
|
@ -293,10 +293,17 @@ EVENT_RESOURCE(event, METHOD_GET, "s/button", "title=\"Event demo\";obs");
|
||||||
void
|
void
|
||||||
event_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
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);
|
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||||
/* Usually, a CoAP server would response with the current resource representation. */
|
REST.set_response_payload(response, buffer, length);
|
||||||
const char *msg = "It's eventful!";
|
|
||||||
REST.set_response_payload(response, (uint8_t *)msg, strlen(msg));
|
|
||||||
|
|
||||||
/* A post_handler that handles subscriptions/observing will be called for periodic resources by the framework. */
|
/* A post_handler that handles subscriptions/observing will be called for periodic resources by the framework. */
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ ISR(INT4_vect)
|
||||||
static int
|
static int
|
||||||
value(int type)
|
value(int type)
|
||||||
{
|
{
|
||||||
return (PORTE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer);
|
return (PINE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer);
|
||||||
|
|
||||||
//return 0;
|
//return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue