7 years, 3 months ago.

Static ip error

Hi,

When i try to compile the sketch below for my nucleo 144 i get the following : "Error: Class "EthernetInterface" has no member "init" in "main.cpp", Line: 35, Col: 10" because of this line : "eth.init(IP, MASK, GATEWAY);".

DHCP is working but static IP still dont working ....

Pls help.... thanks

"#if !FEATURE_LWIP

  1. error [NOT_SUPPORTED] LWIP not supported for this target
  2. endif
  1. include "mbed.h"
  2. include "EthernetInterface.h"
  3. include "TCPServer.h"
  4. include "TCPSocket.h"
  1. define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
  2. define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
  3. define HTTP_MESSAGE_BODY "" \ "<html>" "\r\n" \ " <body style=\"display:flex;text-align:center\">" "\r\n" \ " <div style=\"margin:auto\">" "\r\n" \ " <h1>Hello World</h1>" "\r\n" \ " <p>It works !</p>" "\r\n" \ " </div>" "\r\n" \ " </body>" "\r\n" \ "</html>"
  1. define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n" \ HTTP_HEADER_FIELDS "\r\n" \ "\r\n" \ HTTP_MESSAGE_BODY "\r\n"
  1. define IP "192.168.1.102"
  2. define GATEWAY "192.168.1.1"
  3. define MASK "255.255.255.0" int main() { printf("Basic HTTP server example\n");

EthernetInterface eth; eth.init(IP, MASK, GATEWAY); eth.connect();

printf("The target IP address is '%s'\n", eth.get_ip_address());

TCPServer srv; TCPSocket clt_sock; SocketAddress clt_addr;

/* Open the server on ethernet stack */ srv.open(&eth);

/* Bind the HTTP port (TCP 80) to the server */ srv.bind(eth.get_ip_address(), 80);

/* Can handle 5 simultaneous connections */ srv.listen(1);

while (true) { srv.accept(&clt_sock, &clt_addr); printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port()); clt_sock.send(HTTP_RESPONSE, strlen(HTTP_RESPONSE)); } }"

FYI, when posting here. please use

<<code>>
your code here
<</code>>

The code formatting is then correctly preserved.

posted by Andy A 28 Mar 2017

1 Answer