mesh_netif.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Mesh IP Internal Networking Example
  2. This example code is in the Public Domain (or CC0 licensed, at your option.)
  3. Unless required by applicable law or agreed to in writing, this
  4. software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied.
  6. */
  7. #pragma once
  8. /*******************************************************
  9. * Macros
  10. *******************************************************/
  11. #define MAC_ADDR_LEN (6u)
  12. #define MAC_ADDR_EQUAL(a, b) (0 == memcmp(a, b, MAC_ADDR_LEN))
  13. /*******************************************************
  14. * Type Definitions
  15. *******************************************************/
  16. typedef void (mesh_raw_recv_cb_t)(mesh_addr_t *from, mesh_data_t *data);
  17. /*******************************************************
  18. * Function Declarations
  19. *******************************************************/
  20. /**
  21. * @brief Initializes netifs in a default way before knowing if we are going to be a root
  22. *
  23. * @param cb callback receive function for mesh raw packets
  24. *
  25. * @return ESP_OK on success
  26. */
  27. esp_err_t mesh_netifs_init(mesh_raw_recv_cb_t *cb);
  28. /**
  29. * @brief Destroy the netifs and related structures
  30. *
  31. * @return ESP_OK on success
  32. */
  33. esp_err_t mesh_netifs_destroy(void);
  34. /**
  35. * @brief Start the mesh netifs based on the configuration (root/node)
  36. *
  37. * @return ESP_OK on success
  38. */
  39. esp_err_t mesh_netifs_start(bool is_root);
  40. /**
  41. * @brief Stop the netifs and reset to the default mode
  42. *
  43. * @return ESP_OK on success
  44. */
  45. esp_err_t mesh_netifs_stop(void);
  46. /**
  47. * @brief Start the netif for root AP
  48. *
  49. * Note: The AP netif needs to be started separately after root received
  50. * an IP address from the router so the DNS address could be used for dhcps
  51. *
  52. * @param is_root must be true, ignored otherwise
  53. * @param dns_addr DNS address to use in DHCP server running on roots AP
  54. *
  55. * @return ESP_OK on success
  56. */
  57. esp_err_t mesh_netif_start_root_ap(bool is_root, uint32_t dns_addr);
  58. /**
  59. * @brief Returns MAC address of the station interface
  60. *
  61. * Used mainly for checking node addresses of the peers in routing table
  62. * to avoid sending data to oneself
  63. *
  64. * @return Pointer to MAC address
  65. */
  66. uint8_t* mesh_netif_get_station_mac(void);