Skip to content

Commit

Permalink
Merge pull request #522 from zwx1995esp/feature/mdns_add_browse_suport
Browse files Browse the repository at this point in the history
mdns add browse support (IDFGH-12512)
  • Loading branch information
gabsuren authored Apr 10, 2024
2 parents 0b94d9e + af330b6 commit fbdb248
Show file tree
Hide file tree
Showing 3 changed files with 818 additions and 8 deletions.
28 changes: 28 additions & 0 deletions components/mdns/include/mdns.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ extern "C" {
*/
typedef struct mdns_search_once_s mdns_search_once_t;

/**
* @brief Daemon query handle
*/
typedef struct mdns_browse_s mdns_browse_t;

typedef enum {
MDNS_EVENT_ENABLE_IP4 = 1 << 1,
MDNS_EVENT_ENABLE_IP6 = 1 << 2,
Expand Down Expand Up @@ -97,6 +102,7 @@ typedef struct mdns_result_s {
} mdns_result_t;

typedef void (*mdns_query_notify_t)(mdns_search_once_t *search);
typedef void (*mdns_browse_notify_t)(mdns_result_t *result);

/**
* @brief Initialize mDNS on given interface
Expand Down Expand Up @@ -830,6 +836,28 @@ esp_err_t mdns_unregister_netif(esp_netif_t *esp_netif);
*/
esp_err_t mdns_netif_action(esp_netif_t *esp_netif, mdns_event_actions_t event_action);

/**
* @brief Browse mDNS for a service `_service._proto`.
*
* @param service Pointer to the `_service` which will be browsed.
* @param proto Pointer to the `_proto` which will be browsed.
* @param notifier The callback which will be called when the browsing service changed.
* @return mdns_browse_t pointer to new browse object if initiated successfully.
* NULL otherwise.
*/
mdns_browse_t *mdns_browse_new(const char *service, const char *proto, mdns_browse_notify_t notifier);

/**
* @brief Stop the `_service._proto` browse.
* @param service Pointer to the `_service` which will be browsed.
* @param proto Pointer to the `_proto` which will be browsed.
* @return
* - ESP_OK success.
* - ESP_ERR_FAIL mDNS is not running or the browsing of `_service._proto` is never started.
* - ESP_ERR_NO_MEM memory error.
*/
esp_err_t mdns_browse_delete(const char *service, const char *proto);

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit fbdb248

Please sign in to comment.