Skip to content

Commit

Permalink
Separate fake traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed Jan 21, 2024
1 parent 0f2c8bf commit b42b40b
Show file tree
Hide file tree
Showing 17 changed files with 394 additions and 319 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ jobs:
esphome -s external_components_source components config esp32-ble-example-multiple-devices.yaml
esphome -s external_components_source components config esp32-ble-uart-hybrid-example.yaml
esphome -s external_components_source components config esp32-ble-v11-example.yaml
esphome -s external_components_source components config esp32-ble-v11-example-debug.yaml
esphome -s external_components_source components config esp32-ble-v11-example-faker.yaml
- name: Write yaml-snippets/secrets.yaml
shell: bash
Expand Down Expand Up @@ -262,4 +264,4 @@ jobs:
- name: Compile esp32 (jk_bms_ble) example configurations
run: |
esphome -s external_components_source components compile esp32-ble-example-faker.yaml
esphome -s external_components_source components compile esp32-ble-v11-example.yaml
esphome -s external_components_source components compile esp32-ble-v11-example-faker.yaml
3 changes: 0 additions & 3 deletions components/heltec_balancer_ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
MULTI_CONF = True

CONF_HELTEC_BALANCER_BLE_ID = "heltec_balancer_ble_id"
CONF_ENABLE_FAKE_TRAFFIC = "enable_fake_traffic"

heltec_balancer_ble_ns = cg.esphome_ns.namespace("heltec_balancer_ble")
HeltecBalancerBle = heltec_balancer_ble_ns.class_(
Expand All @@ -29,7 +28,6 @@
cv.Optional(
CONF_THROTTLE, default="2s"
): cv.positive_time_period_milliseconds,
cv.Optional(CONF_ENABLE_FAKE_TRAFFIC, default=False): cv.boolean,
}
)
.extend(ble_client.BLE_CLIENT_SCHEMA)
Expand All @@ -42,5 +40,4 @@ async def to_code(config):
await cg.register_component(var, config)
await ble_client.register_ble_node(var, config)

cg.add(var.set_enable_fake_traffic(config[CONF_ENABLE_FAKE_TRAFFIC]))
cg.add(var.set_throttle(config[CONF_THROTTLE]))
89 changes: 2 additions & 87 deletions components/heltec_balancer_ble/heltec_balancer_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ uint8_t checksum_xor(const uint8_t data[], const uint16_t len) {

void HeltecBalancerBle::dump_config() { // NOLINT(google-readability-function-size,readability-function-size)
ESP_LOGCONFIG(TAG, "HeltecBalancerBle");
ESP_LOGCONFIG(TAG, " Fake traffic enabled: %s", YESNO(this->enable_fake_traffic_));
LOG_SENSOR("", "Minimum Cell Voltage", this->min_cell_voltage_sensor_);
LOG_SENSOR("", "Maximum Cell Voltage", this->max_cell_voltage_sensor_);
LOG_SENSOR("", "Minimum Voltage Cell", this->min_voltage_cell_sensor_);
Expand Down Expand Up @@ -196,7 +195,7 @@ void HeltecBalancerBle::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt
if (param->notify.handle != this->char_handle_)
break;

this->assemble_(param->notify.value, param->notify.value_len);
this->assemble(param->notify.value, param->notify.value_len);

break;
}
Expand All @@ -206,90 +205,6 @@ void HeltecBalancerBle::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt
}

