ESP32 WiFi Library – WiFi.softAPenableIPv6

Home / References / ESP32 Library / WiFi API / AP

Description

The softAPenableIPv6 method is used to enable IPv6 support for the ESP32’s Soft Access Point (Soft-AP) mode. This allows the Soft-AP to handle IPv6 connections and provide IPv6 addresses to connected devices.

Syntax and Usage

The softAPenableIPv6 method can be used with or without specifying the enable argument. Below are the different ways to use this method:

bool softAPenableIPv6(bool enable = true);

Argument(s)

  • enable: A boolean value to enable or disable IPv6 support. Default is true.

Return Value

The method returns a boolean value:

  • true: If the IPv6 support is successfully enabled or disabled.
  • false: If the operation fails.

Example Codes

Enabling IPv6 Support

This code demonstrates how to configure an ESP32 to act as a Soft Access Point (AP) with IPv6 support enabled. The ESP32 creates a password-protected WiFi network using the SSID “AvantMaker-ESP32-AP” and password “12345678”. After setting up the AP, the code attempts to enable IPv6 support using the softAPenableIPv6() method. If successful, it prints a confirmation message along with the IPv4 address of the AP. However, due to limitations in the ESP32 Arduino core, the code does not retrieve or display the IPv6 address directly. To verify IPv6 functionality, please checkout the step-by-step instruction below the following code.

The example highlights the ESP32’s capability to support both IPv4 and IPv6 protocols, which is essential for modern networking applications requiring compatibility with next-generation internet protocols. While the ESP32 enables IPv6 functionality, retrieving the IPv6 address programmatically is not supported in the Arduino core. Users can confirm IPv6 support by connecting a client device to the ESP32’s AP and inspecting the assigned IPv6 address using tools like ipconfig (Windows) or ifconfig/ip addr (Linux/Mac). This setup serves as a foundation for integrating IPv6 support into ESP32-based projects, with further exploration required for advanced IPv6 features.

/*
 * Author: Avant Maker
 * Date: February 14, 2025
 * Version: 1.0
 * Description: This example code demonstrates how to use 
 * softAPenableIPv6 to enable IPv6 support for ESP32 Soft-AP.
 *
 * License: MIT 
 * 
 * Code Source: This example code is sourced from the Comprehensive 
 * Guide to the ESP32 Arduino Core Library, accessible on 
 * AvantMaker.com. For additional code examples and in-depth 
 * documentation related to the ESP32 Arduino Core Library, 
 * please visit:
 *
 * https://avantmaker.com/references/esp32-arduino-core-index/
 *
 * AvantMaker.com, your premier destination for all things 
 * DIY, AI, IoT, Smart Home, and STEM projects. We are dedicated 
 * to empowering makers,learners, and enthusiasts with the resources
 *  they need to bring their innovative ideas to life.
 */
#include <WiFi.h>

void setup() {
    Serial.begin(115200);

    // Configure Soft-AP
    WiFi.softAP("AvantMaker-ESP32-AP", "12345678");

    // Enable IPv6 support
    if (WiFi.softAPenableIPv6(true)) {
        Serial.println("IPv6 support enabled successfully.");

        // Get and print the IPv4 address
        IPAddress apIP = WiFi.softAPIP();
        Serial.print("AP IPv4 address: ");
        Serial.println(apIP);

        // Note: ESP32 Arduino core does not provide a way to retrieve the IPv6 address.
        Serial.println("IPv6 address cannot be retrieved directly. Check code description for details.");
    } else {
        Serial.println("Failed to enable IPv6 support.");
    }
}

void loop() {
    // Empty loop
}

How to Verify IPv6 Functionality

Since the ESP32 Arduino core does not provide a way to retrieve the IPv6 address programmatically, you can verify IPv6 functionality as follows:

  1. Connect a computer to the ESP32’s Soft AP using the SSID AvantMaker-ESP32-AP and password 12345678.
  2. Check Network ConfigurationOn the client device, check the network settings to see if an IPv6 address is assigned:
    • Windows: Open Command Prompt and run ipconfig. Look for an IPv6 address under the wireless adapter connected to the ESP32 AP.
    • Linux/Mac: Run ifconfig or ip addr in the terminal and look for an IPv6 address.
    You should see a link-local IPv6 address (starting with fe80::) assigned to the connection.
  3. Test IPv6 ConnectivityUse tools like ping6 (on Linux/Mac) or similar utilities to test IPv6 connectivity between the client device and the ESP32.

AvantMaker Tutorial Suggestion

If you want to learn more about the ESP32’s WiFi capabilities, we’ve created a beginner-friendly guide that explains them in detail. Just click the link below, and you’ll be teleported to that page. It will clear up any confusion you may have while connecting your ESP32 to WiFi or setting it up as a WiFi access point (AP).

ESP32 Essential Guide – Network Section – WiFi Chapter

ESP32 Library Index

ESP32 Arduino Core Library


FAQ

Ready to experiment and explore more about ESP32? Visit our website’s All About ESP32 Resources Hub, packed with tutorials, guides, and tools to inspire your maker journey. Experiment, explore, and elevate your skills with everything you need to master this powerful microcontroller platform!

error: Content is protected !!