Skip to content

Commit 462c8d8

Browse files
jayteemoanangl
authored andcommitted
net: lib: nrf_cloud: add kconfig opts for Wi-Fi location req encoding
Add Kconfig choice `NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT` to control the data included in Wi-Fi location requests. By default, requests now include only the MAC and RSSI. IRIS-6815 Signed-off-by: Justin Morton <[email protected]>
1 parent bab262a commit 462c8d8

File tree

3 files changed

+44
-17
lines changed

3 files changed

+44
-17
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,14 @@ Libraries for networking
643643
* Support for CoAP CBOR type handling to nrf_cloud_obj.
644644
* Warning message discouraging use of :kconfig:option:`CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES` for purposes other than testing.
645645
* Reporting of protocol (MQTT, REST, or CoAP) as well as method (LTE or Wi-Fi) to the device shadow.
646+
* Kconfig choice :kconfig:option:`NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT` for selecting the data that is encoded in Wi-Fi location requests.
646647

647648
* Updated:
648649

649650
* Moved JSON manipulation from :file:`nrf_cloud_fota.c` to :file:`nrf_cloud_codec_internal.c`.
650651
* :c:func:`nrf_cloud_obj_location_request_create` to use the new function :c:func:`nrf_cloud_obj_location_request_payload_add`.
651652
* Retry handling for P-GPS data download errors to retry ``ECONNREFUSED`` errors.
653+
* By default, Wi-Fi location requests include only the MAC address and RSSI value.
652654

653655
* Fixed:
654656

subsys/net/lib/nrf_cloud/Kconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,27 @@ config NRF_CLOUD_DEVICE_STATUS_ENCODE_VOLTAGE
7474
depends on MODEM_INFO_ADD_DEVICE
7575
default y
7676

77+
choice NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT
78+
prompt "Encoding options for Wi-Fi location requests"
79+
default NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_RSSI
80+
81+
config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_ONLY
82+
bool "Encode only the MAC address"
83+
help
84+
The MAC address is the only required parameter.
85+
86+
config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_RSSI
87+
bool "Encode the MAC address and the RSSI value"
88+
help
89+
The RSSI value may improve location accuracy.
90+
91+
config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_ALL
92+
bool "Encode all available parameters"
93+
help
94+
This option increases the memory required for creating requests.
95+
It also increases the amount of data sent to nRF Cloud.
96+
endchoice
97+
7798
endif
7899

79100
if NRF_CLOUD_AGPS || NRF_CLOUD_PGPS

subsys/net/lib/nrf_cloud/src/nrf_cloud_codec_internal.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,6 +2666,9 @@ int nrf_cloud_wifi_req_json_encode(struct wifi_scan_info const *const wifi,
26662666
int encoded_cnt = 0;
26672667
cJSON *wifi_obj = NULL;
26682668
cJSON *ap_array = NULL;
2669+
const bool add_all = IS_ENABLED(CONFIG_NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_ALL);
2670+
const bool add_rssi = (add_all ||
2671+
IS_ENABLED(CONFIG_NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_RSSI));
26692672

26702673
LOG_DBG("Encoding wifi_scan_info with count: %u", wifi->cnt);
26712674

@@ -2705,28 +2708,29 @@ int nrf_cloud_wifi_req_json_encode(struct wifi_scan_info const *const wifi,
27052708
}
27062709

27072710
/* Optional parameters for the API call */
2708-
memset(str_buf, 0, sizeof(str_buf));
2709-
if ((ap->ssid_length > 0) && (ap->ssid_length <= WIFI_SSID_MAX_LEN)) {
2710-
memcpy(str_buf, ap->ssid, ap->ssid_length);
2711-
}
2712-
2713-
if ((str_buf[0] != '\0') &&
2714-
json_add_str_cs(ap_obj, NRF_CLOUD_LOCATION_JSON_KEY_WIFI_SSID, str_buf)) {
2711+
if (add_rssi && (ap->rssi != NRF_CLOUD_LOCATION_WIFI_OMIT_RSSI) &&
2712+
json_add_num_cs(ap_obj, NRF_CLOUD_LOCATION_JSON_KEY_WIFI_RSSI, ap->rssi)) {
27152713
goto cleanup;
27162714
}
27172715

2718-
if ((ap->rssi != NRF_CLOUD_LOCATION_WIFI_OMIT_RSSI) &&
2719-
json_add_num_cs(ap_obj, NRF_CLOUD_LOCATION_JSON_KEY_WIFI_RSSI,
2720-
ap->rssi)) {
2721-
goto cleanup;
2722-
}
2716+
if (add_all) {
2717+
memset(str_buf, 0, sizeof(str_buf));
2718+
if ((ap->ssid_length > 0) && (ap->ssid_length <= WIFI_SSID_MAX_LEN)) {
2719+
memcpy(str_buf, ap->ssid, ap->ssid_length);
2720+
}
27232721

2724-
if ((ap->channel != NRF_CLOUD_LOCATION_WIFI_OMIT_CHAN) &&
2725-
json_add_num_cs(ap_obj, NRF_CLOUD_LOCATION_JSON_KEY_WIFI_CH,
2726-
ap->channel)) {
2727-
goto cleanup;
2728-
}
2722+
if ((str_buf[0] != '\0') &&
2723+
json_add_str_cs(ap_obj, NRF_CLOUD_LOCATION_JSON_KEY_WIFI_SSID,
2724+
str_buf)) {
2725+
goto cleanup;
2726+
}
27292727

2728+
if ((ap->channel != NRF_CLOUD_LOCATION_WIFI_OMIT_CHAN) &&
2729+
json_add_num_cs(ap_obj, NRF_CLOUD_LOCATION_JSON_KEY_WIFI_CH,
2730+
ap->channel)) {
2731+
goto cleanup;
2732+
}
2733+
}
27302734
++encoded_cnt;
27312735
}
27322736

0 commit comments

Comments
 (0)