-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp_bq76_ble_i2c_read_code.txt
554 lines (445 loc) · 18.8 KB
/
esp_bq76_ble_i2c_read_code.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
/*Created by Ayush Pranav*/
#include <Wire.h>
#include <stdio.h>
#include <stdint.h>
#include "commands.h"
/* Program to send data over BLE to a mobile app from ESP32 */
// Include the necessary libraries for BLE functionality
#include "BLEDevice.h" // Main BLE library
#include "BLEUtils.h" // BLE utility functions
#include "BLEServer.h" // BLE server functions
// Define UUIDs for the BLE service and characteristic
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b" // UUID for the BLE service
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8" // UUID for the BLE characteristic
#define CELL_DATA_SERVICE_UUID "48471ebd-25bd-4e43-9052-d62cc372e1c2" //UUID for the cell data service
#define CELL_DATA_CHARACTERISTIC_UUID "194cf614-3108-4740-96c6-88bcd43541f8" //UUID for the cell data characteristic
// Pointers for the BLE server and characteristic
BLEServer *pServer = NULL; // Pointer to the BLE server
BLECharacteristic *pCharacteristic = NULL; // Pointer to the BLE characteristic
BLECharacteristic *cellDataCharacteristic = NULL; // Pointer to the cell data characteristic
// Flags to keep track of the connection status
bool deviceConnected = false; // Flag for device connection status
bool oldDeviceConnected = false; // Flag for previous connection status
// Callbacks for client connection and disconnection events
class MyServerCallbacks : public BLEServerCallbacks {
void onConnect(BLEServer *pServer) {
deviceConnected = true; // Set the flag to true when a client connects
};
void onDisconnect(BLEServer *pServer) {
deviceConnected = false; // Set the flag to false when a client disconnects
// Start advertising the BLE service
pServer->getAdvertising()->start(); // Make the server discoverable by clients
Serial.println("Waiting for a client connection to notify..."); // Print a message to the serial monitor
}
};
const int slaveAddress = 0x08; // I2C address of the slave device
byte dataByte_32[32] = { 0 };
byte cell_volt[32] = {0};
uint16_t cell_voltage[16] = {0};
uint16_t device_num = 0;
byte data_1 = 0;
byte control_reg_data[2] = {0};
uint16_t data = 0, bat_status_reg = 0, fet_status_reg = 0, stack_volt_reg = 0, pack_pin_volt_reg = 0, ld_pin_volt_reg = 0, cc2_curr_reg = 0, control_reg = 0;
/*temperature data*/
struct temp {
uint16_t internal_temp;
uint16_t cfet_off_temp;
uint16_t dfet_off_temp;
uint16_t alert_temp;
uint16_t ts1_temp;
uint16_t ts2_temp;
uint16_t ts3_temp;
uint16_t hdq_temp;
uint16_t dchg_temp;
uint16_t ddsg_temp;
} t1;
/*safety faults and permanent failure status and alerts data*/
struct safety_faults {
byte sf_alert_a;
byte sf_status_a;
byte sf_alert_b;
byte sf_status_b;
byte sf_alert_c;
byte sf_status_c;
byte pf_alert_a;
byte pf_status_a;
byte pf_alert_b;
byte pf_status_b;
byte pf_alert_c;
byte pf_status_c;
byte pf_alert_d;
byte pf_status_d;
} sf;
/*alarm data*/
struct alarm {
uint16_t alarm_status;
uint16_t alarm_raw_status;
uint16_t alarm_enable;
} a1;
/*subcommand data*/
struct sub_command {
byte manu_data[_32_BYTE_DATA];
byte dastatus1[_32_BYTE_DATA];
byte dastatus2[_32_BYTE_DATA];
byte dastatus3[_32_BYTE_DATA];
byte dastatus4[_32_BYTE_DATA];
byte dastatus5[_32_BYTE_DATA];
byte dastatus6[_32_BYTE_DATA];
byte cuv_snapshot[_32_BYTE_DATA];
byte cov_snapshot[_32_BYTE_DATA];
byte cbstatus2[_32_BYTE_DATA];
byte cbstatus3[_32_BYTE_DATA];
byte dastatus7[_16_BYTE_DATA];
byte read_cal1[_12_BYTE_DATA];
byte security_keys[_8_BYTE_DATA];
byte fw_version[_6_BYTE_DATA];
byte saved_pf_status[_5_BYTE_DATA];
byte otp_wr_check[_3_BYTE_DATA];
byte otp_write[_3_BYTE_DATA];
byte device_num[_2_BYTE_DATA];
byte hw_version[_2_BYTE_DATA];
byte irom_sig[_2_BYTE_DATA];
byte static_cfg_sig[_2_BYTE_DATA];
byte prev_macwrite[_2_BYTE_DATA];
byte drom_sig[_2_BYTE_DATA];
byte cb_active_cells[_2_BYTE_DATA];
byte mfg_status[_2_BYTE_DATA];
byte cbstatus1[_2_BYTE_DATA];
byte cal_cuv[_2_BYTE_DATA];
byte cal_cov[_2_BYTE_DATA];
} sub_cmd;
void setup() {
Wire.begin(); // Initialize the Wire library
Serial.begin(115200); // Initialize serial communication for debugging
// Initialize the BLE device with a name
BLEDevice::init("ESP32 BLE Test Ayush"); // Set the name for the BLE device
// Create and set up the BLE server
pServer = BLEDevice::createServer(); // Create a new BLE server
pServer->setCallbacks(new MyServerCallbacks()); // Set the server callbacks
// Create the BLE service
BLEService *cellDataService = pServer->createService(CELL_DATA_SERVICE_UUID); //Cell data service UUID
BLEService *pService = pServer->createService(SERVICE_UUID); // Service with the defined UUID
// Create the BLE characteristic
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ); // Set the characteristic properties
//Cell Data characteristic
cellDataCharacteristic = cellDataService->createCharacteristic(
CELL_DATA_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ); // Set the characteristic properties
// Start the BLE service
pService->start(); // Make the service available
cellDataService->start(); //
// Start advertising the BLE service
pServer->getAdvertising()->start(); // Make the server discoverable by clients
Serial.println("Waiting for a client connection to notify..."); // Print a message to the serial monitor
}
/*
to read subcommand data
actual parameters: 16bit subcommand, size of data to get
*/
void read_subcommand(uint16_t subcommand, short int size) {
// Writing lower byte of subcommand to 0x3E
Wire.beginTransmission(slaveAddress);
Wire.write(0x3E);
Wire.write(subcommand & 0xFF);
Wire.endTransmission();
// Writing upper byte of subcommand to 0x3F
Wire.beginTransmission(slaveAddress);
Wire.write(0x3F);
Wire.write((subcommand >> 8) & 0xFF);
Wire.endTransmission();
delay(2);
// Reading subcommand data
Wire.requestFrom(slaveAddress, size); // Reading size number of bytes
int i = 0;
while (Wire.available()) {
dataByte_32[i] = Wire.read();
i++;
}
delay(100);
}
/*
to read command data, data to be received is 16bit
*/
short int read_data(byte register_addr) {
Wire.beginTransmission(slaveAddress);
Wire.write(register_addr);
Wire.endTransmission();
Wire.requestFrom(slaveAddress, _2_BYTE_DATA); // Request 2 bytes from the slave
while (Wire.available()) {
byte lsb = Wire.read();
byte msb = Wire.read();
data = ((msb << 8) | lsb);
}
return data;
}
/*
to read command data, data to be received is 8bit
*/
byte read_data_1(byte register_addr) {
Wire.beginTransmission(slaveAddress);
Wire.write(register_addr);
Wire.endTransmission();
Wire.requestFrom(slaveAddress, _1_BYTE_DATA); // Request 1 bytes from the slave
while (Wire.available()) {
data_1 = Wire.read();
}
return data_1;
}
/*
to read cell voltage data,
data to be received is 16bit
actual parameters: 8bit command, num of cell
*/
void read_cell_vol(byte register_addr, short int num) {
Wire.beginTransmission(slaveAddress);
Wire.write(register_addr);
Wire.endTransmission();
Wire.requestFrom(slaveAddress, _2_BYTE_DATA); // Request 2 bytes from the slave
while (Wire.available()) {
byte lsb = Wire.read();
byte msb = Wire.read();
cell_voltage[num] = ((msb << 8) | lsb);
}
//delay(200);
}
/*
to send data over ble
actual parameters: 4 byte data to be send over ble
*/
void sendSomeDataBLE_4(uint32_t message)
{
if (deviceConnected)
{
pCharacteristic->setValue(message);
pCharacteristic->notify();
delay(100); // bluetooth stack will go into congestion, if too many packets are sent
}
}
/*
to send data over ble
actual parameters: 2 byte data to be send over ble
*/
void sendSomeDataBLE_2(uint16_t message)
{
if (deviceConnected)
{
pCharacteristic->setValue(message);
pCharacteristic->notify();
delay(100); // bluetooth stack will go into congestion, if too many packets are sent
}
}
void sendCell_volt(uint16_t message)
{
if (deviceConnected)
{
cellDataCharacteristic->setValue(message);
cellDataCharacteristic->notify();
delay(100); // bluetooth stack will go into congestion, if too many packets are sent
}
}
/*
to send data over ble
actual parameters: 1 byte data to be send over ble
*/
void sendSomeDataBLE_1(uint8_t message)
{
if (deviceConnected)
{
pCharacteristic->setValue(&message, 1);
pCharacteristic->notify();
delay(200); // bluetooth stack will go into congestion, if too many packets are sent
}
}
void loop() {
//reading individual cell voltage
short int i = 20;
for (short int j = 0; j <= 15; j++) {
read_cell_vol(i, j);
i = i + 2;
}
for (int j = 0; j <= 15; j++) {
printf("cell_volt[%d]: %.2f V\n\r", j + 1, (float)cell_voltage[j]/1000);
}
Serial.println();
/*reading battery status*/
control_reg = read_data(CONTROL_STATUS_CMD); // reading control register status
printf("control register status: %x\n\r", control_reg); // printing control register status
sf.sf_alert_a = read_data_1(SAFETY_ALERT_A_CMD); // reading safety alert a
sf.sf_status_a = read_data_1(SAFETY_STATUS_A_CMD); // reading safety status a
sf.sf_alert_b = read_data_1(SAFETY_ALERT_B_CMD); // reading safety alert b
sf.sf_status_b = read_data_1(SAFETY_STATUS_B_CMD); // reading safety status b
sf.sf_alert_c = read_data_1(SAFETY_ALERT_C_CMD); // reading safety alert c
sf.sf_status_c = read_data_1(SAFETY_STATUS_C_CMD); // reading safety status c
sf.pf_alert_a = read_data_1(PF_ALERT_A_CMD); // reading permanent failure alert a
sf.pf_status_a = read_data_1(PF_STATUS_A_CMD); // reading permanent failure status a
sf.pf_alert_b = read_data_1(PF_ALERT_B_CMD); // reading permanent failure alert b
sf.pf_status_b = read_data_1(PF_STATUS_B_CMD); // reading permanent failure status b
sf.pf_alert_c = read_data_1(PF_ALERT_C_CMD); // reading permanent failure alert c
sf.pf_status_c = read_data_1(PF_STATUS_C_CMD); // reading permanent failure status c
sf.pf_alert_d = read_data_1(PF_ALERT_D_CMD); // reading permanent failure alert d
sf.pf_status_d = read_data_1(PF_STATUS_D_CMD); // reading permanent failure status c
/*Reading voltage*/
bat_status_reg = read_data(BAT_STATUS_CMD); // reading bat status
stack_volt_reg = read_data(STACK_VOLT_CMD); //Reading stack voltage
pack_pin_volt_reg = read_data(PACK_PIN_VOLT_CMD); //Reading pack pin voltage
ld_pin_volt_reg = read_data(LD_PIN_VOLT_CMD); //Reading ld pin voltage
//////////////////////////////////////////////
cc2_curr_reg = read_data(CC2_CUR_CMD); //Reading cc2 current
/*reading alarms status*/
a1.alarm_status = read_data(ALARM_STATUS_CMD); //Reading alarm status
a1.alarm_raw_status = read_data(ALARM_RAW_STATUS_CMD); //Reading alarm raw status
a1.alarm_enable = read_data_1(ALARM_ENABLE_CMD); //Reading alarm enable
//////////////////////////////////////////////
/*Reading temperatres*/
t1.internal_temp = read_data(INTERAL_TEMP_CMD); //Reading internal temp
t1.cfet_off_temp = read_data(CFETOFF_TEMP_CMD); //Reading cfet off temp
t1.dfet_off_temp = read_data(DFETOFF_TEMP_CMD); //Reading dfet off temp
t1.alert_temp = read_data(ALERT_TEMP_CMD); //Reading alert temp
t1.ts1_temp = read_data(TS1_TEMP_STATUS); //Reading ts1 temp
t1.ts2_temp = read_data(TS2_TEMP_STATUS); //Reading ts2 temp
t1.ts3_temp = read_data(TS3_TEMP_STATUS); //Reading ts3 temp
t1.hdq_temp = read_data(HDQ_TEMP_CMD); //Reading hdq temp
t1.dchg_temp = read_data(DCHG_TEMP); //Reading dchg temp
t1.ddsg_temp = read_data(DDSG_TEMP); //Reading ddsg temp
/*fet status*/
fet_status_reg = read_data(FET_STATUS_CMD); //reading fet status
/////////////////////////////////////////////////////////
read_subcommand(FW_VERSION_SUB_CMD, _6_BYTE_DATA); //Reading fw version
for (int i = 0; i < _6_BYTE_DATA; i++) {
sub_cmd.fw_version[i] = dataByte_32[i];
}
read_subcommand(HW_VERSION_SUB_CMD, _2_BYTE_DATA); //Reading hw version
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.hw_version[i] = dataByte_32[i];
}
read_subcommand(IROM_SIG_SUB_CMD, _2_BYTE_DATA); //Reading irom sig
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.irom_sig[i] = dataByte_32[i];
}
read_subcommand(STATIC_CFG_SIG_SUB_CMD, _2_BYTE_DATA); //Reading static cfg sig
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.static_cfg_sig[i] = dataByte_32[i];
}
read_subcommand(DROM_SIG_SUB_CMD, _2_BYTE_DATA); //Reading drom sig
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.drom_sig[i] = dataByte_32[i];
}
read_subcommand(SECURITY_KEYS_SUB_CMD, _8_BYTE_DATA); //Reading security keys
for (int i = 0; i < _8_BYTE_DATA; i++) {
sub_cmd.security_keys[i] = dataByte_32[i];
}
read_subcommand(SAVED_PF_STATUS_SUB_CMD, _5_BYTE_DATA); //Reading saved pf status
for (int i = 0; i < _5_BYTE_DATA; i++) {
sub_cmd.saved_pf_status[i] = dataByte_32[i];
}
read_subcommand(MFG_STATUS_SUB_CMD, _2_BYTE_DATA); //Reading mfg status
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.mfg_status[i] = dataByte_32[i];
}
read_subcommand(MANU_DATA_SUB_CMD, _32_BYTE_DATA); //Reading manu data
for (int i = 0; i < _32_BYTE_DATA; i++) {
sub_cmd.manu_data[i] = dataByte_32[i];
}
read_subcommand(DASTATUS5_SUB_CMD, _32_BYTE_DATA); //Reading dastatus5
for (int i = 0; i < _32_BYTE_DATA; i++) {
sub_cmd.dastatus5[i] = dataByte_32[i];
}
read_subcommand(DASTATUS6_SUB_CMD, _32_BYTE_DATA); //Reading dastatus6
for (int i = 0; i < _32_BYTE_DATA; i++) {
sub_cmd.dastatus6[i] = dataByte_32[i];
}
read_subcommand(CB_ACTIVE_CELLS, _2_BYTE_DATA); //Reading cb active cells
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.cb_active_cells[i] = dataByte_32[i];
}
read_subcommand(CBSTATUS1_SUB_CMD, _2_BYTE_DATA); //Reading cbstatus1
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.cbstatus1[i] = dataByte_32[i];
}
read_subcommand(READ_CAL1_SUB_CMD, _12_BYTE_DATA); //Reading read cal1
for (int i = 0; i < _12_BYTE_DATA; i++) {
sub_cmd.read_cal1[i] = dataByte_32[i];
}
read_subcommand(CAL_CUV_SUB_CMD, _2_BYTE_DATA); //Reading cal cuv
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.cal_cuv[i] = dataByte_32[i];
}
read_subcommand(CAL_COV_SUB_CMD, _2_BYTE_DATA); //Reading cal cov
for (int i = 0; i < _2_BYTE_DATA; i++) {
sub_cmd.cal_cov[i] = dataByte_32[i];
}
//send all the data over ble to mobile app
pCharacteristic->setValue("Start");
pCharacteristic->notify();
//delay(500);
for (int i = 0; i < 16; i++) {
sendCell_volt(cell_voltage[i]);
delay(200); //, sizeof(cell_volt));//sending cell voltage over ble
}
sendSomeDataBLE_2(control_reg); //sending control reg status over ble
sendSomeDataBLE_1((uint8_t)sf.sf_alert_a);
sendSomeDataBLE_1((uint8_t)sf.sf_status_a);
sendSomeDataBLE_1((uint8_t)sf.sf_alert_b);
sendSomeDataBLE_1((uint8_t)sf.sf_status_b);
sendSomeDataBLE_1((uint8_t)sf.sf_alert_c);
sendSomeDataBLE_1((uint8_t)sf.sf_status_c);
sendSomeDataBLE_1((uint8_t)sf.pf_alert_a);
sendSomeDataBLE_1((uint8_t)sf.pf_status_a);
sendSomeDataBLE_1((uint8_t)sf.pf_alert_b);
sendSomeDataBLE_1((uint8_t)sf.pf_status_b);
sendSomeDataBLE_1((uint8_t)sf.pf_alert_c);
sendSomeDataBLE_1((uint8_t)sf.pf_status_c);
sendSomeDataBLE_1((uint8_t)sf.pf_alert_d);
sendSomeDataBLE_1((uint8_t)sf.pf_status_d);
sendSomeDataBLE_2(bat_status_reg);
sendSomeDataBLE_2(stack_volt_reg);
sendSomeDataBLE_2(pack_pin_volt_reg);
sendSomeDataBLE_2(ld_pin_volt_reg);
sendSomeDataBLE_2(cc2_curr_reg);
sendSomeDataBLE_2(a1.alarm_status);
sendSomeDataBLE_2(a1.alarm_raw_status);
sendSomeDataBLE_1(a1.alarm_enable);
sendSomeDataBLE_2(t1.internal_temp);
sendSomeDataBLE_2(t1.cfet_off_temp);
sendSomeDataBLE_2(t1.dfet_off_temp);
sendSomeDataBLE_2(t1.alert_temp);
sendSomeDataBLE_2(t1.ts2_temp);
sendSomeDataBLE_2(t1.ts3_temp);
sendSomeDataBLE_2(t1.hdq_temp);
sendSomeDataBLE_2(t1.dchg_temp);
sendSomeDataBLE_2(t1.ddsg_temp);
sendSomeDataBLE_2(fet_status_reg);
sendSomeDataBLE_2(((sub_cmd.fw_version[0] << 8) | sub_cmd.fw_version[1]));
sendSomeDataBLE_2(((sub_cmd.fw_version[2] << 8) | sub_cmd.fw_version[3]));
sendSomeDataBLE_2(((sub_cmd.fw_version[4] << 8) | sub_cmd.fw_version[5]));
sendSomeDataBLE_2(((sub_cmd.hw_version[1] << 8) | sub_cmd.hw_version[0]));
sendSomeDataBLE_2((sub_cmd.irom_sig[1] << 8) | sub_cmd.irom_sig[0]);
sendSomeDataBLE_2((sub_cmd.static_cfg_sig[1] << 8) | sub_cmd.static_cfg_sig[0]);
sendSomeDataBLE_2((sub_cmd.drom_sig[1] << 8) | sub_cmd.drom_sig[0]);
for (int i = 0; i < _5_BYTE_DATA; i++) {
sendSomeDataBLE_1(sub_cmd.saved_pf_status[i]);
}
sendSomeDataBLE_2(((sub_cmd.mfg_status[1] << 8) | sub_cmd.mfg_status[0]));
for (int i = 0; i < _32_BYTE_DATA; i++) {
sendSomeDataBLE_1(sub_cmd.manu_data[i]);
}
sendSomeDataBLE_2(((sub_cmd.dastatus5[11] << 8) | sub_cmd.dastatus5[10]));
sendSomeDataBLE_2(((sub_cmd.dastatus5[13] << 8) | sub_cmd.dastatus5[12]));
sendSomeDataBLE_2(((sub_cmd.dastatus5[21] << 8) | sub_cmd.dastatus5[20]));
sendSomeDataBLE_2(((sub_cmd.dastatus5[23] << 8) | sub_cmd.dastatus5[22]));
sendSomeDataBLE_2((sub_cmd.dastatus6[0] | sub_cmd.dastatus6[1] << 8));
sendSomeDataBLE_4((sub_cmd.dastatus6[8] | sub_cmd.dastatus6[9] << 8 | sub_cmd.dastatus6[10] << 16 | sub_cmd.dastatus6[11] << 24));
sendSomeDataBLE_2(((sub_cmd.cb_active_cells[1] << 8) | sub_cmd.cb_active_cells[0]));
sendSomeDataBLE_2(((sub_cmd.cbstatus1[1] << 8) | sub_cmd.cbstatus1[0]));
sendSomeDataBLE_2(((sub_cmd.read_cal1[1] << 8) | sub_cmd.read_cal1[0]));
sendSomeDataBLE_2(((sub_cmd.read_cal1[2]) | (sub_cmd.read_cal1[3] << 8) | (sub_cmd.read_cal1[4] << 16) | (sub_cmd.read_cal1[5] << 24)));
sendSomeDataBLE_2(((sub_cmd.read_cal1[7] << 8) | sub_cmd.read_cal1[6]));
sendSomeDataBLE_2(((sub_cmd.read_cal1[9] << 8) | sub_cmd.read_cal1[8]));
sendSomeDataBLE_2(((sub_cmd.read_cal1[11] << 8) | sub_cmd.read_cal1[10]));
sendSomeDataBLE_2(((sub_cmd.cal_cuv[1] << 8) | sub_cmd.cal_cuv[0]));
sendSomeDataBLE_2(((sub_cmd.cal_cov[1] << 8) | sub_cmd.cal_cov[0]));
pCharacteristic->setValue("End");
pCharacteristic->notify();
}