mirror of
https://github.com/esphome/esphome.git
synced 2025-08-01 07:57:47 +00:00
remove dead code
This commit is contained in:
parent
1aab2f5a7f
commit
7f5eefed10
@ -1091,9 +1091,6 @@ void APIConnection::subscribe_bluetooth_le_advertisements(const SubscribeBluetoo
|
||||
void APIConnection::unsubscribe_bluetooth_le_advertisements(const UnsubscribeBluetoothLEAdvertisementsRequest &msg) {
|
||||
bluetooth_proxy::global_bluetooth_proxy->unsubscribe_api_connection(this);
|
||||
}
|
||||
bool APIConnection::send_bluetooth_le_advertisement(const BluetoothLEAdvertisementResponse &msg) {
|
||||
return this->send_message(msg, BluetoothLEAdvertisementResponse::MESSAGE_TYPE);
|
||||
}
|
||||
void APIConnection::bluetooth_device_request(const BluetoothDeviceRequest &msg) {
|
||||
bluetooth_proxy::global_bluetooth_proxy->bluetooth_device_request(msg);
|
||||
}
|
||||
|
@ -116,7 +116,6 @@ class APIConnection : public APIServerConnection {
|
||||
#ifdef USE_BLUETOOTH_PROXY
|
||||
void subscribe_bluetooth_le_advertisements(const SubscribeBluetoothLEAdvertisementsRequest &msg) override;
|
||||
void unsubscribe_bluetooth_le_advertisements(const UnsubscribeBluetoothLEAdvertisementsRequest &msg) override;
|
||||
bool send_bluetooth_le_advertisement(const BluetoothLEAdvertisementResponse &msg);
|
||||
|
||||
void bluetooth_device_request(const BluetoothDeviceRequest &msg) override;
|
||||
void bluetooth_gatt_read(const BluetoothGATTReadRequest &msg) override;
|
||||
|
@ -1821,6 +1821,7 @@ bool SubscribeBluetoothLEAdvertisementsRequest::decode_varint(uint32_t field_id,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
void BluetoothServiceData::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_string(1, this->uuid);
|
||||
buffer.encode_bytes(3, reinterpret_cast<const uint8_t *>(this->data.data()), this->data.size());
|
||||
@ -1829,34 +1830,7 @@ void BluetoothServiceData::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->uuid);
|
||||
ProtoSize::add_string_field(total_size, 1, this->data);
|
||||
}
|
||||
void BluetoothLEAdvertisementResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint64(1, this->address);
|
||||
buffer.encode_bytes(2, reinterpret_cast<const uint8_t *>(this->name.data()), this->name.size());
|
||||
buffer.encode_sint32(3, this->rssi);
|
||||
for (auto &it : this->service_uuids) {
|
||||
buffer.encode_string(4, it, true);
|
||||
}
|
||||
for (auto &it : this->service_data) {
|
||||
buffer.encode_message(5, it, true);
|
||||
}
|
||||
for (auto &it : this->manufacturer_data) {
|
||||
buffer.encode_message(6, it, true);
|
||||
}
|
||||
buffer.encode_uint32(7, this->address_type);
|
||||
}
|
||||
void BluetoothLEAdvertisementResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_uint64_field(total_size, 1, this->address);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_sint32_field(total_size, 1, this->rssi);
|
||||
if (!this->service_uuids.empty()) {
|
||||
for (const auto &it : this->service_uuids) {
|
||||
ProtoSize::add_string_field_repeated(total_size, 1, it);
|
||||
}
|
||||
}
|
||||
ProtoSize::add_repeated_message(total_size, 1, this->service_data);
|
||||
ProtoSize::add_repeated_message(total_size, 1, this->manufacturer_data);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->address_type);
|
||||
}
|
||||
#ifdef USE_BLUETOOTH_PROXY
|
||||
void BluetoothLERawAdvertisement::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint64(1, this->address);
|
||||
buffer.encode_sint32(2, this->rssi);
|
||||
|
@ -1679,6 +1679,7 @@ class SubscribeBluetoothLEAdvertisementsRequest : public ProtoDecodableMessage {
|
||||
protected:
|
||||
bool decode_varint(uint32_t field_id, ProtoVarInt value) override;
|
||||
};
|
||||
#endif
|
||||
class BluetoothServiceData : public ProtoMessage {
|
||||
public:
|
||||
std::string uuid{};
|
||||
@ -1691,28 +1692,7 @@ class BluetoothServiceData : public ProtoMessage {
|
||||
|
||||
protected:
|
||||
};
|
||||
class BluetoothLEAdvertisementResponse : public ProtoMessage {
|
||||
public:
|
||||
static constexpr uint8_t MESSAGE_TYPE = 67;
|
||||
static constexpr uint8_t ESTIMATED_SIZE = 107;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *message_name() const override { return "bluetooth_le_advertisement_response"; }
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
std::string name{};
|
||||
int32_t rssi{0};
|
||||
std::vector<std::string> service_uuids{};
|
||||
std::vector<BluetoothServiceData> service_data{};
|
||||
std::vector<BluetoothServiceData> manufacturer_data{};
|
||||
uint32_t address_type{0};
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void dump_to(std::string &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
};
|
||||
#ifdef USE_BLUETOOTH_PROXY
|
||||
class BluetoothLERawAdvertisement : public ProtoMessage {
|
||||
public:
|
||||
uint64_t address{0};
|
||||
|
@ -2910,6 +2910,7 @@ void SubscribeBluetoothLEAdvertisementsRequest::dump_to(std::string &out) const
|
||||
out.append("\n");
|
||||
out.append("}");
|
||||
}
|
||||
#endif
|
||||
void BluetoothServiceData::dump_to(std::string &out) const {
|
||||
__attribute__((unused)) char buffer[64];
|
||||
out.append("BluetoothServiceData {\n");
|
||||
@ -2922,47 +2923,7 @@ void BluetoothServiceData::dump_to(std::string &out) const {
|
||||
out.append("\n");
|
||||
out.append("}");
|
||||
}
|
||||
void BluetoothLEAdvertisementResponse::dump_to(std::string &out) const {
|
||||
__attribute__((unused)) char buffer[64];
|
||||
out.append("BluetoothLEAdvertisementResponse {\n");
|
||||
out.append(" address: ");
|
||||
snprintf(buffer, sizeof(buffer), "%llu", this->address);
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
|
||||
out.append(" name: ");
|
||||
out.append(format_hex_pretty(this->name));
|
||||
out.append("\n");
|
||||
|
||||
out.append(" rssi: ");
|
||||
snprintf(buffer, sizeof(buffer), "%" PRId32, this->rssi);
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
|
||||
for (const auto &it : this->service_uuids) {
|
||||
out.append(" service_uuids: ");
|
||||
out.append("'").append(it).append("'");
|
||||
out.append("\n");
|
||||
}
|
||||
|
||||
for (const auto &it : this->service_data) {
|
||||
out.append(" service_data: ");
|
||||
it.dump_to(out);
|
||||
out.append("\n");
|
||||
}
|
||||
|
||||
for (const auto &it : this->manufacturer_data) {
|
||||
out.append(" manufacturer_data: ");
|
||||
it.dump_to(out);
|
||||
out.append("\n");
|
||||
}
|
||||
|
||||
out.append(" address_type: ");
|
||||
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->address_type);
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
out.append("}");
|
||||
}
|
||||
#ifdef USE_BLUETOOTH_PROXY
|
||||
void BluetoothLERawAdvertisement::dump_to(std::string &out) const {
|
||||
__attribute__((unused)) char buffer[64];
|
||||
out.append("BluetoothLERawAdvertisement {\n");
|
||||
|
@ -140,46 +140,6 @@ void BluetoothProxy::flush_pending_advertisements() {
|
||||
this->advertisement_count_ = 0;
|
||||
}
|
||||
|
||||
#ifdef USE_ESP32_BLE_DEVICE
|
||||
void BluetoothProxy::send_api_packet_(const esp32_ble_tracker::ESPBTDevice &device) {
|
||||
api::BluetoothLEAdvertisementResponse resp;
|
||||
resp.address = device.address_uint64();
|
||||
resp.address_type = device.get_address_type();
|
||||
if (!device.get_name().empty())
|
||||
resp.name = device.get_name();
|
||||
resp.rssi = device.get_rssi();
|
||||
|
||||
// Pre-allocate vectors based on known sizes
|
||||
auto service_uuids = device.get_service_uuids();
|
||||
resp.service_uuids.reserve(service_uuids.size());
|
||||
for (auto &uuid : service_uuids) {
|
||||
resp.service_uuids.emplace_back(uuid.to_string());
|
||||
}
|
||||
|
||||
// Pre-allocate service data vector
|
||||
auto service_datas = device.get_service_datas();
|
||||
resp.service_data.reserve(service_datas.size());
|
||||
for (auto &data : service_datas) {
|
||||
resp.service_data.emplace_back();
|
||||
auto &service_data = resp.service_data.back();
|
||||
service_data.uuid = data.uuid.to_string();
|
||||
service_data.data.assign(data.data.begin(), data.data.end());
|
||||
}
|
||||
|
||||
// Pre-allocate manufacturer data vector
|
||||
auto manufacturer_datas = device.get_manufacturer_datas();
|
||||
resp.manufacturer_data.reserve(manufacturer_datas.size());
|
||||
for (auto &data : manufacturer_datas) {
|
||||
resp.manufacturer_data.emplace_back();
|
||||
auto &manufacturer_data = resp.manufacturer_data.back();
|
||||
manufacturer_data.uuid = data.uuid.to_string();
|
||||
manufacturer_data.data.assign(data.data.begin(), data.data.end());
|
||||
}
|
||||
|
||||
this->api_connection_->send_message(resp, api::BluetoothLEAdvertisementResponse::MESSAGE_TYPE);
|
||||
}
|
||||
#endif // USE_ESP32_BLE_DEVICE
|
||||
|
||||
void BluetoothProxy::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Bluetooth Proxy:");
|
||||
ESP_LOGCONFIG(TAG,
|
||||
|
@ -131,9 +131,6 @@ class BluetoothProxy : public esp32_ble_tracker::ESPBTDeviceListener, public Com
|
||||
}
|
||||
|
||||
protected:
|
||||
#ifdef USE_ESP32_BLE_DEVICE
|
||||
void send_api_packet_(const esp32_ble_tracker::ESPBTDevice &device);
|
||||
#endif
|
||||
void send_bluetooth_scanner_state_(esp32_ble_tracker::ScannerState state);
|
||||
|
||||
BluetoothConnection *get_connection_(uint64_t address, bool reserve);
|
||||
|
@ -999,6 +999,10 @@ def build_type_usage_map(
|
||||
|
||||
# Analyze field usage
|
||||
for message in file_desc.message_type:
|
||||
# Skip deprecated messages entirely
|
||||
if message.options.deprecated:
|
||||
continue
|
||||
|
||||
for field in message.field:
|
||||
# Skip deprecated fields when tracking enum usage
|
||||
if field.options.deprecated:
|
||||
@ -1593,6 +1597,10 @@ def build_service_message_type(
|
||||
message_source_map: dict[str, int],
|
||||
) -> tuple[str, str] | None:
|
||||
"""Builds the service message type."""
|
||||
# Skip deprecated messages
|
||||
if mt.options.deprecated:
|
||||
return None
|
||||
|
||||
snake = camel_to_snake(mt.name)
|
||||
id_: int | None = get_opt(mt, pb.id)
|
||||
if id_ is None:
|
||||
@ -1760,6 +1768,10 @@ namespace api {
|
||||
current_ifdef = None
|
||||
|
||||
for m in mt:
|
||||
# Skip deprecated messages
|
||||
if m.options.deprecated:
|
||||
continue
|
||||
|
||||
s, c, dc = build_message_type(m, base_class_fields, message_source_map)
|
||||
msg_ifdef = message_ifdef_map.get(m.name)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user