Skip to content

ESP8266 set_network static function not working. #12552

@star297

Description

@star297

Description of defect

Can't set static parameters on the ESP8266, works for ETHERNET but not WIFI.
Not sure whether the Mbed driver ever has worked tbh.
Connects with no errors, but has default IP.

#define IP         "192.168.1.180"
#define GATEWAY    "192.168.1.1"
#define NETMASK    "255.255.255.0" 

NetworkInterface* net = NetworkInterface::get_default_instance();  

net->set_network((SocketAddress)IP,(SocketAddress)NETMASK,(SocketAddress)GATEWAY);

if (!net) {
    printf("No network interface found, select an interface in 'mbed_app.json'\n");
    return NULL;
}
nsapi_error_t connect_status = net->connect();
if (connect_status != NSAPI_ERROR_OK) {
    printf("Failed to connect to network (%d)\n", connect_status);
    return NULL;
}
SocketAddress net_addr;   
net->get_ip_address(&net_addr);
printf("IP address: %s\n", net_addr.get_ip_address() ? net_addr.get_ip_address() : "None");
net->get_netmask(&net_addr);
printf("Netmask:    %s\n", net_addr.get_ip_address() ? net_addr.get_ip_address() : "None");
net->get_gateway(&net_addr);
printf("Gateway:    %s\n", net_addr.get_ip_address() ? net_addr.get_ip_address() : "None");    
printf("MAC:        %s\n", net->get_mac_address());

Target(s) affected by this defect ?

Testing on STM32F767ZI, but will affect all that would use ESP8266

Toolchain(s) (name and version) displaying this defect ?

Mbed Online

What version of Mbed-os are you using (tag or sha) ?

OS 5.15.1 rev. 7355

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Mbed Online

How is this defect reproduced ?

The example will show the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions