2v06 ESP32 Static IP not available?

Posted on
  • I'm running 2v06 esp32 espruino.

    If I read the docs correctly (no options in connect and setIP is unknown) it is not possible at this time to set a static IP (although it seems possible for esp8266)?

  • Yes, just checked setIP, getIP() setAPIP() and getAPIP() are not jet implemented for ESP32 implementation.

    If you like do the implementation.

  • Well if it involves CPP code that's a maybe. I've been exploring espruino as an option to writing CPP since CPP is not a language I know very well like node. Still, if it has been done for esp8266 maybe the implementation can more or less be copied.

  • ESP32 stuff is written in C.

    Starting point is jswrap_esp32_network.c and jswrap_esp32_network.h

    if it has been done for esp8266 maybe the implementation can more or less be copied.

    Not sure about this, because ESP32 is a bit different.

  • This library from espressif has a config method that accepts static ip as demonstrated in tutorial below.

    https://github.com/espressif/arduino-esp­32/blob/37a7fb3d6ada8a9230c96e2df999c95e­f10fd4d3/libraries/WiFi/src/WiFiSTA.h#L4­3

    Can this just be incorporated?

    https://randomnerdtutorials.com/esp32-st­atic-fixed-ip-address-arduino-ide/

    Alternatively If I can't get to this I'll set up a fixed IP from my DHCP server based on MAC for now.

  • I guess this is what you are looking for:

    // info about the structure 
    typedef struct {
        ip4_addr_t ip;
        ip4_addr_t netmask;
        ip4_addr_t gw;
    } tcpip_adapter_ip_info_t;
    
    
    // STA calls
    tcpip_adapter_dhcpc_stop(WIFI_IF_STA);
    tcpip_adapter_set_ip_info(WIFI_IF_STA, const tcpip_adapter_ip_info_t *ip_info)
    
    // AP - calls
    tcpip_adapter_dhcpc_stop(WIFI_IF_AP);
    tcpip_adapter_set_ip_info(WIFI_IF_AP, const tcpip_adapter_ip_info_t *ip_info)
    tcpip_adapter_dhcpc_start(WIFI_IF_AP);
    
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

2v06 ESP32 Static IP not available?

Posted by Avatar for dgk @dgk

Actions