Skip to content

Commit a2347f8

Browse files
authored
Separate fake traffic (syssi#429)
1 parent 0f2c8bf commit a2347f8

17 files changed

+394
-319
lines changed

.github/workflows/ci.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ jobs:
199199
esphome -s external_components_source components config esp32-ble-example-multiple-devices.yaml
200200
esphome -s external_components_source components config esp32-ble-uart-hybrid-example.yaml
201201
esphome -s external_components_source components config esp32-ble-v11-example.yaml
202+
esphome -s external_components_source components config esp32-ble-v11-example-debug.yaml
203+
esphome -s external_components_source components config esp32-ble-v11-example-faker.yaml
202204
203205
- name: Write yaml-snippets/secrets.yaml
204206
shell: bash
@@ -262,4 +264,4 @@ jobs:
262264
- name: Compile esp32 (jk_bms_ble) example configurations
263265
run: |
264266
esphome -s external_components_source components compile esp32-ble-example-faker.yaml
265-
esphome -s external_components_source components compile esp32-ble-v11-example.yaml
267+
esphome -s external_components_source components compile esp32-ble-v11-example-faker.yaml

components/heltec_balancer_ble/__init__.py

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
MULTI_CONF = True
1010

1111
CONF_HELTEC_BALANCER_BLE_ID = "heltec_balancer_ble_id"
12-
CONF_ENABLE_FAKE_TRAFFIC = "enable_fake_traffic"
1312

1413
heltec_balancer_ble_ns = cg.esphome_ns.namespace("heltec_balancer_ble")
1514
HeltecBalancerBle = heltec_balancer_ble_ns.class_(
@@ -29,7 +28,6 @@
2928
cv.Optional(
3029
CONF_THROTTLE, default="2s"
3130
): cv.positive_time_period_milliseconds,
32-
cv.Optional(CONF_ENABLE_FAKE_TRAFFIC, default=False): cv.boolean,
3331
}
3432
)
3533
.extend(ble_client.BLE_CLIENT_SCHEMA)
@@ -42,5 +40,4 @@ async def to_code(config):
4240
await cg.register_component(var, config)
4341
await ble_client.register_ble_node(var, config)
4442

45-
cg.add(var.set_enable_fake_traffic(config[CONF_ENABLE_FAKE_TRAFFIC]))
4643
cg.add(var.set_throttle(config[CONF_THROTTLE]))

components/heltec_balancer_ble/heltec_balancer_ble.cpp

+2-87
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ uint8_t checksum_xor(const uint8_t data[], const uint16_t len) {
9292

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

199-
this->assemble_(param->notify.value, param->notify.value_len);
198+
this->assemble(param->notify.value, param->notify.value_len);
200199

201200
break;
202201
}
@@ -206,90 +205,6 @@ void HeltecBalancerBle::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt
206205
}
207206

