* simple_secure_chat now with a proper CLI

* new: BaseChatMesh class, for abstract chat client
This commit is contained in:
Scott Powell
2025-01-25 22:03:25 +11:00
parent a3b7701bc0
commit 00a9e93754
8 changed files with 712 additions and 306 deletions
+28
View File
@@ -51,3 +51,31 @@
_valid = true;
}
}
#include <Arduino.h>
void AdvertTimeHelper::formatRelativeTimeDiff(char dest[], int32_t seconds_from_now, bool short_fmt) {
const char *suffix;
if (seconds_from_now < 0) {
suffix = short_fmt ? "" : " ago";
seconds_from_now = -seconds_from_now;
} else {
suffix = short_fmt ? "" : " from now";
}
if (seconds_from_now < 60) {
sprintf(dest, "%d secs %s", seconds_from_now, suffix);
} else {
int32_t mins = seconds_from_now / 60;
if (mins < 60) {
sprintf(dest, "%d mins %s", mins, suffix);
} else {
int32_t hours = mins / 60;
if (hours < 24) {
sprintf(dest, "%d hours %s", hours, suffix);
} else {
sprintf(dest, "%d days %s", hours / 24, suffix);
}
}
}
}