mirror of
https://github.com/esphome/esphome.git
synced 2025-09-04 04:12:23 +01:00
add custom ble name
This commit is contained in:
@@ -23,4 +23,5 @@ async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
zephyr_add_prj_conf("BT", True)
|
||||
zephyr_add_prj_conf("BT_PERIPHERAL", True)
|
||||
zephyr_add_prj_conf("BT_DEVICE_NAME_DYNAMIC", True)
|
||||
await cg.register_component(var, config)
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "ble_server.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/conn.h>
|
||||
|
||||
@@ -64,7 +65,14 @@ void BLEServer::setup() {
|
||||
int rc = bt_enable(bt_ready);
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(TAG, "Bluetooth enable failed: %d", rc);
|
||||
return;
|
||||
}
|
||||
rc = bt_set_name(App.get_name().c_str());
|
||||
if (rc != 0) {
|
||||
ESP_LOGE(TAG, "Bluetooth set name failed: %d", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace zephyr_ble_server
|
||||
|
Reference in New Issue
Block a user