9

Is there any way to check if actually my embedded device has a working connection (i.e. can reach the WAN)? My device has no RTOS, so I cannot rely on OS functionalities like ping. I can see that the DHCP gives a correct IP to my device, but it's not 100% true that given a correct IP I can then reach for example www.google.com.

I've already done some research, and there are different approaches:

  1. it's impossible
  2. it's a stupid question
  3. workarounds of every sort, but I feel confident with respect to SO so I'll give it a try.

So, if this is question has 1) or 2) as replies, I'll remove it and it's ok.

Bence Kaulics
  • 7,843
  • 8
  • 42
  • 90
panc_fab
  • 311
  • 1
  • 6

2 Answers2

4

Thanks guys for the support. I've finally used the method described by Helmar in which I just try to reach the desired target and see. If I can obtain a reply from the target, I know that my connection is alive and functioning, otherwise I manage to disconnect the device and retry with a fresh new connection.

Helmar
  • 8,450
  • 6
  • 36
  • 84
panc_fab
  • 311
  • 1
  • 6
3

I cannot rely on OS functionalities like ping.

Implement ping yourself. You can probably find an example for your platform.

Or contact some service via some other protocol you can support; just don't assume that the service will remain available for the lifetime of the device, unless it's a server you manage.

I need to access the device from the internet and exchange data with it

If your actual goal is to allow inbound traffic, generally that is a bad idea and hard for end users to enable their networks to permit. Instead, you'd typically make/maintain an outbound connection to a server down which it could tunnel or relay vetted incoming traffic intended for your device. You can readily equip the code which makes / maintains / reconnects this tunnel with an output mechanism to indicate its health.

Chris Stratton
  • 1,898
  • 8
  • 18