Two device hotspot on android - android

I'm trying to use two phones in my car as a reversing camera: one being the camera and the other being the viewer. I have the software but the problem is I can't get it to work using two phones. I can get it to work using a third phone as the hotspot gateway. The problem seems to be I can't seem to communicate with any app running on the device running the hotspot yet they all have the same ip range. One machine is running a http server accessing the camera (similar to "IP webcam" app) and one is running software accessing the web server (in this case a web browser). There is no internet component. I assume this is being blocked because of some sort of security feature. I see no technical reason why it can't work.
I have tested this using HTC one, HTC DesireHD, Samsung galaxy camera and other various friend's phones so it seems to be consistent across android. Not an odd feature of some type of phone. Android 5 has not helped either. If it is a security feature do I need to root the device running the hotspot to overcome it? Any pointers to discussions on this subject would be very helpful.
I have searched many similar threads but most are discussing tethering issues or connecting through to the internet. Not sure what keywords to use. I have also tried "Hotspot control" app which did not work although I don't think it relates to this issue.
e.g How to make two android devices to communicate through TCP This has the right title but then goes on about NAT translation which is not related. Others go on about DNS. Just a simple DHCP server (which the hotspot has) and a router?
So in essence this is simply getting a local tcp/ip network set up between two android devices so apps can talk to each other. I would have thought this was quite straight forward. Hotspot is almost there as a solution.

I had a brainwave and solved my own problem at least on my HTC one (and I think before the 5.01 upgrade which would have been kitkat).
When in "settings" select "more" under "Wirelesss Networks".
Then under "Mobile network sharing"->"Portable Wifi Hotspot" click the menu button at the top and select "Advanced".
Then click LAN Settings:
Here we select the ip address of the host (i.e this mobile) and the "Starting IP" for the DHCP server for devices connecting in. It seems to choose zero (last in group of 4 numbers used for the ip address) for the mobile running the hotpsot and and then, presumably, 10 for the starting address of connecting machines. However, it seems only addresses from starting address onwards can see each other so the simple fix is to change the ip address of the host to a number greater than 10. I chose 200 and all worked. My camera can connect to the phone and the two can talk.
However, on my Galaxy camera (model EK-GC100) running 4.1.2 (Jelly Bean) these addresses can't be configured. It also doesn't allow a hotspot to start if a sim card isn't inserted. It seems to think there is no other reason to use a hot spot other than for tethering. Just another in the list short sighted design features that cost almost nothing to implement.
Unfortunately it would have been better if the camera device is running the hotspot. Oh well not a major issue as I wouldn't use a galaxy camera for a car reversing camera.

Related

Why the address of my BluetoothDevice changes every time I relaunch the app?

I'm doing some simple scanning + advertising testing on bluetooth LE feature for Android using this sample-code
I'm testing it using a Samsung 6 and a Nexus 9, and for some reason if I leave the app running on the Samsung and restart the app on the Nexus, the next time the Samsung devices finds the other device, it has a different address.
In code:
On the device:
The funny thing it doesn't happen the other way around. (Samsung always has the same address when discovered from the Nexus 9)
Is this a common behavior between devices?
Is there another way to identify a specific device besides it's mac address?
As CommonsWare mentioned, as of Android 6.0, Android has removed access to the hardware address programmatically, and made it so that the address appears to be randomly generated to scanning devices. The change log can be found here:
http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id
The fact that scanning devices see a random Bluetooth address rather than the actual one is a highly useful privacy feature. It was adopted by the Bluetooth specification as of BTv4.0 and is known as LE privacy:
"This feature causes the MAC address within the advertising packets to be replaced with a random value that changes at timing intervals determined by the manufacturer. Any malicious device(s), placed at intervals along your travel route, would not be able to determine that the series of different, randomly generated MAC addresses received from your device actually relates to the same physical device. It actually looks like a series of different devices, thus, it will not be possible to track you using the advertised MAC address"[1]
You can find a similar question here:-
Since marshmallow update Bluetooth discovery using BluetoothAdapter.getDefaultAdapter().startDiscovery(); is broken
[1] http://blog.bluetooth.com/bluetooth-technology-protecting-your-privacy/

