Bluetooth Latency compensation on Android - java

I'm wanting to develop an app for my personal use so that several mobile devices can pair to several Bluetooth speakers (regardless of the brand).
Because the sync will take place through internet, and that the app may become cross-platform overtime, it is essential that I can give to the device which is synced to me the ability to manually tweak its Bluetooth latency (ms offset), so that the speakers can be in phase. That was achieved previously because I saw it in certain apps; yet I can't find any developer information about it!
Any ideas as to how one would go about developing it?

I don't think compensating for Android Bluetooth Latency using app side code only is possible, because the latency varies a lot by manufacturer.
It might be possible though if you can modify your speaker firmwares in order to add timestamp based syncing between your speakers... or use Wi-Fi speakers
For more developer information about Android Bluetooth Latency, read this:
https://www.soundguys.com/android-bluetooth-latency-22732/

Related

Is there a way to find out what a bluetooth LE device listens to?

I have a bluetooth LE device that is powered by its developer's app.
Sadly it is not maintained anymore and therefore I intend to rewrite the app from scratch.
Additionally it is not possible to pair to the device. It only listens to BLE.
Is it possible in any way to find out, how the device is being controlled?
I tried to decompile the code via JADX but since the manufacturer is chinese and decompilation already comes with its own problems, I thought if it would be possible to find it out without this procedure. (GitHub)App-Decompiled-Code (External)Original-APK-Download-Page
It depends what the device is really. There are number of profiles/services defined in the Bluetooth standard. If the device uses one of them then you could design from the specification rather than the device/app.
A good place to start is to use a generic Bluetooth Low Energy scanning and exploration tool such as nRF Connect to explore the device. Find out the UUIDs of the services and characteristics and compare it to the assigned 16-bit UUIDs values on https://www.bluetooth.com/specifications/assigned-numbers/
If it has a custom BLE profile/service then you can still use the nRF Connect app to explore it. If it is not obvious how to access the data or what commands need to be sent, then looking at the HCI logs on the phone after using the developer's app might be helpful.

Receive accelerometer and gyroscope signals from smartwatch using BLE

I'm trying to develop an android app that should connect itself with a general smartwatch (miband, polar, etc.). In particular, I want to receive
accelerometer and gyroscope signals using Bluetooth.
I already read many articles about BLE but I didn't find any additional information about these signals. Does anyone know if it's possible to receive general signals like these? Is the solution feasible with any type of device?
Thanks for your help
Manufacturers of smartwatches generally don’t publish their bluetooth protocol. So even if it is theoretically possible, it is very hard to do it.
However, Some people reverse engineer the protocols and find ways to do it. Here is an article about how to get raw accelerometer and heartrate data from a MiBand device:
https://medium.com/machine-learning-world/how-i-hacked-xiaomi-miband-2-to-control-it-from-linux-a5bd2f36d3ad
First, you need to get the SDKs from the manufacturers. And use the SDKs to make your APP compatible with the smartwatches with different brand. It's really a giant and trivial work because you are not sure whether the manufacturers are willing to cooperate with you.
I found an app, that can connect to mi fit and offers additional tools for xiaomi bands. In the "Tools" section you can extract the accelerometer data, however there is no option for gyroscope
P.S. Sorry, the site is in Russian, hope you can figure it out ;)

WP10 Detected Bluetooth device functions

As all users of Windows Phone 10 know, the Bluetooth connectivity on this system is cutted to the simplest for end-user, which ends for programmers as a horror to create anything. When connecting to a device, system automatically looks for a "functions" that device has, for ex. audio. The questions are as following:1. How to define a function like that on external Android device? The main goal is, to control all types of music playback from it (ex. Groove music playing)2. Where can i find a list of things like this, for future app functions?
And to get ahead of answers, I already tried the easier ways, which came to nothing due to UWP limits of controlling other apps playback.
Main target of project is to make a xamarin c# (or java, I can "translate" from one to another with ease) android app for a smartwatch and in c# uwp for windows phone to do most common tasks, like - as mentioned before - music playback control and notifications reciever.
Based on your description, you want to develop an Android app to send Bluetooth command to control the music player of a windows phone device, then it depends on your Bluetooth of your android device.
But control music player by Bluetooth need the profile Avrcp I have check the google Bluetooth API I did not find the profile of Avrcp, I think it is may be hard to send the Avrcp command at the android application level.
And Android is source opened, many device factories prefer to customize their own Android system, it is possible that the device uses a Bluetooth module as a serial device, then the official Bluetooth APIs are not suitable for this scenario, the develop protocol of this Bluetooth module is in need.

Is it possible to find other nearby phones?

