|
27 | 27 | #include "cloud_internal.h" |
28 | 28 | #include "cloud_provisioning.h" |
29 | 29 | #include "cloud_location.h" |
| 30 | +#include "cloud_environmental.h" |
30 | 31 | #include "app_common.h" |
31 | 32 | #include "network.h" |
32 | 33 | #include "storage.h" |
@@ -339,7 +340,6 @@ static void send_request_failed(void) |
339 | 340 | } |
340 | 341 | } |
341 | 342 |
|
342 | | - |
343 | 343 | #if defined(CONFIG_APP_NETWORK) |
344 | 344 | static void handle_network_data_message(const struct network_msg *msg) |
345 | 345 | { |
@@ -413,37 +413,7 @@ static int send_storage_data_to_cloud(const struct storage_data_item *item) |
413 | 413 | if (item->type == STORAGE_TYPE_ENVIRONMENTAL) { |
414 | 414 | const struct environmental_msg *env = &item->data.ENVIRONMENTAL; |
415 | 415 |
|
416 | | - err = nrf_cloud_coap_sensor_send(NRF_CLOUD_JSON_APPID_VAL_TEMP, |
417 | | - env->temperature, |
418 | | - timestamp_ms, |
419 | | - confirmable); |
420 | | - if (err) { |
421 | | - LOG_ERR("Failed to send temperature data to cloud, error: %d", err); |
422 | | - return err; |
423 | | - } |
424 | | - |
425 | | - err = nrf_cloud_coap_sensor_send(NRF_CLOUD_JSON_APPID_VAL_AIR_PRESS, |
426 | | - env->pressure, |
427 | | - timestamp_ms, |
428 | | - confirmable); |
429 | | - if (err) { |
430 | | - LOG_ERR("Failed to send pressure data to cloud, error: %d", err); |
431 | | - return err; |
432 | | - } |
433 | | - |
434 | | - err = nrf_cloud_coap_sensor_send(NRF_CLOUD_JSON_APPID_VAL_HUMID, |
435 | | - env->humidity, |
436 | | - timestamp_ms, |
437 | | - confirmable); |
438 | | - if (err) { |
439 | | - LOG_ERR("Failed to send humidity data to cloud, error: %d", err); |
440 | | - return err; |
441 | | - } |
442 | | - |
443 | | - LOG_DBG("Environmental data sent to cloud: T=%.1f°C, P=%.1fhPa, H=%.1f%%", |
444 | | - (double)env->temperature, (double)env->pressure, (double)env->humidity); |
445 | | - |
446 | | - return 0; |
| 416 | + return cloud_environmental_send(env, timestamp_ms, confirmable); |
447 | 417 | } |
448 | 418 | #endif /* CONFIG_APP_ENVIRONMENTAL */ |
449 | 419 |
|
|
0 commit comments