mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 18:29:48 +02:00
Merge pull request #1400 from dalathegreat/bugfix/pairing-success-rate-SMA
SMA (All protocols): Improve pairing success rate
This commit is contained in:
commit
ca1bb08973
5 changed files with 27 additions and 9 deletions
|
@ -225,9 +225,10 @@ void SmaBydHInverter::map_can_frame_to_variable(CAN_frame rx_frame) {
|
|||
case 0x5E6:
|
||||
datalayer.system.status.CAN_inverter_still_alive = CAN_STILL_ALIVE;
|
||||
break;
|
||||
case 0x5E7: //Pairing request
|
||||
case 0x5E7: //Message originating from SMA inverter - Pairing request
|
||||
case 0x660: //Message originating from SMA inverter - Pairing request
|
||||
#ifdef DEBUG_LOG
|
||||
logging.println("Received 0x5E7: SMA pairing request");
|
||||
logging.println("Received SMA pairing request");
|
||||
#endif // DEBUG_LOG
|
||||
pairing_events++;
|
||||
set_event(EVENT_SMA_PAIRING, pairing_events);
|
||||
|
@ -245,7 +246,7 @@ void SmaBydHInverter::map_can_frame_to_variable(CAN_frame rx_frame) {
|
|||
void SmaBydHInverter::transmit_can(unsigned long currentMillis) {
|
||||
// Send CAN Message every 100ms if inverter allows contactor closing
|
||||
if (datalayer.system.status.inverter_allows_contactor_closing) {
|
||||
if (currentMillis - previousMillis100ms >= 100) {
|
||||
if (currentMillis - previousMillis100ms >= INTERVAL_100_MS) {
|
||||
previousMillis100ms = currentMillis;
|
||||
transmit_can_frame(&SMA_158);
|
||||
transmit_can_frame(&SMA_358);
|
||||
|
@ -254,6 +255,11 @@ void SmaBydHInverter::transmit_can(unsigned long currentMillis) {
|
|||
transmit_can_frame(&SMA_518);
|
||||
transmit_can_frame(&SMA_4D8);
|
||||
}
|
||||
// Send CAN Message every 60s (potentially SMA_458 is not required for stable operation)
|
||||
if (currentMillis - previousMillis60s >= INTERVAL_60_S) {
|
||||
previousMillis60s = currentMillis;
|
||||
transmit_can_frame(&SMA_458);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class SmaBydHInverter : public SmaInverterBase {
|
|||
void transmit_can_init();
|
||||
|
||||
unsigned long previousMillis100ms = 0;
|
||||
|
||||
unsigned long previousMillis60s = 0;
|
||||
uint8_t pairing_events = 0;
|
||||
uint32_t inverter_time = 0;
|
||||
uint16_t inverter_voltage = 0;
|
||||
|
|
|
@ -216,9 +216,10 @@ void SmaBydHvsInverter::map_can_frame_to_variable(CAN_frame rx_frame) {
|
|||
case 0x5E6:
|
||||
datalayer.system.status.CAN_inverter_still_alive = CAN_STILL_ALIVE;
|
||||
break;
|
||||
case 0x5E7: //Pairing request
|
||||
case 0x5E7: //Message originating from SMA inverter - Pairing request
|
||||
case 0x660: //Message originating from SMA inverter - Pairing request
|
||||
#ifdef DEBUG_LOG
|
||||
logging.println("Received 0x5E7: SMA pairing request");
|
||||
logging.println("Received SMA pairing request");
|
||||
#endif // DEBUG_LOG
|
||||
pairing_events++;
|
||||
set_event(EVENT_SMA_PAIRING, pairing_events);
|
||||
|
@ -279,7 +280,7 @@ void SmaBydHvsInverter::transmit_can(unsigned long currentMillis) {
|
|||
|
||||
// Send CAN Message every 100ms if inverter allows contactor closing
|
||||
if (datalayer.system.status.inverter_allows_contactor_closing) {
|
||||
if (currentMillis - previousMillis100ms >= 100) {
|
||||
if (currentMillis - previousMillis100ms >= INTERVAL_100_MS) {
|
||||
previousMillis100ms = currentMillis;
|
||||
transmit_can_frame(&SMA_158);
|
||||
transmit_can_frame(&SMA_358);
|
||||
|
@ -288,5 +289,10 @@ void SmaBydHvsInverter::transmit_can(unsigned long currentMillis) {
|
|||
transmit_can_frame(&SMA_518);
|
||||
transmit_can_frame(&SMA_4D8);
|
||||
}
|
||||
// Send CAN Message every 60s (potentially SMA_458 is not required for stable operation)
|
||||
if (currentMillis - previousMillis60s >= INTERVAL_60_S) {
|
||||
previousMillis60s = currentMillis;
|
||||
transmit_can_frame(&SMA_458);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class SmaBydHvsInverter : public SmaInverterBase {
|
|||
static const int READY_STATE = 0x03;
|
||||
static const int STOP_STATE = 0x02;
|
||||
static const int THIRTY_MINUTES = 1200;
|
||||
|
||||
unsigned long previousMillis60s = 0;
|
||||
unsigned long previousMillis100ms = 0;
|
||||
unsigned long previousMillisBatch = 0;
|
||||
uint8_t batch_send_index = 0;
|
||||
|
|
|
@ -124,9 +124,10 @@ void SmaTripowerInverter::map_can_frame_to_variable(CAN_frame rx_frame) {
|
|||
datalayer.system.status.CAN_inverter_still_alive = CAN_STILL_ALIVE;
|
||||
//Inverter brand (frame1-3 = 0x53 0x4D 0x41) = SMA
|
||||
break;
|
||||
case 0x5E7: //Message originating from SMA inverter - Pairing request
|
||||
case 0x660: //Message originating from SMA inverter - Pairing request
|
||||
#ifdef DEBUG_LOG
|
||||
logging.println("Received 0x660: SMA pairing request");
|
||||
logging.println("Received SMA pairing request");
|
||||
#endif // DEBUG_LOG
|
||||
pairing_events++;
|
||||
set_event(EVENT_SMA_PAIRING, pairing_events);
|
||||
|
@ -184,6 +185,11 @@ void SmaTripowerInverter::transmit_can(unsigned long currentMillis) {
|
|||
pushFrame(&SMA_4D8);
|
||||
pushFrame(&SMA_3D8);
|
||||
}
|
||||
// Send CAN Message every 60s (potentially SMA_458 is not required for stable operation)
|
||||
if (currentMillis - previousMillis60s >= INTERVAL_60_S) {
|
||||
previousMillis60s = currentMillis;
|
||||
pushFrame(&SMA_458);
|
||||
}
|
||||
}
|
||||
|
||||
void SmaTripowerInverter::completePairing() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue