-
Notifications
You must be signed in to change notification settings - Fork 6
98 implement ftm #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
cbicari
wants to merge
27
commits into
main
Choose a base branch
from
98-implement-ftm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
98 implement ftm #102
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b2225f2
initiating ftm implementation
cbicari a5e158e
added all FTM from past initiative and tested- compiles - should try …
cbicari 843d730
made initateFTM() an API public method call to let the user decide if…
cbicari 84b203d
details on c_str() of logging
cbicari c329476
stash pop after fetch pull might have some bizarre conflicts- will ha…
cbicari 6528eab
Merge remote-tracking branch 'origin/main' into 98-implement-ftm
cbicari 33f60a6
all compiles in verbose mode, FTM session initiated properly
cbicari 348529c
ftm is giving back positive communication but we need to clarify cali…
cbicari 21c5ae4
cleaning up and adding to API for better control in template. current…
cbicari c67c360
fixed memory leak by unregistering one of two WIFI_EVENT handlers. co…
cbicari 2e08b78
refactored all FTM variables back into FTM instead of leaving them in…
cbicari ddd447b
cleaning up some dev debugging lines and adapting var names to signif…
cbicari 78b5978
added offset control to responder in API for template calibration pur…
cbicari dbbbcfc
added last FTM function from ESP32 SDK as API - an end_ftm_request_se…
cbicari a745d64
added rssi api for ftm measure
cbicari 24f48da
solved some var declarartion
cbicari e8c5495
ftm updates on api method
cbicari fe1cf9a
modified bandwidth to 20MHz by default
cbicari 6c0894b
reordered some slight details for clarity, no new additions
cbicari 78ed0e7
working on documenting FTM responders during the wifi scan routine at…
cbicari 8a35d3e
review wifi_scan() as it seems broken
cbicari 31f2d48
looking for reason wifi scan always returns 0 APs
cbicari 7ddb24c
WIP: making modifications to make the ftm connectionless
cbicari 1adae39
WIP : first beacon based FTM query succes :)
cbicari f9fe5c4
WIP : dynamic wifi_ftm_cfg_t allocation
cbicari 0ff455c
modding API and FTM functions to get beacon-based implementation. cur…
cbicari 20b2045
WIP : packaging all in one ftm_init while running tests with prior ap…
cbicari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #include "puara_ftm.hpp" | ||
| #include "puara_logger.hpp" | ||
| #include "puara_wifi.hpp" | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| // #include <.h> | ||
| //#include <iostream> | ||
|
|
||
| namespace PuaraAPI | ||
| { | ||
|
|
||
| // Return a map of responders defined by user and their wifi_ftm_cfg_t struct info (MAC, channel) | ||
| const std::map<std::string, wifi_ftm_initiator_cfg_t> FTM::get_map_of_responder_configs( | ||
| uint8_t frame_count, uint16_t burst_period, | ||
| const std::vector<std::string>& returned_ssids) | ||
| { | ||
|
|
||
| std::map<std::string, wifi_ftm_initiator_cfg_t> responder_configs; | ||
| std::unordered_set<std::string> wanted_ssids(returned_ssids.begin(), returned_ssids.end()); | ||
|
|
||
| for (const auto& ap : scanned_responder_aps) { | ||
| // Check if the AP is in the list of returned_ssids from the web interface (i.e. user selected it for FTM) | ||
| if (wanted_ssids.count(ap.ssid)) { | ||
| wifi_ftm_initiator_cfg_t ftm_config{}; | ||
| std::copy(std::begin(ap.bssid), std::end(ap.bssid), std::begin(ftm_config.resp_mac)); | ||
| ftm_config.channel = ap.primary_channel; | ||
| ftm_config.frm_count = frame_count; | ||
| ftm_config.burst_period = burst_period; | ||
| ftm_config.use_get_report_api = false; // use WIFI_EVENT_FTM_REPORT to get FTM report | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant comment |
||
| responder_configs[ap.ssid] = ftm_config; | ||
|
|
||
| ESP_LOGI(PUARA_TAG, "Added FTM responder config for AP: SSID: %s, BSSID: %02x:%02x:%02x:%02x:%02x:%02x, Channel: %d", | ||
| ap.ssid.c_str(), | ||
| ap.bssid[0], ap.bssid[1], ap.bssid[2], ap.bssid[3], ap.bssid[4], ap.bssid[5], | ||
| ap.primary_channel | ||
| ); | ||
| } | ||
| } | ||
| return responder_configs; | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
| /* | ||
| //make this take in a position from an array of wifi_ftm_cfg | ||
| void FTM::requestFTM(){ | ||
| esp_err_t result = esp_wifi_ftm_initiate_session(&wifi_ftm_cfg); | ||
| if (result != ESP_OK) { | ||
| ESP_LOGD(PUARA_TAG, "FTM Session Failed : %s", esp_err_to_name(result)); | ||
| }else if(result == ESP_OK) { | ||
| ESP_LOGD(PUARA_TAG, "FTM session initiated successfully"); | ||
| } | ||
| } | ||
|
|
||
| bool FTM::set_offset_responder(int16_t offset_cm){ | ||
| // Set offset in cm for FTM Responder : | ||
| // An equivalent offset is calculated in picoseconds and added in TOD of FTM | ||
| // Measurement frame (T1). | ||
| esp_err_t result = esp_wifi_ftm_resp_set_offset(offset_cm); | ||
| if(result == ESP_OK) { | ||
| ESP_LOGD(PUARA_TAG, "FTM responder offset set successfully"); | ||
| return true; | ||
| } else { | ||
| ESP_LOGD(PUARA_TAG, "Failed to set FTM responder offset : %s", esp_err_to_name(result)); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| void FTM::end_ftm_request_session(){ | ||
| //End the ongoing FTM Initiator session. This API works only on FTM Initiator | ||
| esp_err_t result = esp_wifi_ftm_end_session(); | ||
| if(result == ESP_OK) { | ||
| ESP_LOGD(PUARA_TAG, "FTM session ended successfully"); | ||
| } else { | ||
| ESP_LOGD(PUARA_TAG, "Failed to end FTM session : %s", esp_err_to_name(result)); | ||
| } | ||
| } | ||
| */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #pragma once | ||
|
|
||
| #include "esp_log.h" | ||
| #include <esp_wifi.h> | ||
|
|
||
| #include <algorithm> | ||
| #include <iomanip> | ||
| #include <iostream> | ||
| #include <map> | ||
| #include <string> | ||
| #include <unordered_set> | ||
| #include <vector> | ||
|
|
||
| namespace PuaraAPI | ||
| { | ||
| //struct WiFi; | ||
|
|
||
| struct FTM | ||
| { | ||
| // flag to indicate if FTM report data is available | ||
| bool ftm_report_available = false; //API accessible | ||
|
|
||
| struct scanned_responder_ap_info | ||
| { | ||
| std::string ssid; | ||
| uint8_t bssid[6]; | ||
| int8_t rssi; | ||
| uint8_t primary_channel; | ||
| }; | ||
|
|
||
| // Vector to hold scanned found Responder-Ready APs, populated during WiFi scan | ||
| std::vector<scanned_responder_ap_info> scanned_responder_aps{}; //internal only - No API calls | ||
|
|
||
|
|
||
| struct ftm_report_info | ||
| { | ||
| uint32_t rtt_est; // in nanoseconds | ||
| uint32_t dist_est; // in centimeters | ||
| int8_t rssi; // RSSI of the FTM frame, as an indicator of signal strength of the FTM responder AP | ||
| }; | ||
|
|
||
| ftm_report_info last_ftm_report{}; // API accessible | ||
|
|
||
| // fast accessor for the last report; returns const reference so caller can | ||
| // peek multiple fields without copying | ||
| const ftm_report_info& get_last_ftm_report() const { return last_ftm_report; } | ||
|
|
||
| // check if a report is available and optionally copy it into provided struct | ||
| // returns true when a report was present; does **not** consume the flag | ||
| bool get_ftm_report(ftm_report_info &out) const { | ||
| if (ftm_report_available) { | ||
| out = last_ftm_report; | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| // Map of user-defined FTM responder configurations, with SSID as key and | ||
| // wifi_ftm_initiator_cfg_t struct (holding responder MAC, channel, frame count, | ||
| // burst period) as value | ||
| std::map<std::string, wifi_ftm_initiator_cfg_t> map_of_responder_configs{}; // API accessible | ||
|
|
||
|
|
||
| // Return a map of responders defined by user and their wifi_ftm_cfg_t struct info | ||
| // (MAC, channel, frame count, burst period) for upcoming FTM session initiation. | ||
| // `returned_ssids` is passed by const-reference to avoid copying. | ||
| const std::map<std::string, wifi_ftm_initiator_cfg_t> get_map_of_responder_configs( | ||
| uint8_t frame_count, uint16_t burst_period, const std::vector<std::string>& returned_ssids); | ||
|
|
||
|
|
||
|
|
||
| }; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need that comment?