bugfix float resources, save energy enabled

This commit is contained in:
Harald Pichler 2015-09-14 16:55:18 +02:00
parent e3ffbe36c8
commit 7404e75213
4 changed files with 10 additions and 10 deletions

View file

@ -44,8 +44,8 @@
//#define RDC_CONF_PT_YIELD_OFF
/* For Debug: Dont allow MCU sleeping between channel checks */
#undef RDC_CONF_MCU_SLEEP
#define RDC_CONF_MCU_SLEEP 0
//#undef RDC_CONF_MCU_SLEEP
//#define RDC_CONF_MCU_SLEEP 0
/* Disabling RDC for demo purposes. Core updates often require more memory. */
/* For projects, optimize memory and enable RDC again. */

View file

@ -52,7 +52,7 @@ RESOURCE(res_htu21dhum,
NULL,
NULL);
extern float htu21d_hum;
extern char htu21d_hum_s[8];
static void
@ -64,12 +64,12 @@ res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferr
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%f", (double) htu21d_hum);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s", htu21d_hum_s);
REST.set_response_payload(response, buffer, strlen((char *)buffer));
} else if(accept == REST.type.APPLICATION_JSON) {
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'moisture':%f}", (double) htu21d_hum);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'moisture':%s}", htu21d_hum_s);
REST.set_response_payload(response, buffer, strlen((char *)buffer));
} else {

View file

@ -52,7 +52,7 @@ RESOURCE(res_htu21dtemp,
NULL,
NULL);
extern float htu21d_temp;
extern char htu21d_temp_s[8];
static void
res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
@ -63,12 +63,12 @@ res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferr
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%f", (double) htu21d_temp);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s", htu21d_temp_s);
REST.set_response_payload(response, buffer, strlen((char *)buffer));
} else if(accept == REST.type.APPLICATION_JSON) {
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'moisture':%f}", (double) htu21d_temp);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'moisture':%s}", htu21d_temp_s);
REST.set_response_payload(response, buffer, strlen((char *)buffer));
} else {

View file

@ -54,6 +54,6 @@ void loop (void)
htu21d_hum = htu.readHumidity();
dtostrf(htu21d_temp , 6, 2, htu21d_temp_s );
dtostrf(htu21d_hum , 6, 2, htu21d_hum_s );
printf("Temp: %s",htu21d_temp_s);
printf("\t\tHum: %s\n",htu21d_hum_s);
// printf("Temp: %s",htu21d_temp_s);
// printf("\t\tHum: %s\n",htu21d_hum_s);
}