fix n tidy
This commit is contained in:
parent
3e6460b820
commit
52a62e0851
26
ESPBMS.ino
26
ESPBMS.ino
@ -120,22 +120,23 @@ void loop() {
|
||||
strncpy(currentName, deviceName.c_str(), sizeof(currentName) - 1);
|
||||
currentName[sizeof(currentName) - 1] = '\0'; // Ensure null-termination
|
||||
|
||||
while(gotBasicInfo==false || gotCellInfo==false){
|
||||
unsigned long start=millis();
|
||||
while( millis()-start<10000 && (gotBasicInfo==false || gotCellInfo==false) ){
|
||||
// REQUEST BASIC INFO
|
||||
// header status command length data checksum footer
|
||||
// DD A5 03 00 FF FD 77
|
||||
if(gotBasicInfo==false){
|
||||
delay(500);
|
||||
// header status command length data checksum footer
|
||||
// DD A5 03 00 FF FD 77
|
||||
uint8_t a_data[7] = {0xdd, 0xa5, 3, 0x0, 0xff, 0xfd, 0x77};
|
||||
pRemoteCharacteristic_tx->writeValue(a_data, sizeof(a_data), false);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// REQUEST CELL INFO
|
||||
// header status command length data checksum footer
|
||||
// DD A5 03 00 FF FD 77
|
||||
if(gotCellInfo==false){
|
||||
delay(500);
|
||||
// header status command length data checksum footer
|
||||
// DD A5 03 00 FF FD 77
|
||||
uint8_t b_data[7] = {0xdd, 0xa5, 4, 0x0, 0xff, 0xfc, 0x77};
|
||||
pRemoteCharacteristic_tx->writeValue(b_data, sizeof(b_data), false);
|
||||
delay(500);
|
||||
@ -290,16 +291,17 @@ bool processBasicInfo(byte *data, unsigned int dataLen){
|
||||
uint16_t BalanceCodeHigh = (two_ints_into16(data[14], data[15]));
|
||||
uint8_t MosfetStatus = ((byte)data[20]);
|
||||
|
||||
Serial.printf("%s Total voltage: %f\r\n",currentName, (float)Volts / 1000);
|
||||
Serial.printf("%s Voltage: %f\r\n",currentName, (float)Volts / 1000);
|
||||
Serial.printf("%s Amps: %f\r\n",currentName, (float)Amps / 1000);
|
||||
Serial.printf("%s Capacity Remain Ah: %f\r\n",currentName, (float)CapacityRemainAh / 1000);
|
||||
Serial.printf("%s Capacity Remain Percent: %d\r\n",currentName, CapacityRemainPercent);
|
||||
Serial.printf("%s Temp1: %f\r\n",currentName, (float)Temp1 / 10);
|
||||
Serial.printf("%s Temp2: %f\r\n",currentName, (float)Temp2 / 10);
|
||||
/*
|
||||
Serial.printf("%s Balance Code Low: 0x%x\r\n",currentName, BalanceCodeLow);
|
||||
Serial.printf("%s Balance Code High: 0x%x\r\n",currentName, BalanceCodeHigh);
|
||||
Serial.printf("%s Mosfet Status: 0x%x\r\n",currentName, MosfetStatus);
|
||||
|
||||
*/
|
||||
gotBasicInfo=true;
|
||||
|
||||
return true;
|
||||
@ -328,13 +330,13 @@ bool processCellInfo(byte *data, unsigned int dataLen)
|
||||
_cellMin = CellVolt;
|
||||
}
|
||||
|
||||
Serial.printf("%s Cell %d volt: %f\r\n",currentName, i,(float)CellVolt/1000);
|
||||
Serial.printf("%s Cell %d Voltage: %f\r\n",currentName, i,(float)CellVolt/1000);
|
||||
}
|
||||
|
||||
Serial.printf("%s Max cell volt: %f\r\n",currentName, (float)_cellMax / 1000);
|
||||
Serial.printf("%s Min cell volt: %f\r\n",currentName, (float)_cellMin / 1000);
|
||||
Serial.printf("%s Difference cell volt: %f\r\n",currentName, (float)_cellMax - _cellMin / 1000);
|
||||
Serial.printf("%s Average cell volt: %f\r\n",currentName, (float)_cellSum / NumOfCells / 1000);
|
||||
Serial.printf("%s Max Cell Voltage: %f\r\n",currentName, (float)_cellMax / 1000);
|
||||
Serial.printf("%s Min Cell Voltage: %f\r\n",currentName, (float)_cellMin / 1000);
|
||||
Serial.printf("%s Difference Cell Voltage: %f\r\n",currentName, (float)(_cellMax - _cellMin) / 1000);
|
||||
Serial.printf("%s Average Cell Voltage: %f\r\n",currentName, (float)(_cellSum / NumOfCells) / 1000);
|
||||
|
||||
gotCellInfo=true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user