Skip to content

Commit

Permalink
optimize # client reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
dkerr64 committed Oct 29, 2024
1 parent 448771a commit 48232ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ void handle_status()
{
unsigned long upTime = millis();
#define paired homekit_is_paired()
#define accessoryID std::string(arduino_homekit_get_running_server() ? arduino_homekit_get_running_server()->accessory_id : "Inactive")
#define clientCount std::to_string(arduino_homekit_get_running_server() ? arduino_homekit_get_running_server()->nfds : 0)
#define accessoryID arduino_homekit_get_running_server() ? arduino_homekit_get_running_server()->accessory_id : "Inactive"
#define clientCount arduino_homekit_get_running_server() ? arduino_homekit_get_running_server()->nfds : 0
#define IPaddr WiFi.localIP().toString().c_str()
#define subnetMask WiFi.subnetMask().toString().c_str()
#define gatewayIP WiFi.gatewayIP().toString().c_str()
Expand All @@ -608,7 +608,8 @@ void handle_status()
ADD_STR(json, "userName", userConfig->wwwUsername);
ADD_BOOL(json, "paired", paired);
ADD_STR(json, "firmwareVersion", std::string(AUTO_VERSION).c_str());
ADD_STR(json, "accessoryID", (accessoryID + " (clients:" + clientCount + ")").c_str());
ADD_STR(json, "accessoryID", accessoryID);
ADD_INT(json, "clients", clientCount);
ADD_STR(json, "localIP", IPaddr);
ADD_STR(json, "subnetMask", subnetMask);
ADD_STR(json, "gatewayIP", gatewayIP);
Expand Down Expand Up @@ -1023,7 +1024,7 @@ void SSEheartbeat(SSESubscription *s)
if (arduino_homekit_get_running_server() && arduino_homekit_get_running_server()->nfds != lastClientCount)
{
lastClientCount = arduino_homekit_get_running_server()->nfds;
ADD_STR(json, "accessoryID", (accessoryID + " (clients:" + std::to_string(lastClientCount) + ")").c_str());
ADD_INT(json, "clients", lastClientCount);
}
END_JSON(json);
REMOVE_NL(json);
Expand Down
2 changes: 1 addition & 1 deletion src/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</tr>
<tr>
<td>HomeKit ID:</td>
<td id="accessoryID"></td>
<td><span id="accessoryID"></span><br><sup style="font-size: 0.6em;">(clients:<span id="clients"></span>)</sup></td>
</tr>
</table>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/www/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"deviceName": "Garage Door ABCDEF",
"paired": false,
"firmwareVersion": "9.9.9",
"accessoryID": "BA:98:76:54:32:10 (clients:1)",
"accessoryID": "BA:98:76:54:32:10",
"clients": 1,
"staticIP": true,
"localIP": "192.168.99.99",
"subnetMask": "255.255.255.0",
Expand Down

0 comments on commit 48232ad

Please sign in to comment.