Skip to content

Fixes BLEScanResults to be used by reference #8759

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

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libraries/BLE/examples/Beacon_Scanner/Beacon_Scanner.ino
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ void setup()
void loop()
{
// put your main code here, to run repeatedly:
BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
BLEScanResults *foundDevices = pBLEScan->start(scanTime, false);
Serial.print("Devices found: ");
Serial.println(foundDevices.getCount());
Serial.println(foundDevices->getCount());
Serial.println("Scan done!");
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
Expand Down
4 changes: 2 additions & 2 deletions libraries/BLE/examples/Scan/Scan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ void setup() {

void loop() {
// put your main code here, to run repeatedly:
BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
BLEScanResults *foundDevices = pBLEScan->start(scanTime, false);
Serial.print("Devices found: ");
Serial.println(foundDevices.getCount());
Serial.println(foundDevices->getCount());
Serial.println("Scan done!");
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
Expand Down
8 changes: 4 additions & 4 deletions libraries/BLE/src/BLEScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ bool BLEScan::start(uint32_t duration, void (*scanCompleteCB)(BLEScanResults), b
* @param [in] duration The duration in seconds for which to scan.
* @return The BLEScanResults.
*/
BLEScanResults BLEScan::start(uint32_t duration, bool is_continue) {
BLEScanResults* BLEScan::start(uint32_t duration, bool is_continue) {
if(start(duration, nullptr, is_continue)) {
m_semaphoreScanEnd.wait("start"); // Wait for the semaphore to release.
}
return m_scanResults;
return &m_scanResults;
} // start


Expand Down Expand Up @@ -500,8 +500,8 @@ BLEAdvertisedDevice BLEScanResults::getDevice(uint32_t i) {
return dev;
}

BLEScanResults BLEScan::getResults() {
return m_scanResults;
BLEScanResults* BLEScan::getResults() {
return &m_scanResults;
}

void BLEScan::clearResults() {
Expand Down
4 changes: 2 additions & 2 deletions libraries/BLE/src/BLEScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class BLEScan {
void setInterval(uint16_t intervalMSecs);
void setWindow(uint16_t windowMSecs);
bool start(uint32_t duration, void (*scanCompleteCB)(BLEScanResults), bool is_continue = false);
BLEScanResults start(uint32_t duration, bool is_continue = false);
BLEScanResults* start(uint32_t duration, bool is_continue = false);
void stop();
void erase(BLEAddress address);
BLEScanResults getResults();
BLEScanResults* getResults();
void clearResults();

#ifdef SOC_BLE_50_SUPPORTED
Expand Down