add pin status
This commit is contained in:
parent
265d4e8723
commit
cf40f59843
|
@ -11,6 +11,7 @@ const struct sensors_sensor button_sensor;
|
||||||
static struct timer debouncetimer;
|
static struct timer debouncetimer;
|
||||||
static int status(int type);
|
static int status(int type);
|
||||||
static int enabled = 0;
|
static int enabled = 0;
|
||||||
|
volatile static int bstate;
|
||||||
struct sensors_sensor *sensors[1];
|
struct sensors_sensor *sensors[1];
|
||||||
unsigned char sensors_flags[1];
|
unsigned char sensors_flags[1];
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ ISR(INT4_vect)
|
||||||
if(timer_expired(&debouncetimer)) {
|
if(timer_expired(&debouncetimer)) {
|
||||||
// led1_on();
|
// led1_on();
|
||||||
timer_set(&debouncetimer, CLOCK_SECOND / 8);
|
timer_set(&debouncetimer, CLOCK_SECOND / 8);
|
||||||
|
bstate = (PINE & _BV(PE4) ? 0 : 1);
|
||||||
sensors_changed(&button_sensor);
|
sensors_changed(&button_sensor);
|
||||||
// led1_off();
|
// led1_off();
|
||||||
}
|
}
|
||||||
|
@ -39,9 +41,9 @@ ISR(INT4_vect)
|
||||||
static int
|
static int
|
||||||
value(int type)
|
value(int type)
|
||||||
{
|
{
|
||||||
return (PINE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer);
|
//return (PINE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer);
|
||||||
|
|
||||||
//return 0;
|
return bstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
//#define NETSTACK_CONF_RDC nullrdc_driver
|
//#define NETSTACK_CONF_RDC nullrdc_driver
|
||||||
|
|
||||||
/* Increase rpl-border-router IP-buffer when using more than 64. */
|
/* Increase rpl-border-router IP-buffer when using more than 64. */
|
||||||
#undef REST_MAX_CHUNK_SIZE
|
//#undef REST_MAX_CHUNK_SIZE
|
||||||
#define REST_MAX_CHUNK_SIZE 64
|
//#define REST_MAX_CHUNK_SIZE 64
|
||||||
|
|
||||||
/* Estimate your header size, especially when using Proxy-Uri. */
|
/* Estimate your header size, especially when using Proxy-Uri. */
|
||||||
/*
|
/*
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
/* Multiplies with chunk size, be aware of memory constraints. */
|
/* Multiplies with chunk size, be aware of memory constraints. */
|
||||||
#undef COAP_MAX_OPEN_TRANSACTIONS
|
#undef COAP_MAX_OPEN_TRANSACTIONS
|
||||||
#define COAP_MAX_OPEN_TRANSACTIONS 4
|
#define COAP_MAX_OPEN_TRANSACTIONS 8
|
||||||
|
|
||||||
/* Must be <= open transaction number, default is COAP_MAX_OPEN_TRANSACTIONS-1. */
|
/* Must be <= open transaction number, default is COAP_MAX_OPEN_TRANSACTIONS-1. */
|
||||||
/*
|
/*
|
||||||
|
@ -82,10 +82,4 @@
|
||||||
#define COAP_LINK_FORMAT_FILTERING 0
|
#define COAP_LINK_FORMAT_FILTERING 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* PROJECT_RPL_WEB_CONF_H_ */
|
#endif /* PROJECT_RPL_WEB_CONF_H_ */
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "rest-engine.h"
|
#include "rest-engine.h"
|
||||||
#include "er-coap.h"
|
#include "er-coap.h"
|
||||||
|
#include "dev/button-sensor.h"
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -76,8 +77,20 @@ static int32_t event_counter = 0;
|
||||||
static void
|
static void
|
||||||
res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
{
|
{
|
||||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
int buttonstate = button_sensor.value(0);
|
||||||
REST.set_response_payload(response, buffer, snprintf((char *)buffer, preferred_size, "EVENT %lu", event_counter));
|
|
||||||
|
unsigned int accept = -1;
|
||||||
|
REST.get_header_accept(request, &accept);
|
||||||
|
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
|
||||||
|
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||||
|
REST.set_response_payload(response, buffer, snprintf((char *)buffer, preferred_size, "EVENT %lu STATE %d", event_counter, buttonstate));
|
||||||
|
} else if(accept == REST.type.APPLICATION_JSON) {
|
||||||
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
|
REST.set_response_payload(response, buffer, snprintf((char *)buffer, preferred_size, "{'EVENT':%lu ,'STATE': %d}", event_counter, buttonstate));
|
||||||
|
} else {
|
||||||
|
REST.set_response_status(response, REST.status.NOT_ACCEPTABLE);
|
||||||
|
REST.set_response_payload(response, buffer, snprintf((char *)buffer, preferred_size, "Supporting content-types text/plain and application/json"));
|
||||||
|
}
|
||||||
|
|
||||||
/* 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. */
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,6 +174,8 @@ typedef unsigned short uip_stats_t;
|
||||||
#define NETSTACK_CONF_RDC sicslowmac_driver
|
#define NETSTACK_CONF_RDC sicslowmac_driver
|
||||||
#define NETSTACK_CONF_FRAMER framer_802154
|
#define NETSTACK_CONF_FRAMER framer_802154
|
||||||
#define NETSTACK_CONF_RADIO rf230_driver
|
#define NETSTACK_CONF_RADIO rf230_driver
|
||||||
|
/* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the $ */
|
||||||
|
#define RF230_CONF_CCA_THRES -85
|
||||||
/* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
|
/* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
|
||||||
#define RF230_CONF_AUTOACK 1
|
#define RF230_CONF_AUTOACK 1
|
||||||
/* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */
|
/* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */
|
||||||
|
@ -228,6 +230,7 @@ typedef unsigned short uip_stats_t;
|
||||||
#define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0
|
#define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0
|
||||||
#define CONTIKIMAC_CONF_COMPOWER 1
|
#define CONTIKIMAC_CONF_COMPOWER 1
|
||||||
#define RIMESTATS_CONF_ENABLED 0
|
#define RIMESTATS_CONF_ENABLED 0
|
||||||
|
#define WITH_FAST_SLEEP 0
|
||||||
|
|
||||||
#if NETSTACK_CONF_WITH_IPV6
|
#if NETSTACK_CONF_WITH_IPV6
|
||||||
#define NETSTACK_CONF_FRAMER framer_802154
|
#define NETSTACK_CONF_FRAMER framer_802154
|
||||||
|
|
Loading…
Reference in a new issue