mirror of
https://github.com/esphome/esphome.git
synced 2024-12-28 16:31:44 +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_SERVICES,
|
||||
CONF_VALUE,
|
||||
CONF_MAX_LENGTH
|
||||
CONF_MAX_LENGTH,
|
||||
)
|
||||
from esphome.components import esp32_ble
|
||||
from esphome.core import CORE
|
||||
|
@ -65,7 +65,7 @@ PROPERTIES_SCHEMA = cv.All(
|
|||
upper=True,
|
||||
)
|
||||
),
|
||||
cv.Length(min=1)
|
||||
cv.Length(min=1),
|
||||
)
|
||||
|
||||
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):
|
||||
total = 1
|
||||
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]:
|
||||
total += 1
|
||||
return total
|
||||
|
@ -202,7 +202,7 @@ async def to_code(config):
|
|||
char_conf[CONF_ID],
|
||||
service_var.create_characteristic(
|
||||
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:
|
||||
|
@ -233,6 +233,7 @@ async def to_code(config):
|
|||
if CORE.using_esp_idf:
|
||||
add_idf_sdkconfig_option("CONFIG_BT_ENABLED", True)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"ble_server.characteristic_set_value",
|
||||
BLECharacteristicSetValueAction,
|
||||
|
|
|
@ -63,7 +63,7 @@ void BLEServer::loop() {
|
|||
// Remove the services that have been started
|
||||
if (index_to_remove > 0) {
|
||||
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;
|
||||
|
@ -86,7 +86,7 @@ void BLEServer::loop() {
|
|||
}
|
||||
if (this->device_information_service_ == nullptr) {
|
||||
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->state_ = STARTING_SERVICE;
|
||||
|
@ -152,7 +152,7 @@ BLEService *BLEServer::create_service(ESPBTUUID uuid, bool advertise, uint16_t n
|
|||
return nullptr;
|
||||
}
|
||||
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);
|
||||
if (this->parent_->is_active() && this->registered_) {
|
||||
service->do_create(this);
|
||||
|
|
|
@ -31,13 +31,13 @@ class BLEServerAutomationInterface {
|
|||
static Trigger<std::string> *create_on_write_trigger(BLECharacteristic *characteristic);
|
||||
|
||||
template<typename... Ts> class BLECharacteristicSetValueAction : public Action<Ts...> {
|
||||
public:
|
||||
BLECharacteristicSetValueAction(BLECharacteristic *characteristic) : parent_(characteristic) {}
|
||||
TEMPLATABLE_VALUE(std::string, value)
|
||||
void play(Ts... x) override { this->parent_->set_value(this->value_.value(x...)); }
|
||||
public:
|
||||
BLECharacteristicSetValueAction(BLECharacteristic *characteristic) : parent_(characteristic) {}
|
||||
TEMPLATABLE_VALUE(std::string, value)
|
||||
void play(Ts... x) override { this->parent_->set_value(this->value_.value(x...)); }
|
||||
|
||||
protected:
|
||||
BLECharacteristic *parent_;
|
||||
protected:
|
||||
BLECharacteristic *parent_;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void BLEService::emit_client_connect(const uint16_t 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())
|
||||
this->on_client_disconnect_(conn_id);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue