### Install Git and Raspi-gpio Utility Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/Linux_based_readme.md Installs Git for version control and the raspi-gpio utility, which are required tools for the ESP-IoT-Bridge setup on Raspberry Pi. ```bash $ sudo apt install git raspi-gpio ``` -------------------------------- ### Create Project from ESP-IoT-Bridge Example Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/README.md Generate a new project from an ESP-IoT-Bridge example template using the `create-project-from-example` command. The `wifi_router` example is shown. ```bash idf.py create-project-from-example "espressif/iot_bridge=*:wifi_router" ``` -------------------------------- ### Get esptool Help Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/User_Guide.md Run this command to view the full features and options available for the esptool. ```bash ./components/esptool_py/esptool/esptool.py --help ``` -------------------------------- ### Create All Kconfig-Enabled Netifs with ESP-IDF Initialization Source: https://context7.com/espressif/esp-iot-bridge/llms.txt Initializes ESP-IDF components and creates all network interfaces enabled in `idf.py menuconfig`. This is the recommended starting point for most applications. ```c #include "nvs_flash.h" #include "esp_netif.h" #include "esp_event.h" #include "esp_bridge.h" void app_main(void) { // Required ESP-IDF initialization ESP_ERROR_CHECK(nvs_flash_init()); ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_event_loop_create_default()); // Creates all netifs configured in menuconfig // e.g. SoftAP (data-forwarding) + Station (external) for Wi-Fi Router mode esp_bridge_create_all_netif(); // At this point, the bridge is running. // Clients connecting to the SoftAP will get DHCP addresses and // have their traffic NAT-forwarded through the Station interface. } ``` -------------------------------- ### Install Python Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/Linux_based_readme.md Installs Python, which is a requirement for the ESP-IoT-Bridge solution. This command installs Python 2.x. For Python 3.x, use 'python3'. ```bash $ sudo apt install python ``` -------------------------------- ### Install Bluetooth Stack Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/Linux_based_readme.md Installs the Bluetooth stack and utilities required for the ESP-IoT-Bridge solution on Raspberry Pi. ```bash $ sudo apt install pi-bluetooth ``` -------------------------------- ### Install Raspberry Pi Kernel Headers Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/Linux_based_readme.md Installs the necessary kernel headers for Raspberry Pi, which are required for driver compilation. Run this command before proceeding with other setup steps. ```bash $ sudo apt update $ sudo apt install raspberrypi-kernel-headers ``` -------------------------------- ### Install Python 3 Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/Linux_based_readme.md Installs Python 3, which is a requirement for the ESP-IoT-Bridge solution. This command installs Python 3.x. ```bash $ sudo apt install python3 ``` -------------------------------- ### Verify Kernel Headers Installation Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/Linux_based_readme.md Verifies if the kernel headers are installed correctly by checking for the presence of the build directory. If this command fails, kernel headers may not be installed properly. ```bash $ ls /lib/modules/$(uname -r)/build ``` -------------------------------- ### JavaScript: Get Available Wi-Fi Networks Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/web_server/fs_image/index.html Requests a list of available Wi-Fi networks from the device and initializes the Wi-Fi list display. Handles potential errors during the request. ```javascript function getaprecord(){showLoading();console.log("getaprecord");Ajax.get("/getaprecord",function(c){c=JSON.parse(c);console.log(c);try{if(c.state==0){wifiList=c.aplist;initWifiList(wifiList,null);hideLoading("msg-load")}else{showMessage(getPrompt("getWifiFailed"),2000)}}catch(d){showMessage(getPrompt("getWifiFailed"),2000)}})} ``` -------------------------------- ### Update IDF Component Manager Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/README.md If you encounter issues with the package manager, update it by running `pip install -U idf-component-manager` in your ESP-IDF environment. ```bash pip install -U idf-component-manager ``` -------------------------------- ### esp_bridge_create_softap_netif Source: https://context7.com/espressif/esp-iot-bridge/llms.txt Creates a Wi-Fi SoftAP network interface used as a downstream (LAN/data-forwarding) interface. Requires `CONFIG_BRIDGE_DATA_FORWARDING_NETIF_SOFTAP`. The SoftAP gets a DHCP server and NAT enabled automatically; its SSID/password are configured via menuconfig or `esp_bridge_wifi_set`. ```APIDOC ## esp_bridge_create_softap_netif — Create SoftAP (LAN) netif ### Description Creates a Wi-Fi SoftAP network interface used as a downstream (LAN/data-forwarding) interface. Requires `CONFIG_BRIDGE_DATA_FORWARDING_NETIF_SOFTAP`. The SoftAP gets a DHCP server and NAT enabled automatically; its SSID/password are configured via menuconfig or `esp_bridge_wifi_set`. ### Usage Example ```c #include "esp_bridge.h" // Custom IP for SoftAP subnet (optional; NULL = auto-allocate from pool) esp_netif_ip_info_t ap_ip = { .ip = { .addr = ESP_IP4TOADDR(192, 168, 5, 1) }, .gw = { .addr = ESP_IP4TOADDR(192, 168, 5, 1) }, .netmask = { .addr = ESP_IP4TOADDR(255, 255, 255, 0) }, }; // data_forwarding=true, enable_dhcps=true esp_netif_t *ap = esp_bridge_create_softap_netif(&ap_ip, NULL, true, true); if (ap == NULL) { ESP_LOGE("app", "Failed to create SoftAP netif"); return; } // Configure SoftAP credentials ESP_ERROR_CHECK(esp_bridge_wifi_set(WIFI_MODE_AP, "ESP_Bridge_AP", "bridge123", NULL)); // Clients can now connect to "ESP_Bridge_AP" and receive IPs in 192.168.5.x ``` ``` -------------------------------- ### Set Minimum CMake Version and Include Project Script Source: https://github.com/espressif/esp-iot-bridge/blob/master/examples/wired_nic/CMakeLists.txt Specifies the minimum required CMake version and includes the main project build script from the ESP-IDF tools directory. This is a standard setup for ESP-IDF projects. ```cmake cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) ``` -------------------------------- ### Load IP Info from NVS and Control Conflict Check Source: https://context7.com/espressif/esp-iot-bridge/llms.txt Loads previously persisted IP information from NVS for a named netif and allows enabling/disabling IP conflict-check behavior per netif at runtime. Use this to restore saved configurations or disable conflict checks for static setups. ```c #include "esp_bridge.h" // Load saved IP config for the SoftAP netif from NVS esp_netif_ip_info_t loaded_ip = {0}; bool conflict_check = true; esp_err_t err = esp_bridge_load_ip_info_from_nvs("WIFI_AP_DEF", &loaded_ip, &conflict_check); if (err == ESP_OK) { ESP_LOGI("app", "Loaded IP: " IPSTR ", conflict_check=%d", IP2STR(&loaded_ip.ip), conflict_check); } else { ESP_LOGW("app", "No saved IP found in NVS, using auto-allocation"); } // Disable conflict checking for a specific netif (e.g. for a static known-good config) esp_netif_t *ap = esp_bridge_get_softap_netif(); ESP_ERROR_CHECK(esp_bridge_netif_set_conflict_check(ap, false)); ``` -------------------------------- ### Build the Project Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/User_Guide.md After configuring the project using 'idf.py menuconfig', run this command to generate the project's binary files. ```bash idf.py build ``` -------------------------------- ### Flash the Project onto the Device Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/User_Guide.md Connect the ESP device via USB and use this command to flash the compiled project onto the device. ```bash idf.py flash ``` -------------------------------- ### Configure Wi-Fi Provisioning Manager Component Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/wifi_prov_mgr/CMakeLists.txt Defines the source files, include directories, and dependencies for the Wi-Fi provisioning manager component. Ensure 'wifi_provisioning', 'qrcode', and 'esp_wifi' are available. ```cmake set(srcs "src/wifi_prov_mgr.c") set(requires "wifi_provisioning" "qrcode" "esp_wifi") idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "include" REQUIRES "${requires}") ``` -------------------------------- ### Initialize Wi-Fi List Display Logic Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/web_server/fs_image/index.html Sets up event listeners for showing and hiding the Wi-Fi list, and for handling user input in the SSID field. It also manages the display of the Wi-Fi list based on mobile device detection. ```javascript function initShowList(){ document.getElementById("show-wifi-list").onclick=function(b){ console.log(isShowWifi); isShowWifi=!isShowWifi; console.log(isShowWifi); if(isShowWifi){ getaprecord() }else{ removeWifiList() } document.getElementById("ssid").focus(); window.event?window.event.cancelBubble=true:b.stopPropagation() }; document.getElementById("ssid").onclick=function(b){ window.event?window.event.cancelBubble=true:b.stopPropagation() }; document.getElementById("body-wrap").onclick=function(b){ if(!isMobile){ isShowWifi=false; removeWifiList() } }; document.getElementById("ssid").oninput=function(){ console.log("oninput"); console.log(isShowWifi); console.log(isMobile); if(isShowWifi&&!isMobile){ var b=document.getElementById("wifi-list-wrap"); console.log(b); if(b){ console.log(this.value); document.getElementById("ssid-wrap").removeChild(b); initWifiList(wifiList,this.value) } } } } ``` -------------------------------- ### Create Wi-Fi Station (WAN) Netif and Connect Source: https://context7.com/espressif/esp-iot-bridge/llms.txt Creates a Wi-Fi Station network interface for upstream connectivity and connects to a router. Requires `CONFIG_BRIDGE_EXTERNAL_NETIF_STATION` to be enabled. Handles DNS and IP-segment conflict updates automatically upon connection. ```c #include "esp_bridge.h" #include "esp_bridge_wifi.h" // for esp_bridge_wifi_set // Create station netif (ip_info=NULL: DHCP client; mac=NULL: auto-assign) esp_netif_t *sta = esp_bridge_create_station_netif(NULL, NULL, false, false); if (sta == NULL) { ESP_LOGE("app", "Failed to create station netif"); } // Connect to an upstream router ESP_ERROR_CHECK(esp_bridge_wifi_set(WIFI_MODE_STA, "MyRouter_SSID", "MyRouter_Pass", NULL)); ESP_ERROR_CHECK(esp_wifi_connect()); // On IP_EVENT_STA_GOT_IP, bridge automatically updates DNS and resolves // IP segment conflicts for all data-forwarding netifs. ``` -------------------------------- ### AJAX Request Handling in JavaScript Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/web_server/fs_image/index.html Provides functions for making GET, POST, and file POST requests using XMLHttpRequest. Use these for asynchronous communication with the server. ```javascript var Ajax={ get:function(e,d){ var f; if(window.XMLHttpRequest){ f=new XMLHttpRequest() }else{ if(window.ActiveObject){ f=new ActiveXobject("Microsoft.XMLHTTP") } } f.open("GET",e,true); f.onreadystatechange=function(){ if(f.readyState==4){ console.log(f.status); if(f.status==200||f.status==304){ d.call(this,f.responseText) }else{ showMessage(getPrompt("requestFailed"),1000); hideLoading("msg-load") } } }; f.send() }, post:function(e,g,h){ showLoading(); var f; if(window.XMLHttpRequest){ f=new XMLHttpRequest() }else{ if(window.ActiveObject){ f=new ActiveXobject("Microsoft.XMLHTTP") } } f.open("POST",e,true); f.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"); f.onreadystatechange=function(){ if(f.readyState==4){ if(f.status==200||f.status==304){ h.call(this,f.responseText) }else{ hideLoading("msg-load"); showMessage(getPrompt("connectFailed"),2000) } } }; f.send(g) }, postFile:function(e,g,h){ showLoading(); var f; if(window.XMLHttpRequest){ f=new XMLHttpRequest() }else{ if(window.ActiveObject){ f=new ActiveXobject("Microsoft.XMLHTTP") } } f.open("POST",e,true); f.setRequestHeader("Content-Type","application/octet-stream;charset=UTF-8"); f.onreadystatechange=function(){ if(f.readyState==4){ if(f.status==200||f.status==304){ h.call(this,f.responseText) }else{ hideLoading("msg-load"); showConfirm(getPrompt("prompt"),getPrompt("otaFailed"),getPrompt("confirm")) } } }; f.send(g) } }; ``` -------------------------------- ### Initialize Host Driver on Raspberry Pi Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/SDIO_setup.md Execute these commands in the root directory of the ESP-IoT-Bridge repository on the Raspberry Pi to compile and load the host driver for SDIO communication. ```bash cd esp-iot-bridge/examples/spi_and_sdio_host/host_driver/linux/host_control ./rpi_init.sh sdio ``` -------------------------------- ### JavaScript: Get Wi-Fi Station Info Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/web_server/fs_image/index.html Fetches the current Wi-Fi station information from the device. It handles success and failure cases, including timeouts and connection failures. ```javascript function getStatus(){if(timeoutNum>40){hideLoading("msg-load");showMessage(getPrompt("connectTimeout"),2000);return false}timeoutNum++;Ajax.get("/getstainfo",function(b){b=JSON.parse(b); console.log(b);document.getElementById("message").value=b.message;if(b.state==1){getResult()}else{if(b.state==0){setTimeout(function(){getStatus()},1000)}else{hideLoading("msg-load");showMessage(getPrompt("connectFailed"),2000)}}})} ``` -------------------------------- ### Configure ESP-IoT-Bridge Driver Sources and Includes Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/drivers/CMakeLists.txt Defines the main source files and include directories for the drivers. Conditionally appends source files based on build configurations like SDIO, SPI, or Bluetooth. ```cmake set(sub_srcs "drivers/src/network_adapter.c" "drivers/src/mempool.c" "drivers/src/mempool_ll.c") set(drivers_include "drivers/include") if (CONFIG_BRIDGE_EXTERNAL_NETIF_SDIO OR CONFIG_BRIDGE_DATA_FORWARDING_NETIF_SDIO) list(APPEND sub_srcs "drivers/src/sdio_slave_api.c") endif() if (CONFIG_BRIDGE_EXTERNAL_NETIF_SPI OR CONFIG_BRIDGE_DATA_FORWARDING_NETIF_SPI) list(APPEND sub_srcs "drivers/src/spi_slave_api.c") endif() if(CONFIG_BRIDGE_BT_ENABLED) list(APPEND sub_srcs "drivers/src/slave_bt.c") endif() set(include_dirs "${include_dirs}" "${drivers_include}" PARENT_SCOPE) set(srcs "${srcs}" "${sub_srcs}" PARENT_SCOPE) ``` -------------------------------- ### JavaScript: Initialize Wi-Fi List Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/web_server/fs_image/index.html Renders the list of Wi-Fi networks in the UI. It supports filtering and highlights the currently selected network. Includes mobile-specific styling with a mask. ```javascript function initWifiList(x,r){removeWifiList();var s=document.createElement("div");s.setAttribute("id","wifi-list-wrap");s.setAttribute("class","wifi-list-wrap");if(isMobile){var q=document.createElement("div");q.setAttribute("class","mask");q.setAttribute("id","mask");q.onclick=function(){removeWifiList()};s.appendChild(q)}var y=document.createElement("ul");var v="";var t=document.getElementById("ssid").value;console.log(t);for(var u=0;u'+p.ssid;if(p.auth_mode&&p.auth_mode!=0){v+='0){ b=b[0]; Ajax.postFile("/setotadata",b,function(a){ a=JSON.parse(a); console.log(a); hideLoading("msg-load"); if(a.state==0){ showConfirm(getPrompt("prompt"),getPrompt("otaSuc"),getPrompt("confirm")) }else{ showConfirm(getPrompt("prompt"),getPrompt("otaFailed"),getPrompt("confirm")) } }) }else{ showMessage(getPrompt("selectFile"),2000) } } ``` -------------------------------- ### Configure ethsta0 Network Interface Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/SDIO_setup.md After the SDIO driver is loaded, use this script to enable and configure the `ethsta0` network interface. The MAC address can be customized. ```bash $ cd esp-iot-bridge/example/spi_and_sdio_host/host_driver/linux/host_control $ ./ethsta0_config.sh 12:34:56:78:9a:bc ``` -------------------------------- ### Compile and Flash ESP Firmware Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/SPI_setup.md Compile the ESP-IoT-Bridge project and flash it to the ESP device using the specified serial port. Replace `` with the actual port of your ESP device. ```bash idf.py -p build flash ``` -------------------------------- ### Create All Network Interfaces Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/README.md The application layer can create all network interfaces by calling this API. Ensure the correct external and data forwarding netifs are selected in menuconfig. ```c esp_bridge_create_all_netif() ``` -------------------------------- ### Create All Network Interfaces Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/README.md This API is the primary entry point for the application layer to initialize all network interfaces managed by the ESP-IoT-Bridge. It allows selection of external and data forwarding network interfaces via menuconfig. ```APIDOC ## esp_bridge_create_all_netif() ### Description Initializes all network interfaces for the ESP-IoT-Bridge. Users can select specific network interfaces (external and data forwarding) through the Bridge Configuration menu in menuconfig. ### Usage This function should be called by the application to set up the bridge functionality. ### Note By default, calling this function is sufficient. Alternatively, specific netif creation APIs like `esp_bridge_create_xxx_netif` can be called manually. ``` -------------------------------- ### Configure Wi-Fi Station or SoftAP Credentials Source: https://context7.com/espressif/esp-iot-bridge/llms.txt Sets SSID, password, and optional BSSID for Wi-Fi Station or SoftAP. Appends MAC address to SSID if `CONFIG_BRIDGE_SOFTAP_SSID_END_WITH_THE_MAC` is enabled. ```c #include "esp_bridge.h" #include "esp_wifi.h" // Connect Station to upstream router ESP_ERROR_CHECK(esp_bridge_wifi_set(WIFI_MODE_STA, "HomeRouter", "securepass123", NULL)); ESP_ERROR_CHECK(esp_wifi_connect()); // Change SoftAP SSID and password at runtime ESP_ERROR_CHECK(esp_bridge_wifi_set(WIFI_MODE_AP, "MyBridge", "mypassword", NULL)); // All currently connected SoftAP clients are deauthenticated automatically. // Connect STA with a specific BSSID (to pin to a particular AP) uint8_t bssid[6] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; ESP_ERROR_CHECK(esp_bridge_wifi_set(WIFI_MODE_STA, "HomeRouter", "securepass123", (const char *)bssid)); ``` -------------------------------- ### Enable SPI on Raspberry Pi Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/SPI_setup.md Add these lines to `/boot/config.txt` to enable the SPI master driver and disable Bluetooth. Reboot is required after changes. ```bash dtparam=spi=on dtoverlay=disable-bt ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/espressif/esp-iot-bridge/blob/master/examples/wifi_router/CMakeLists.txt Sets the minimum CMake version, includes ESP-IDF build scripts, and defines the project name based on the current directory. ```cmake cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) string(REGEX REPLACE ".*/\\(.*)" "\\1" CURDIR ${CMAKE_CURRENT_SOURCE_DIR}) project(${CURDIR}) ``` -------------------------------- ### Configure ESP-IoT-Bridge for SDIO Interface Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/SDIO_setup.md Use `idf.py menuconfig` to open the project configuration. Navigate to 'Bridge Driver Configuration -> Transport layer -> SDIO interface' and select it to configure the project for SDIO communication. ```bash cd esp-iot-bridge idf.py menuconfig ``` -------------------------------- ### Initialize Host Driver on Raspberry Pi Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/SPI_setup.md This script compiles and loads the host driver for SPI communication on the Raspberry Pi. It creates a virtual serial interface `/dev/esps0` for control. ```bash $ cd esp-iot-bridge/examples/spi_and_sdio_host/host_driver/linux/host_control $ ./rpi_init.sh spi ``` -------------------------------- ### Create SPI/SDIO Netifs (WAN/LAN) Source: https://context7.com/espressif/esp-iot-bridge/llms.txt Creates SPI or SDIO network interfaces. Can operate as WAN or LAN, and support dual-role creation. Use `esp_bridge_spi_set_netif_type` or `esp_bridge_sdio_set_netif_type` to switch roles at runtime. ```c #include "esp_bridge.h" // SPI as LAN (data-forwarding, DHCP server for MCU host) esp_netif_t *spi_lan = esp_bridge_create_spi_netif(NULL, NULL, true, true); // SPI as WAN (external, DHCP client, fixed MAC) uint8_t spi_wan_mac[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; esp_netif_t *spi_wan = esp_bridge_create_spi_netif(NULL, spi_wan_mac, false, false); // Switch the SPI netif active role at runtime ESP_ERROR_CHECK(esp_bridge_spi_set_netif_type(IOT_BRIDGE_NETIF_LAN)); // Retrieve SPI netif by type esp_netif_t *spi = esp_bridge_get_spi_netif(IOT_BRIDGE_NETIF_LAN); // SDIO usage is identical: esp_netif_t *sdio_lan = esp_bridge_create_sdio_netif(NULL, NULL, true, true); ESP_ERROR_CHECK(esp_bridge_sdio_set_netif_type(IOT_BRIDGE_NETIF_LAN)); esp_netif_t *sdio = esp_bridge_get_sdio_netif(IOT_BRIDGE_NETIF_LAN); ``` -------------------------------- ### Set ESP-IDF Environment Variables Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/docs/SPI_setup.md Source this script in your terminal to set up the necessary ESP-IDF environment variables for compilation and flashing. ```bash . $HOME/esp/esp-idf/export.sh ``` -------------------------------- ### Create Ethernet Netif (WAN/LAN) Source: https://context7.com/espressif/esp-iot-bridge/llms.txt Creates an Ethernet network interface. Use WAN role for DHCP client and LAN role for DHCP server. Requires `CONFIG_BRIDGE_ETHERNET_NETIF_ENABLE`. ```c #include "esp_bridge.h" // --- WAN role: Ethernet receives IP from upstream router via DHCP --- // data_forwarding=false, enable_dhcps=false esp_netif_t *eth_wan = esp_bridge_create_eth_netif(NULL, NULL, false, false); // --- LAN role: Ethernet serves as a downlink NIC with DHCP server --- // data_forwarding=true, enable_dhcps=true esp_netif_t *eth_lan = esp_bridge_create_eth_netif(NULL, NULL, true, true); // Retrieve netif by type later esp_netif_t *wan = esp_bridge_get_eth_netif(IOT_BRIDGE_NETIF_WAN); esp_netif_t *lan = esp_bridge_get_eth_netif(IOT_BRIDGE_NETIF_LAN); ``` -------------------------------- ### Handle File Input for OTA Update Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/web_server/fs_image/index.html Validates the selected file for OTA updates, checking for the '.bin' extension and file size limits. Updates the file name input field and logs the file information. ```javascript function fileChange(e){ var c=e.files; if(c&&c.length>0){ c=c[0]; var d=c.name.toLowerCase(); if(d.indexOf(".bin")!=(d.length-4)){ document.getElementById("file-info").value=""; showMessage(getPrompt("formatError"),2000); return } if(c.size>=2097152){ document.getElementById("file-info").value=""; showMessage(getPrompt("fileLarge"),2000); return } document.getElementById("file-name").value=d; console.log(document.getElementById("file-info").files) } ``` -------------------------------- ### Apply Patches with Default Settings Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/iot_bridge/cmake/README.md Includes the patch utilities and applies patches using default configuration file and base directory settings. ```cmake # Include the patch utilities include(/path/to/esp-iot-bridge/components/iot_bridge/cmake/patch_utils.cmake) # Apply patches with default settings apply_patches_from_list() ``` -------------------------------- ### Language Initialization and Handling Source: https://github.com/espressif/esp-iot-bridge/blob/master/components/web_server/fs_image/index.html Initializes the application language based on the browser's locale and provides functions to set text content and input placeholders for different languages. Call `loadLanguage()` to apply the correct language on page load. ```javascript var curLangeage="en"; loadLanguage(); function loadLanguage(){ var c=navigator.language||navigator.userLanguage; c=c.substr(0,2); if(c=="zh"){ curLangeage="zh" }else{ curLangeage="en" } for(var a=0;a