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