diff options
author | Anthony Stange <stange@google.com> | 2022-04-20 17:19:58 +0000 |
---|---|---|
committer | Anthony Stange <stange@google.com> | 2022-04-20 19:21:42 +0000 |
commit | 1a1f47c44a63279e0e4d800785d6aa2fdcfac81e (patch) | |
tree | 21889e2a472faff1b149e2e962e1be9ea867e8f6 | |
parent | 246aeb3106da57e834c461e50117485723b297b1 (diff) | |
download | chre-1a1f47c44a63279e0e4d800785d6aa2fdcfac81e.tar.gz |
Update power test nanoapp to issue NAN ranging req
Bug: 206614765
Test: Run locally
Change-Id: Ib271f903af96aadc640a8e8afc8f05871723e694
-rw-r--r-- | apps/power_test/common/include/request_manager.h | 6 | ||||
-rw-r--r-- | apps/power_test/common/power_test.cc | 13 | ||||
-rw-r--r-- | apps/power_test/common/request_manager.cc | 8 |
3 files changed, 27 insertions, 0 deletions
diff --git a/apps/power_test/common/include/request_manager.h b/apps/power_test/common/include/request_manager.h index 80dbbf5e..e7e17b32 100644 --- a/apps/power_test/common/include/request_manager.h +++ b/apps/power_test/common/include/request_manager.h @@ -53,6 +53,12 @@ class RequestManager { void handleNanIdResult(const struct chreWifiNanIdentifierEvent *event); /** + * Requests NAN ranging using the provided discovery event to populate a NAN + * RTT config. + */ + void requestNanRanging(const struct chreWifiNanDiscoveryEvent *event); + + /** * Responds to a host request indicating whether the request was successfully * executed. * diff --git a/apps/power_test/common/power_test.cc b/apps/power_test/common/power_test.cc index e839a15a..b56c4d91 100644 --- a/apps/power_test/common/power_test.cc +++ b/apps/power_test/common/power_test.cc @@ -62,6 +62,7 @@ void nanoappHandleEvent(uint32_t senderInstanceId, uint16_t eventType, static_cast<const struct chreWifiNanDiscoveryEvent *>(eventData); LOGD("NAN discovery subId %" PRIu32 " pubId %" PRIu32, event->subscribeId, event->publishId); + RequestManagerSingleton::get()->requestNanRanging(event); break; } case CHRE_EVENT_WIFI_NAN_SESSION_LOST: { @@ -94,6 +95,18 @@ void nanoappHandleEvent(uint32_t senderInstanceId, uint16_t eventType, event->resultCount, event->scanType, event->radioChainPref); break; } + case CHRE_EVENT_WIFI_RANGING_RESULT: { + auto *event = static_cast<const struct chreWifiRangingEvent *>(eventData); + LOGD("Wifi ranging result received with %" PRIu8 " results", + event->resultCount); + for (uint8_t i = 0; i < event->resultCount; ++i) { + LOGD("Ranging result #%" PRIu8 " status %" PRIu8 " rssi %" PRId8 + " distance (mm) %" PRIu32, + i, event->results[i].status, event->results[i].rssi, + event->results[i].distance); + } + break; + } case CHRE_EVENT_GNSS_ASYNC_RESULT: { const struct chreAsyncResult *event = static_cast<const struct chreAsyncResult *>(eventData); diff --git a/apps/power_test/common/request_manager.cc b/apps/power_test/common/request_manager.cc index 8539b688..84a5c760 100644 --- a/apps/power_test/common/request_manager.cc +++ b/apps/power_test/common/request_manager.cc @@ -350,6 +350,14 @@ void RequestManager::handleNanIdResult( } } +void RequestManager::requestNanRanging( + const struct chreWifiNanDiscoveryEvent *event) { + chreWifiNanRangingParams params = {}; + memcpy(params.macAddress, event->publisherAddress, CHRE_WIFI_BSSID_LEN); + bool success = chreWifiNanRequestRangingAsync(¶ms, nullptr); + LOGI("Requested NAN ranging %d", success); +} + bool RequestManager::requestWifiNanSub(const WifiNanSubMessage *msg) { chreWifiNanSubscribeConfig config{}; config.subscribeType = msg->sub_type(); |