1 /* 2 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /* 8 * All the APIs declared here are internal only APIs, it can only be used by 9 * espressif internal modules, such as SSC, LWIP, esp-netif etc, espressif 10 * customers are not recommended to use them. 11 * 12 * If someone really want to use specified APIs declared in here, please contact 13 * espressif AE/developer to make sure you know the limitations or risk of 14 * the API, otherwise you may get unexpected behavior!!! 15 * 16 */ 17 18 19 #ifndef __ESP_WIFI_INTERNAL_H__ 20 #define __ESP_WIFI_INTERNAL_H__ 21 22 #include <stdint.h> 23 #include <stdbool.h> 24 25 #include <zephyr/kernel.h> 26 27 #include "sys/queue.h" 28 #include "esp_err.h" 29 #include "esp_wifi_types.h" 30 // #include "esp_event.h" 31 #include "esp_wifi.h" 32 #include "esp_smartconfig.h" 33 #include "wifi_types.h" 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 typedef struct { 40 void *handle; /**< FreeRTOS queue handler */ 41 void *storage; /**< storage for FreeRTOS queue */ 42 } wifi_static_queue_t; 43 44 /** 45 * @brief WiFi log level 46 * 47 */ 48 typedef enum { 49 WIFI_LOG_NONE = 0, 50 WIFI_LOG_ERROR , /*enabled by default*/ 51 WIFI_LOG_WARNING, /*enabled by default*/ 52 WIFI_LOG_INFO, /*enabled by default*/ 53 WIFI_LOG_DEBUG, /*can be set in menuconfig*/ 54 WIFI_LOG_VERBOSE, /*can be set in menuconfig*/ 55 } wifi_log_level_t; 56 57 /** 58 * @brief WiFi log module definition 59 * 60 */ 61 typedef enum { 62 WIFI_LOG_MODULE_ALL = 0, /*all log modules */ 63 WIFI_LOG_MODULE_WIFI, /*logs related to WiFi*/ 64 WIFI_LOG_MODULE_COEX, /*logs related to WiFi and BT(or BLE) coexist*/ 65 WIFI_LOG_MODULE_MESH, /*logs related to Mesh*/ 66 } wifi_log_module_t; 67 68 /** 69 * @brief WiFi log submodule definition 70 * 71 */ 72 #define WIFI_LOG_SUBMODULE_ALL (0) /*all log submodules*/ 73 #define WIFI_LOG_SUBMODULE_INIT (1) /*logs related to initialization*/ 74 #define WIFI_LOG_SUBMODULE_IOCTL (1<<1) /*logs related to API calling*/ 75 #define WIFI_LOG_SUBMODULE_CONN (1<<2) /*logs related to connecting*/ 76 #define WIFI_LOG_SUBMODULE_SCAN (1<<3) /*logs related to scaning*/ 77 78 79 /** 80 * @brief Initialize Wi-Fi Driver 81 * Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer, 82 * WiFi NVS structure among others. 83 * 84 * For the most part, you need not call this function directly. It gets called 85 * from esp_wifi_init(). 86 * 87 * This function may be called, if you only need to initialize the Wi-Fi driver 88 * without having to use the network stack on top. 89 * 90 * @param config provide WiFi init configuration 91 * 92 * @return 93 * - ESP_OK: succeed 94 * - ESP_ERR_NO_MEM: out of memory 95 * - others: refer to error code esp_err.h 96 */ 97 esp_err_t esp_wifi_init_internal(const wifi_init_config_t *config); 98 99 /** 100 * @brief Deinitialize Wi-Fi Driver 101 * Free resource for WiFi driver, such as WiFi control structure, RX/TX buffer, 102 * WiFi NVS structure among others. 103 * 104 * For the most part, you need not call this function directly. It gets called 105 * from esp_wifi_deinit(). 106 * 107 * This function may be called, if you call esp_wifi_init_internal to initialize 108 * WiFi driver. 109 * 110 * @return 111 * - ESP_OK: succeed 112 * - others: refer to error code esp_err.h 113 */ 114 esp_err_t esp_wifi_deinit_internal(void); 115 116 /** 117 * @brief free the rx buffer which allocated by wifi driver 118 * 119 * @param void* buffer: rx buffer pointer 120 */ 121 void esp_wifi_internal_free_rx_buffer(void* buffer); 122 123 /** 124 * @brief transmit the buffer via wifi driver 125 * 126 * This API makes a copy of the input buffer and then forwards the buffer 127 * copy to WiFi driver. 128 * 129 * @param wifi_interface_t wifi_if : wifi interface id 130 * @param void *buffer : the buffer to be transmit 131 * @param uint16_t len : the length of buffer 132 * 133 * @return 134 * - ESP_OK : Successfully transmit the buffer to wifi driver 135 * - ESP_ERR_NO_MEM: out of memory 136 * - ESP_ERR_WIFI_ARG: invalid argument 137 * - ESP_ERR_WIFI_IF : WiFi interface is invalid 138 * - ESP_ERR_WIFI_CONN : WiFi interface is not created, e.g. send the data to STA while WiFi mode is AP mode 139 * - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started 140 * - ESP_ERR_WIFI_STATE : WiFi internal state is not ready, e.g. WiFi is not started 141 * - ESP_ERR_WIFI_NOT_ASSOC : WiFi is not associated 142 * - ESP_ERR_WIFI_TX_DISALLOW : WiFi TX is disallowed, e.g. WiFi hasn't pass the authentication 143 * - ESP_ERR_WIFI_POST : caller fails to post event to WiFi task 144 */ 145 int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, uint16_t len); 146 147 /** 148 * @brief The net stack buffer reference counter callback function 149 * 150 */ 151 typedef void (*wifi_netstack_buf_ref_cb_t)(void *netstack_buf); 152 153 /** 154 * @brief The net stack buffer free callback function 155 * 156 */ 157 typedef void (*wifi_netstack_buf_free_cb_t)(void *netstack_buf); 158 159 /** 160 * @brief transmit the buffer by reference via wifi driver 161 * 162 * This API firstly increases the reference counter of the input buffer and 163 * then forwards the buffer to WiFi driver. The WiFi driver will free the buffer 164 * after processing it. Use esp_wifi_internal_tx() if the uplayer buffer doesn't 165 * supports reference counter. 166 * 167 * @param wifi_if : wifi interface id 168 * @param buffer : the buffer to be tansmit 169 * @param len : the length of buffer 170 * @param netstack_buf : the netstack buffer related to bufffer 171 * 172 * @return 173 * - ESP_OK : Successfully transmit the buffer to wifi driver 174 * - ESP_ERR_NO_MEM: out of memory 175 * - ESP_ERR_WIFI_ARG: invalid argument 176 * - ESP_ERR_WIFI_IF : WiFi interface is invalid 177 * - ESP_ERR_WIFI_CONN : WiFi interface is not created, e.g. send the data to STA while WiFi mode is AP mode 178 * - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started 179 * - ESP_ERR_WIFI_STATE : WiFi internal state is not ready, e.g. WiFi is not started 180 * - ESP_ERR_WIFI_NOT_ASSOC : WiFi is not associated 181 * - ESP_ERR_WIFI_TX_DISALLOW : WiFi TX is disallowed, e.g. WiFi hasn't pass the authentication 182 * - ESP_ERR_WIFI_POST : caller fails to post event to WiFi task 183 */ 184 esp_err_t esp_wifi_internal_tx_by_ref(wifi_interface_t ifx, void *buffer, size_t len, void *netstack_buf); 185 186 /** 187 * @brief Initialize WAPI function when wpa_supplicant initialize. 188 * 189 * This API is privately used, be careful not open to external applicantion. 190 * 191 * @return 192 * - ESP_OK : succeed 193 * - ESP_ERR_WAPI_INTERNAL : Internal error 194 */ 195 esp_err_t esp_wifi_internal_wapi_init(void); 196 197 /** 198 * @brief De-initialize WAPI function when wpa_supplicant de-initialize. 199 * 200 * This API is privately used, be careful not open to external applicantion. 201 * 202 * @return 203 * - ESP_OK : succeed 204 */ 205 esp_err_t esp_wifi_internal_wapi_deinit(void); 206 207 /** 208 * @brief register the net stack buffer reference increasing and free callback 209 * 210 * @param ref : net stack buffer reference callback 211 * @param free: net stack buffer free callback 212 * 213 * @return 214 * - ESP_OK : Successfully transmit the buffer to wifi driver 215 * - others : failed to register the callback 216 */ 217 esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, wifi_netstack_buf_free_cb_t free); 218 219 220 /** 221 * @brief The WiFi RX callback function 222 * 223 * Each time the WiFi need to forward the packets to high layer, the callback function will be called 224 */ 225 typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *eb); 226 227 /** 228 * @brief Set the WiFi RX callback 229 * 230 * @attention 1. Currently we support only one RX callback for each interface 231 * 232 * @param wifi_interface_t ifx : interface 233 * @param wifi_rxcb_t fn : WiFi RX callback 234 * 235 * @return 236 * - ESP_OK : succeed 237 * - others : fail 238 */ 239 esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn); 240 241 /** 242 * @brief Notify WIFI driver that the station got ip successfully 243 * 244 * @return 245 * - ESP_OK : succeed 246 * - others : fail 247 */ 248 esp_err_t esp_wifi_internal_set_sta_ip(void); 249 250 /** 251 * @brief enable or disable transmitting WiFi MAC frame with fixed rate 252 * 253 * @attention 1. If fixed rate is enabled, both management and data frame are transmitted with fixed rate 254 * @attention 2. Make sure that the receiver is able to receive the frame with the fixed rate if you want the frame to be received 255 * @attention 3. Not support to set fix rate for espnow and 80211_tx 256 * 257 * @param ifx : wifi interface 258 * @param en : false - disable, true - enable 259 * @param rate : PHY rate 260 * 261 * @return 262 * - ERR_OK : succeed 263 * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 264 * - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start 265 * - ESP_ERR_WIFI_IF : invalid WiFi interface 266 * - ESP_ERR_INVALID_ARG : invalid rate 267 * - ESP_ERR_NOT_SUPPORTED : do not support to set fixed rate if TX AMPDU is enabled 268 */ 269 esp_err_t esp_wifi_internal_set_fix_rate(wifi_interface_t ifx, bool en, wifi_phy_rate_t rate); 270 271 /** 272 * @brief Start SmartConfig, config ESP device to connect AP. You need to broadcast information by phone APP. 273 * Device sniffer special packets from the air that containing SSID and password of target AP. 274 * 275 * @attention 1. This API can be called in station or softAP-station mode. 276 * @attention 2. Can not call esp_smartconfig_start twice before it finish, please call 277 * esp_smartconfig_stop first. 278 * 279 * @param config pointer to smartconfig start configure structure 280 * 281 * @return 282 * - ESP_OK: succeed 283 * - others: fail 284 */ 285 esp_err_t esp_smartconfig_internal_start(const smartconfig_start_config_t *config); 286 287 /** 288 * @brief Stop SmartConfig, free the buffer taken by esp_smartconfig_start. 289 * 290 * @attention Whether connect to AP succeed or not, this API should be called to free 291 * memory taken by smartconfig_start. 292 * 293 * @return 294 * - ESP_OK: succeed 295 * - others: fail 296 */ 297 esp_err_t esp_smartconfig_internal_stop(void); 298 299 /** 300 * @brief Check the MD5 values of the OS adapter header files in IDF and WiFi library 301 * 302 * @attention 1. It is used for internal CI version check 303 * 304 * @return 305 * - ESP_OK : succeed 306 * - ESP_WIFI_INVALID_ARG : MD5 check fail 307 */ 308 esp_err_t esp_wifi_internal_osi_funcs_md5_check(const char *md5); 309 310 /** 311 * @brief Check the MD5 values of the crypto types header files in IDF and WiFi library 312 * 313 * @attention 1. It is used for internal CI version check 314 * 315 * @return 316 * - ESP_OK : succeed 317 * - ESP_WIFI_INVALID_ARG : MD5 check fail 318 */ 319 esp_err_t esp_wifi_internal_crypto_funcs_md5_check(const char *md5); 320 321 /** 322 * @brief Check the MD5 values of the esp_wifi_types.h in IDF and WiFi library 323 * 324 * @attention 1. It is used for internal CI version check 325 * 326 * @return 327 * - ESP_OK : succeed 328 * - ESP_WIFI_INVALID_ARG : MD5 check fail 329 */ 330 esp_err_t esp_wifi_internal_wifi_type_md5_check(const char *md5); 331 332 /** 333 * @brief Check the MD5 values of the esp_wifi_he_types.h in IDF and WiFi library 334 * 335 * @attention 1. It is used for internal CI version check 336 * 337 * @return 338 * - ESP_OK : succeed 339 * - ESP_WIFI_INVALID_ARG : MD5 check fail 340 */ 341 esp_err_t esp_wifi_internal_wifi_he_type_md5_check(const char *md5); 342 343 /** 344 * @brief Check the MD5 values of the esp_wifi.h in IDF and WiFi library 345 * 346 * @attention 1. It is used for internal CI version check 347 * 348 * @return 349 * - ESP_OK : succeed 350 * - ESP_WIFI_INVALID_ARG : MD5 check fail 351 */ 352 esp_err_t esp_wifi_internal_esp_wifi_md5_check(const char *md5); 353 354 /** 355 * @brief Check the MD5 values of the esp_wifi_he.h in IDF and WiFi library 356 * 357 * @attention 1. It is used for internal CI version check 358 * 359 * @return 360 * - ESP_OK : succeed 361 * - ESP_WIFI_INVALID_ARG : MD5 check fail 362 */ 363 esp_err_t esp_wifi_internal_esp_wifi_he_md5_check(const char *md5); 364 365 /** 366 * @brief Allocate a chunk of memory for WiFi driver 367 * 368 * @attention This API is not used for DMA memory allocation. 369 * 370 * @param size_t size : Size, in bytes, of the amount of memory to allocate 371 * 372 * @return A pointer to the memory allocated on success, NULL on failure 373 */ 374 void *wifi_malloc( size_t size ); 375 376 /** 377 * @brief Reallocate a chunk of memory for WiFi driver 378 * 379 * @attention This API is not used for DMA memory allocation. 380 * 381 * @param void * ptr : Pointer to previously allocated memory, or NULL for a new allocation. 382 * @param size_t size : Size, in bytes, of the amount of memory to allocate 383 * 384 * @return A pointer to the memory allocated on success, NULL on failure 385 */ 386 void *wifi_realloc( void *ptr, size_t size ); 387 388 /** 389 * @brief Callocate memory for WiFi driver 390 * 391 * @attention This API is not used for DMA memory allocation. 392 * 393 * @param size_t n : Number of continuing chunks of memory to allocate 394 * @param size_t size : Size, in bytes, of the amount of memory to allocate 395 * 396 * @return A pointer to the memory allocated on success, NULL on failure 397 */ 398 void *wifi_calloc( size_t n, size_t size ); 399 400 /** 401 * @brief Update WiFi MAC time 402 * 403 * @param uint32_t time_delta : time duration since the WiFi/BT common clock is disabled 404 * 405 * @return Always returns ESP_OK 406 */ 407 typedef esp_err_t (* wifi_mac_time_update_cb_t)( uint32_t time_delta ); 408 409 /** 410 * @brief Update WiFi MAC time 411 * 412 * @param uint32_t time_delta : time duration since the WiFi/BT common clock is disabled 413 * 414 * @return Always returns ESP_OK 415 */ 416 esp_err_t esp_wifi_internal_update_mac_time( uint32_t time_delta ); 417 418 /** 419 * @brief Set current WiFi log level 420 * 421 * @param level Log level. 422 * 423 * @return 424 * - ESP_OK: succeed 425 * - ESP_FAIL: level is invalid 426 */ 427 esp_err_t esp_wifi_internal_set_log_level(wifi_log_level_t level); 428 429 /** 430 * @brief Set current log module and submodule 431 * 432 * @param module Log module 433 * @param submodule Log submodule 434 * @param enable enable or disable 435 * If module == 0 && enable == 0, all log modules are disabled. 436 * If module == 0 && enable == 1, all log modules are enabled. 437 * If submodule == 0 && enable == 0, all log submodules are disabled. 438 * If submodule == 0 && enable == 1, all log submodules are enabled. 439 * 440 * @return 441 * - ESP_OK: succeed 442 * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 443 * - ESP_ERR_WIFI_ARG: invalid argument 444 */ 445 esp_err_t esp_wifi_internal_set_log_mod(wifi_log_module_t module, uint32_t submodule, bool enable); 446 447 /** 448 * @brief Get current WiFi log info 449 * 450 * @param log_level the return log level. 451 * @param log_mod the return log module and submodule 452 * 453 * @return 454 * - ESP_OK: succeed 455 */ 456 esp_err_t esp_wifi_internal_get_log(wifi_log_level_t *log_level, uint32_t *log_mod); 457 458 /** 459 * @brief A general API to set/get WiFi internal configuration, it's for debug only 460 * 461 * @param cmd : ioctl command type 462 * @param cfg : configuration for the command 463 * 464 * @return 465 * - ESP_OK: succeed 466 * - others: failed 467 */ 468 esp_err_t esp_wifi_internal_ioctl(int cmd, wifi_ioctl_config_t *cfg); 469 470 /** 471 * @brief Get the user-configured channel info 472 * 473 * @param ifx : WiFi interface 474 * @param primary : store the configured primary channel 475 * @param second : store the configured second channel 476 * 477 * @return 478 * - ESP_OK: succeed 479 */ 480 esp_err_t esp_wifi_internal_get_config_channel(wifi_interface_t ifx, uint8_t *primary, uint8_t *second); 481 482 /** 483 * @brief Get the negotiated channel info after WiFi connection established 484 * 485 * @param ifx : WiFi interface 486 * @param aid : the connection number when a STA connects to the softAP 487 * @param primary : store the negotiated primary channel 488 * @param second : store the negotiated second channel 489 * @attention the aid param is only works when the device in softAP/softAP+STA mode 490 * 491 * @return 492 * - ESP_OK: succeed 493 */ 494 esp_err_t esp_wifi_internal_get_negotiated_channel(wifi_interface_t ifx, uint8_t aid, uint8_t *primary, uint8_t *second); 495 496 /** 497 * @brief Get the negotiated bandwidth info after WiFi connection established 498 * 499 * @param ifx : WiFi interface 500 * @param bw : store the negotiated bandwidth 501 * 502 * @return 503 * - ESP_OK: succeed 504 */ 505 esp_err_t esp_wifi_internal_get_negotiated_bandwidth(wifi_interface_t ifx, uint8_t aid, uint8_t *bw); 506 507 #if SOC_WIFI_HW_TSF 508 /** 509 * @brief Check if WiFi TSF is active 510 * 511 * @return 512 * - true: Active 513 * - false: Not active 514 */ 515 bool esp_wifi_internal_is_tsf_active(void); 516 517 /** 518 * @brief Update WIFI light sleep wake ahead time 519 * 520 */ 521 void esp_wifi_internal_update_light_sleep_wake_ahead_time(uint32_t); 522 523 /** 524 * @brief Update WiFi TSF tick interval 525 * 526 * @return 527 * - true: Active 528 * - false: Not active 529 */ 530 esp_err_t esp_wifi_update_tsf_tick_interval(void); 531 #endif 532 533 /** 534 * @brief Wifi power domain power on 535 */ 536 void esp_wifi_power_domain_on(void); 537 538 /** 539 * @brief Wifi power domain power off 540 */ 541 void esp_wifi_power_domain_off(void); 542 543 #if CONFIG_MAC_BB_PD 544 /** 545 * @brief Enable or disable powering down MAC and baseband when Wi-Fi is sleeping. 546 * 547 * @param enable : enable or disable 548 * 549 * @return 550 * - ESP_OK: succeed 551 */ 552 esp_err_t esp_wifi_internal_set_mac_sleep(bool enable); 553 554 /** 555 * @brief mac bb sleep. 556 */ 557 void pm_mac_sleep(void); 558 559 /** 560 * @brief mac bb wakeup. 561 */ 562 void pm_mac_wakeup(void); 563 #endif 564 565 /** 566 * @breif TxDone callback function type. Should be registered using esp_wifi_set_tx_done_cb() 567 * 568 * @param ifidx The interface id that the tx callback has been triggered from 569 * @param data Pointer to the data transmitted 570 * @param data_len Length of the data transmitted 571 * @param txStatus True:if the data was transmitted sucessfully False: if data transmission failed 572 */ 573 typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data, uint16_t *data_len, bool txStatus); 574 575 /** 576 * @brief Register the txDone callback function of type wifi_tx_done_cb_t 577 * 578 * @param cb The callback function 579 * 580 * @return 581 * - ESP_OK: succeed 582 * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 583 * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start 584 */ 585 esp_err_t esp_wifi_set_tx_done_cb(wifi_tx_done_cb_t cb); 586 587 /** 588 * @brief Set device spp amsdu attributes 589 * 590 * @param ifx: WiFi interface 591 * @param spp_cap: spp amsdu capable 592 * @param spp_req: spp amsdu require 593 * 594 * @return 595 * - ESP_OK: succeed 596 * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 597 * - ESP_ERR_WIFI_IF : invalid WiFi interface 598 */ 599 esp_err_t esp_wifi_internal_set_spp_amsdu(wifi_interface_t ifidx, bool spp_cap, bool spp_req); 600 601 /** 602 * @brief Update WIFI light sleep default parameters 603 * 604 * @param min_freq_mhz: minimum frequency of DFS 605 * @param max_freq_mhz: maximum frequency of DFS 606 */ 607 void esp_wifi_internal_update_light_sleep_default_params(int min_freq_mhz, int max_freq_mhz); 608 609 /** 610 * @brief Set the delay time for wifi to enter the sleep state when light sleep 611 * 612 * @param return_to_sleep_delay: minimum timeout time for waiting to receive 613 * data, when no data is received during the timeout period, 614 * the wifi enters the sleep process. 615 */ 616 void esp_wifi_set_sleep_delay_time(uint32_t return_to_sleep_delay); 617 618 /** 619 * @brief Set wifi keep alive time 620 * 621 * @param keep_alive_time: keep alive time 622 */ 623 void esp_wifi_set_keep_alive_time(uint32_t keep_alive_time); 624 625 /** 626 * @brief Configure wifi beacon montior default parameters 627 * 628 * @param config: the configuration parameters for wifi beacon monitor 629 */ 630 void esp_wifi_beacon_monitor_configure(wifi_beacon_monitor_config_t *config); 631 632 /** 633 * @brief Require WiFi to enable or disable Advanced DTIM sleep function 634 * 635 * @param light_sleep_enable: true for light sleep mode is enabled, false for light sleep mode is disabled. 636 * @param modem_state_enable: true for require WiFi to enable Advanced DTIM sleep function, 637 * false for require WiFi to disable Advanced DTIM sleep function. 638 * @return 639 * - ESP_OK: succeed 640 */ 641 void esp_wifi_internal_mac_sleep_configure(bool light_sleep_enable, bool modem_state_enable); 642 643 /** 644 * @brief Start Publishing a service in the NAN cluster 645 * 646 * @attention This API should be called after esp_wifi_start() in NAN Mode. 647 * 648 * @param publish_cfg Configuration parameters for publishing a service. 649 * @param id Identifier for the Publish service. 650 * @param cancel Cancel the service identified by the id. 651 * 652 * @return 653 * - ESP_OK: succeed 654 * - others: failed 655 */ 656 esp_err_t esp_nan_internal_publish_service(const wifi_nan_publish_cfg_t *publish_cfg, 657 uint8_t *id, bool cancel); 658 659 /** 660 * @brief Subscribe for a service within the NAN cluster 661 * 662 * @attention This API should be called after esp_wifi_start() in NAN Mode. 663 * 664 * @param subscribe_cfg Configuration parameters for subscribing for a service. 665 * @param id Identifier for the Subscribe service. 666 * @param cancel Cancel the service identified by the id. 667 * 668 * @return 669 * - ESP_OK: succeed 670 * - others: failed 671 */ 672 esp_err_t esp_nan_internal_subscribe_service(const wifi_nan_subscribe_cfg_t *subscribe_cfg, 673 uint8_t *id, bool cancel); 674 675 /** 676 * @brief Send Follow-up to the Publisher with matching service 677 * 678 * @attention This API should be called after WIFI_EVENT_NAN_SVC_MATCH event is received. 679 * 680 * @param fup_params Configuration parameters for sending a Follow-up to the Peer. 681 * 682 * @return 683 * - ESP_OK: succeed 684 * - others: failed 685 */ 686 esp_err_t esp_nan_internal_send_followup(const wifi_nan_followup_params_t *fup_params); 687 688 /** 689 * @brief Send Datapath Request to the Publisher with matching service 690 * 691 * @attention This API should be called after WIFI_EVENT_NAN_SVC_MATCH event is received. 692 * 693 * @param req NAN Datapath Request parameters. 694 * 695 * @return 696 * - ESP_OK: succeed 697 * - others: failed 698 */ 699 esp_err_t esp_nan_internal_datapath_req(wifi_nan_datapath_req_t *req, uint8_t *ndp_id); 700 701 /** 702 * @brief Send Datapath Response to accept or reject the received request 703 * 704 * @attention This API should be called on the Publisher after receiving WIFI_EVENT_NDP_INDICATION event. 705 * 706 * @param resp NAN Datapath Response parameters. 707 * 708 * @return 709 * - ESP_OK: succeed 710 * - others: failed 711 */ 712 esp_err_t esp_nan_internal_datapath_resp(wifi_nan_datapath_resp_t *resp); 713 714 /** 715 * @brief End NAN Datapath that is active 716 * 717 * @attention This API should be called after receiving WIFI_EVENT_NDP_CONFIRM event. 718 * 719 * @param req NAN Datapath end request parameters. 720 * 721 * @return 722 * - ESP_OK: succeed 723 * - others: failed 724 */ 725 esp_err_t esp_nan_internal_datapath_end(wifi_nan_datapath_end_req_t *req); 726 727 #ifdef __cplusplus 728 } 729 #endif 730 731 #endif /* __ESP_WIFI_H__ */ 732