change battery and cpttem format to xx.xx
This commit is contained in:
parent
a656cf1dcd
commit
678891a1a9
1 changed files with 6 additions and 5 deletions
|
@ -804,14 +804,15 @@ temperature_handler(void* request, void* response, uint8_t *buffer, uint16_t pre
|
|||
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
|
||||
{
|
||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", temperature);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d.%02d", temperature/100, temperature % 100);
|
||||
|
||||
|
||||
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
||||
}
|
||||
else if (num && (accept[0]==REST.type.APPLICATION_JSON))
|
||||
{
|
||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'temperature':%d}", temperature);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'temperature':%d.%02d}", temperature/100, temperature % 100);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
}
|
||||
|
@ -839,15 +840,15 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
|
|||
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
|
||||
{
|
||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", battery);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d.%02d", battery/1000, battery % 1000);
|
||||
|
||||
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
||||
}
|
||||
else if (num && (accept[0]==REST.type.APPLICATION_JSON))
|
||||
{
|
||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'battery':%d}", battery);
|
||||
|
||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{\"battery\":%d.%02d}", battery/1000, battery % 1000);
|
||||
|
||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue