Skip to content

Conversation

@PilnyTomas
Copy link
Contributor

It was not easy or obvious how to retrieve a MAC address of a local BT device.
There is an IDF function esp_bt_dev_get_address which accomplishes that and is used in this solution.
However, there was no BluetoothSerialmethod that would facilitate this.
This PR adds three new methods, slightly extends the BTAddress::toString, and adds a new example GetLocalMAC which demonstrates the usage of the new additions.

@PilnyTomas PilnyTomas added the Area: BT&Wifi BT & Wifi related issues label Jan 31, 2023
@PilnyTomas PilnyTomas requested a review from SuGlider January 31, 2023 13:18
@PilnyTomas PilnyTomas self-assigned this Jan 31, 2023
Copy link
Member

@P-R-O-C-H-Y P-R-O-C-H-Y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PilnyTomas please check my comments (typo and format issues), example is working great! Thank for the PR. After fixes it will be ready to merge.

Copy link
Member

@P-R-O-C-H-Y P-R-O-C-H-Y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@VojtechBartoska VojtechBartoska added this to the 2.0.7 milestone Feb 1, 2023
* @return The string representation of the address.
*/
std::string BTAddress::toString() const {
std::string BTAddress::toString(bool capital) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that originally the method returns std::string, but please change it to Arduino String instead.

*
* @return The BT MAC address string.
*/
std::string BluetoothSerial::getBtAddressString() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here std::string =>> String

@VojtechBartoska VojtechBartoska added the Type: Example Issue is related to specific example. label Feb 6, 2023
@PilnyTomas PilnyTomas requested a review from me-no-dev February 8, 2023 13:10
operator bool() const;
void getBtAddress(uint8_t *mac);
BTAddress getBtAddressObject();
std::string getBtAddressString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you forgot to change the type here

* Every %BT device has a unique address which can be used to identify it and form connections.
*/
class BTAddress {
public:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up in the includes, you need to change #include <string> to #include "Arduino.h"

Copy link
Member

@me-no-dev me-no-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change include and left over std::string in BluetoothSerial.h

@PilnyTomas PilnyTomas requested a review from me-no-dev February 11, 2023 11:56
@me-no-dev me-no-dev merged commit 2ddce3c into espressif:master Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: BT&Wifi BT & Wifi related issues Type: Example Issue is related to specific example.

Projects

Development

Successfully merging this pull request may close these issues.

4 participants