Local IP address? - android

I'm building an android app for connecting two devices together, but just as general question: Since we are all connected to a wireless LAN, the IP addresses are local, not global. I'm just wondering if we can connect to a devices using it's local IP address?!

#Tina: Sure you can. The trick is to use static IP, not DHCP IP, so that it will be clear which client is identified by what IP address.

You could also use a multicast to find other devices in the same local network

Related

android volley library does not work on local IP

volley is not working when i want to fetch data from a system on my local network.
where URL is like http://192.168.x.x/data.php
it works well on emulator but not on a real device. it show a time our error.
even i tried setting a maximum time our and retry policy. but in vain.
There are two ways to solve this:
a) keep your device connected to the PC which is connected to your local network either using lan or wifi. Keep debugging mode on. Use ipconfig to check your pcs ipv4 address and use that.
forward your server's port on your router and then use the ipv4 address found on your pc's ipconfig command.
c) Best option-> i use this. Forward your pc's server port on your router, Go to your router's DHCP configurations and give your pc mac a preferred DHCP ip to make sure your router always gives that local ip to your pc(global will still be dynamic if you dont have a static ip). Register to a DDNS and use the set ip above and you will be able to access your web service from anywhere in the world. (i use dynudns for the ddns part)
see How can I access my localhost from my Android device? for other ideas
In the first two steps, make sure that the mobile is connected via wifi so that the router can forward it requests. in third, it can be connected to the internet anyway it likes. Also in the first, you will have to change the url everytime your local ip changes.
In second option, the dns will give a tool for auto ip updation :)

How to find all the esp8266 connected to a router

Hi all I want to connect multiple esp8266 devices to my router and create a mobile app that can find those devices and send messages to them using udp.
Currently my plan is to let esp devices listen to a port and then my app would send a message on that port, esp would respond and the app will store the IP.
Is there any better way to do that?
A friend of mine told me that this approach will fail if routers's gateway is changed. Is it true?
I am just calling WiFi.begin(Ssid, Password); to connect to wifi without doing any changes with wifi.conf().
I am using arduino SDK.
Give your ESP8266 devices a static IP addresses so the mobile app will know in advance where they could be 'found':
IPAddress ip(192,168,1,xx); // desired static IP address
IPAddress gateway(192,168,1,yy); // IP address of the router
IPAddress subnet(255,255,255,0);
WiFi.begin(ssid, password);
WiFi.config(ip, gateway, subnet);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
and use dynamic DNS service (unless you have a static IP address) with port forwarding to access each of the ESPs. You can choose ports 8266, 8267, 8268, 8269, ... or any other above 1024 and then set the port forwarding in your router settings so port 8266 will be forwarded to the IP address of your first ESP and port 80 (or any other), port 8267 will be forwarded to the IP address of your second ESP and port 80 etc.
Afterwards you can access your ESPs from mobile app (or internet) using URLs looking like http://xx.xx.xx.xx:8266, http://xx.xx.xx.xx:8267, http://xx.xx.xx.xx:8268, http://xx.xx.xx.xx:8269, ... or by using dynamic DNS service with: http://myhome.something.com:8266, http://myhome.something.com:8267 etc. Or you can access them from your local network by known static IP addresses. That is - your mobile app will have to determine if it is inside local network or not. Or you can always access ESPs using proxy - in that case the URLs will not depend upon being inside or outside the local network.
Your friend may have more of the details of your solution, but IMO the gateway has nothing to do with it. If all clients and the server are on the same subnet inside the router's local network then the gateway doesn't come into play.
I would do a UDP multicast. Your mobile app would just need to send one request and then listen for replies from the ESPs for a few seconds.
One way is to check all the Mac addresses on the network. The first 6 digits is the unique code for the company that made the wifi dongle.
This is assuming you do not have any other devices on the network using the same dongle and aren't what you're trying to search for.
You can find all the Mac addresses on a network by performing an ARP request on each IP.
But all the devices would have to be on the same subnet.
If you devices are remote, then I would go with your original plan, however your friend is correct if the gateway changes this would require something a little more robust. Use a Dynamic DNS service along with a domain name. The Dynamic DNS will update your DNS records in almost real time if your gateway address changes.

Connecting to WiFi with Static IP Address on Android

Setting static IP Address(192.168.55.155) on android device, results in its WiFi connection not working (no internet).
If its DHCP on the android device, WiFi (internet) works. The Gateway on the device is pointing to Wifi Router.
I have a few android devices on the WiFi router. I need to know the IP Addresses of these devices in advance, so having static IP address is one way.
What configuration is missing?
You cannot give it a fixed address of 192.168.55.### when the router gives you one like 192.168.0.### but only 192.168.0.### also. Try 192.168.0.155.
Its easy, use an APP called Fing this APP allows you to watch all devices connected to your network and their IPs.

Cannot get android device to talk to local server

I have done this successfully before but I am not sure what is going on in this case.
Case that worked:
When I am at home and I connect my computer and my phone to same wifi such that they are on the same network. I can lookup the IP address of my computer and use that IP on my android app to talk to my computer. The local IP is something like 192.168.1.5.
However now I am using a public wifi router. When I connect my computer to wifi I get an IP like 10.10.77.162. When I try to use that IP in my android app to talk to my computer it fails everytime.
What am I doing wrong? Is there an easy way around this?
You have to make sure you forward the port you connect on from your router to your local computer inside your network. Similar to when you open ports for some games such as wow.
Connect your phone the same WiFi network.
Addresses in the 192.168.* and 10.* range aren't globally accessible. They're only used for local networks. If both devices are on the network, they can communicate with each other, but they can't if only one is.
Basically this was due to the fact that I was on a public network in which the router was outside of my control. The router was blocking traffic as one would expect.

How to run a Apache Tomcat Webserver on my PC and access if from a real Android Device?

I have a Tomcat 7.0 server running on my PC, I access the servlet via Emulator through Url
http://10.0.2.2:8084/MyServer
I am struggling with this for few hours now. I have understood the following steps to achieve this
I need to have a Static IP address? So I am using No-IP Free to covert dynamic IP (I have a dial-up connection) to Static IP.
I need to change the firewall rules in Windows 7. I tried changing Inbound Rules for 'port 8084', but it did not work.
My Question is how to access the same server on my PC via a real Android device having GPRS connection?
Thanks so much.
wifi is the best answer. Get your machine and phone on the same network. If that isn't an option, I'd suggest local tunnel: http://progrium.com/localtunnel/
As long as your server has a public IP address, you'll be fine. The first you should try is to access it from your device using the known IP address and then go for the name resolution, for which DynDNS or No-IP Free will be valid options.
Let's say your pablic IP at any given time is 1.2.3.4, just try
http://1.2.3.4:8084/MyServer
and it should work. Then configure any of the mentioned services and try using the host and domain name.
Firewall rules on your Windows PC and wired/wireless router will both need to allow incoming connections to port 8084.
On the router, set up incoming connections to 8084 to redirect to your Windows PC's local IP address (127.0.0.1). This is called "port forwarding" – look into your router's manual on how to do it.
Once your router forwards incoming port 8084 requests to your Windows machine, you can access it from the outside:
http://your-dynamic-address.com:8084/MyServer

Categories

Resources