I'm writing an Android app that I would like to eventually port to iOS and Windows Mobile (though I know absolutely nothing about them right now). I'd like my app to be able to find other phones within a certain radius (maybe 20-30 feet) that also have the game installed so that the users can interact with others in their current physical space. Is this possible and, if so, how?
I plan on the app requiring an internet connection so my first thought was to use GPS like described at iOS Find Other Nearby Devices (GPS locations), but that would require continually transmitting data to the server to update the user's location using both bandwidth and battery (not to mention the server resources). GPS also seems to take a while to get any sort of accurate fix, and even though I wouldn't store historical data I wouldn't expect users to trust me with that sort of private information (as well they shouldn't!)
I know there are proprietary technologies, such as Sony's NFC, but that's far too narrow a focus to use for an app that I'd like to be device and OS agnostic. What other options are there? Assuming the user is willing to give the app the appropriate permissions, what other methods could allow one device to find another nearby one, within a 10-15 meter range, that is practical for a large (million+) userbase? Is HTML5 Geolocation a better path? Or is GPS my only real option?
I did find Use Android GPS to detect and connect with other phones, but was hoping the past few years have opened up further options.
UPDATE
Thank you for all the responses so far. To answer some questions posed in the comments and answers, I thought I'd describe how I expect the apps/devices to interact.
All users who install this app will have an agent running in the background to update their current geolocation and to listen for pings. Any user may open the full program and send a quick request for all other users nearby. If I go the central server route, then the server responds to that request with a list of nearby usernames. The user can then pick one of those to initiate a connection, in which case the target device makes a sound to notify of a request to connect.
From there it's easy enough to handle the interaction between two devices. Finding those nearby users is the sticking point for me.
Options I can see
Bluetooth (BT). I don't know, if I'm not too skeptical about it, but I see couple of problems. Short range. The biggest energy consumption. Maximum 7 peers connected at the same time (but maybe it's enough...). The big advantage is that a lot of devices support BT.
BT LE (low energy). Ok, it helps energy consumption problem. But, requires Android 4.3.
WiFi Direct (aka P2P). I gave it a shot, I'm a bit disappointed. The problem is that it needs Android 4.0 or higher. Even worse, some devices don't have required hardware. I launched WiFiDirectDemo from Android samples on Samsung Xperia Miro ST23i. Clicked on "search" and the only thing I got was a toast "enable WiFi P2P - in your settings". I clicked on everything in that settings, there is just normal WiFi and other stuff, no mention about Direct or P2P. Xperio Miro just doesn't support WiFi Direct.
WiFi connection with a server through internet + device geolocation. Server keeps positions of users and answers questions like "who is 20 feet in my range?". The problem can be the precision of geolocation. If the walls are thick or you are in a place on earth with few satellites - it can be very inaccurate.
To sum up
There is greater probability that somebody will have WiFi turned on all the time than BT. BT also have some time limits after which it is turned off (they make it this way to probably save battery). So, WiFi seems a better choice than BT.
If WiFi Direct is popular enough for you - I would give it a try. If not, option number 4 seems the best. It's not ideal, I know, but at this point it's hard to come with something better (we still need technology development, WiFi Direct looks promising).
I would use the central server approach. Each phone sends position data to the server. The server notifies the other users when they are in range. To limit used data, only send positions when the device reports movement more then X meters.
Also, consider using a Ping button. The user presses it to send the position when they wish to find someone nearby. Position data would only be sent on this ping. This would use very little power and provide good privacy.
It might be possible to detect details about the connected Wifi access point. If you could get the AP or Gateway's MAC address, you could send that as a kind of position. All the players on the same Gateway would be close by.

Simple application that simulates a bluetooth accessory

I'm looking for a no-brain application that allows me to send a pre-defined list of commands through a bluetooth connection, or an equivalent Java/Scala library that works decently in OSX (64bits).
In short, I want to use my computer to "simulate" a bluetooth accessory, so I must be able to control the pairing, the exchanged code, and so on...
Thoughts?
Simulating jsr-82 can be done with the BlueCove Emulator Module:
http://bluecove.org/bluecove-emu/
http://bluecove.org/ works on OS/X and am sure there wouldn't be any issues with a 64bit OS.
I'd refer you to this Answer: https://askubuntu.com/questions/20195/bluetooth-emulator
You may want to reconsider your question...
To emulate a bluetooth device you would need to develop a bluetooth driver getting it's input from a different source, this would be far more complex than buying a real device.
If you are looking to get some NMEA data though, you may be interested in this:
Most bluetooth enabled phones have apps that do that:
Android: https://market.android.com/details?id=com.cajax.gps2bt2
Any J2ME: http://www.digitalmobilemap.com/bluetooth-gps-simulator-for-j2me-phone
Haven't found one for iPhone, only reference it can be done: http://spench.net/drupal/software/iphone-gps
Hope that helps!
Can you be more exact?
Simulate a Bluetooth accessory for ..?
There are different BT accessories for different smartphones...
Making a BT accessory for iPhone usually requires an authentication chip from Apple...I don't know if a Mac can do it, probably it could - however I'm pretty sure it couldn't describe itself as an accessory.
Accessories usually imply a piece of hardware, in my understanding at least.

Categories