-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0ba4180
Added methods + example to retrive local MAC for BT
PilnyTomas c6f8658
Added .skip files in the new example folder
PilnyTomas a9d1219
Fixed typos and formatting + added doxygen comments
PilnyTomas 51c34aa
changed std::string to String
PilnyTomas 7268d13
another std::string -> String
PilnyTomas f186d67
Changed std::string to String
PilnyTomas a9ba46a
chaged string type in example
PilnyTomas 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
Fixed typos and formatting + added doxygen comments
- Loading branch information
commit a9d121947997186a2df0be884283c5f26f854b54
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1181,18 +1181,31 @@ std::map<int, std::string> BluetoothSerial::getChannels(const BTAddress &remoteA | |
return sdpRecords; | ||
} | ||
|
||
void BluetoothSerial::getBtAddress(uint8_t *mac){ | ||
const uint8_t *dev_mac = esp_bt_dev_get_address(); | ||
memcpy(mac, dev_mac, ESP_BD_ADDR_LEN); | ||
/** | ||
* @brief Gets the MAC address of local BT device in byte array. | ||
* | ||
* @param mac [out] The mac | ||
*/ | ||
void BluetoothSerial::getBtAddress(uint8_t *mac) { | ||
const uint8_t *dev_mac = esp_bt_dev_get_address(); | ||
memcpy(mac, dev_mac, ESP_BD_ADDR_LEN); | ||
} | ||
|
||
BTAddress BluetoothSerial::getBtAddressObject(){ | ||
uint8_t mac_arr[ESP_BD_ADDR_LEN]; | ||
getBtAddress(mac_arr); | ||
return BTAddress(mac_arr); | ||
/** | ||
* @brief Gets the MAC address of local BT device as BTAddress object. | ||
* | ||
* @return The BTAddress object. | ||
*/ | ||
BTAddress BluetoothSerial::getBtAddressObject() { | ||
uint8_t mac_arr[ESP_BD_ADDR_LEN]; | ||
getBtAddress(mac_arr); | ||
return BTAddress(mac_arr); | ||
} | ||
|
||
std::string BluetoothSerial::getBtAddressString(){ | ||
return getBtAddressObject().toString(true); | ||
/** | ||
* @brief Gets the MAC address of local BT device as string. | ||
* | ||
* @return The BT MAC address string. | ||
*/ | ||
std::string BluetoothSerial::getBtAddressString() { | ||
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. Same here |
||
return getBtAddressObject().toString(true); | ||
} | ||
#endif |
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.
I see that originally the method returns
std::string
, but please change it to ArduinoString
instead.