I am new to Android programming and was wondering if it was possible to connect an Android device with a BLE Peripheral, without needing an App.
I am experimenting with the Node.js package "bleno" for the peripheral and connecting using an app and even a webapp are working just fine, but connecting using the standard android settings functions dont work. The device does find my peripheral after scanning but when I try to connect with it it always returns that I need an app.
Is this a problem of bleno or does this not work that way in generell?
If the peripheral has for example a HID GATT service exposed, then you can pair and connect to it through the system settings. This means BLE keyboards and mice can be used without any app.
If your peripheral only has custom services or only services the OS knows nothing about, then you will need some app to connect to it.
Related
I am developing a device that needs to communicate securely to an Android app via Bluetooth. I need that only a predefined phone to be able to communicate with my device for security reason. And I also need to assure that this is not an intruder device that is trying to communicate falsified data to the app.
Looking at Bluetooth specs, I had the impression the only way to do that is with out of band (OOB) authentication with a pre-provisioning temporary key (TK). This looked very promising but after trying to find how to use OOB on an Android app, it seems like it is not supported.
Is it still possible to use OOB authentification on Android ?
If no, is there another alternative to solve my issue ?
This is doable but it depends on the BLE peripheral that you are developing and the features that it supports. Namely, your device needs to support Whitelisting and bonding. This is how it should work.
Upon first connection to the BLE device, the BLE device should accept the connection regardless.
Once the connection is made, the central device (Android phone) needs to initiate bonding. This doesn't need to be Out of Band (OOB) bonding, and the standard Just Works bonding should do.
Once bonding is succesful, the BLE peripheral should add the Android device's IRK to the list of whitelisted devices.
From this point onwards, the BLE peripheral will activate the whitelist, and therefore only devices in the whitelist will be able to connect to your BLE peripheral, and in your case it will be the Android phone that you used to make the very first connection.
It is not straight-forward and requires an initial secure-less connection with the target phone, but if that is not an issue then this should work.
You can find more information about this in the links below:-
Set and activate whitelist with Android phone
Android BLE server - allow only previously connected device to connect
Whitelisting with resolvable random addresses
For quite some time now, I have had a keen interest with the Bluetooth Low Energy (BLE) Protocol version 4.0 and how it works. I have developed an android application that would serve as a central device to the BLE peripheral device. The problem is the BLE device is not yet ready and I would like to know if there is a simulator or an emulator for BLE devices that can interact with my android application installed in my smartphone.
The easiest way to do that without any specific additional HW is to use another Android or iOS mobile phone acting as a peripheral emulating the BLE device that's not ready yet. Thus, you'll be able to test your Central role Android app in a simple way.
All you have to do is download one of the following apps for example, set up your services and characteristics and start playing.
[Android]: nRF Connect for Mobile
[iOS]: nRF Connect for Mobile or LightBlue
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.
I am a little confused on how to build this android app. Here's how it should work. I have a list of paired bluetooth devices. Lets say paired devices are:
1. A bluetooth head set.
2. A mobile phone.
And my app should automatically connect only to my headset when ever it comes in range.
Thats the basic functionality. I have been doing some research on bluetooth technology and its implementation. I came across the bluetooth chat application, when I started using the application I realized that both phones should have the app on it in order to connect and exchange messages. I tried connecting to my headset but it doesnt connect. And also when I removed the bluetooth chat app from one of my device and tried to connect it from a device which had bluetooth chat app, the devices couldnt connect.
If you have already worked on bluetooth this might look very simple. But how can I connect to a bluetooth device from my app when ever its in range even if the other device doesnt have my app.
Thanks.
This will be a 2 sections answer:
-To connect to a Bluetooth Headset, check my answer on here
-To Always connect to that device, you can save device address to memory then create a service with BroadCastReciever that listens for Bluetooth Connectivity. and check which device gets connected and compare it address to the one save in memory once its finds it connected call ibth.connect(device). ibth is inside the above link.
I am interested in using my Android phone (running my application) to do all the heavy computing/data storage for an accompanying app running on Glass. Is there a way to make a connection over wifi or bluetooth to send/receive data between the two?
For Bluetooth, you can check out this library.
I tested it before and I'm able to connect between my phone and Glass.
Also, Google Glass GDK: How to Communicate with Android Device is helpful.
I haven't tried connecting over WiFi.