mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[packet_transport] Make some arguments const (#8700)
Co-authored-by: clydeps <U5yx99dok9>
This commit is contained in:
		| @@ -353,7 +353,7 @@ static bool process_rolling_code(Provider &provider, PacketDecoder &decoder) { | ||||
| /** | ||||
|  * Process a received packet | ||||
|  */ | ||||
| void PacketTransport::process_(std::vector<uint8_t> &data) { | ||||
| void PacketTransport::process_(const std::vector<uint8_t> &data) { | ||||
|   auto ping_key_seen = !this->ping_pong_enable_; | ||||
|   PacketDecoder decoder((data.data()), data.size()); | ||||
|   char namebuf[256]{}; | ||||
|   | ||||
| @@ -101,12 +101,12 @@ class PacketTransport : public PollingComponent { | ||||
|  | ||||
|  protected: | ||||
|   // child classes must implement this | ||||
|   virtual void send_packet(std::vector<uint8_t> &buf) const = 0; | ||||
|   virtual void send_packet(const std::vector<uint8_t> &buf) const = 0; | ||||
|   virtual size_t get_max_packet_size() = 0; | ||||
|   virtual bool should_send() { return true; } | ||||
|  | ||||
|   // to be called by child classes when a data packet is received. | ||||
|   void process_(std::vector<uint8_t> &data); | ||||
|   void process_(const std::vector<uint8_t> &data); | ||||
|   void send_data_(bool all); | ||||
|   void flush_(); | ||||
|   void add_data_(uint8_t key, const char *id, float data); | ||||
| @@ -146,7 +146,6 @@ class PacketTransport : public PollingComponent { | ||||
|   const char *platform_name_{""}; | ||||
|   void add_key_(const char *name, uint32_t key); | ||||
|   void send_ping_pong_request_(); | ||||
|   void process_ping_request_(const char *name, uint8_t *ptr, size_t len); | ||||
|  | ||||
|   inline bool is_encrypted_() { return !this->encryption_key_.empty(); } | ||||
| }; | ||||
|   | ||||
| @@ -74,7 +74,7 @@ void UARTTransport::write_byte_(uint8_t byte) const { | ||||
|   this->parent_->write_byte(byte); | ||||
| } | ||||
|  | ||||
| void UARTTransport::send_packet(std::vector<uint8_t> &buf) const { | ||||
| void UARTTransport::send_packet(const std::vector<uint8_t> &buf) const { | ||||
|   this->parent_->write_byte(FLAG_BYTE); | ||||
|   for (uint8_t byte : buf) { | ||||
|     this->write_byte_(byte); | ||||
|   | ||||
| @@ -29,7 +29,7 @@ class UARTTransport : public packet_transport::PacketTransport, public UARTDevic | ||||
|  | ||||
|  protected: | ||||
|   void write_byte_(uint8_t byte) const; | ||||
|   void send_packet(std::vector<uint8_t> &buf) const override; | ||||
|   void send_packet(const std::vector<uint8_t> &buf) const override; | ||||
|   bool should_send() override { return true; }; | ||||
|   size_t get_max_packet_size() override { return MAX_PACKET_SIZE; } | ||||
|   std::vector<uint8_t> receive_buffer_{}; | ||||
|   | ||||
| @@ -31,6 +31,6 @@ void UDPTransport::update() { | ||||
|   this->resend_data_ = this->should_broadcast_; | ||||
| } | ||||
|  | ||||
| void UDPTransport::send_packet(std::vector<uint8_t> &buf) const { this->parent_->send_packet(buf); } | ||||
| void UDPTransport::send_packet(const std::vector<uint8_t> &buf) const { this->parent_->send_packet(buf); } | ||||
| }  // namespace udp | ||||
| }  // namespace esphome | ||||
|   | ||||
| @@ -16,7 +16,7 @@ class UDPTransport : public packet_transport::PacketTransport, public Parented<U | ||||
|   float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } | ||||
|  | ||||
|  protected: | ||||
|   void send_packet(std::vector<uint8_t> &buf) const override; | ||||
|   void send_packet(const std::vector<uint8_t> &buf) const override; | ||||
|   bool should_send() override; | ||||
|   bool should_broadcast_{false}; | ||||
|   size_t get_max_packet_size() override { return MAX_PACKET_SIZE; } | ||||
|   | ||||
| @@ -30,7 +30,7 @@ class UDPComponent : public Component { | ||||
|   void loop() override; | ||||
|   void dump_config() override; | ||||
|   void send_packet(const uint8_t *data, size_t size); | ||||
|   void send_packet(std::vector<uint8_t> &buf) { this->send_packet(buf.data(), buf.size()); } | ||||
|   void send_packet(const std::vector<uint8_t> &buf) { this->send_packet(buf.data(), buf.size()); } | ||||
|   float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }; | ||||
|  | ||||
|  protected: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user