Android 3G Tethering

For a research project, I must work on the design of 3G/WiMAX Access Point (AP) protocols. I have access to 2 Android smartphones.
Android devices can become WiFi hotspots for other devices, allowing WiFi tethering.
In this scheme, does the Android devices behave like a regular WiFi AP (like the one present in your home WLAN) or does it just forward the connection from the AP it is connected to ?
Similarily, is there a way of turning one of my smartphone into a 3G/WiMAX AP, so that the other can connect to it as if it was a 3G/WiMAX tower ? If so, can you provide some references and resources that would allow to do that ?
EDIT:
Ok so the keyword is "AP mode", it is a mode available in some Wireless Network Drivers like ath9k, bcm but is absent from most others. It is used to turn the device into an AP (or more accurately a simulated one).
The answer of the first question "Does it behave like an AP?" is Yes: the Android device can behave exactly like an AP (management frames, ack, etc.) AND internaly it forwards the connection from the real AP.
The answer to the second question "Can we turn it on ?" is "It depends on your wireless driver, and thus on your wireless card". Some drivers (ath9k, bcmon) have the options, some others don't. You will have to search for your network card name and check it out.
In my case, I wanted to change the behaviour of on AP (by modifying the driver / kernel), but found out that my driver is a firmware (and proprietary). I ended up adding an USB Wifi adapter that is supported by the driver ath9k (open-source driver for Atheros chipsets).
It behaves like a 'regular' AP, taking into account that both Android and WiFi are constantly evolving and hence the definition of regular may be a moving target.
You can test the behaviour by finding a location with no 2G/3G/4G etc coverage and run a local network with your phone as the AP for multiple devices. An long distance flight for example (where devices on flight laws allow...).
For testing I am not aware of any free or open source 3G network elements yet, but there are some 2G open source projects it might be worth you looking at:
http://openbsc.osmocom.org/trac/
http://openbts.org
The former has definitely mentioned plans for an open RNC (3G access point) but it is not clear what stage these are at.
Turning a smartphone into a 3G access point (RNC) is definitely not going to be just a matter of developing an app. Given the hardware is probably all there, I am sure it is technically possible if you are prepared to write a lot of low level software, but I think you would probably find it much easier to look at the approaches the above project have taken and see what their plans are for 3G.

Detect laptop from Android

I need to find if there is a laptop running on the same network as my Android device. Something similar to Android's native NsdManager, but as I understand it, NsdManager only detects devices that are running a particular service, so it can only detect other Android devices.
Is there a way to "find" a laptop in the same wireless network? The problem is, I won't know the specific IP address of the laptop, as I would prefer my application to be able to search for the laptops by itself in order to sweeten the UI experience.

Can Android 2.X devices connect to an Android 4.0 Wifi Direct AP?

I'll explain the problem I'm trying to solve first. I have two Adobe AIR applications that can be deployed to Android (Receiver App and Broadcaster App). The Receiver App sits on one Android device and waits for any Android devices running the Broadcaster App (on the local network). This is all currently working and I can have the devices talking over a local WiFi connection with no problem.
The issue is I need to be able to do this without an external router/AP. I was able to setup a third Android device as a Wireless AP and have two other Android devices communicate over the WiFi connection just fine. However, the device setting up the Wireless AP connection is not able to join the network.
After searching google and stackoverflow I came up with a few solutions.
(1) Set up an Ad-Hoc network using a rooted Android device and running Barnacle. I was able to try this and set up an Ad-Hoc network successfully between two devices but they were not able to establish a connection in the Adobe AIR apps (using Adobe P2P support).
(2) If I can get my hands on the new Android 4.0 Galaxy Nexus I understand I'll have access to WiFi-Direct. I'm curious if this will solve my problem. Can I set up AND join a Wireless AP using the Galaxy Nexus, and connect to the Wireless AP from my older 2.X devices? Reading this makes me believe I can, but I wanted to know if anyone can confirm.
P.S. I am using NetConnection/NetGroup/NetStreams on the Adobe AIR side over a serverless rtmfp connection.
Thanks.
Sean, this may not answer your question, but I've used rtmfp for serverless p2p also (of the kind described in this blogpost by Tom Krcha) and have a couple data points for you:
Many HTC devices and other smartphones have a multicast issue that prevents them from communicating in this way. Google 'htc multicast' and read about it on this blog. Interestingly, these devices can work in such a group as long as there are non-impaired devices also, because they can transmit multicast, just not receive it. So the other devices initiate the group and all can participate. But the impaired devices can't initiate the group by themselves.
I had no trouble communicating between a range of devices, from Android to iOS to desktop, so I assume you should be fine across versions of Android.
I have a rooted phone that I run an app called 'wireless tether' to create a hotspot / wifi access point, and when two other devices connect to that hotspot, they can communicate with each other using this method, but they cannot communicate with the phone that is creating the hotspot network.

