| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #pragma once
- #include "esp_err.h"
- #include "esp_wifi_types.h"
- #include <stdbool.h>
- /**
- * Initialize WiFi in both AP and STA modes
- * @param ap_ssid AP SSID (if NULL, uses default)
- * @param ap_password AP password (if NULL, uses default or open)
- */
- void wifi_init_apsta(const char *ap_ssid, const char *ap_password);
- /**
- * Block until WiFi is connected and has an IP address
- * @param timeout_ms Timeout in milliseconds (0 = wait forever)
- * @return true if connected, false if timeout
- */
- bool wifi_wait_connected(uint32_t timeout_ms);
- /**
- * Get the device MAC address as a string (XX:XX:XX:XX:XX:XX)
- */
- void wifi_get_mac_str(char *mac_str, size_t len);
- /**
- * Check if WiFi STA is connected
- */
- bool wifi_is_connected(void);
- /**
- * Get current IP address as string
- * @param ip_str Output buffer
- * @param len Buffer size
- * @return ESP_OK on success
- */
- esp_err_t wifi_get_ip_str(char *ip_str, size_t len);
- /**
- * Scan for available WiFi networks
- * @param ap_list Output array of AP info (caller must free)
- * @param ap_count Output: number of APs found
- * @return ESP_OK on success
- */
- esp_err_t wifi_scan(wifi_ap_record_t **ap_list, uint16_t *ap_count);
- /**
- * Disconnect and stop WiFi
- */
- void wifi_stop(void);
- /**
- * Set the DHCP hostname from the given device name.
- * Sanitizes to a valid DNS label (lowercase, hyphens for spaces/symbols).
- * Takes effect on the next DHCP transaction.
- */
- void wifi_set_hostname(const char *device_name);
|