@@ -28,11 +28,12 @@ LOG_MODULE_REGISTER(cloud, CONFIG_APP_CLOUD_LOG_LEVEL);
28
28
#define CUSTOM_JSON_APPID_VAL_CONEVAL "CONEVAL"
29
29
#define CUSTOM_JSON_APPID_VAL_BATTERY "BATTERY"
30
30
#define MAX_MSG_SIZE (MAX(sizeof(struct cloud_payload), \
31
- MAX(sizeof(struct network_msg), sizeof(struct battery_msg))))
31
+ MAX(sizeof(struct network_msg), \
32
+ MAX(sizeof(struct battery_msg), sizeof(struct environmental_msg)))))
32
33
33
34
BUILD_ASSERT (CONFIG_APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS >
34
- CONFIG_APP_CLOUD_EXEC_TIME_SECONDS_MAX ,
35
- "Watchdog timeout must be greater than maximum execution time" );
35
+ CONFIG_APP_CLOUD_EXEC_TIME_SECONDS_MAX ,
36
+ "Watchdog timeout must be greater than maximum execution time" );
36
37
37
38
/* Register subscriber */
38
39
ZBUS_MSG_SUBSCRIBER_DEFINE (cloud );
@@ -42,6 +43,7 @@ ZBUS_CHAN_ADD_OBS(PAYLOAD_CHAN, cloud, 0);
42
43
ZBUS_CHAN_ADD_OBS (NETWORK_CHAN , cloud , 0 );
43
44
ZBUS_CHAN_ADD_OBS (BATTERY_CHAN , cloud , 0 );
44
45
ZBUS_CHAN_ADD_OBS (TRIGGER_CHAN , cloud , 0 );
46
+ ZBUS_CHAN_ADD_OBS (ENVIRONMENTAL_CHAN , cloud , 0 );
45
47
46
48
/* Define channels provided by this module */
47
49
@@ -546,6 +548,38 @@ static void state_connected_ready_run(void *o)
546
548
}
547
549
}
548
550
551
+ if (state_object -> chan == & ENVIRONMENTAL_CHAN ) {
552
+ struct environmental_msg msg = MSG_TO_ENVIRONMENTAL_MSG (state_object -> msg_buf );
553
+
554
+ if (msg .type == ENVIRONMENTAL_SENSOR_SAMPLE_RESPONSE ) {
555
+ err = nrf_cloud_coap_sensor_send (NRF_CLOUD_JSON_APPID_VAL_TEMP ,
556
+ msg .temperature ,
557
+ NRF_CLOUD_NO_TIMESTAMP , true);
558
+ if (err ) {
559
+ LOG_ERR ("nrf_cloud_coap_sensor_send, error: %d" , err );
560
+ SEND_FATAL_ERROR ();
561
+ }
562
+
563
+ err = nrf_cloud_coap_sensor_send (NRF_CLOUD_JSON_APPID_VAL_AIR_PRESS ,
564
+ msg .pressure ,
565
+ NRF_CLOUD_NO_TIMESTAMP , true);
566
+ if (err ) {
567
+ LOG_ERR ("nrf_cloud_coap_sensor_send, error: %d" , err );
568
+ SEND_FATAL_ERROR ();
569
+ }
570
+
571
+ err = nrf_cloud_coap_sensor_send (NRF_CLOUD_JSON_APPID_VAL_HUMID ,
572
+ msg .humidity ,
573
+ NRF_CLOUD_NO_TIMESTAMP , true);
574
+ if (err ) {
575
+ LOG_ERR ("nrf_cloud_coap_sensor_send, error: %d" , err );
576
+ SEND_FATAL_ERROR ();
577
+ }
578
+
579
+ return ;
580
+ }
581
+ }
582
+
549
583
if (state_object -> chan == & PAYLOAD_CHAN ) {
550
584
struct cloud_payload * payload = MSG_TO_PAYLOAD (state_object -> msg_buf );
551
585
0 commit comments