Local Network / Internet connexion detect

Topics related to the iOS and/or Apple Watch app.
Post Reply
typiak84
Posts: 4
Joined: Wed Feb 14, 2018 11:31 pm

Local Network / Internet connexion detect

Post by typiak84 » Tue Jan 22, 2019 5:12 pm

Hi Dave,
I have a problem to submit to you:

Currently, all my configuration is enginered to be controlled from the internet.
The configuration of the Interface Manager uses my public IP address with the ports that I configured in the port forwarding section of my router.
All work all right

Here is what I want to do:
When I'm at home, in the Interface Manager, I would like the IP adresses of my equipments are the local ones
And from the Internet (outside my home),I would like the IP adresses of my equipments are changed to my public IP (as currently).
I managed to make a first step with a button in an Activity that changes the value of some variables that are declared in the IP Address field of the Interface Manager.
So far so good.
But I need your help to know how to detect that I am on my local network or outside to automatically ( whithout a button to do this) change the IP in the Interfaces Manager.
Do you know a way to do it?
Maybe a "what is my IP" to compare it whith my fixed public IP address but I do not see an easy way to do that in a script.
Do you see another way to do it and if so how?

Thank you.

User avatar
Dave
Site Admin
Posts: 77
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Local Network / Internet connexion detect

Post by Dave » Wed Jan 23, 2019 1:51 am

Hi typiak84!. Great question - TouchControl should already handle all of this for you! You should only need to do two things:

1) When creating the interface host entry in Interface Manager, specify a WAN port that matches the port you use in the port forwarding in your router for that device. It can be the same as or different from the normal LAN port.

Image

2) When adding the server entry in Network Settings in TouchControl on your device (or when editing a server entry that was automatically added via Zero Config Networking), just add the hostname or IP address used by your dynamic DNS service in the "WAN Server" field for the desired server.

Image

Then, whenever TouchControl detects that it is not on WiFi, it will automatically use the WAN Server address/hostname for all connections, and it will use the WAN port specified for each interface host. Also, if you are outside your network, but are still on Wifi (such as a public WiFi connection at a hotel or coffee shop), just turn on the "Force WAN" option in Network Settings in TC on your device, and even though it detects that it is on WiFi, it will still use the WAN connection settings.

Let me know if this is what you are looking for.

Thanks!
Dave

typiak84
Posts: 4
Joined: Wed Feb 14, 2018 11:31 pm

Re: Local Network / Internet connexion detect

Post by typiak84 » Wed Jan 23, 2019 2:34 pm

All right!
If i understand: At startup, the app try to connect the TC Server:
- If it could, the app use the local ip addresses inputed of the Interface Manager.
- If not, the app use the hostname or IP public adress inputed in the server settings fiels of the device.
I understand better why I did not succeed until now: my TC server in on a Laptop always whith me.
Then, i just have to install a TC server at home.
Do i have to let him open ? or is it a service?

User avatar
Dave
Site Admin
Posts: 77
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Local Network / Internet connexion detect

Post by Dave » Wed Jan 23, 2019 3:02 pm

If the app detects that it’s on WiFi it will try to reach the server at startup, but no, the server does not have to be running at all to use the app. If the app fails to find the server it will not affect the use of the app at all. Whether the app uses the LAN or WAN addresses is not dependent on whether or not it finds the server, it is only dependent on whether it detects a WiFi connection on the device or not. Hope that makes sense.

typiak84
Posts: 4
Joined: Wed Feb 14, 2018 11:31 pm

Re: Local Network / Internet connexion detect

Post by typiak84 » Thu Jan 24, 2019 2:45 pm

Yes, it makes sense for me.

It just detect if the device has a wifi connexion and if not, it use the IP public adress inputed in the server settings fiels of the device.
Well:
"At home": Local IP Addresses
"In the street": IP public adress inputed in the server settings fiels of the device.
"Whith my office wifi connexion": Local IP Addresses ,then ,don't work. I juste have to tick the "Force WAN" option in the Network Settings of the device. and all is all right...

Still just an issue: my conf is tune to open on a default activity.
When i change the "Force Wan" option, i had to restart the app because after change this, it reload the profile but stay blank (just the TC background) and don't reload the default activity. Is it possible you modify the app in the next release to correct this issue?

Post Reply