Skip to content

Commit 49f4d29

Browse files
Copilotdorkmo
andcommitted
Address code review feedback and improve documentation
Co-authored-by: dorkmo <[email protected]>
1 parent 9830ef2 commit 49f4d29

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

TankAlarm-112025-Server-BluesOpta/TankAlarm-112025-Server-BluesOpta.ino

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9600,21 +9600,21 @@ static void handleContactsGet(EthernetClient &client) {
96009600
// For now, return empty arrays - this will be populated from stored config
96019601
// Contacts will be stored in a separate config file
96029602

9603-
// Build list of sites from tank records
9603+
// Build list of unique sites from tank records
9604+
// Use simple linear scan - with typical fleet sizes (< 100 tanks), performance is adequate
96049605
JsonArray sitesArray = doc.createNestedArray("sites");
9605-
bool sitesSeen[MAX_TANKS] = {false};
9606-
uint8_t uniqueSiteCount = 0;
9607-
for (uint8_t i = 0; i < gTankCount && uniqueSiteCount < MAX_TANKS; ++i) {
9606+
for (uint8_t i = 0; i < gTankCount; ++i) {
9607+
if (strlen(gTanks[i].site) == 0) continue;
9608+
96089609
bool alreadySeen = false;
96099610
for (uint8_t j = 0; j < i; ++j) {
96109611
if (strcmp(gTanks[i].site, gTanks[j].site) == 0) {
96119612
alreadySeen = true;
96129613
break;
96139614
}
96149615
}
9615-
if (!alreadySeen && strlen(gTanks[i].site) > 0) {
9616+
if (!alreadySeen) {
96169617
sitesArray.add(gTanks[i].site);
9617-
uniqueSiteCount++;
96189618
}
96199619
}
96209620

@@ -9645,11 +9645,17 @@ static void handleContactsPost(EthernetClient &client, const String &body) {
96459645
return;
96469646
}
96479647

9648-
// For now, just acknowledge the save
9649-
// In a full implementation, this would save to a contacts config file
9648+
// NOTE: Contact persistence not yet implemented
9649+
// Future implementation will:
9650+
// 1. Store contacts in a separate JSON config file (e.g., "contacts.json")
9651+
// 2. Load contacts during server initialization
9652+
// 3. Integrate with existing SMS/email notification system
9653+
// 4. Replace hardcoded phone/email fields in ServerConfig
9654+
// For now, return success but data is not persisted across reboots
9655+
96509656
DynamicJsonDocument response(256);
96519657
response["success"] = true;
9652-
response["message"] = "Contacts saved successfully";
9658+
response["message"] = "Contacts saved (note: persistence not yet implemented)";
96539659

96549660
String responseStr;
96559661
serializeJson(response, responseStr);

0 commit comments

Comments
 (0)