mirror of
https://github.com/esphome/esphome.git
synced 2025-01-01 10:21:43 +01:00
Fix linting issues
This commit is contained in:
parent
c72bb488f2
commit
4ba9392325
4 changed files with 15 additions and 14 deletions
|
@ -7,7 +7,7 @@ from esphome.const import (
|
||||||
CONF_UUID,
|
CONF_UUID,
|
||||||
CONF_SERVICES,
|
CONF_SERVICES,
|
||||||
CONF_VALUE,
|
CONF_VALUE,
|
||||||
CONF_MAX_LENGTH
|
CONF_MAX_LENGTH,
|
||||||
)
|
)
|
||||||
from esphome.components import esp32_ble
|
from esphome.components import esp32_ble
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
@ -65,7 +65,7 @@ PROPERTIES_SCHEMA = cv.All(
|
||||||
upper=True,
|
upper=True,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
cv.Length(min=1)
|
cv.Length(min=1),
|
||||||
)
|
)
|
||||||
|
|
||||||
UUID_SCHEMA = cv.Any(cv.All(cv.string, validate_uuid), cv.hex_uint32_t)
|
UUID_SCHEMA = cv.Any(cv.All(cv.string, validate_uuid), cv.hex_uint32_t)
|
||||||
|
@ -164,7 +164,7 @@ def parse_value(value):
|
||||||
def calculate_num_handles(service_config):
|
def calculate_num_handles(service_config):
|
||||||
total = 1
|
total = 1
|
||||||
for char_conf in service_config[CONF_CHARACTERISTICS]:
|
for char_conf in service_config[CONF_CHARACTERISTICS]:
|
||||||
total += 2 # One for the char_conf itself and one for the value
|
total += 2 # One for the char_conf itself and one for the value
|
||||||
for _ in char_conf[CONF_DESCRIPTORS]:
|
for _ in char_conf[CONF_DESCRIPTORS]:
|
||||||
total += 1
|
total += 1
|
||||||
return total
|
return total
|
||||||
|
@ -202,7 +202,7 @@ async def to_code(config):
|
||||||
char_conf[CONF_ID],
|
char_conf[CONF_ID],
|
||||||
service_var.create_characteristic(
|
service_var.create_characteristic(
|
||||||
parse_uuid(char_conf[CONF_UUID]),
|
parse_uuid(char_conf[CONF_UUID]),
|
||||||
parse_properties(char_conf[CONF_PROPERTIES])
|
parse_properties(char_conf[CONF_PROPERTIES]),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if CONF_ON_WRITE in char_conf:
|
if CONF_ON_WRITE in char_conf:
|
||||||
|
@ -233,6 +233,7 @@ async def to_code(config):
|
||||||
if CORE.using_esp_idf:
|
if CORE.using_esp_idf:
|
||||||
add_idf_sdkconfig_option("CONFIG_BT_ENABLED", True)
|
add_idf_sdkconfig_option("CONFIG_BT_ENABLED", True)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
@automation.register_action(
|
||||||
"ble_server.characteristic_set_value",
|
"ble_server.characteristic_set_value",
|
||||||
BLECharacteristicSetValueAction,
|
BLECharacteristicSetValueAction,
|
||||||
|
|
|
@ -63,7 +63,7 @@ void BLEServer::loop() {
|
||||||
// Remove the services that have been started
|
// Remove the services that have been started
|
||||||
if (index_to_remove > 0) {
|
if (index_to_remove > 0) {
|
||||||
this->services_to_start_.erase(this->services_to_start_.begin(),
|
this->services_to_start_.erase(this->services_to_start_.begin(),
|
||||||
this->services_to_start_.begin() + index_to_remove - 1);
|
this->services_to_start_.begin() + index_to_remove - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -86,7 +86,7 @@ void BLEServer::loop() {
|
||||||
}
|
}
|
||||||
if (this->device_information_service_ == nullptr) {
|
if (this->device_information_service_ == nullptr) {
|
||||||
this->device_information_service_ =
|
this->device_information_service_ =
|
||||||
this->create_service(ESPBTUUID::from_uint16(DEVICE_INFORMATION_SERVICE_UUID), false, 7);
|
this->create_service(ESPBTUUID::from_uint16(DEVICE_INFORMATION_SERVICE_UUID), false, 7);
|
||||||
this->create_device_characteristics_();
|
this->create_device_characteristics_();
|
||||||
}
|
}
|
||||||
this->state_ = STARTING_SERVICE;
|
this->state_ = STARTING_SERVICE;
|
||||||
|
@ -152,7 +152,7 @@ BLEService *BLEServer::create_service(ESPBTUUID uuid, bool advertise, uint16_t n
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
BLEService *service =
|
BLEService *service =
|
||||||
new BLEService(uuid, num_handles, inst_id, advertise); // NOLINT(cppcoreguidelines-owning-memory)
|
new BLEService(uuid, num_handles, inst_id, advertise); // NOLINT(cppcoreguidelines-owning-memory)
|
||||||
this->services_.emplace(BLEServer::get_service_key(uuid, inst_id), service);
|
this->services_.emplace(BLEServer::get_service_key(uuid, inst_id), service);
|
||||||
if (this->parent_->is_active() && this->registered_) {
|
if (this->parent_->is_active() && this->registered_) {
|
||||||
service->do_create(this);
|
service->do_create(this);
|
||||||
|
|
|
@ -31,13 +31,13 @@ class BLEServerAutomationInterface {
|
||||||
static Trigger<std::string> *create_on_write_trigger(BLECharacteristic *characteristic);
|
static Trigger<std::string> *create_on_write_trigger(BLECharacteristic *characteristic);
|
||||||
|
|
||||||
template<typename... Ts> class BLECharacteristicSetValueAction : public Action<Ts...> {
|
template<typename... Ts> class BLECharacteristicSetValueAction : public Action<Ts...> {
|
||||||
public:
|
public:
|
||||||
BLECharacteristicSetValueAction(BLECharacteristic *characteristic) : parent_(characteristic) {}
|
BLECharacteristicSetValueAction(BLECharacteristic *characteristic) : parent_(characteristic) {}
|
||||||
TEMPLATABLE_VALUE(std::string, value)
|
TEMPLATABLE_VALUE(std::string, value)
|
||||||
void play(Ts... x) override { this->parent_->set_value(this->value_.value(x...)); }
|
void play(Ts... x) override { this->parent_->set_value(this->value_.value(x...)); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BLECharacteristic *parent_;
|
BLECharacteristic *parent_;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ void BLEService::emit_client_connect(const uint16_t conn_id) {
|
||||||
this->on_client_connect_(conn_id);
|
this->on_client_connect_(conn_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void emit_client_disconnect(const uint16_t conn_id) {
|
void BLEService::emit_client_disconnect(const uint16_t conn_id) {
|
||||||
if (this->on_client_disconnect_ && this->is_running())
|
if (this->on_client_disconnect_ && this->is_running())
|
||||||
this->on_client_disconnect_(conn_id);
|
this->on_client_disconnect_(conn_id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue