How do Internet-Of-Things apps detect if the device is local or not?
Internet of Things
IoT Frameworks
2 years ago
5
Star Rating
1
Rating
_x000D_
_x000D_
Among other devices, I have a Belkin WeMo switch and a 3M WiFi Thermostat. Both come with Android apps. When I open the app when at home (phone on the same WiFi subnet as the devices) the app says the devices are "local", or that the app is connected "directly" to the device. Any change I make is then directly reflected on the device.
If I connect from anywhere outside my house, it some how "knows" that the device is not local. If I understand correctly, it then updates its own server somewhere, and eventually the device at home gets the update.
How does an app do that? I want to replicate that functionality.
Basically, I have a Raspberry Pi that, let's say does something over GPIO and I can trigger that action by visiting a web page. On my home network, the web page is accessible at http://192.168.10.25/do_something ...Outside my home network, the web page is accessible at http://my_custom_name.some_free_dynamic_dns.com:8080/do_something. I have set up my router to port forward 8080 on WAN to 192.168.10.25:80 on LAN. This works.
How do I avoid having 2 pages? I want to write an app which effectively shows me the 192.168.10.25/do_something URL. When I am at home, it should "automatically" detect that the phone is on the same network as the URL, and just open 192.168.10.25/do_something directly ... and when I am outside, it should "automatically" detect that too and launch http://my_custom_name.some_Free_dynamaic_dns.com:8080/do_something.
The key part here is that when at home, even if my ISP is down and host names aren't resolving, it shouldn't matter because everything is local.
How do I go about doing this?
Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Take Quiz To Earn Credits!
Turn Your Knowledge into Earnings.