diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 1892f06c9192..509e431938b6 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -680,6 +680,7 @@ Libraries for networking * An :c:struct:`nrf_cloud_obj_shadow_data` structure to the :c:struct:`nrf_cloud_evt` structure to be used during shadow update events. * The :kconfig:option:`CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_FOTA` Kconfig option to enable sending configured FOTA service info on the device's initial connection to nRF Cloud. * The :kconfig:option:`CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_UI` Kconfig option to enable sending configured UI service info on the device's initial connection to nRF Cloud. + * Support for handling location request responses fulfilled by a Wi-Fi anchor. * Updated: diff --git a/include/net/nrf_cloud_defs.h b/include/net/nrf_cloud_defs.h index 3dfee1749c60..17b02cb7b2d4 100644 --- a/include/net/nrf_cloud_defs.h +++ b/include/net/nrf_cloud_defs.h @@ -77,6 +77,9 @@ #define NRF_CLOUD_LOCATION_KEY_DOREPLY "doReply" #define NRF_CLOUD_LOCATION_JSON_KEY_WIFI "wifi" #define NRF_CLOUD_LOCATION_JSON_KEY_APS "accessPoints" +#define NRF_CLOUD_LOCATION_JSON_KEY_ANCHORS "anchors" +#define NRF_CLOUD_LOCATION_JSON_KEY_ANC_NAME "name" +#define NRF_CLOUD_LOCATION_JSON_KEY_ANC_MAC "macAddress" #define NRF_CLOUD_LOCATION_JSON_KEY_WIFI_MAC "macAddress" #define NRF_CLOUD_LOCATION_JSON_KEY_WIFI_CH "channel" #define NRF_CLOUD_LOCATION_JSON_KEY_WIFI_RSSI "signalStrength" @@ -87,6 +90,7 @@ #define NRF_CLOUD_LOCATION_TYPE_VAL_MCELL "MCELL" #define NRF_CLOUD_LOCATION_TYPE_VAL_SCELL "SCELL" #define NRF_CLOUD_LOCATION_TYPE_VAL_WIFI "WIFI" +#define NRF_CLOUD_LOCATION_TYPE_VAL_ANCHOR "ANCHOR" /* P-GPS */ #define NRF_CLOUD_JSON_PGPS_PRED_COUNT "predictionCount" diff --git a/subsys/net/lib/nrf_cloud/src/nrf_cloud_codec_internal.c b/subsys/net/lib/nrf_cloud/src/nrf_cloud_codec_internal.c index 89b68d4475cd..eda539adcf79 100644 --- a/subsys/net/lib/nrf_cloud/src/nrf_cloud_codec_internal.c +++ b/subsys/net/lib/nrf_cloud/src/nrf_cloud_codec_internal.c @@ -2823,6 +2823,7 @@ static int nrf_cloud_parse_location_json(const cJSON *const loc_obj, } cJSON *lat, *lon, *unc; + bool anchor = false; char *type; lat = cJSON_GetObjectItem(loc_obj, @@ -2849,6 +2850,9 @@ static int nrf_cloud_parse_location_json(const cJSON *const loc_obj, location_out->type = LOCATION_TYPE_SINGLE_CELL; } else if (!strcmp(type, NRF_CLOUD_LOCATION_TYPE_VAL_WIFI)) { location_out->type = LOCATION_TYPE_WIFI; + } else if (!strcmp(type, NRF_CLOUD_LOCATION_TYPE_VAL_ANCHOR)) { + location_out->type = LOCATION_TYPE_WIFI; + anchor = true; } else { LOG_WRN("Unhandled location type: %s", type); } @@ -2856,6 +2860,31 @@ static int nrf_cloud_parse_location_json(const cJSON *const loc_obj, LOG_WRN("Location type not found in message"); } + /* Print anchor info */ + if (anchor) { + cJSON *anchors, *mac, *name; + int anc_cnt; + + /* Anchor info is provided in an array of objects */ + anchors = cJSON_GetObjectItem(loc_obj, NRF_CLOUD_LOCATION_JSON_KEY_ANCHORS); + anc_cnt = cJSON_GetArraySize(anchors); + + for (int idx = 0; idx < anc_cnt; ++idx) { + cJSON *anc = cJSON_GetArrayItem(anchors, idx); + + mac = cJSON_GetObjectItem(anc, NRF_CLOUD_LOCATION_JSON_KEY_ANC_MAC); + name = cJSON_GetObjectItem(anc, NRF_CLOUD_LOCATION_JSON_KEY_ANC_NAME); + + if (cJSON_IsString(mac)) { + LOG_DBG("Wi-Fi anchor MAC: %s", mac->valuestring); + } + + if (cJSON_IsString(name)) { + LOG_INF("Wi-Fi anchor name: %s", name->valuestring); + } + } + } + return 0; }