ESPHome  2022.8.0
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::bedjet::BedjetCodec Class Reference

This class is responsible for encoding command packets and decoding status packets. More...

#include <bedjet_codec.h>

Public Member Functions

BedjetPacketget_button_request (BedjetButton button)
 Returns a BedjetPacket that will initiate a BedjetButton press. More...
 
BedjetPacketget_set_target_temp_request (float temperature)
 Returns a BedjetPacket that will set the device's target temperature. More...
 
BedjetPacketget_set_fan_speed_request (uint8_t fan_step)
 Returns a BedjetPacket that will set the device's target fan speed. More...
 
BedjetPacketget_set_time_request (uint8_t hour, uint8_t minute)
 Returns a BedjetPacket that will set the device's current time. More...
 
BedjetPacketget_set_runtime_remaining_request (uint8_t hour, uint8_t minute)
 Returns a BedjetPacket that will set the device's remaining runtime. More...
 
bool decode_notify (const uint8_t *data, uint16_t length)
 Decodes the incoming status packet received on the BEDJET_STATUS_UUID. More...
 
void decode_extra (const uint8_t *data, uint16_t length)
 Decodes the extra bytes that were received after being notified with a partial packet. More...
 
bool compare (const uint8_t *data, uint16_t length)
 
bool has_status ()
 
const BedjetStatusPacketget_status_packet () const
 
void clear_status ()
 

Protected Member Functions

BedjetPacketclean_packet_ ()
 Cleans up the packet before sending. More...
 

Protected Attributes

uint8_t last_buffer_size_ = 0
 
BedjetPacket packet_
 
BedjetStatusPacketstatus_packet_
 
BedjetStatusPacket buf_
 

Detailed Description

This class is responsible for encoding command packets and decoding status packets.

Status Packets

The BedJet protocol depends on registering for notifications on the esphome::BedJet::BEDJET_SERVICE_UUID characteristic. If the BedJet is on, it will send rapid updates as notifications. If it is off, it generally will not notify of any status.

As the BedJet V3's BedjetStatusPacket exceeds the buffer size allowed for BLE notification packets, the notification packet will contain BedjetStatusPacket::is_partial == 1. When that happens, an additional read of the esphome::BedJet::BEDJET_SERVICE_UUID characteristic will contain the second portion of the full status packet.

Command Packets

This class supports encoding a number of BedjetPacket commands:

Definition at line 163 of file bedjet_codec.h.

Member Function Documentation

◆ clean_packet_()

BedjetPacket * esphome::bedjet::BedjetCodec::clean_packet_ ( )
protected

Cleans up the packet before sending.

Definition at line 15 of file bedjet_codec.cpp.

◆ clear_status()

void esphome::bedjet::BedjetCodec::clear_status ( )
inline

Definition at line 177 of file bedjet_codec.h.

◆ compare()

bool esphome::bedjet::BedjetCodec::compare ( const uint8_t *  data,
uint16_t  length 
)
Returns
true if the new packet is meaningfully different from the last seen packet.

Definition at line 131 of file bedjet_codec.cpp.

◆ decode_extra()

void esphome::bedjet::BedjetCodec::decode_extra ( const uint8_t *  data,
uint16_t  length 
)

Decodes the extra bytes that were received after being notified with a partial packet.

Definition at line 68 of file bedjet_codec.cpp.

◆ decode_notify()

bool esphome::bedjet::BedjetCodec::decode_notify ( const uint8_t *  data,
uint16_t  length 
)

Decodes the incoming status packet received on the BEDJET_STATUS_UUID.

Returns
true if the packet was decoded and represents a "partial" packet; false otherwise.

Definition at line 90 of file bedjet_codec.cpp.

◆ get_button_request()

BedjetPacket * esphome::bedjet::BedjetCodec::get_button_request ( BedjetButton  button)

Returns a BedjetPacket that will initiate a BedjetButton press.

Definition at line 26 of file bedjet_codec.cpp.

◆ get_set_fan_speed_request()

BedjetPacket * esphome::bedjet::BedjetCodec::get_set_fan_speed_request ( uint8_t  fan_step)

Returns a BedjetPacket that will set the device's target fan speed.

Definition at line 42 of file bedjet_codec.cpp.

◆ get_set_runtime_remaining_request()

BedjetPacket * esphome::bedjet::BedjetCodec::get_set_runtime_remaining_request ( uint8_t  hour,
uint8_t  minute 
)

Returns a BedjetPacket that will set the device's remaining runtime.

Definition at line 59 of file bedjet_codec.cpp.

◆ get_set_target_temp_request()

BedjetPacket * esphome::bedjet::BedjetCodec::get_set_target_temp_request ( float  temperature)

Returns a BedjetPacket that will set the device's target temperature.

Definition at line 34 of file bedjet_codec.cpp.

◆ get_set_time_request()

BedjetPacket * esphome::bedjet::BedjetCodec::get_set_time_request ( uint8_t  hour,
uint8_t  minute 
)

Returns a BedjetPacket that will set the device's current time.

Definition at line 50 of file bedjet_codec.cpp.

◆ get_status_packet()

const BedjetStatusPacket* esphome::bedjet::BedjetCodec::get_status_packet ( ) const
inline

Definition at line 176 of file bedjet_codec.h.

◆ has_status()

bool esphome::bedjet::BedjetCodec::has_status ( )
inline

Definition at line 175 of file bedjet_codec.h.

Field Documentation

◆ buf_

BedjetStatusPacket esphome::bedjet::BedjetCodec::buf_
protected

Definition at line 187 of file bedjet_codec.h.

◆ last_buffer_size_

uint8_t esphome::bedjet::BedjetCodec::last_buffer_size_ = 0
protected

Definition at line 182 of file bedjet_codec.h.

◆ packet_

BedjetPacket esphome::bedjet::BedjetCodec::packet_
protected

Definition at line 184 of file bedjet_codec.h.

◆ status_packet_

BedjetStatusPacket* esphome::bedjet::BedjetCodec::status_packet_
protected

Definition at line 186 of file bedjet_codec.h.


The documentation for this class was generated from the following files: