Unverified Commit 1f9350dc authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Allow setting SerialBT advertised name (#2181)

Trivial fix #2179
parent 361b4e08
......@@ -22,6 +22,7 @@
#include <SerialBT.h>
void setup() {
SerialBT.setName("PicoW UPPERCASE 00:00:00:00:00:00");
SerialBT.begin();
}
......
......@@ -11,6 +11,7 @@ SerialBT KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
setName KEYWORD2
#######################################
# Constants (LITERAL1)
......
......@@ -76,7 +76,10 @@ void SerialBT_::begin(unsigned long baud, uint16_t config) {
gap_discoverable_control(1);
gap_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
gap_set_local_name("PicoW Serial 00:00:00:00:00:00");
if (!_name) {
setName("PicoW Serial 00:00:00:00:00:00");
}
gap_set_local_name(_name);
// Turn on!
hci_power_control(HCI_POWER_ON);
......
......@@ -37,6 +37,14 @@ public:
SerialBT_();
bool setFIFOSize(size_t size);
bool setName(const char *name) {
if (_running) {
return false;
}
free(_name);
_name = strdup(name);
return true;
}
void begin(unsigned long baud = 115200) override {
begin(baud, SERIAL_8N1);
......@@ -82,4 +90,6 @@ private:
volatile int _writeLen = 0;
const void *_writeBuff;
char *_name = nullptr;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment