mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 01:08:03 +01:00
commit
e006045f59
3 changed files with 15 additions and 2 deletions
|
@ -91,7 +91,16 @@ bool ESP32BLE::ble_setup_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_gap_set_device_name(App.get_name().c_str());
|
std::string name = App.get_name();
|
||||||
|
if (name.length() > 20) {
|
||||||
|
if (App.is_name_add_mac_suffix_enabled()) {
|
||||||
|
name.erase(name.begin() + 13, name.end() - 7); // Remove characters between 13 and the mac address
|
||||||
|
} else {
|
||||||
|
name = name.substr(0, 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = esp_ble_gap_set_device_name(name.c_str());
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "esp_ble_gap_set_device_name failed: %d", err);
|
ESP_LOGE(TAG, "esp_ble_gap_set_device_name failed: %d", err);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
MAJOR_VERSION = 1
|
MAJOR_VERSION = 1
|
||||||
MINOR_VERSION = 19
|
MINOR_VERSION = 19
|
||||||
PATCH_VERSION = "0b5"
|
PATCH_VERSION = "0b6"
|
||||||
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
|
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
|
||||||
__version__ = f"{__short_version__}.{PATCH_VERSION}"
|
__version__ = f"{__short_version__}.{PATCH_VERSION}"
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace esphome {
|
||||||
class Application {
|
class Application {
|
||||||
public:
|
public:
|
||||||
void pre_setup(const std::string &name, const char *compilation_time, bool name_add_mac_suffix) {
|
void pre_setup(const std::string &name, const char *compilation_time, bool name_add_mac_suffix) {
|
||||||
|
this->name_add_mac_suffix_ = name_add_mac_suffix;
|
||||||
if (name_add_mac_suffix) {
|
if (name_add_mac_suffix) {
|
||||||
this->name_ = name + "-" + get_mac_address().substr(6);
|
this->name_ = name + "-" + get_mac_address().substr(6);
|
||||||
} else {
|
} else {
|
||||||
|
@ -97,6 +98,8 @@ class Application {
|
||||||
/// Get the name of this Application set by set_name().
|
/// Get the name of this Application set by set_name().
|
||||||
const std::string &get_name() const { return this->name_; }
|
const std::string &get_name() const { return this->name_; }
|
||||||
|
|
||||||
|
bool is_name_add_mac_suffix_enabled() const { return this->name_add_mac_suffix_; }
|
||||||
|
|
||||||
const std::string &get_compilation_time() const { return this->compilation_time_; }
|
const std::string &get_compilation_time() const { return this->compilation_time_; }
|
||||||
|
|
||||||
/** Set the target interval with which to run the loop() calls.
|
/** Set the target interval with which to run the loop() calls.
|
||||||
|
@ -245,6 +248,7 @@ class Application {
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string compilation_time_;
|
std::string compilation_time_;
|
||||||
|
bool name_add_mac_suffix_;
|
||||||
uint32_t last_loop_{0};
|
uint32_t last_loop_{0};
|
||||||
uint32_t loop_interval_{16};
|
uint32_t loop_interval_{16};
|
||||||
int dump_config_at_{-1};
|
int dump_config_at_{-1};
|
||||||
|
|
Loading…
Reference in a new issue