Skip to content

Ethernet::begin incompatible with ESP8266 #34

@GiovanniCmpaner

Description

@GiovanniCmpaner

Currently using
void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet)
generates a compiler error, as IPAddress from the ESP8266 core doesn't have a _address member:
https://github.com/esp8266/Arduino/blob/master/cores/esp8266/IPAddress.h

These lines:

#if ARDUINO > 106 || TEENSYDUINO > 121
W5100.setIPAddress(ip._address.bytes);
W5100.setGatewayIp(gateway._address.bytes);
W5100.setSubnetMask(subnet._address.bytes);
#else
W5100.setIPAddress(ip._address);
W5100.setGatewayIp(gateway._address);
W5100.setSubnetMask(subnet._address);
#endif

Should be:

W5100.setIPAddress(ip.raw_address());
W5100.setGatewayIp(gateway.raw_address());
W5100.setSubnetMask(subnet.raw_address());

It isn't necessary to check the version, as raw_address() is available since Arduino 1.0.5:
https://github.com/arduino/Arduino/blob/22997bbfd5c841a60e9a5909868c62cd459c798d/hardware/arduino/cores/arduino/IPAddress.h

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions