I have an Android watch that can be in one of the following:
1a. standalone - connected to a WiFi network directly;
1b. standalone - connected via a cellular link (if SIM present, unlocked, etc.);
2. bluetooth connected to a phone and using the phone's connection (WiFi/cellular);
It can also be that both the watch and the phone have a SIM (though this is less important).
On the watch I run a standalone app (no counterpart app/service on the phone) and I need to find the 'end' connection type I have when tethering. Namely, using the watch only, I need to know if I am tethering via a WiFi or via a cellular connection.
Or, in other words, when tethering, I need to know if the phone (to which the watch is connected via bluetooth) sends my data further using WiFi or a cellular connection.
I did look around for a solution but what I found only allows identifying the type of connection the watch has, e.g. WiFi, cellular or bluetooth.
Is this even possible? Thanks in advance for your help!
Related
I have an Android device that has wifi and Bluetooth modules. I want to build applications to connect the device to the internet using a smartphone's data connection. Is this possible?
The smartphone will have wifi as well as data connection. Can the smartphone's data connection be shared through Bluetooth? Or is there better alternatives like wifi-direct or NFC? I am aware that enabling Hotspot on the smartphone is an option. But with hotspot, the issue of wifi being turned off makes it not usable for my use case. Is there any alternative to wifi-hotspot?
What will be the best option for this and what things should I consider when building my applications and services?
NFC is definitely not the answer, the data rate is far too slow and the connection unreliable and the OS does not allow it.
You might be better with a USB ethernet adapter if your phone support USB On The Go (OTG)
Your phone should already support sharing a data connection using Bluetooth. This is called Bluetooth tethering. But you also have wifi, so wifi tethering is also an option to share your data connection. No additional app is required.
I have a device with no screen + a microcontroller + a wifi module.
So far so good but basically I'd like to setup my device so it can connect to a wifi network, so I made an app to do that.
The strategy is:
put the device in wifi AP mode with a custom ssid like "Device XXXX"
connect to this ssid "Device XXXX"
Ask the user for its home wifi credentials
send the credentials to the device (for example using http) -> POST http://x.x.x.x/wifi_creds "Home" "homepassword"
poll the device to check whether it could connect to the "Home" network -> GET http://x.x.x.x/conn_status
Once it's connected, stop the AP mode -> POST http://x.x.x.x/wifi_ap_mode 0
This works pretty well, but it requires the user to manually connect to the "Device XXXX" ssid.
And actually on Android I can make things even easier by connecting automatically to this ssid, but I need to find the ssid first.
So my idea was to scan all the ssids and to connect to the first one that matches the pattern /^Device [0-9a-zA-Z]{4}/ (like Device 1234).
However this doesn't look like a good way to find a hotspot, and there might be a better way.
Also, I don't want to give it a default name as it could conflict with another ssid.
Is there another way to find my device (or my device ssid) without this trick?
I know that Google home is able to connect to a Chromecast allowing you to configure it while the Chromecast is in AP mode with a ssid that looks like "Chromecast XXXX" (when the bluetooth is disabled), and I'm not sure how they do it
*I've assumed (perhaps wrongly) that your headless device is Android based. If it is Android and has Bluetooth, specifically Bluetooth Low Energy and is above Android 5.0:
You could get the device to act as a Bluetooth beacon which constantly broadcasts it's SSID.
So your app first scans for Bluetooth beacons - the beacon payload could be any arbitrary data - perhaps some known hard coded GUID to be sure you're talking to the correct Bluetooth beacon and also embed the SSID.
Now go and scan for the SSID and connect to it.
See this library for details on how to do this.
I believe you can even configure a kind of 'geofence' so that as soon as you come into range of the beacon your app wakes up and does the pairing.
I have a device that creates a WiFi network that is not connected to the internet. This device hosts a website using IIS. To operate the device, a smartphone connects to the WiFi and browses the site. The smartphone needs to get data from an api (internet) and pass it to the website on the device.
I have tried to remove the default gateway setting from the DHCP server on the local WiFi, but this is not permitted on the device.
I have not been able to find an app that will allow both WiFi and Cellular data to be used simultaneously.
If I were to allow the device to connect to a hot spot that the smartphone creates, the smart phone cannot access the device's WAP.
The next option I'm considering is to toggle the WiFi Off and On during the process.
I'm wondering if anyone has another solution to this issue?
Since I don't have an Android 4.0 device I haven't been able to test this myself. Also I wonder if connecting device A (a smartphone) to device B (a wifi direct capable device) using Wifi direct would mean that device A would assume it is provided with internet from device B (tethering?). I am trying to make an application for device A that would communicate with a device B that does NOT provide internet, thus it would be interesting to know if such a scenario would lead to device A losing internet connectivity for the duration of the connection. Is the situation different depending on if device A is connected to internet through an AP or through 3G/4G?
Perhaps using Bluetooth would be a solution, but in my case security is an issue, and it seems to me that Wifi direct provides stronger security (WPA2).
Any info would be helpful!
/S
On Android, Wi-Fi Direct doesn't interfere with your connection to the Internet (Wi-Fi or 3G/4G). A problem may be that once your turn on the Wi-Fi (to enable Wi-Fi Direct, your phone will try to connect to one of the saved available networks and will disable your 3G connection. That is because Android (by default) doesn't support dual connection (via both Wi-Fi and 3G/4G), but there is some applications around that claim that they can provide such functionality.
Can someone explain a couple of very simple concepts to me - I'm interested in mobile devices running android and how they are identified over networks. Some scenarios:
Device is connected over WiFi - presumably the device has a standard IP address as with any host and can communicate with any other android host over TCP/IP (assuming it knows the participating device's IP?
Device is connected over bluetooth - how are devices identified in this case?
Device is connected over mobile operator's network - this is the one I'm interested in and confused by - is there anyway for two or more devices to discover each other and communicate via the mobile operator's network? How does a device communicate with a backend server in this scenario? In other words, how do apps and devices communicate when not connected to a WiFi network?
Thanks for any advice..
I'm only sure about the bluetooth thing, so i only answer this part:
The Bluetooth interface on your device has an MAC adresse. So while communicationg over Bluetooth you can assume that this MAC adresse is a unique identifier for a specific device. You can also reach other devices by establishing a connection over this MAC adress- However, to get this mac adress in the first place, you have to know it from somwhere, or you have to search for other bluetooth devices in the reachabla area before.
WiFi and 3g both attach the [mobile] device to the internet so it can make internet connections. 3G assigns a publicly addressable IP to the device, so one could, presumably open a server socket and listen for connections. The client would have to know the mobile IP, which may change quite frequently.
Bluetooth is more geared toward close-proximity. Devices in the vicinity can be connected to, after you have paired with them, which requires the cooperation of both devices which are to communicate.
If the goal is to produce an application which connects to nearby devices, I can think of the following ideas:
3g: all devices running the client register their position with a central database server. If the server detects that two clients are in close proximity, let them know so they can connect through the internet or through the server
WiFi: you could use the same idea as 3g, or use broadcast/multicast packets to broadcast your presence. Other apps can listen for those broadcasts and discover which other devices are near.
Bluetooth: A little trickier, as a device must be placed into discoverable mode in order for others to "see it". Discoverable mode is a temporary state and only lasts about 30 seconds (at a time).