bugfix - ordering is oposite in events page and mqtt publish

This commit is contained in:
amarofarinha 2024-09-20 09:33:38 +01:00
parent 086c3dfa29
commit eb901da385
4 changed files with 14 additions and 5 deletions

View file

@ -463,14 +463,22 @@ static void update_bms_status(void) {
}
}
// Function to compare events by timestamp
bool compareEventsByTimestamp(const EventData& a, const EventData& b) {
// Function to compare events by timestamp descending
bool compareEventsByTimestampDesc(const EventData& a, const EventData& b) {
if (a.event_pointer->millisrolloverCount != b.event_pointer->millisrolloverCount) {
return a.event_pointer->millisrolloverCount > b.event_pointer->millisrolloverCount;
}
return a.event_pointer->timestamp > b.event_pointer->timestamp;
}
// Function to compare events by timestamp ascending
bool compareEventsByTimestampAsc(const EventData& a, const EventData& b) {
if (a.event_pointer->millisrolloverCount != b.event_pointer->millisrolloverCount) {
return a.event_pointer->millisrolloverCount < b.event_pointer->millisrolloverCount;
}
return a.event_pointer->timestamp < b.event_pointer->timestamp;
}
static void update_event_level(void) {
EVENTS_LEVEL_TYPE temporary_level = EVENT_LEVEL_INFO;
for (uint8_t i = 0u; i < EVENT_NOF_EVENTS; i++) {