208207
void HeltecBalancerBle::update() {
209-
if (this->enable_fake_traffic_) {
210-
// Device info frame (0x01)
211-
const uint8_t device_info_frame[100] = {
212-
0x55, 0xAA, 0x11, 0x01, 0x01, 0x00, 0x64, 0x00, 0x47, 0x57, 0x2D, 0x32, 0x34, 0x53, 0x34, 0x45, 0x42,
213-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x57, 0x2D, 0x32, 0x2E, 0x38, 0x2E, 0x30, 0x5A, 0x48,
214-
0x2D, 0x31, 0x2E, 0x32, 0x2E, 0x33, 0x56, 0x31, 0x2E, 0x30, 0x2E, 0x30, 0x00, 0x00, 0x32, 0x30, 0x32,
215-
0x32, 0x30, 0x35, 0x33, 0x31, 0x05, 0x00, 0x00, 0x00, 0x01, 0x91, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00,
216-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
217-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xFF};
218-
this->assemble_(device_info_frame, 100);
219-
220-
// Cell info frame (0x02)
221-
const uint8_t cell_info_frame[300] = {
222-
0x55, 0xaa, 0x11, 0x01, 0x02, 0x00, 0x2c, 0x01, 0x38, 0xe7, 0xfa, 0x50, 0x40, 0xb6, 0x04, 0x51, 0x40, 0x85,
223-
0x0e, 0x51, 0x40, 0xf0, 0x05, 0x51, 0x40, 0xb6, 0x04, 0x51, 0x40, 0x75, 0x1e, 0x51, 0x40, 0x7f, 0x4f, 0x51,
224-
0x40, 0x43, 0x02, 0x51, 0x40, 0x1c, 0x3d, 0x51, 0x40, 0x78, 0x6a, 0x51, 0x40, 0xfe, 0x82, 0x51, 0x40, 0x16,
225-
0x7e, 0x51, 0x40, 0xbc, 0x76, 0x51, 0x40, 0x16, 0x7e, 0x51, 0x40, 0x8b, 0x80, 0x51, 0x40, 0xca, 0x66, 0x51,
226-
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
227-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x93, 0x24,
228-
0x3e, 0x68, 0x94, 0x26, 0x3e, 0x3d, 0x25, 0x1b, 0x3e, 0x90, 0x8e, 0x1b, 0x3e, 0xb3, 0xf3, 0x23, 0x3e, 0x2e,
229-
0x91, 0x25, 0x3e, 0xc6, 0x1b, 0x1a, 0x3e, 0x4a, 0x7c, 0x1c, 0x3e, 0x6f, 0x1b, 0x1a, 0x3e, 0xc2, 0x43, 0x1b,
230-
0x3e, 0x85, 0x1e, 0x18, 0x3e, 0x4b, 0x27, 0x19, 0x3e, 0x5e, 0xdf, 0x18, 0x3e, 0xd0, 0xeb, 0x1a, 0x3e, 0xe6,
231-
0xd4, 0x18, 0x3e, 0x0c, 0xfe, 0x18, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
233-
0x00, 0x00, 0x00, 0xde, 0x40, 0x51, 0x42, 0xde, 0x40, 0x51, 0x40, 0x00, 0x17, 0x08, 0x3c, 0x0a, 0x00, 0x0f,
234-
0x05, 0x19, 0xa1, 0x82, 0xc0, 0xc3, 0xf5, 0x48, 0x42, 0xc3, 0xf5, 0x48, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00,
235-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
236-
0x00, 0x00, 0x76, 0x2e, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
237-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
238-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0xff};
239-
this->assemble_(cell_info_frame, 300);
240-
241-
const uint8_t cell_info_frame2[300] = {
242-
0x55, 0xaa, 0x11, 0x01, 0x02, 0x00, 0x2c, 0x01, 0x39, 0xe7, 0xfa, 0x50, 0x40, 0xb6, 0x04, 0x51, 0x40, 0x85,
243-
0x0e, 0x51, 0x40, 0xf0, 0x05, 0x51, 0x40, 0xb6, 0x04, 0x51, 0x40, 0x75, 0x1e, 0x51, 0x40, 0x7f, 0x4f, 0x51,
244-
0x40, 0x43, 0x02, 0x51, 0x40, 0x1c, 0x3d, 0x51, 0x40, 0x78, 0x6a, 0x51, 0x40, 0xfe, 0x82, 0x51, 0x40, 0x16,
245-
0x7e, 0x51, 0x40, 0xbc, 0x76, 0x51, 0x40, 0x16, 0x7e, 0x51, 0x40, 0x8b, 0x80, 0x51, 0x40, 0xca, 0x66, 0x51,
246-
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
247-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x93, 0x24,
248-
0x3e, 0x68, 0x94, 0x26, 0x3e, 0x3d, 0x25, 0x1b, 0x3e, 0x90, 0x8e, 0x1b, 0x3e, 0xb3, 0xf3, 0x23, 0x3e, 0x2e,
249-
0x91, 0x25, 0x3e, 0xc6, 0x1b, 0x1a, 0x3e, 0x4a, 0x7c, 0x1c, 0x3e, 0x6f, 0x1b, 0x1a, 0x3e, 0xc2, 0x43, 0x1b,
250-
0x3e, 0x85, 0x1e, 0x18, 0x3e, 0x4b, 0x27, 0x19, 0x3e, 0x5e, 0xdf, 0x18, 0x3e, 0xd0, 0xeb, 0x1a, 0x3e, 0xe6,
251-
0xd4, 0x18, 0x3e, 0x0c, 0xfe, 0x18, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
253-
0x00, 0x00, 0x00, 0xde, 0x40, 0x51, 0x42, 0xde, 0x40, 0x51, 0x40, 0x00, 0x17, 0x08, 0x3c, 0x0a, 0x00, 0x0f,
254-
0x05, 0x19, 0xa1, 0x82, 0xc0, 0xc3, 0xf5, 0x48, 0x42, 0xc3, 0xf5, 0x48, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00,
255-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
256-
0x00, 0x00, 0x77, 0x2e, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
258-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xff};
259-
this->assemble_(cell_info_frame2, 300);
260-
261-
// Factory defaults (0x03)
262-
const uint8_t factory_defaults_frame[100] = {
263-
0x55, 0xAA, 0x11, 0x01, 0x03, 0x00, 0x64, 0x00, 0x7B, 0xD2, 0xBF, 0x3F, 0x35, 0xCC, 0xBF, 0x3F, 0x51,
264-
0x82, 0x54, 0x40, 0x33, 0x33, 0x73, 0x40, 0xAA, 0xC0, 0xDB, 0x3F, 0x7B, 0xE1, 0xDB, 0x3F, 0x61, 0xD6,
265-
0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x33, 0x33, 0xD3, 0x3F, 0x5C, 0x8F, 0xD2,
266-
0x3F, 0x48, 0xE1, 0xBA, 0x3F, 0x00, 0x00, 0xAA, 0x42, 0x00, 0x00, 0x82, 0x42, 0x08, 0x00, 0x00, 0x00,
267-
0xF6, 0xE1, 0x0B, 0x00, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35, 0x33, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
268-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF};
269-
this->assemble_(factory_defaults_frame, 100);
270-
271-
const uint8_t factory_defaults_frame2[100] = {
272-
0x55, 0xAA, 0x11, 0x01, 0x03, 0x00, 0x64, 0x00, 0x75, 0xD5, 0xBF, 0x3F, 0x35, 0xCC, 0xBF, 0x3F, 0x17,
273-
0x81, 0x54, 0x40, 0x33, 0x33, 0x73, 0x40, 0x74, 0xB6, 0xDB, 0x3F, 0x7B, 0xE1, 0xDB, 0x3F, 0x62, 0xD0,
274-
0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x33, 0x33, 0xD3, 0x3F, 0x5C, 0x8F, 0xD2,
275-
0x3F, 0x48, 0xE1, 0xBA, 0x3F, 0x00, 0x00, 0xAA, 0x42, 0x00, 0x00, 0x82, 0x42, 0x08, 0x00, 0x00, 0x00,
276-
0xF6, 0xE1, 0x0B, 0x00, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35, 0x33, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
277-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9D, 0xFF};
278-
this->assemble_(factory_defaults_frame2, 100);
279-
280-
// Settings frame (0x04)
281-
const uint8_t settings_frame[100] = {
282-
0x55, 0xaa, 0x11, 0x01, 0x04, 0x00, 0x64, 0x00, 0x10, 0x0a, 0xd7, 0xa3, 0x3b, 0x00, 0x00, 0x80, 0x40,
283-
0x00, 0x00, 0x20, 0x40, 0x01, 0x01, 0x02, 0x18, 0x01, 0x00, 0x00, 0x66, 0x66, 0x26, 0x40, 0x00, 0x00,
284-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
286-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
287-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0xff};
288-
this->assemble_(settings_frame, 100);
289-
290-
return;
291-
}
292-
293208
this->track_online_status_();
294209
if (this->node_state != espbt::ClientState::ESTABLISHED) {
295210
ESP_LOGW(TAG, "[%s] Not connected", this->parent_->address_str().c_str());
@@ -303,7 +218,7 @@ void HeltecBalancerBle::update() {
303218
}
304219

305220
// TODO: There is no need to assemble frames if the MTU can be increased to > MAX_RESPONSE_SIZE
306-
void HeltecBalancerBle::assemble_(const uint8_t *data, uint16_t length) {
221+
void HeltecBalancerBle::assemble(const uint8_t *data, uint16_t length) {
307222
if (this->frame_buffer_.size() > MAX_RESPONSE_SIZE) {
308223
ESP_LOGW(TAG, "Frame dropped because of invalid length");
309224
this->frame_buffer_.clear();

components/heltec_balancer_ble/heltec_balancer_ble.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ class HeltecBalancerBle : public esphome::ble_client::BLEClientNode, public Poll
131131
}
132132

133133
void set_balancer_switch(switch_::Switch *balancer_switch) { balancer_switch_ = balancer_switch; }
134-
135-
void set_enable_fake_traffic(bool enable_fake_traffic) { enable_fake_traffic_ = enable_fake_traffic; }
134+
void assemble(const uint8_t *data, uint16_t length);
136135
bool send_command(uint8_t function, uint8_t command, uint8_t register_address = 0x00, uint32_t value = 0x00000000);
137136

138137
struct Cell {
@@ -182,13 +181,11 @@ class HeltecBalancerBle : public esphome::ble_client::BLEClientNode, public Poll
182181

183182
std::vector<uint8_t> frame_buffer_;
184183
bool status_notification_received_ = false;
185-
bool enable_fake_traffic_;
186184
uint8_t no_response_count_{0};
187185
uint16_t char_handle_;
188186
uint32_t last_cell_info_{0};
189187
uint32_t throttle_;
190188

191-
void assemble_(const uint8_t *data, uint16_t length);
192189
void decode_(const std::vector<uint8_t> &data);
193190
void decode_device_info_(const std::vector<uint8_t> &data);
194191
void decode_cell_info_(const std::vector<uint8_t> &data);

components/jk_bms/__init__.py

-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
MULTI_CONF = True
99

1010
CONF_JK_BMS_ID = "jk_bms_id"
11-
CONF_ENABLE_FAKE_TRAFFIC = "enable_fake_traffic"
1211

1312
jk_bms_ns = cg.esphome_ns.namespace("jk_bms")
1413
JkBms = jk_bms_ns.class_("JkBms", cg.PollingComponent, jk_modbus.JkModbusDevice)
@@ -17,7 +16,6 @@
1716
cv.Schema(
1817
{
1918
cv.GenerateID(): cv.declare_id(JkBms),
20-
cv.Optional(CONF_ENABLE_FAKE_TRAFFIC, default=False): cv.boolean,
2119
}
2220
)
2321
.extend(cv.polling_component_schema("5s"))
@@ -35,5 +33,3 @@ async def to_code(config):
3533
var = cg.new_Pvariable(config[CONF_ID])
3634
await cg.register_component(var, config)
3735
await jk_modbus.register_jk_modbus_device(var, config)
38-
39-
cg.add(var.set_enable_fake_traffic(config[CONF_ENABLE_FAKE_TRAFFIC]))

components/jk_bms/jk_bms.cpp

-49
Original file line numberDiff line numberDiff line change
@@ -385,54 +385,6 @@ void JkBms::on_status_data_(const std::vector<uint8_t> &data) {
385385
void JkBms::update() {
386386
this->track_online_status_();
387387
this->read_registers();
388-
389-
if (this->enable_fake_traffic_) {
390-
// Start: 0x4E, 0x57, 0x01, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01
391-
this->on_jk_modbus_data(
392-
FUNCTION_READ_ALL,
393-
{
394-
0x79, 0x2A, 0x01, 0x0E, 0xED, 0x02, 0x0E, 0xFA, 0x03, 0x0E, 0xF7, 0x04, 0x0E, 0xEC, 0x05, 0x0E, 0xF8, 0x06,
395-
0x0E, 0xFA, 0x07, 0x0E, 0xF1, 0x08, 0x0E, 0xF8, 0x09, 0x0E, 0xE3, 0x0A, 0x0E, 0xFA, 0x0B, 0x0E, 0xF1, 0x0C,
396-
0x0E, 0xFB, 0x0D, 0x0E, 0xFB, 0x0E, 0x0E, 0xF2, 0x80, 0x00, 0x1D, 0x81, 0x00, 0x1E, 0x82, 0x00, 0x1C, 0x83,
397-
0x14, 0xEF, 0x84, 0x80, 0xD0, 0x85, 0x0F, 0x86, 0x02, 0x87, 0x00, 0x04, 0x89, 0x00, 0x00, 0x00, 0x00, 0x8A,
398-
0x00, 0x0E, 0x8B, 0x00, 0x00, 0x8C, 0x00, 0x07, 0x8E, 0x16, 0x26, 0x8F, 0x10, 0xAE, 0x90, 0x0F, 0xD2, 0x91,
399-
0x0F, 0xA0, 0x92, 0x00, 0x05, 0x93, 0x0B, 0xEA, 0x94, 0x0C, 0x1C, 0x95, 0x00, 0x05, 0x96, 0x01, 0x2C, 0x97,
400-
0x00, 0x07, 0x98, 0x00, 0x03, 0x99, 0x00, 0x05, 0x9A, 0x00, 0x05, 0x9B, 0x0C, 0xE4, 0x9C, 0x00, 0x08, 0x9D,
401-
0x01, 0x9E, 0x00, 0x5A, 0x9F, 0x00, 0x46, 0xA0, 0x00, 0x64, 0xA1, 0x00, 0x64, 0xA2, 0x00, 0x14, 0xA3, 0x00,
402-
0x46, 0xA4, 0x00, 0x46, 0xA5, 0xFF, 0xEC, 0xA6, 0xFF, 0xF6, 0xA7, 0xFF, 0xEC, 0xA8, 0xFF, 0xF6, 0xA9, 0x0E,
403-
0xAA, 0x00, 0x00, 0x00, 0x0E, 0xAB, 0x01, 0xAC, 0x01, 0xAD, 0x04, 0x11, 0xAE, 0x01, 0xAF, 0x01, 0xB0, 0x00,
404-
0x0A, 0xB1, 0x14, 0xB2, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x00, 0x00, 0x00, 0x00, 0xB3, 0x00, 0xB4, 0x49,
405-
0x6E, 0x70, 0x75, 0x74, 0x20, 0x55, 0x73, 0xB5, 0x32, 0x31, 0x30, 0x31, 0xB6, 0x00, 0x00, 0xE2, 0x00, 0xB7,
406-
0x48, 0x36, 0x2E, 0x58, 0x5F, 0x5F, 0x53, 0x36, 0x2E, 0x31, 0x2E, 0x33, 0x53, 0x5F, 0x5F, 0xB8, 0x00, 0xB9,
407-
0x00, 0x00, 0x00, 0x00, 0xBA, 0x42, 0x54, 0x33, 0x30, 0x37, 0x32, 0x30, 0x32, 0x30, 0x31, 0x32, 0x30, 0x30,
408-
0x30, 0x30, 0x32, 0x30, 0x30, 0x35, 0x32, 0x31, 0x30, 0x30, 0x31, 0xC0, 0x01,
409-
});
410-
// End: 0x00 0x00 0x00 0x00 0x68 0x00 0x00 0x54 0xD1
411-
412-
// Start: 0x4E, 0x57, 0x01, 0x18, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01
413-
/*
414-
this->on_jk_modbus_data(
415-
FUNCTION_READ_ALL,
416-
{
417-
0x79, 0x27, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0x10, 0x34, 0x04, 0x10, 0x28, 0x05, 0x10, 0x29, 0x06,
418-
0x10, 0x35, 0x07, 0x10, 0x2B, 0x08, 0x10, 0x2B, 0x09, 0x10, 0x35, 0x0A, 0x10, 0x35, 0x0B, 0x10, 0x35, 0x0C,
419-
0x10, 0x3D, 0x0D, 0x10, 0x26, 0x80, 0x00, 0x1A, 0x81, 0x00, 0x18, 0x82, 0x00, 0x18, 0x83, 0x11, 0xCE, 0x84,
420-
0x00, 0x00, 0x85, 0x00, 0x86, 0x02, 0x87, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x00, 0x0D, 0x8B,
421-
0x00, 0x00, 0x8C, 0x00, 0x08, 0x8E, 0x15, 0x54, 0x8F, 0x0E, 0xBA, 0x90, 0x10, 0x68, 0x91, 0x10, 0x04, 0x92,
422-
0x00, 0x05, 0x93, 0x0B, 0x54, 0x94, 0x0C, 0x80, 0x95, 0x00, 0x05, 0x96, 0x01, 0x2C, 0x97, 0x00, 0x3C, 0x98,
423-
0x01, 0x2C, 0x99, 0x00, 0x19, 0x9A, 0x00, 0x1E, 0x9B, 0x0C, 0xE4, 0x9C, 0x00, 0x0A, 0x9D, 0x01, 0x9E, 0x00,
424-
0x5A, 0x9F, 0x00, 0x46, 0xA0, 0x00, 0x64, 0xA1, 0x00, 0x64, 0xA2, 0x00, 0x14, 0xA3, 0x00, 0x46, 0xA4, 0x00,
425-
0x46, 0xA5, 0xFF, 0xEC, 0xA6, 0xFF, 0xF6, 0xA7, 0xFF, 0xEC, 0xA8, 0xFF, 0xF6, 0xA9, 0x0D, 0xAA, 0x00, 0x00,
426-
0x00, 0x05, 0xAB, 0x00, 0xAC, 0x00, 0xAD, 0x02, 0xD5, 0xAE, 0x01, 0xAF, 0x01, 0xB0, 0x00, 0x0A, 0xB1, 0x14,
427-
0xB2, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x00, 0x00, 0x00, 0x00, 0xB3, 0x00, 0xB4, 0x49, 0x6E, 0x70, 0x75,
428-
0x74, 0x20, 0x55, 0x73, 0xB5, 0x32, 0x31, 0x30, 0x36, 0xB6, 0x00, 0x00, 0x00, 0x00, 0xB7, 0x48, 0x37, 0x2E,
429-
0x58, 0x5F, 0x5F, 0x53, 0x37, 0x2E, 0x31, 0x2E, 0x30, 0x48, 0x5F, 0x5F, 0xB8, 0x00, 0xB9, 0x00, 0x00, 0x00,
430-
0x00, 0xBA, 0x42, 0x54, 0x33, 0x30, 0x37, 0x32, 0x30, 0x32, 0x30, 0x31, 0x32, 0x30, 0x30, 0x30, 0x30, 0x32,
431-
0x30, 0x30, 0x35, 0x32, 0x31, 0x30, 0x30, 0x31, 0xC0, 0x01,
432-
});
433-
*/
434-
// End: 0x00 0x00 0x00 0x00 0x68 0x00 0x00 0x47 0x28
435-
}
436388
}
437389

438390
void JkBms::track_online_status_() {
@@ -592,7 +544,6 @@ std::string JkBms::mode_bits_to_string_(const uint16_t mask) {
592544
void JkBms::dump_config() { // NOLINT(google-readability-function-size,readability-function-size)
593545
ESP_LOGCONFIG(TAG, "JkBms:");
594546
ESP_LOGCONFIG(TAG, " Address: 0x%02X", this->address_);
595-
ESP_LOGCONFIG(TAG, " Fake traffic enabled: %s", YESNO(this->enable_fake_traffic_));
596547
LOG_SENSOR("", "Minimum Cell Voltage", this->min_cell_voltage_sensor_);
597548
LOG_SENSOR("", "Maximum Cell Voltage", this->max_cell_voltage_sensor_);
598549
LOG_SENSOR("", "Minimum Voltage Cell", this->min_voltage_cell_sensor_);

components/jk_bms/jk_bms.h

-3
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ class JkBms : public PollingComponent, public jk_modbus::JkModbusDevice {
240240
total_runtime_formatted_text_sensor_ = total_runtime_formatted_text_sensor;
241241
}
242242

243-
void set_enable_fake_traffic(bool enable_fake_traffic) { enable_fake_traffic_ = enable_fake_traffic; }
244-
245243
void dump_config() override;
246244

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

340-
bool enable_fake_traffic_;
341338
uint8_t no_response_count_{0};
342339

343340
void on_status_data_(const std::vector<uint8_t> &data);

components/jk_bms_ble/__init__.py

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
CONF_JK_BMS_BLE_ID = "jk_bms_ble_id"
1212
CONF_PROTOCOL_VERSION = "protocol_version"
13-
CONF_ENABLE_FAKE_TRAFFIC = "enable_fake_traffic"
1413

1514
jk_bms_ble_ns = cg.esphome_ns.namespace("jk_bms_ble")
1615
JkBmsBle = jk_bms_ble_ns.class_(
@@ -40,7 +39,6 @@
4039
cv.Optional(
4140
CONF_THROTTLE, default="2s"
4241
): cv.positive_time_period_milliseconds,
43-
cv.Optional(CONF_ENABLE_FAKE_TRAFFIC, default=False): cv.boolean,
4442
}
4543
)
4644
.extend(ble_client.BLE_CLIENT_SCHEMA)
@@ -53,6 +51,5 @@ async def to_code(config):
5351
await cg.register_component(var, config)
5452
await ble_client.register_ble_node(var, config)
5553

56-
cg.add(var.set_enable_fake_traffic(config[CONF_ENABLE_FAKE_TRAFFIC]))
5754
cg.add(var.set_throttle(config[CONF_THROTTLE]))
5855
cg.add(var.set_protocol_version(config[CONF_PROTOCOL_VERSION]))

0 commit comments

Comments
 (0)