Make a mobile device a remote control for a tablet?

I'm trying to make an app on an Android device that will control an application on an iPad or Android tablet. (I'm testing with an Samsung Galaxy S2 and an iPad 2).
The application is pretty simple for now. When one selects a colour on the Android mobile, that colour displays on the tablet device.
The question is, how to connect the two devices. Just now I've verified that I can pair the two devices using Bluetooth. Also, the Samsung has a "Kies" Wifi Direct feature (which I don't understand fully), that allows the iPad to connect to the Galaxy as a wifi hotspot.
The connections are there, but I don't know if either protocol can be used to actually get the apps to talk to each other to get the control I'm looking for.
Should I be using Bluetooth, Wifi, or something else?
And in whichever case, how?
My opinion is that you should not stick so much around the physical medium used for connectivity either is WiFi or Bluetooth. You should abstract this aspect, in both cases you will be using sockets (I'm speaking about Android), if it's Bluetooth you will be using Bluetooth Sockets, if it's WiFi: TCP sockets. You could have a intermediate layer that abstracts the type of connection and through a factory to use either Bluetooth or TCP.
Bluetooth - http://developer.android.com/guide/topics/wireless/bluetooth.html
For WiFi you should study if P2P would help.
You will need two applications:
- one on the tablet - the server which listens for commands from the client (change color, do this or this)
- second on the smartphone - the client which sends commands.
I've built a few apps that do exactly that between iPhone and iPad. But the principle is the same. I used Bonjour networking. It's just a fancy name for ZeroConfig networking between devices. It's written originally by Apple but it's open source so there should be Android support out there for it too. Really simple and easy to work with.
If you already have a working connection then you already have the first half of your answer, that said you should really consider implementing a solution that uses a variety of connection types, WIFI, Bluetooth, etc.. The question I think you are really asking is how to pass data and messages between the apps once you have the connection.
There are a lot of ways to accomplish this. You could implement your own lightweight message passing system. If you haven't done this before it is more complicated than it originally seems, especially as you would be required to implement the system for each OS you end up using.
Should I be using Bluetooth, Wifi, or something else?
It depends on what situations you want your program to work in.
Bluetooth can provide a direct connection between your devices. A potential issue with bluetooth is that it has a limited range. If you're devices need to be far away from each other, you may want to go with wifi. Otherwise, bluetooth could work great.
If both devices are connected to the internet, you can make them talk to each other through there. The advantage of this approach is that it doesn't matter how far apart your devices are as long as they're both online. A disadvantage is that you'll have to figure out how to find the tablet's ip address before you can talk to it. This is actually a HUGE disadvantage because it can be quite problematic if both of your devices are not on the same wifi. You could have the user type in the destination ip address, but you'll have problems getting it to work if the user is behind a router (which will almost always be the case). The point is, it gets hairy.
If both of your devices are on the same wifi, you can use ZeroConf AKA bonjour (like Dancreek said) to figure out what ip address you need to send info to. I've previously used a library called jmdns (easy to find with google) to implement zero configuration networking. It's good because the user doesn't have to worry about ip addresses... it's intuitive for the user.
And in whichever case, how?
Networking is a pretty big topic, so I can't expand on this question to much. Short answer is, it depends on what method you choose. Search for some tutorials and start by getting one of your devices to send something as simple as an int to the other.

Categories

Resources