@@ -92,7 +92,6 @@ uint8_t checksum_xor(const uint8_t data[], const uint16_t len) {
92
92
93
93
void HeltecBalancerBle::dump_config () { // NOLINT(google-readability-function-size,readability-function-size)
94
94
ESP_LOGCONFIG (TAG, " HeltecBalancerBle" );
95
- ESP_LOGCONFIG (TAG, " Fake traffic enabled: %s" , YESNO (this ->enable_fake_traffic_ ));
96
95
LOG_SENSOR (" " , " Minimum Cell Voltage" , this ->min_cell_voltage_sensor_ );
97
96
LOG_SENSOR (" " , " Maximum Cell Voltage" , this ->max_cell_voltage_sensor_ );
98
97
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
196
195
if (param->notify .handle != this ->char_handle_ )
197
196
break ;
198
197
199
- this ->assemble_ (param->notify .value , param->notify .value_len );
198
+ this ->assemble (param->notify .value , param->notify .value_len );
200
199
201
200
break ;
202
201
}
@@ -206,90 +205,6 @@ void HeltecBalancerBle::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt
206
205
}
207
206
208
207
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
-
293
208
this ->track_online_status_ ();
294
209
if (this ->node_state != espbt::ClientState::ESTABLISHED) {
295
210
ESP_LOGW (TAG, " [%s] Not connected" , this ->parent_ ->address_str ().c_str ());
@@ -303,7 +218,7 @@ void HeltecBalancerBle::update() {
303
218
}
304
219
305
220
// 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) {
307
222
if (this ->frame_buffer_ .size () > MAX_RESPONSE_SIZE) {
308
223
ESP_LOGW (TAG, " Frame dropped because of invalid length" );
309
224
this ->frame_buffer_ .clear ();
0 commit comments