bugfix dallas coap resource

This commit is contained in:
Harald Pichler 2016-01-06 21:39:35 +01:00
parent d484585e39
commit 836a483f7e
2 changed files with 10 additions and 6 deletions

View file

@ -53,6 +53,8 @@ RESOURCE(res_dtemp1,
NULL,
NULL);
extern char d_temp_s[8];
static void
res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
@ -62,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, "%s", ds1820[0].stemp);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%s", d_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, "{'temperature':%s}", ds1820[0].stemp);
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'temperature':%s}", d_temp_s);
REST.set_response_payload(response, buffer, strlen((char *)buffer));
} else {

View file

@ -127,21 +127,21 @@ void setup (void)
}
// at project-conf.h
// LOOP_INTERVAL (10 * CLOCK_SECOND)
// LOOP_INTERVAL (20 * CLOCK_SECOND)
void loop (void)
{
mcusleepcycle=0; // dont sleep
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
printf("Requesting temperatures...");
// printf("Requesting temperatures...");
dsensors.requestTemperatures();
printf("DONE\n");
// printf("DONE\n");
// print the device information
printData(outsideThermometer,0);
htu21d_temp = htu.readTemperature();
htu21d_hum = htu.readHumidity();
mcusleepcycle=32; // sleep, wakeup every 32 cycles
dtostrf(htu21d_temp , 6, 2, htu21d_temp_s );
dtostrf(htu21d_hum , 6, 2, htu21d_hum_s );
// remove space
@ -155,4 +155,6 @@ void loop (void)
// debug only
printf("Temp: %s",htu21d_temp_s);
printf("\t\tHum: %s\n",htu21d_hum_s);
mcusleepcycle=32; // sleep, wakeup every 32 cycles
}