Skip to content

Commit 1bda7aa

Browse files
committed
Add function to close HomeKit server
When performing a OTA firmware update, we need to shutdown the HomeKit sever because all network processing (including pings) stop during file uploads. So system cannot process incoming TCP requests, risking out-of-memory crashes as buffers fill up.
1 parent 63607e6 commit 1bda7aa

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/arduino_homekit_server.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3559,6 +3559,16 @@ void arduino_homekit_setup(homekit_server_config_t *config) {
35593559
});
35603560
}
35613561

3562+
void arduino_homekit_close() {
3563+
if (homekit_mdns_started) {
3564+
homekit_mdns_started = false;
3565+
MDNS.close();
3566+
}
3567+
if (running_server) {
3568+
server_free(running_server);
3569+
}
3570+
}
3571+
35623572
void arduino_homekit_loop() {
35633573
if (homekit_mdns_started) {
35643574
MDNS.update();

src/arduino_homekit_server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ typedef struct _client_event {
226226

227227

228228
void arduino_homekit_setup(homekit_server_config_t *config);
229+
void arduino_homekit_close();
229230
void arduino_homekit_loop();
230231

231232
homekit_server_t * arduino_homekit_get_running_server();

0 commit comments

Comments
 (0)