mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 01:19:45 +08:00
[api] Enable zero-copy bytes SOURCE_BOTH messages (#12816)
This commit is contained in:
@@ -2425,7 +2425,7 @@ message ZWaveProxyFrame {
|
|||||||
option (ifdef) = "USE_ZWAVE_PROXY";
|
option (ifdef) = "USE_ZWAVE_PROXY";
|
||||||
option (no_delay) = true;
|
option (no_delay) = true;
|
||||||
|
|
||||||
bytes data = 1 [(pointer_to_buffer) = true];
|
bytes data = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ZWaveProxyRequestType {
|
enum ZWaveProxyRequestType {
|
||||||
@@ -2439,5 +2439,5 @@ message ZWaveProxyRequest {
|
|||||||
option (ifdef) = "USE_ZWAVE_PROXY";
|
option (ifdef) = "USE_ZWAVE_PROXY";
|
||||||
|
|
||||||
ZWaveProxyRequestType type = 1;
|
ZWaveProxyRequestType type = 1;
|
||||||
bytes data = 2 [(pointer_to_buffer) = true];
|
bytes data = 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1046,7 +1046,7 @@ class SubscribeLogsRequest final : public ProtoDecodableMessage {
|
|||||||
class SubscribeLogsResponse final : public ProtoMessage {
|
class SubscribeLogsResponse final : public ProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 29;
|
static constexpr uint8_t MESSAGE_TYPE = 29;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 11;
|
static constexpr uint8_t ESTIMATED_SIZE = 21;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "subscribe_logs_response"; }
|
const char *message_name() const override { return "subscribe_logs_response"; }
|
||||||
#endif
|
#endif
|
||||||
@@ -1069,7 +1069,7 @@ class SubscribeLogsResponse final : public ProtoMessage {
|
|||||||
class NoiseEncryptionSetKeyRequest final : public ProtoDecodableMessage {
|
class NoiseEncryptionSetKeyRequest final : public ProtoDecodableMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 124;
|
static constexpr uint8_t MESSAGE_TYPE = 124;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 9;
|
static constexpr uint8_t ESTIMATED_SIZE = 19;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "noise_encryption_set_key_request"; }
|
const char *message_name() const override { return "noise_encryption_set_key_request"; }
|
||||||
#endif
|
#endif
|
||||||
@@ -1161,7 +1161,7 @@ class HomeassistantActionRequest final : public ProtoMessage {
|
|||||||
class HomeassistantActionResponse final : public ProtoDecodableMessage {
|
class HomeassistantActionResponse final : public ProtoDecodableMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 130;
|
static constexpr uint8_t MESSAGE_TYPE = 130;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 24;
|
static constexpr uint8_t ESTIMATED_SIZE = 34;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "homeassistant_action_response"; }
|
const char *message_name() const override { return "homeassistant_action_response"; }
|
||||||
#endif
|
#endif
|
||||||
@@ -1388,7 +1388,7 @@ class ListEntitiesCameraResponse final : public InfoResponseProtoMessage {
|
|||||||
class CameraImageResponse final : public StateResponseProtoMessage {
|
class CameraImageResponse final : public StateResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 44;
|
static constexpr uint8_t MESSAGE_TYPE = 44;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 20;
|
static constexpr uint8_t ESTIMATED_SIZE = 30;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "camera_image_response"; }
|
const char *message_name() const override { return "camera_image_response"; }
|
||||||
#endif
|
#endif
|
||||||
@@ -2123,7 +2123,7 @@ class BluetoothGATTReadRequest final : public ProtoDecodableMessage {
|
|||||||
class BluetoothGATTReadResponse final : public ProtoMessage {
|
class BluetoothGATTReadResponse final : public ProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 74;
|
static constexpr uint8_t MESSAGE_TYPE = 74;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 17;
|
static constexpr uint8_t ESTIMATED_SIZE = 27;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "bluetooth_gatt_read_response"; }
|
const char *message_name() const override { return "bluetooth_gatt_read_response"; }
|
||||||
#endif
|
#endif
|
||||||
@@ -2146,7 +2146,7 @@ class BluetoothGATTReadResponse final : public ProtoMessage {
|
|||||||
class BluetoothGATTWriteRequest final : public ProtoDecodableMessage {
|
class BluetoothGATTWriteRequest final : public ProtoDecodableMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 75;
|
static constexpr uint8_t MESSAGE_TYPE = 75;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 19;
|
static constexpr uint8_t ESTIMATED_SIZE = 29;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "bluetooth_gatt_write_request"; }
|
const char *message_name() const override { return "bluetooth_gatt_write_request"; }
|
||||||
#endif
|
#endif
|
||||||
@@ -2182,7 +2182,7 @@ class BluetoothGATTReadDescriptorRequest final : public ProtoDecodableMessage {
|
|||||||
class BluetoothGATTWriteDescriptorRequest final : public ProtoDecodableMessage {
|
class BluetoothGATTWriteDescriptorRequest final : public ProtoDecodableMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 77;
|
static constexpr uint8_t MESSAGE_TYPE = 77;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 17;
|
static constexpr uint8_t ESTIMATED_SIZE = 27;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "bluetooth_gatt_write_descriptor_request"; }
|
const char *message_name() const override { return "bluetooth_gatt_write_descriptor_request"; }
|
||||||
#endif
|
#endif
|
||||||
@@ -2218,7 +2218,7 @@ class BluetoothGATTNotifyRequest final : public ProtoDecodableMessage {
|
|||||||
class BluetoothGATTNotifyDataResponse final : public ProtoMessage {
|
class BluetoothGATTNotifyDataResponse final : public ProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 79;
|
static constexpr uint8_t MESSAGE_TYPE = 79;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 17;
|
static constexpr uint8_t ESTIMATED_SIZE = 27;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "bluetooth_gatt_notify_data_response"; }
|
const char *message_name() const override { return "bluetooth_gatt_notify_data_response"; }
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -362,12 +362,12 @@ def create_field_type_info(
|
|||||||
# Traditional fixed array approach with copy (takes priority)
|
# Traditional fixed array approach with copy (takes priority)
|
||||||
return FixedArrayBytesType(field, fixed_size)
|
return FixedArrayBytesType(field, fixed_size)
|
||||||
|
|
||||||
# For SOURCE_CLIENT only messages (decode but no encode), use pointer
|
# For messages that decode (SOURCE_CLIENT or SOURCE_BOTH), use pointer
|
||||||
# for zero-copy access to the receive buffer
|
# for zero-copy access to the receive buffer
|
||||||
if needs_decode and not needs_encode:
|
if needs_decode:
|
||||||
return PointerToBytesBufferType(field, None)
|
return PointerToBytesBufferType(field, None)
|
||||||
|
|
||||||
# For SOURCE_BOTH/SOURCE_SERVER, explicit annotation is still needed
|
# For SOURCE_SERVER (encode only), explicit annotation is still needed
|
||||||
if get_field_opt(field, pb.pointer_to_buffer, False):
|
if get_field_opt(field, pb.pointer_to_buffer, False):
|
||||||
return PointerToBytesBufferType(field, None)
|
return PointerToBytesBufferType(field, None)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user