Skip to content

Commit

Permalink
samples: cellular: nrf_cloud_multi_service: enable info send kconfigs
Browse files Browse the repository at this point in the history
The sample now enables the Kconfig options:
CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_FOTA
CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_UI
It no longer sends a device status update on initial connection;
this is now handled by the nrf_cloud library.
IRIS-6851

Signed-off-by: Justin Morton <[email protected]>
  • Loading branch information
jayteemo committed Dec 19, 2023
1 parent 0df90ef commit 76bd0a8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ Cellular samples

* The sample now explicitly uses the :c:func:`conn_mgr_all_if_connect` function to start network connectivity, instead of the :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START` and :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT` Kconfig options.
* The sample to use the FOTA support functions in the :file:`nrf_cloud_fota_poll.c` and :file:`nrf_cloud_fota_common.c` files.
* The sample now enables the Kconfig options :kconfig:option:`CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_FOTA` and :kconfig:option:`CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_UI`.
It no longer sends a device status update on initial connection; this is now handled by the :ref:`lib_nrf_cloud` library.

* Removed nRF7002 EK DTC overlay file ``nrf91xxdk_with_nrf7002ek.overlay`` because UART1 is disabled through the shield configuration.

Expand Down
1 change: 1 addition & 0 deletions samples/cellular/nrf_cloud_multi_service/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ config TEMP_DATA_USE_SENSOR
config TEMP_TRACKING
bool "Track temperature"
default y
select NRF_CLOUD_ENABLE_SVC_INF_UI_TEMP
help
Sets whether to take temperature measurements.

Expand Down
4 changes: 4 additions & 0 deletions samples/cellular/nrf_cloud_multi_service/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n
CONFIG_NRF_CLOUD_ALERT=y
CONFIG_NRF_CLOUD_LOG_DIRECT=y
CONFIG_NRF_CLOUD_LOG_OUTPUT_LEVEL=3

# On initial connection to the cloud, add info sections to the shadow
CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS=y
CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS_NETWORK=y
CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS_SIM=y
CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_FOTA=y
CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_UI=y
62 changes: 4 additions & 58 deletions samples/cellular/nrf_cloud_multi_service/src/cloud_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ static K_EVENT_DEFINE(cloud_events);
/* Atomic status flag tracking whether an initial association is in progress. */
atomic_t initial_association;

static void update_shadow(void);

/* Helper functions for pending on pendable events. */
bool await_network_ready(k_timeout_t timeout)
{
Expand Down Expand Up @@ -215,7 +213,6 @@ static bool connect_cloud(void)
if (!err) {
cloud_connected();
cloud_ready();
update_shadow();
return true;
}
#endif
Expand Down Expand Up @@ -245,59 +242,6 @@ static bool connect_cloud(void)
return true;
}

/**
* @brief Updates the nRF Cloud shadow with information about supported capabilities, current
* firmware running, FOTA support, and so on.
*/
static void update_shadow(void)
{
#if !defined(CONFIG_NRF_CLOUD_COAP) || defined(CONFIG_COAP_SHADOW)
static bool updated;
int err;
struct nrf_cloud_svc_info_fota fota_info = {
.application = nrf_cloud_fota_is_type_enabled(NRF_CLOUD_FOTA_APPLICATION),
.bootloader = nrf_cloud_fota_is_type_enabled(NRF_CLOUD_FOTA_BOOTLOADER),
.modem = nrf_cloud_fota_is_type_enabled(NRF_CLOUD_FOTA_MODEM_DELTA),
.modem_full = nrf_cloud_fota_is_type_enabled(NRF_CLOUD_FOTA_MODEM_FULL)
};
struct nrf_cloud_svc_info_ui ui_info = {
.gnss = location_tracking_enabled(),
.temperature = IS_ENABLED(CONFIG_TEMP_TRACKING),
.log = nrf_cloud_is_text_logging_enabled(),
.dictionary_log = nrf_cloud_is_dict_logging_enabled()
};
struct nrf_cloud_svc_info service_info = {
.fota = &fota_info,
.ui = &ui_info
};
struct nrf_cloud_device_status device_status = {
/* Modem info is sent automatically since CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS
* is enabled, so it can be skipped here.
*/
.modem = NULL,
.svc = &service_info,
.conn_inf = NRF_CLOUD_INFO_NO_CHANGE
};

if (updated) {
return; /* It is not necessary to do this more than once per boot. */
}
LOG_DBG("Updating shadow");
#if defined(CONFIG_NRF_CLOUD_MQTT)
err = nrf_cloud_shadow_device_status_update(&device_status);
#elif defined(CONFIG_NRF_CLOUD_COAP)
err = nrf_cloud_coap_shadow_device_status_update(&device_status);
#endif

if (err) {
LOG_ERR("Failed to update device shadow, error: %d", err);
} else {
LOG_DBG("Updated shadow");
updated = true;
}
#endif /* !defined(CONFIG_NRF_CLOUD_COAP) || defined(CONFIG_COAP_SHADOW) */
}

/* External event handlers */

/* Handler for L4/connectivity events
Expand Down Expand Up @@ -446,8 +390,10 @@ static void cloud_event_handler(const struct nrf_cloud_evt *nrf_cloud_evt)
/* Handle achievement of readiness */
cloud_ready();

/* Update the device shadow */
update_shadow();
/* The nRF Cloud library will automatically update the
* device's shadow based on the build configuration.
* See config NRF_CLOUD_SEND_SHADOW_INFO for details.
*/

break;
case NRF_CLOUD_EVT_SENSOR_DATA_ACK:
Expand Down

0 comments on commit 76bd0a8

Please sign in to comment.