Skip to content

Commit 0f76deb

Browse files
committed
modules: cloud: Make confirmability optional
Add option that lets the user decode if messages sent from the cloud module is to be confirmable or not. Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
1 parent 71138c5 commit 0f76deb

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

app/src/modules/cloud/Kconfig.cloud

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
menu "Cloud module"
88
depends on NRF_CLOUD_COAP
99

10+
config APP_CLOUD_CONFIRMABLE_MESSAGES
11+
bool "Use confirmable messages"
12+
help
13+
Use confirmable messages for CoAP communications with nRF Cloud.
14+
Confirmable messages are retransmitted COAP_MAX_RETRANSMIT times
15+
until an acknowledgment is received.
16+
1017
config APP_CLOUD_BACKOFF_INITIAL_SECONDS
1118
int "Reconnection backoff time in seconds"
1219
default 60

app/src/modules/cloud/cloud_module.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ static void state_connected_ready_run(void *o)
516516
{
517517
int err;
518518
const struct cloud_state *state_object = (const struct cloud_state *)o;
519+
bool confirmable = IS_ENABLED(CONFIG_APP_CLOUD_CONFIRMABLE_MESSAGES);
519520

520521
if (state_object->chan == &NETWORK_CHAN) {
521522
struct network_msg msg = MSG_TO_NETWORK_MSG(state_object->msg_buf);
@@ -532,7 +533,8 @@ static void state_connected_ready_run(void *o)
532533
case NETWORK_QUALITY_SAMPLE_RESPONSE:
533534
err = nrf_cloud_coap_sensor_send(CUSTOM_JSON_APPID_VAL_CONEVAL,
534535
msg.conn_eval_params.energy_estimate,
535-
NRF_CLOUD_NO_TIMESTAMP, true);
536+
NRF_CLOUD_NO_TIMESTAMP,
537+
confirmable);
536538
if (err) {
537539
LOG_ERR("nrf_cloud_coap_sensor_send, error: %d", err);
538540
SEND_FATAL_ERROR();
@@ -541,7 +543,8 @@ static void state_connected_ready_run(void *o)
541543

542544
err = nrf_cloud_coap_sensor_send(NRF_CLOUD_JSON_APPID_VAL_RSRP,
543545
msg.conn_eval_params.rsrp,
544-
NRF_CLOUD_NO_TIMESTAMP, true);
546+
NRF_CLOUD_NO_TIMESTAMP,
547+
confirmable);
545548
if (err) {
546549
LOG_ERR("nrf_cloud_coap_sensor_send, error: %d", err);
547550
SEND_FATAL_ERROR();
@@ -562,7 +565,8 @@ static void state_connected_ready_run(void *o)
562565
if (msg.type == BATTERY_PERCENTAGE_SAMPLE_RESPONSE) {
563566
err = nrf_cloud_coap_sensor_send(CUSTOM_JSON_APPID_VAL_BATTERY,
564567
msg.percentage,
565-
NRF_CLOUD_NO_TIMESTAMP, true);
568+
NRF_CLOUD_NO_TIMESTAMP,
569+
confirmable);
566570
if (err) {
567571
LOG_ERR("nrf_cloud_coap_sensor_send, error: %d", err);
568572
SEND_FATAL_ERROR();
@@ -580,23 +584,26 @@ static void state_connected_ready_run(void *o)
580584
if (msg.type == ENVIRONMENTAL_SENSOR_SAMPLE_RESPONSE) {
581585
err = nrf_cloud_coap_sensor_send(NRF_CLOUD_JSON_APPID_VAL_TEMP,
582586
msg.temperature,
583-
NRF_CLOUD_NO_TIMESTAMP, true);
587+
NRF_CLOUD_NO_TIMESTAMP,
588+
confirmable);
584589
if (err) {
585590
LOG_ERR("nrf_cloud_coap_sensor_send, error: %d", err);
586591
SEND_FATAL_ERROR();
587592
}
588593

589594
err = nrf_cloud_coap_sensor_send(NRF_CLOUD_JSON_APPID_VAL_AIR_PRESS,
590595
msg.pressure,
591-
NRF_CLOUD_NO_TIMESTAMP, true);
596+
NRF_CLOUD_NO_TIMESTAMP,
597+
confirmable);
592598
if (err) {
593599
LOG_ERR("nrf_cloud_coap_sensor_send, error: %d", err);
594600
SEND_FATAL_ERROR();
595601
}
596602

597603
err = nrf_cloud_coap_sensor_send(NRF_CLOUD_JSON_APPID_VAL_HUMID,
598604
msg.humidity,
599-
NRF_CLOUD_NO_TIMESTAMP, true);
605+
NRF_CLOUD_NO_TIMESTAMP,
606+
confirmable);
600607
if (err) {
601608
LOG_ERR("nrf_cloud_coap_sensor_send, error: %d", err);
602609
SEND_FATAL_ERROR();
@@ -610,7 +617,7 @@ static void state_connected_ready_run(void *o)
610617
if (state_object->chan == &PAYLOAD_CHAN) {
611618
const struct cloud_payload *payload = MSG_TO_PAYLOAD(state_object->msg_buf);
612619

613-
err = nrf_cloud_coap_json_message_send(payload->buffer, false, false);
620+
err = nrf_cloud_coap_json_message_send(payload->buffer, false, confirmable);
614621
if (err) {
615622
LOG_ERR("nrf_cloud_coap_json_message_send, error: %d", err);
616623
SEND_FATAL_ERROR();

0 commit comments

Comments
 (0)