Skip to content

Commit 57915c9

Browse files
maxd-nordicnordicjm
authored andcommitted
samples: cellular: nrf_cloud_rest_*: make credentials check optional
This patch makes it possible to build the nRF Cloud REST samples without checking the credentials. Jira: IRIS-9758 Signed-off-by: Maximilian Deubel <[email protected]>
1 parent a07b87c commit 57915c9

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,18 @@ Bluetooth Mesh samples
265265
Cellular samples
266266
----------------
267267

268+
* Updated the :kconfig:option:`CONFIG_NRF_CLOUD_CHECK_CREDENTIALS` Kconfig option to be optional and enabled by default for the following samples:
269+
270+
* :ref:`nrf_cloud_rest_cell_pos_sample`
271+
* :ref:`nrf_cloud_rest_device_message`
272+
* :ref:`nrf_cloud_rest_fota`
273+
268274
* :ref:`location_sample` sample:
269275

270276
* Updated:
271277

272278
* The Thingy:91 X build to support Wi-Fi by default without overlays.
273279

274-
275280
Cryptography samples
276281
--------------------
277282

samples/cellular/nrf_cloud_rest_cell_location/src/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ static void connect_to_network(void)
579579

580580
static void check_credentials(void)
581581
{
582+
#if defined(CONFIG_NRF_CLOUD_CHECK_CREDENTIALS)
582583
int err = nrf_cloud_credentials_configured_check();
583584

584585
if ((err == -ENOTSUP) || (err == -ENOPROTOOPT)) {
@@ -589,6 +590,9 @@ static void check_credentials(void)
589590
LOG_ERR("nrf_cloud_credentials_configured_check() failed, error: %d", err);
590591
LOG_WRN("Continuing without verifying that credentials are installed");
591592
}
593+
#else
594+
LOG_DBG("nRF Cloud credentials check not enabled");
595+
#endif /* defined(CONFIG_NRF_CLOUD_CHECK_CREDENTIALS) */
592596
}
593597

594598
int main(void)

samples/cellular/nrf_cloud_rest_device_message/src/main.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ static int set_leds_off(void)
236236

237237
static bool cred_check(struct nrf_cloud_credentials_status *const cs)
238238
{
239+
#if defined(CONFIG_NRF_CLOUD_CHECK_CREDENTIALS)
239240
int ret;
240241

241242
ret = nrf_cloud_credentials_check(cs);
@@ -248,24 +249,29 @@ static bool cred_check(struct nrf_cloud_credentials_status *const cs)
248249
* - a CA for the TLS connections
249250
* - a private key to sign the JWT
250251
*/
252+
253+
if (!cs->ca || !cs->ca_aws || !cs->prv_key) {
254+
LOG_WRN("Missing required nRF Cloud credential(s) in sec tag %u:", cs->sec_tag);
255+
}
256+
if (!cs->ca || !cs->ca_aws) {
257+
LOG_WRN("\t-CA Cert");
258+
}
259+
if (!cs->prv_key) {
260+
LOG_WRN("\t-Private Key");
261+
}
262+
251263
return (cs->ca && cs->ca_aws && cs->prv_key);
264+
#else
265+
LOG_DBG("nRF Cloud credentials check not enabled");
266+
return true;
267+
#endif /* defined(CONFIG_NRF_CLOUD_CHECK_CREDENTIALS) */
252268
}
253269

254270
static void await_credentials(void)
255271
{
256272
struct nrf_cloud_credentials_status cs;
257273

258274
if (!cred_check(&cs)) {
259-
LOG_WRN("Missing required nRF Cloud credential(s) in sec tag %u:",
260-
cs.sec_tag);
261-
262-
if (!cs.ca) {
263-
LOG_WRN("\t-CA Cert");
264-
}
265-
266-
if (!cs.prv_key) {
267-
LOG_WRN("\t-Private Key");
268-
}
269275

270276
#if defined(CONFIG_NRF_PROVISIONING)
271277
LOG_INF("Waiting for credentials to be remotely provisioned...");

samples/cellular/nrf_cloud_rest_fota/src/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ static void sample_reboot(enum nrf_cloud_fota_reboot_status status)
472472

473473
static void check_credentials(void)
474474
{
475+
#if defined(CONFIG_NRF_CLOUD_CHECK_CREDENTIALS)
475476
int err = nrf_cloud_credentials_configured_check();
476477

477478
if (err == -ENOTSUP) {
@@ -485,6 +486,9 @@ static void check_credentials(void)
485486
LOG_ERR("nrf_cloud_credentials_configured_check() failed, error: %d", err);
486487
LOG_WRN("Continuing without verifying that credentials are installed");
487488
}
489+
#else
490+
LOG_DBG("nRF Cloud credentials check not enabled");
491+
#endif /* defined(CONFIG_NRF_CLOUD_CHECK_CREDENTIALS) */
488492
}
489493

490494
int main(void)

0 commit comments

Comments
 (0)