Skip to content

Commit

Permalink
sets BLEScanResults by reference (#8759)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuGlider authored Oct 16, 2023
1 parent a8622c4 commit f218209
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
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

0 comments on commit f218209

Please sign in to comment.