Skip to content

Commit

Permalink
Merge branch 'task/gitlab_sync' into 'master'
Browse files Browse the repository at this point in the history
Minor fixes

See merge request app-frameworks/esp-homekit-sdk!25
  • Loading branch information
shahpiyushv committed Apr 3, 2023
2 parents b8095bb + efca14e commit 3e6955a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.
9 changes: 9 additions & 0 deletions components/homekit/esp_hap_core/src/esp_hap_char.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ int hap_event_queue_init()
}
}

int hap_event_queue_deinit()
{
if (hap_event_queue) {
vQueueDelete(hap_event_queue);
hap_event_queue = NULL;
}
return HAP_SUCCESS;
}

hap_char_t * hap_get_pending_notif_char()
{
hap_char_t *hc;
Expand Down
19 changes: 18 additions & 1 deletion components/homekit/esp_hap_core/src/esp_hap_ip_services.c
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,13 @@ httpd_handle_t * hap_httpd_get_handle()
{
return &hap_priv.server;
}

int hap_httpd_stop(void)
{
hap_platform_httpd_stop(&hap_priv.server);
return HAP_SUCCESS;
}

static bool first_announce_done;

int hap_mdns_deannounce(void)
Expand Down Expand Up @@ -1678,9 +1685,9 @@ int hap_mdns_announce(bool first)
return HAP_SUCCESS;
}

static bool hap_ip_services_started;
int hap_ip_services_start()
{
static bool hap_ip_services_started;
if (hap_ip_services_started) {
return HAP_SUCCESS;
}
Expand All @@ -1692,3 +1699,13 @@ int hap_ip_services_start()
hap_ip_services_started = true;
return HAP_SUCCESS;
}

int hap_ip_services_stop()
{
if (hap_ip_services_started) {
hap_mdns_deannounce();
hap_unregister_http_handlers();
hap_ip_services_started = false;
}
return HAP_SUCCESS;
}
20 changes: 19 additions & 1 deletion components/homekit/esp_hap_core/src/esp_hap_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ static void hap_loop_task(void *param)
}
vQueueDelete(xQueue);
xQueue = NULL;
ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "HAP Main Loop Stopped");
vTaskDelete(NULL);
}

Expand Down Expand Up @@ -323,8 +324,13 @@ int hap_trigger_network_revert(void)
return hap_send_event(HAP_INTERNAL_EVENT_NETWORK_REVERT);
}

static bool hap_started;
int hap_start(void)
{
if (hap_started) {
ESP_MFI_DEBUG(ESP_MFI_DEBUG_WARN, "HAP already started");
return HAP_SUCCESS;
}
int ret = 0;
#ifdef CONFIG_HAP_MFI_ENABLE
if (hap_priv.auth_type == HAP_MFI_AUTH_HW) {
Expand Down Expand Up @@ -378,13 +384,25 @@ int hap_start(void)
ESP_MFI_DEBUG(ESP_MFI_DEBUG_ERR, "HAP IP Services Start Failed [%d]", ret);
return ret;
}
ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "HAP Started");
hap_started = true;
return HAP_SUCCESS;
}

int hap_stop(void)
{
int ret = HAP_SUCCESS;
//todo
if (!hap_started) {
ESP_MFI_DEBUG(ESP_MFI_DEBUG_WARN, "HAP is already stopped");
return ret;
}
hap_ip_services_stop();
hap_mdns_deinit();
hap_loop_stop();
hap_event_queue_deinit();
hap_httpd_stop();
hap_started = false;
ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "HAP Stopped");
return ret;
}

Expand Down
3 changes: 1 addition & 2 deletions components/homekit/esp_hap_core/src/esp_hap_setup_payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
static const char *TAG = "esp_hap_setup_payload";

#define SETUP_CODE_MASK 0x0000000007ffffff
#define PRODUCT_DATA_MASK 0x0000010000000000
#define HAP_OVER_IP_MASK 0x0000000010000000
#define WAC_MASK 0x0000000040000000
#define SETUP_PAYLOAD_PREFIX "X-HM://00"
Expand Down Expand Up @@ -70,7 +69,7 @@ char *esp_hap_get_setup_payload(char *setup_code, char *setup_id, bool wac_suppo

payload |= code;
payload |= category;
payload |= ( HAP_OVER_IP_MASK | PRODUCT_DATA_MASK);
payload |= HAP_OVER_IP_MASK;
if (wac_support) {
payload |= WAC_MASK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ bool hap_char_is_ctrl_owner(hap_char_t *hc, int index);
void hap_disable_all_char_notif(int index);
int hap_char_check_val_constraints(__hap_char_t *_hc, hap_val_t *val);
int hap_event_queue_init();
int hap_event_queue_deinit();
hap_char_t * hap_get_pending_notif_char();
#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
int hap_http_session_not_authorized(httpd_req_t *req);
int hap_httpd_get_data(httpd_req_t *req, char *buffer, int len);
int hap_httpd_start();
int hap_httpd_stop();
int hap_ip_services_start();
int hap_ip_services_stop();
int hap_mdns_announce(bool first);
int hap_mdns_deannounce();
void hap_http_send_notif();
Expand Down

0 comments on commit 3e6955a

Please sign in to comment.