Skip to content

Added methods + example to retrive local MAC for BT #7778

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 7 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Changed std::string to String
  • Loading branch information
PilnyTomas committed Feb 11, 2023
commit f186d6763b7062cc383a9415adaadb30dcc1fe56
2 changes: 1 addition & 1 deletion libraries/BluetoothSerial/src/BTAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ String BTAddress::toString(bool capital) const {
}else{
snprintf(res, size, "%02x:%02x:%02x:%02x:%02x:%02x", m_address[0], m_address[1], m_address[2], m_address[3], m_address[4], m_address[5]);
}
std::string ret(res);
String ret(res);
free(res);
return ret;
} // toString
Expand Down
2 changes: 1 addition & 1 deletion libraries/BluetoothSerial/src/BTAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
#include <esp_gap_bt_api.h> // ESP32 BT
#include <string>
#include <Arduino.h>


/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/BluetoothSerial/src/BTAdvertisedDeviceSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool BTAdvertisedDeviceSet::haveRSSI() const { return m_haveRSSI; }
* @return A string representation of this device.
*/
std::string BTAdvertisedDeviceSet::toString() {
std::string res = "Name: " + getName() + ", Address: " + getAddress().toString();
std::string res = "Name: " + getName() + ", Address: " + std::string(getAddress().toString().c_str(), getAddress().toString().length());
if (haveCOD()) {
char val[6];
snprintf(val, sizeof(val), "%d", getCOD());
Expand Down
2 changes: 1 addition & 1 deletion libraries/BluetoothSerial/src/BTScanResultsSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void BTScanResultsSet::clear() {
}

bool BTScanResultsSet::add(BTAdvertisedDeviceSet advertisedDevice, bool unique) {
std::string key = advertisedDevice.getAddress().toString();
std::string key = std::string(advertisedDevice.getAddress().toString().c_str(), advertisedDevice.getAddress().toString().length());
if (!unique || m_vectorAdvertisedDevices.count(key) == 0) {
m_vectorAdvertisedDevices.insert(std::pair<std::string, BTAdvertisedDeviceSet>(key, advertisedDevice));
return true;
Expand Down
2 changes: 1 addition & 1 deletion libraries/BluetoothSerial/src/BluetoothSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class BluetoothSerial: public Stream
operator bool() const;
void getBtAddress(uint8_t *mac);
BTAddress getBtAddressObject();
std::string getBtAddressString();
String getBtAddressString();
private:
String local_name;
int timeoutTicks=0;
Expand Down