EthernetNetIf assign static ip address

10 Dec 2010 . Edited: 10 Dec 2010

Can anyone explain why my code (this is a fragment ) doesnt work .I want to assign an ip address to my mbed. I dont want to use DHCP. I've tried lots of different permutations on calling the EthernetNetIf with and without ip addresses in brackets, with and without preceeding the address with IpAddr, with and without enclosing commas, with and without quotes etc etc etc. In this particular case I get the error ""No instance of constructor "IpAddr::IpAddr" matches the argument list (E289)" in file "/HTTPServerHelloWorld.cpp". Such a simple thing is getting in the way a lot and I'd be grateful for any assistance or guidance.

Greg

#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPServer.h"

EthernetNetIf eth(IpAddr(192.168.1.145),IpAddr(255.255.255.0),IpAddr(192.168.1.1),IpAddr(192.168.1.1));  
HTTPServer svr;

DigitalOut led1(LED1);

int main() {
  printf("Setting up...\n");
  EthernetErr ethErr = eth.setup();
  if(ethErr)
  {
    printf("Error %d in setup.\n", ethErr);
    return -1;
  }
  printf("Setup OK\n")

k. I want to assign a particular ip address to my mbed

10 Dec 2010

Hi Greg

You need a comma instead of a full stop separating the numbers in the IP address, viz:

EthernetNetIf eth(IpAddr(192,168,1,145),IpAddr(255,255,255,0),IpAddr(192,168,1,1),IpAddr(192,168,1,1));  

Regards
Daniel

Edit: PS Sorry I didn't cotton on this was the problem when I answered your previous post.

10 Dec 2010

Thanks for that Daniel. Problem solved !

20 Nov 2012

Hey guys,

I have this problem at hand and haven't been able to figure out how to work it out. The problem is as follows:

My mBed is connected toa temperature sensor. It is also connected to an ethernet port in my university and my university gives me a static IP (the DNS, the gateway and the network mask are unknown at this point in time) What I want to do is I want to connect to the mBed from another computer in a different university and fetch the data of the temperature sensor. The computer in the other university will send a request (such as "abc"). Only when this msg is validated should the mbed respond with the data.

What is the best way of doing this? If someone can help me with a code then it would be great. I am pretty naive at this side of computer science!