@@ -292,6 +292,38 @@ std::string WiFi::getApSSID() {
292
292
return std::string ((char *)conf.sta .ssid );
293
293
} // getApSSID
294
294
295
+ /* *
296
+ * @brief Get the current ESP32 IP form AP.
297
+ * @return The ESP32 IP.
298
+ */
299
+ std::string WiFi::getApIp (){
300
+ tcpip_adapter_ip_info_t ipInfo = getApIpInfo ();
301
+ char ipAddrStr[30 ];
302
+ inet_ntop (AF_INET, &ipInfo.ip .addr , ipAddrStr, sizeof (ipAddrStr));
303
+ return std::string (ipAddrStr);
304
+ } // getStaIp
305
+
306
+ /* *
307
+ * @brief Get the current AP netmask.
308
+ * @return The Netmask IP.
309
+ */
310
+ std::string WiFi::getApNetmask (){
311
+ tcpip_adapter_ip_info_t ipInfo = getApIpInfo ();
312
+ char ipAddrStr[30 ];
313
+ inet_ntop (AF_INET, &ipInfo.netmask .addr , ipAddrStr, sizeof (ipAddrStr));
314
+ return std::string (ipAddrStr);
315
+ } // getStaNetmask
316
+
317
+ /* *
318
+ * @brief Get the current AP Gateway IP.
319
+ * @return The Gateway IP.
320
+ */
321
+ std::string WiFi::getApGateway (){
322
+ tcpip_adapter_ip_info_t ipInfo = getApIpInfo ();
323
+ char ipAddrStr[30 ];
324
+ inet_ntop (AF_INET, &ipInfo.gw .addr , ipAddrStr, sizeof (ipAddrStr));
325
+ return std::string (ipAddrStr);
326
+ } // getStaGateway
295
327
296
328
/* *
297
329
* @brief Lookup an IP address by host name.
@@ -351,6 +383,40 @@ tcpip_adapter_ip_info_t WiFi::getStaIpInfo() {
351
383
return ipInfo;
352
384
} // getStaIpInfo
353
385
386
+ /* *
387
+ * @brief Get the current ESP32 IP form STA.
388
+ * @return The ESP32 IP.
389
+ */
390
+ std::string WiFi::getStaIp (){
391
+ tcpip_adapter_ip_info_t ipInfo = getStaIpInfo ();
392
+ char ipAddrStr[30 ];
393
+ inet_ntop (AF_INET, &ipInfo.ip .addr , ipAddrStr, sizeof (ipAddrStr));
394
+ return std::string (ipAddrStr);
395
+ } // getStaIp
396
+
397
+
398
+ /* *
399
+ * @brief Get the current STA netmask.
400
+ * @return The Netmask IP.
401
+ */
402
+ std::string WiFi::getStaNetmask (){
403
+ tcpip_adapter_ip_info_t ipInfo = getStaIpInfo ();
404
+ char ipAddrStr[30 ];
405
+ inet_ntop (AF_INET, &ipInfo.netmask .addr , ipAddrStr, sizeof (ipAddrStr));
406
+ return std::string (ipAddrStr);
407
+ } // getStaNetmask
408
+
409
+
410
+ /* *
411
+ * @brief Get the current STA Gateway IP.
412
+ * @return The Gateway IP.
413
+ */
414
+ std::string WiFi::getStaGateway (){
415
+ tcpip_adapter_ip_info_t ipInfo = getStaIpInfo ();
416
+ char ipAddrStr[30 ];
417
+ inet_ntop (AF_INET, &ipInfo.gw .addr , ipAddrStr, sizeof (ipAddrStr));
418
+ return std::string (ipAddrStr);
419
+ } // getStaGateway
354
420
355
421
/* *
356
422
* @brief Get the MAC address of the STA interface.
@@ -501,6 +567,27 @@ std::vector<WiFiAPRecord> WiFi::scan() {
501
567
* @return N/A.
502
568
*/
503
569
void WiFi::startAP (const std::string& ssid, const std::string& password, wifi_auth_mode_t auth) {
570
+ startAP (ssid, password, auth, 0 , false , 4 );
571
+ } // startAP
572
+
573
+ /* *
574
+ * @brief Start being an access point.
575
+ *
576
+ * @param[in] ssid The SSID to use to advertize for stations.
577
+ * @param[in] password The password to use for station connections.
578
+ * @param[in] auth The authorization mode for access to this access point. Options are:
579
+ * * WIFI_AUTH_OPEN
580
+ * * WIFI_AUTH_WPA_PSK
581
+ * * WIFI_AUTH_WPA2_PSK
582
+ * * WIFI_AUTH_WPA_WPA2_PSK
583
+ * * WIFI_AUTH_WPA2_ENTERPRISE
584
+ * * WIFI_AUTH_WEP
585
+ * @param[in] channel from the access point.
586
+ * @param[in] is the ssid hidden, ore not.
587
+ * @param[in] limiting number of clients.
588
+ * @return N/A.
589
+ */
590
+ void WiFi::startAP (const std::string& ssid, const std::string& password, wifi_auth_mode_t auth, uint8_t channel, bool ssid_hidden, uint8_t max_connection) {
504
591
ESP_LOGD (LOG_TAG, " >> startAP: ssid: %s" , ssid.c_str ());
505
592
506
593
init ();
@@ -517,10 +604,10 @@ void WiFi::startAP(const std::string& ssid, const std::string& password, wifi_au
517
604
::memcpy (apConfig.ap.ssid, ssid.data(), ssid.size());
518
605
apConfig.ap .ssid_len = ssid.size ();
519
606
::memcpy (apConfig.ap.password, password.data(), password.size());
520
- apConfig.ap .channel = 0 ;
607
+ apConfig.ap .channel = channel ;
521
608
apConfig.ap .authmode = auth;
522
- apConfig.ap .ssid_hidden = 0 ;
523
- apConfig.ap .max_connection = 4 ;
609
+ apConfig.ap .ssid_hidden = ( uint8_t ) ssid_hidden ;
610
+ apConfig.ap .max_connection = max_connection ;
524
611
apConfig.ap .beacon_interval = 100 ;
525
612
526
613
errRc = ::esp_wifi_set_config (WIFI_IF_AP, &apConfig);
@@ -543,7 +630,6 @@ void WiFi::startAP(const std::string& ssid, const std::string& password, wifi_au
543
630
ESP_LOGD (LOG_TAG, " << startAP" );
544
631
} // startAP
545
632
546
-
547
633
/* *
548
634
* @brief Set the event handler to use to process detected events.
549
635
* @param[in] wifiEventHandler The class that will be used to process events.
0 commit comments