Not able to connect to Bluetooth server and WiFi at same time - android

I have a Bluetooth device through which user can take photos. After taking the photos Bluetooth device hosts all the images on its own HTTP server (10.0.0.1), so that other devices can connect to server using Bluetooth and access photos from server using REST APIs which are exposed by server.
Steps to connect to Bluetooth device (Server)
Go to Setting, enable Bluetooth
Select Bluetooth device
Bluetooth device setting ("Paired Bluetooth device")
Select check box for Internet access.
Through this i am able to access Bluetooth server but my WiFi automatically gets disabled and I am not able to access internet.
If i uncheck "Internet access" check box in "Paired Bluetooth device setting" then I am able to connect to WiFi for internet access.
Is it possible to have both WiFi internet as well as Bluetooth internet at the same time? So that my app can connect to Bluetooth device to get the data (images) using REST APIs and post to remote server using WiFi.
I am using Nexus 7 tab for development which is running on Android 4.4.4.

1. ...so that other devices can connect to server using Bluetooth and access photos from server using REST APIs which are exposed by server
If the photos are on the server, devices can connect to it using wifi/internet also..right? To access the APIs and get the photos..
Why do you want other devices to connect to server using bluetooth to access photos from server using REST APIs
2. Is it possible to have both WiFi internet as well as Bluetooth internet at the same time?
Leave aside Bluetooth internet, there have been some issues related to Bluetooth and Wifi, even more with Bluetooth Low Energy and Wifi, many have been device specific.
Regarding what you are facing, there are issues on Android Open Source Project - Issue Tracker and other blogs also;
Issue 39995
Issue 41631
Nexus 5, Nexus 4 and Nexus 7 (2013) Android 4.4 Bluetooth Issues
[Although i haven't faced that issue in Nexus 5]
I have seen the same in MotoG also, turning on Bluetooth weakens the Wifi functionality.
In your case, considering nothing can be done with the device and its hardware,
you can check with the connections whether it happens intermittently, try to connect or send the request to server a couple of times.
3. ...app can connect to Bluetooth device to get the data (images) using REST APIs
If it can "connect" to the Bluetooth device, i suggest you try and get the images on the established connection rather than REST APIs. Simultaneous internet access through two different sources doesn't happen, even with the 3G and wifi :)
Just out of curiosity, when you are connected to the Bluetooth device, why do you want to add the necessity of internet to get the data?
Another approach, gets ugly but would work: Can you get the data that you need and ask the user to switch off the bluetooth so you can send the data..which you might need only on certain devices, if you separately get the data from the established bluetooth connection only

Related

If I connect 2 android devices via WiFi-Direct - can one share its Internet connection with the other?

I am building an SDK for a client to connect 2 android devices for exchanging data (strings, commands...) via various channels, such as Bluetooth, USB cable, WiFi.
One of the devices is a standard android phone, with a SIM card and data, thus able to access the internet. The other has no SIM card.
Currently using WiFi I am opening a HotSpot on the phone device, and so the non-SIM device can access the internet via the HotSpot.
Now my client wants me to connect via WiFi-Direct, too.
So my question is - once I connect the two devices via WiFi-Direct, will I be able to access the internet on the non-SIM device, using the SIM/data on the "normal" phone?
Thx
Well, Wi-Fi direct can create hotspot independent of the legacy Wi-Fi hotspot BUT this hotspot doesn't share internet and any request to external ip will be dropped.
But for android you can use NetShare app to do that, you can download it from
here.
it works as follows:
• in the client side NetShare use the vpn service to catch all internet traffic of the device and send them to NetShare in the server device and wait for the response.
• in the server side NetShare run a server with specific port to receive the internet packets sent from the client side in
previous step, it send these packets to the internet, after receiving the reponse from the internet it will send these responses to the NetShare in the client side which in turn provide it to the back to the client device.
for more details see the official website

Multipath TCP on Android / IPhone

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?

HTTPS connection on wi-fi enabled Android Wear without phone tethering

I can't find any documentation on Android Wear that shows how to create an app that leverages the fact that some watches (like my Samsung Galaxy Gear) can now connect directly to the internet via wi-fi when the phone is not around.
I have a few apps that generate https requests to access a REST service and I would like to know if these can be directly called from a Wear app connected to wi-fi (no phone).
Similar questions don't seem to answer this:
Direct internet connection on Android Wear?
https://stackoverflow.com/questions/26062487/android-wi-fi-direct-persistent-connection
Android: Establish "Wi-Fi Direct" connection with networked devices
My tests on a Wear emulator tethered to an internet enabled Phone emulator show:
java.net.UnknownHostException: Unable to resolve host "api.xxx.com": No address associated with hostname
But of course there's no direct wi-fi connection on the watch emulator so my next step is to try on a real watch and phone.
My suspicion is that Android Wear's data API handles this transparently so direct http requests seem impossible.
Best, thanks in advance for your help.
Even if Android 5.1.1 support Wi-Fi Feature. Android Wear on Wi-Fi: Using a smartwatch without a phone nearby
You should stick to the Data Layer API, you cannot send http request directly from watch. Fetch internet data from the phone, then transfer it to watch with Data Layer API.
You can see this Does Android Wear support directly access the Internet?
And this document Always-on and Wi-Fi with the latest Android Wear update
From the last update its possible to make http requests over wifi using android wear. You can even connect a bluetooth headphone to it to use with some streaming app.
While on wifi, if your mobile phone is connected to the internet too (dont need to be the same wifi, can be even 3g) it will act the same way it would when bluetooth connected yo our phone, but with its own internet access.
This dont mean apps will change their behavior, because most of them are coded to make the requests from your phone, but if you have an app that make direct networks requests, it will send them from your watch without advising or needing your phone.
How to do networks requests on android wear
Just use the same network requests libraries you would use on a normal Android mobile application, like volley, retrofit, okhttp. The code is exactally the same, and by the way, any Android Mobile library works with Android Wear too.

Google glass bluetooth tether connectivity issues

I currently have a pair of google glass paired through bluetooth to an LG G2.
My LG G2 can access the internet and my network without an issue.
Glass can search web pages and browse the internet without an issue.
My custom application works fine through WiFi on my phone and on glass, if glass is going through WiFi.
However I have a custom application that I made that cannot connect to a server on my network through the bluetooth tether. I haven't been able to find anything regarding special permissions or programming changes that would need to be done when tethering, so am I missing something critically important here?
It is absolutely critical that I use my phone's wifi because it supports 5 Ghz WiFi and 2.4 Ghz is completely saturated where I am.
Currently I am trying to use the libstreaming example 3 to stream video to a server:
https://github.com/fyhertz/libstreaming/wiki/Using-libstreaming-with-Wowza-Media-Server
My manifest has been modified to include
android.permissions.BLUETOOTH
android.permissions.BLUETOOTH_ADMIN
I've also hard coded my server IP address and the correct settings to automatically start the video stream inside onCreate. This all works on my phone but I get a connection timeout when connecting through glass when bluetooth tethered.
With the following steps I was able to connect from Google Glass to a server socket:
enable android.permissions.INTERNET to the manifest file
on the android phone: settings->wireless..more->tethering & hotspot ->activate bluetooth tethering
maybe this helps...
As far as I can tell, when data is connected you do not get an ip address... Thus your socket isn't really able to connect. Data requests are sent through bluetooth and really it is your phone making the request....
I will try to look into it, but right now bluetooth connectivity yields an ip address of 0.0.0.0

is it ok to connect 2 devices concurrently to connect Bluetooth in Android?

Iam connecting 3G phone for my Android device for internet connection and another Socket(SPP) for CAN signal receiving.Whenever I manually connect to the Bluetooth tethering via 3G phone, i can browse internet perfectly and speed is good.Whenever programmatically connect to the 3G connection, i couldn't browse internet.i checked in shell and observing that in my mobile 'device is connected' message displayed and E symbol appears.No problem for me to connect Socket.But I got problem to use 3G phone.For this iam using APN/DUN mode.I checked both but no use.Is there any performance issue here or anything wrong to connect different devices by using Bluetooth API in android.Why this happends while connecting Mobile programmatically.Please give me guidance.
Regards,
Rajendar
Yes, you can have several open connections at a time.
In fact, I've used my hands-free bluetooth on my phone, as it is connected to my ELM327 SPP device streaming at full speed. I didn't notice any hiccups.
As for losing connectivity when you are connected to multiple devices, it's most likely an issue with the DUN provider you're using.
Also it's worth stating that, on Verizon/3g phones, when you use the phone as a phone, it suspends all 3g data services until the call is terminated.
The way L2CAP defines the LT_ADDR allows connecting devices up to 7. Your connection problems is something else.

Categories

Resources