Suppose I have two android phones (say Phone A and Phone B). I have paired them through the normal bluetooth pairing procedure. I am developing an app which I will install only on Phone A.
What all data points/events might I be able to get from Phone B through this app by using android bluetooth APIs?
What if instead of Phone B, I have any other bluetooth device that you can think of. What all data points/events might I be able to get?
I'm assuming that my other option could be to build a companion app on Phone B which would talk to the app on Phone A and provide any of the data (say notifications) through providers or accessibility.
Bonus: Any thoughts if Phone B is an iPhone :)
Since nobody has given an answer for this, let me summarize my understanding so far.
When it comes to bluetooth, we can go with some of the predefined bluetooth profiles that are available in the bluetooth standard. We can access any data that is available through the profiles that are supported by the device.
Related
I have a Bluetooth LE Joystick with a couple of buttons. I want to connect it directly to the app without using the Bluetooth Settings, but by connecting to it via BluetoothLeScanner.
I already can connect to a Heart Rate Monitor and get periodic notifications of the HR-values.
I also have created a little temperature/light/humidity sensor with an ESP32 to which I can also connnect and display the sensor values in the app.
My understanding of this HID device may be erroneous. With the help of the App BLE Scanner I can connect to this gadget via BLE and see the offered services.
One of them is 0x1812 HUMAN INTERFACE DEVICE, which contains a couple of characteristics of type REPORT, among others which are described HID OVER GATT PROFILE SPECIFICATION (HOGP_SPEC)
How can I find out which button got pressed, what position the joystick has been moved to? I guess that this has to occur via notifications to which I have to subscribe to.
Is there any Android library avaliable to handle HID input devices? What I do NOT want to do is to use the Bluetooth settings and connect to the device and have it become detected as a HID device and replace the keyboard with some odd mapping. I don't want the OS to get involved at all, just like when I connect and use the HRM and the ESP32.
I couldn't find any information on this.
I can connect to the device with my app, enumerate the services and characteristics. But from there on, I have no clue how to work with HID. Ideally I'd get notifications like "Button A has been pressed" "Joystick got moved to x=32" where x would range from -127 to 127, for example.
Accessing the HID characteristics requires the BLUETOOTH_PRIVILEGED permission since Android 5.0. The only way for an app to obtain that permission is to be signed with the same certificates as system apps.
This is a security feature, to prevent an app from receiving HID events from your keyboard and stealing your passwords.
Quoting from https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/BLE_5F00_on_5F00_Android_5F00_v1.0.1.pdf
4.6 Protected services
Android does not allow to read or write data to the following characteristics (and their descriptors):
HID Service (since Android 5):
a. HID Information
b. Report Map
c. HID Control Point
d. Report
FIDO (https://fidoalliance.org/) (since Android 6)
a. U2F (0000FFFD-0000-1000-8000-00805F9B34FB)
Only applications with BLUETOOTH_PRIVILEGED, that is, applications signed
with the same certificate as the system, are able to read and write
data to those characteristics.
I would like to be able to pre-pair bluetooth devices, to save the step of user confusion when using the app. I have discovered that there is a patent for
System, method and apparatus for pre-pairing bluetooth enabled devices.
I am looking at pairing an array of android devices with an array of embedded devices, so when the android device is set up, I can pre-pair it with the devices it needs to communicate with. I have considered maintaining a list of MAC-addresses that can be downloaded and updated by the app.
Is there a way to pair two devices without having to bring them into contact?
My memory is not exact, it's a while ago I poked around in the Bluetooth stack, however, I don't think this is possible.
Basically there is a white list (text file pretty much) which is kept by the system with devices that may connect to your phone, in order to access that white list outside of the Bluetooth api you need to be platform manufacturer. The Bluetooth Api is strongly guarded (by the specification), if you don't fulfill it you can't say your device supports Bluetooth. Pairing is an important part of the Bluetooth security model, I doubt even an oem would be allowed to do this.
One thing you could look into are Bluetooth low energy devices, those don't require pairing prior to connection (you should be able to connect if you have the MAC address), only Bluetooth classic requires pairing.
More info:
https://developer.android.com/guide/topics/connectivity/bluetooth-le.html
No its not possible unless you make changes to the ROM.
If the use-case supports,you can have ble devices advertising data in a pre-defined format so that the app detect your devices.Once you have recognized your devices,you can internally send a pairing request.
I am using bluetooth adapter to discover bluetooth devices. The search displays all devices (iOS , Android, Speakers etc) which are available in surrounding with Bluetooth turned ON.
My App sends and receive data, so installed on two different Android Devices, app can perform a chat functionality, provided both apps are using same App UUID.
Is it possible that when I perform the device discovery/search, I only limit discovery to those devices which are Android and are using my App i.e. my App UUID and not to show all other bluetooth devices.
I know this happens in iOS using characteristic UUID.
Appreciate Response.
1) First you're doing an Inquiry (search) of all nearby devices
2) for each device enumerated, do a Discovery (SDP) on it to gather all its services/profiles; If you found the one you're searchnign for, display it, otherwise forget it...
PS: I have no idea about selecting Android devices only... You can use the CoD (Class Of Device) but not sure that you can separate Android from other "smartphones"...
It is possible?
I state that NFC is enabled on my phone and everything looks correct
I tried with an app called NFC TagWriter by NXP but don't work.
I create a tag with this app and then I tried to listen with other device but don't work, then I installed same app on the other device but don't work.
Please help me or suggested to me another way to do(share tag NFC).
THANKS!
The Android Beam™ feature allows a device to push an NDEF message onto another device by physically tapping the devices together. This interaction provides an easier way to send data than other wireless technologies like Bluetooth, because with NFC, no manual device discovery or pairing is required. The connection is automatically started when two devices come into range. Android Beam is available through a set of NFC APIs, so any application can transmit information between devices. For example, the Contacts, Browser, and YouTube applications use Android Beam to share contacts, web pages, and videos with other devices.
Reference from Developer Documentation
Also check this for Blog , it explains how to communicate between devices.
You can have (indepedent) p2p communication in 2 directions, and enableForegroundNdefPush is deprecated now; please, use setNdefPushMessage
Is it possible in the Android API to communicate directly to another android phone within close proximity? If so, which version of the API is it in? For example, if both phones had the same app, can they exchange messages in the background within close proximity?
The short answer is yes. Some apps, i.e. Bump, already do that. Usually android phones have both WiFi and Bluetooth capabilities. Given that you are talking about close proximity Bluetooth should be enough for you. Alternatively once one of them is configured as a WiFi hotspot, you can connect them via WiFi.