void HeltecBalancerBle::update() {
if (this->enable_fake_traffic_) {
// Device info frame (0x01)
const uint8_t device_info_frame[100] = {
0x55, 0xAA, 0x11, 0x01, 0x01, 0x00, 0x64, 0x00, 0x47, 0x57, 0x2D, 0x32, 0x34, 0x53, 0x34, 0x45, 0x42,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x57, 0x2D, 0x32, 0x2E, 0x38, 0x2E, 0x30, 0x5A, 0x48,
0x2D, 0x31, 0x2E, 0x32, 0x2E, 0x33, 0x56, 0x31, 0x2E, 0x30, 0x2E, 0x30, 0x00, 0x00, 0x32, 0x30, 0x32,
0x32, 0x30, 0x35, 0x33, 0x31, 0x05, 0x00, 0x00, 0x00, 0x01, 0x91, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xFF};
this->assemble_(device_info_frame, 100);

// Cell info frame (0x02)
const uint8_t cell_info_frame[300] = {
0x55, 0xaa, 0x11, 0x01, 0x02, 0x00, 0x2c, 0x01, 0x38, 0xe7, 0xfa, 0x50, 0x40, 0xb6, 0x04, 0x51, 0x40, 0x85,
0x0e, 0x51, 0x40, 0xf0, 0x05, 0x51, 0x40, 0xb6, 0x04, 0x51, 0x40, 0x75, 0x1e, 0x51, 0x40, 0x7f, 0x4f, 0x51,
0x40, 0x43, 0x02, 0x51, 0x40, 0x1c, 0x3d, 0x51, 0x40, 0x78, 0x6a, 0x51, 0x40, 0xfe, 0x82, 0x51, 0x40, 0x16,
0x7e, 0x51, 0x40, 0xbc, 0x76, 0x51, 0x40, 0x16, 0x7e, 0x51, 0x40, 0x8b, 0x80, 0x51, 0x40, 0xca, 0x66, 0x51,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x93, 0x24,
0x3e, 0x68, 0x94, 0x26, 0x3e, 0x3d, 0x25, 0x1b, 0x3e, 0x90, 0x8e, 0x1b, 0x3e, 0xb3, 0xf3, 0x23, 0x3e, 0x2e,
0x91, 0x25, 0x3e, 0xc6, 0x1b, 0x1a, 0x3e, 0x4a, 0x7c, 0x1c, 0x3e, 0x6f, 0x1b, 0x1a, 0x3e, 0xc2, 0x43, 0x1b,
0x3e, 0x85, 0x1e, 0x18, 0x3e, 0x4b, 0x27, 0x19, 0x3e, 0x5e, 0xdf, 0x18, 0x3e, 0xd0, 0xeb, 0x1a, 0x3e, 0xe6,
0xd4, 0x18, 0x3e, 0x0c, 0xfe, 0x18, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xde, 0x40, 0x51, 0x42, 0xde, 0x40, 0x51, 0x40, 0x00, 0x17, 0x08, 0x3c, 0x0a, 0x00, 0x0f,
0x05, 0x19, 0xa1, 0x82, 0xc0, 0xc3, 0xf5, 0x48, 0x42, 0xc3, 0xf5, 0x48, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0x2e, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0xff};
this->assemble_(cell_info_frame, 300);

const uint8_t cell_info_frame2[300] = {
0x55, 0xaa, 0x11, 0x01, 0x02, 0x00, 0x2c, 0x01, 0x39, 0xe7, 0xfa, 0x50, 0x40, 0xb6, 0x04, 0x51, 0x40, 0x85,
0x0e, 0x51, 0x40, 0xf0, 0x05, 0x51, 0x40, 0xb6, 0x04, 0x51, 0x40, 0x75, 0x1e, 0x51, 0x40, 0x7f, 0x4f, 0x51,
0x40, 0x43, 0x02, 0x51, 0x40, 0x1c, 0x3d, 0x51, 0x40, 0x78, 0x6a, 0x51, 0x40, 0xfe, 0x82, 0x51, 0x40, 0x16,
0x7e, 0x51, 0x40, 0xbc, 0x76, 0x51, 0x40, 0x16, 0x7e, 0x51, 0x40, 0x8b, 0x80, 0x51, 0x40, 0xca, 0x66, 0x51,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x93, 0x24,
0x3e, 0x68, 0x94, 0x26, 0x3e, 0x3d, 0x25, 0x1b, 0x3e, 0x90, 0x8e, 0x1b, 0x3e, 0xb3, 0xf3, 0x23, 0x3e, 0x2e,
0x91, 0x25, 0x3e, 0xc6, 0x1b, 0x1a, 0x3e, 0x4a, 0x7c, 0x1c, 0x3e, 0x6f, 0x1b, 0x1a, 0x3e, 0xc2, 0x43, 0x1b,
0x3e, 0x85, 0x1e, 0x18, 0x3e, 0x4b, 0x27, 0x19, 0x3e, 0x5e, 0xdf, 0x18, 0x3e, 0xd0, 0xeb, 0x1a, 0x3e, 0xe6,
0xd4, 0x18, 0x3e, 0x0c, 0xfe, 0x18, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xde, 0x40, 0x51, 0x42, 0xde, 0x40, 0x51, 0x40, 0x00, 0x17, 0x08, 0x3c, 0x0a, 0x00, 0x0f,
0x05, 0x19, 0xa1, 0x82, 0xc0, 0xc3, 0xf5, 0x48, 0x42, 0xc3, 0xf5, 0x48, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x77, 0x2e, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xff};
this->assemble_(cell_info_frame2, 300);

// Factory defaults (0x03)
const uint8_t factory_defaults_frame[100] = {
0x55, 0xAA, 0x11, 0x01, 0x03, 0x00, 0x64, 0x00, 0x7B, 0xD2, 0xBF, 0x3F, 0x35, 0xCC, 0xBF, 0x3F, 0x51,
0x82, 0x54, 0x40, 0x33, 0x33, 0x73, 0x40, 0xAA, 0xC0, 0xDB, 0x3F, 0x7B, 0xE1, 0xDB, 0x3F, 0x61, 0xD6,
0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x33, 0x33, 0xD3, 0x3F, 0x5C, 0x8F, 0xD2,
0x3F, 0x48, 0xE1, 0xBA, 0x3F, 0x00, 0x00, 0xAA, 0x42, 0x00, 0x00, 0x82, 0x42, 0x08, 0x00, 0x00, 0x00,
0xF6, 0xE1, 0x0B, 0x00, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35, 0x33, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF};
this->assemble_(factory_defaults_frame, 100);

const uint8_t factory_defaults_frame2[100] = {
0x55, 0xAA, 0x11, 0x01, 0x03, 0x00, 0x64, 0x00, 0x75, 0xD5, 0xBF, 0x3F, 0x35, 0xCC, 0xBF, 0x3F, 0x17,
0x81, 0x54, 0x40, 0x33, 0x33, 0x73, 0x40, 0x74, 0xB6, 0xDB, 0x3F, 0x7B, 0xE1, 0xDB, 0x3F, 0x62, 0xD0,
0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x33, 0x33, 0xD3, 0x3F, 0x5C, 0x8F, 0xD2,
0x3F, 0x48, 0xE1, 0xBA, 0x3F, 0x00, 0x00, 0xAA, 0x42, 0x00, 0x00, 0x82, 0x42, 0x08, 0x00, 0x00, 0x00,
0xF6, 0xE1, 0x0B, 0x00, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35, 0x33, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9D, 0xFF};
this->assemble_(factory_defaults_frame2, 100);

// Settings frame (0x04)
const uint8_t settings_frame[100] = {
0x55, 0xaa, 0x11, 0x01, 0x04, 0x00, 0x64, 0x00, 0x10, 0x0a, 0xd7, 0xa3, 0x3b, 0x00, 0x00, 0x80, 0x40,
0x00, 0x00, 0x20, 0x40, 0x01, 0x01, 0x02, 0x18, 0x01, 0x00, 0x00, 0x66, 0x66, 0x26, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0xff};
this->assemble_(settings_frame, 100);

return;
}

this->track_online_status_();
if (this->node_state != espbt::ClientState::ESTABLISHED) {
ESP_LOGW(TAG, "[%s] Not connected", this->parent_->address_str().c_str());
Expand All @@ -303,7 +218,7 @@ void HeltecBalancerBle::update() {
}

// TODO: There is no need to assemble frames if the MTU can be increased to > MAX_RESPONSE_SIZE
void HeltecBalancerBle::assemble_(const uint8_t *data, uint16_t length) {
void HeltecBalancerBle::assemble(const uint8_t *data, uint16_t length) {
if (this->frame_buffer_.size() > MAX_RESPONSE_SIZE) {
ESP_LOGW(TAG, "Frame dropped because of invalid length");
this->frame_buffer_.clear();
Expand Down
5 changes: 1 addition & 4 deletions components/heltec_balancer_ble/heltec_balancer_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ class HeltecBalancerBle : public esphome::ble_client::BLEClientNode, public Poll
}

void set_balancer_switch(switch_::Switch *balancer_switch) { balancer_switch_ = balancer_switch; }

void set_enable_fake_traffic(bool enable_fake_traffic) { enable_fake_traffic_ = enable_fake_traffic; }
void assemble(const uint8_t *data, uint16_t length);
bool send_command(uint8_t function, uint8_t command, uint8_t register_address = 0x00, uint32_t value = 0x00000000);

struct Cell {
Expand Down Expand Up @@ -182,13 +181,11 @@ class HeltecBalancerBle : public esphome::ble_client::BLEClientNode, public Poll

std::vector<uint8_t> frame_buffer_;
bool status_notification_received_ = false;
bool enable_fake_traffic_;
uint8_t no_response_count_{0};
uint16_t char_handle_;
uint32_t last_cell_info_{0};
uint32_t throttle_;

void assemble_(const uint8_t *data, uint16_t length);
void decode_(const std::vector<uint8_t> &data);
void decode_device_info_(const std::vector<uint8_t> &data);
void decode_cell_info_(const std::vector<uint8_t> &data);
Expand Down
4 changes: 0 additions & 4 deletions components/jk_bms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
MULTI_CONF = True

CONF_JK_BMS_ID = "jk_bms_id"
CONF_ENABLE_FAKE_TRAFFIC = "enable_fake_traffic"

jk_bms_ns = cg.esphome_ns.namespace("jk_bms")
JkBms = jk_bms_ns.class_("JkBms", cg.PollingComponent, jk_modbus.JkModbusDevice)
Expand All @@ -17,7 +16,6 @@
cv.Schema(
{
cv.GenerateID(): cv.declare_id(JkBms),
cv.Optional(CONF_ENABLE_FAKE_TRAFFIC, default=False): cv.boolean,
}
)
.extend(cv.polling_component_schema("5s"))
Expand All @@ -35,5 +33,3 @@ async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
await jk_modbus.register_jk_modbus_device(var, config)

cg.add(var.set_enable_fake_traffic(config[CONF_ENABLE_FAKE_TRAFFIC]))
49 changes: 0 additions & 49 deletions components/jk_bms/jk_bms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,54 +385,6 @@ void JkBms::on_status_data_(const std::vector<uint8_t> &data) {
void JkBms::update() {
this->track_online_status_();
this->read_registers();

if (this->enable_fake_traffic_) {
// Start: 0x4E, 0x57, 0x01, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01
this->on_jk_modbus_data(
FUNCTION_READ_ALL,
{
0x79, 0x2A, 0x01, 0x0E, 0xED, 0x02, 0x0E, 0xFA, 0x03, 0x0E, 0xF7, 0x04, 0x0E, 0xEC, 0x05, 0x0E, 0xF8, 0x06,
0x0E, 0xFA, 0x07, 0x0E, 0xF1, 0x08, 0x0E, 0xF8, 0x09, 0x0E, 0xE3, 0x0A, 0x0E, 0xFA, 0x0B, 0x0E, 0xF1, 0x0C,
0x0E, 0xFB, 0x0D, 0x0E, 0xFB, 0x0E, 0x0E, 0xF2, 0x80, 0x00, 0x1D, 0x81, 0x00, 0x1E, 0x82, 0x00, 0x1C, 0x83,
0x14, 0xEF, 0x84, 0x80, 0xD0, 0x85, 0x0F, 0x86, 0x02, 0x87, 0x00, 0x04, 0x89, 0x00, 0x00, 0x00, 0x00, 0x8A,
0x00, 0x0E, 0x8B, 0x00, 0x00, 0x8C, 0x00, 0x07, 0x8E, 0x16, 0x26, 0x8F, 0x10, 0xAE, 0x90, 0x0F, 0xD2, 0x91,
0x0F, 0xA0, 0x92, 0x00, 0x05, 0x93, 0x0B, 0xEA, 0x94, 0x0C, 0x1C, 0x95, 0x00, 0x05, 0x96, 0x01, 0x2C, 0x97,
0x00, 0x07, 0x98, 0x00, 0x03, 0x99, 0x00, 0x05, 0x9A, 0x00, 0x05, 0x9B, 0x0C, 0xE4, 0x9C, 0x00, 0x08, 0x9D,
0x01, 0x9E, 0x00, 0x5A, 0x9F, 0x00, 0x46, 0xA0, 0x00, 0x64, 0xA1, 0x00, 0x64, 0xA2, 0x00, 0x14, 0xA3, 0x00,
0x46, 0xA4, 0x00, 0x46, 0xA5, 0xFF, 0xEC, 0xA6, 0xFF, 0xF6, 0xA7, 0xFF, 0xEC, 0xA8, 0xFF, 0xF6, 0xA9, 0x0E,
0xAA, 0x00, 0x00, 0x00, 0x0E, 0xAB, 0x01, 0xAC, 0x01, 0xAD, 0x04, 0x11, 0xAE, 0x01, 0xAF, 0x01, 0xB0, 0x00,
0x0A, 0xB1, 0x14, 0xB2, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x00, 0x00, 0x00, 0x00, 0xB3, 0x00, 0xB4, 0x49,
0x6E, 0x70, 0x75, 0x74, 0x20, 0x55, 0x73, 0xB5, 0x32, 0x31, 0x30, 0x31, 0xB6, 0x00, 0x00, 0xE2, 0x00, 0xB7,
0x48, 0x36, 0x2E, 0x58, 0x5F, 0x5F, 0x53, 0x36, 0x2E, 0x31, 0x2E, 0x33, 0x53, 0x5F, 0x5F, 0xB8, 0x00, 0xB9,
0x00, 0x00, 0x00, 0x00, 0xBA, 0x42, 0x54, 0x33, 0x30, 0x37, 0x32, 0x30, 0x32, 0x30, 0x31, 0x32, 0x30, 0x30,
0x30, 0x30, 0x32, 0x30, 0x30, 0x35, 0x32, 0x31, 0x30, 0x30, 0x31, 0xC0, 0x01,
});
// End: 0x00 0x00 0x00 0x00 0x68 0x00 0x00 0x54 0xD1

// Start: 0x4E, 0x57, 0x01, 0x18, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01
/*
this->on_jk_modbus_data(
FUNCTION_READ_ALL,
{
0x79, 0x27, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0x10, 0x34, 0x04, 0x10, 0x28, 0x05, 0x10, 0x29, 0x06,
0x10, 0x35, 0x07, 0x10, 0x2B, 0x08, 0x10, 0x2B, 0x09, 0x10, 0x35, 0x0A, 0x10, 0x35, 0x0B, 0x10, 0x35, 0x0C,
0x10, 0x3D, 0x0D, 0x10, 0x26, 0x80, 0x00, 0x1A, 0x81, 0x00, 0x18, 0x82, 0x00, 0x18, 0x83, 0x11, 0xCE, 0x84,
0x00, 0x00, 0x85, 0x00, 0x86, 0x02, 0x87, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x00, 0x0D, 0x8B,
0x00, 0x00, 0x8C, 0x00, 0x08, 0x8E, 0x15, 0x54, 0x8F, 0x0E, 0xBA, 0x90, 0x10, 0x68, 0x91, 0x10, 0x04, 0x92,
0x00, 0x05, 0x93, 0x0B, 0x54, 0x94, 0x0C, 0x80, 0x95, 0x00, 0x05, 0x96, 0x01, 0x2C, 0x97, 0x00, 0x3C, 0x98,
0x01, 0x2C, 0x99, 0x00, 0x19, 0x9A, 0x00, 0x1E, 0x9B, 0x0C, 0xE4, 0x9C, 0x00, 0x0A, 0x9D, 0x01, 0x9E, 0x00,
0x5A, 0x9F, 0x00, 0x46, 0xA0, 0x00, 0x64, 0xA1, 0x00, 0x64, 0xA2, 0x00, 0x14, 0xA3, 0x00, 0x46, 0xA4, 0x00,
0x46, 0xA5, 0xFF, 0xEC, 0xA6, 0xFF, 0xF6, 0xA7, 0xFF, 0xEC, 0xA8, 0xFF, 0xF6, 0xA9, 0x0D, 0xAA, 0x00, 0x00,
0x00, 0x05, 0xAB, 0x00, 0xAC, 0x00, 0xAD, 0x02, 0xD5, 0xAE, 0x01, 0xAF, 0x01, 0xB0, 0x00, 0x0A, 0xB1, 0x14,
0xB2, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x00, 0x00, 0x00, 0x00, 0xB3, 0x00, 0xB4, 0x49, 0x6E, 0x70, 0x75,
0x74, 0x20, 0x55, 0x73, 0xB5, 0x32, 0x31, 0x30, 0x36, 0xB6, 0x00, 0x00, 0x00, 0x00, 0xB7, 0x48, 0x37, 0x2E,
0x58, 0x5F, 0x5F, 0x53, 0x37, 0x2E, 0x31, 0x2E, 0x30, 0x48, 0x5F, 0x5F, 0xB8, 0x00, 0xB9, 0x00, 0x00, 0x00,
0x00, 0xBA, 0x42, 0x54, 0x33, 0x30, 0x37, 0x32, 0x30, 0x32, 0x30, 0x31, 0x32, 0x30, 0x30, 0x30, 0x30, 0x32,
0x30, 0x30, 0x35, 0x32, 0x31, 0x30, 0x30, 0x31, 0xC0, 0x01,
});
*/
// End: 0x00 0x00 0x00 0x00 0x68 0x00 0x00 0x47 0x28
}
}

void JkBms::track_online_status_() {
Expand Down Expand Up @@ -592,7 +544,6 @@ std::string JkBms::mode_bits_to_string_(const uint16_t mask) {
void JkBms::dump_config() { // NOLINT(google-readability-function-size,readability-function-size)
ESP_LOGCONFIG(TAG, "JkBms:");
ESP_LOGCONFIG(TAG, " Address: 0x%02X", this->address_);
ESP_LOGCONFIG(TAG, " Fake traffic enabled: %s", YESNO(this->enable_fake_traffic_));
LOG_SENSOR("", "Minimum Cell Voltage", this->min_cell_voltage_sensor_);
LOG_SENSOR("", "Maximum Cell Voltage", this->max_cell_voltage_sensor_);
LOG_SENSOR("", "Minimum Voltage Cell", this->min_voltage_cell_sensor_);
Expand Down
3 changes: 0 additions & 3 deletions components/jk_bms/jk_bms.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ class JkBms : public PollingComponent, public jk_modbus::JkModbusDevice {
total_runtime_formatted_text_sensor_ = total_runtime_formatted_text_sensor;
}

void set_enable_fake_traffic(bool enable_fake_traffic) { enable_fake_traffic_ = enable_fake_traffic; }

void dump_config() override;

void on_jk_modbus_data(const uint8_t &function, const std::vector<uint8_t> &data) override;
Expand Down Expand Up @@ -337,7 +335,6 @@ class JkBms : public PollingComponent, public jk_modbus::JkModbusDevice {
sensor::Sensor *cell_voltage_sensor_{nullptr};
} cells_[24];

bool enable_fake_traffic_;
uint8_t no_response_count_{0};

void on_status_data_(const std::vector<uint8_t> &data);
Expand Down
3 changes: 0 additions & 3 deletions components/jk_bms_ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

CONF_JK_BMS_BLE_ID = "jk_bms_ble_id"
CONF_PROTOCOL_VERSION = "protocol_version"
CONF_ENABLE_FAKE_TRAFFIC = "enable_fake_traffic"

jk_bms_ble_ns = cg.esphome_ns.namespace("jk_bms_ble")
JkBmsBle = jk_bms_ble_ns.class_(
Expand Down Expand Up @@ -40,7 +39,6 @@
cv.Optional(
CONF_THROTTLE, default="2s"
): cv.positive_time_period_milliseconds,
cv.Optional(CONF_ENABLE_FAKE_TRAFFIC, default=False): cv.boolean,
}
)
.extend(ble_client.BLE_CLIENT_SCHEMA)
Expand All @@ -53,6 +51,5 @@ async def to_code(config):
await cg.register_component(var, config)
await ble_client.register_ble_node(var, config)

cg.add(var.set_enable_fake_traffic(config[CONF_ENABLE_FAKE_TRAFFIC]))
cg.add(var.set_throttle(config[CONF_THROTTLE]))
cg.add(var.set_protocol_version(config[CONF_PROTOCOL_VERSION]))
Loading

0 comments on commit b42b40b

Please sign in to comment.