Bluetooth Low Energy connection with special device - android

I'm writing an android app which is to connect a special BLE device, reading data feedback from the device. First I need to write a shake-hand code "234" to the device, and it will return a code, then start to feeding data.
I've done with the iOS version, which is quite simple to implement, however the android version has so many problems. Hope you guys have any sample which can be used for me to understand how it works in whole process. Many thx.

This is documentation from Android: http://developer.android.com/guide/topics/connectivity/bluetooth-le.html
There is an example. Please use it as guide. Pretty simple example.
About your question. What Profile to you use? You should know that BLE exchange data through the Service/Characteristic/Descriptor system. So on your device should be any Profile. Or your use any of standard?

Related

Is there a common communication protocol between smartwatches and Android phones?

I am very unhappy with my Fossil Q hybrid watch (no screen, tracks activity & sleep and button functions) but honestly it looks good. The app keeps crashing though. I would like to make my own Android app to extract all kinds of data (for future analysis). Before investing a lot of time, I tried to do some research on how to access the watch. It operates obviously on BLE. But all the documentation is either about Wear OS or actual smartwatches with more advanced functionality. Search engines fail to distinguish between what I am looking for and most popular results.
I was wondering, if there are any known communication protocols between apps and smartwatches, where I can start experimenting?
BTW, HCI snoop log reports all traffic but it doesn't look like anything to me. But I can also try to hack it (if it is not encrypted...).
I remember that I have found once a info on dev site regarding the heart rate tracking but I cant find it.
Anyway I have found one thing that might help you:
https://developers.google.com/fit/android/ble-sensors
Unfortunately this is "fit" reference site, which data might be obsolete,
afaik the regular updates might come to API reference:
https://developers.google.com/android/reference/com/google/android/gms/fitness/SensorsApi
You can start by reading code and documentation of the GadgetBridge project: https://codeberg.org/Freeyourgadget/Gadgetbridge/
They support some of the "Q Hybrid" watches to some extent

How can I create a OBD 2 Android application like torqe? Are there any software simulators available or I need a car to test application?

I want to create a OBD 2 android application like Torque. Are there any software simulators available for testing or I need a car with OLM adapter to test the application?
I got to know about the github library https://github.com/pires/android-obd-reader/releases/tag/2.0-RC4 , is there any other library/tool available or I can get all possible data from this?
I did run into a obd II simulator I found in the google app store which I installed on one of my development phones https://play.google.com/store/apps/details?id=com.beastovest.obd.simulator
On a second phone I installed the Car Scanner from the store (free)
https://play.google.com/store/apps/details?id=com.ovz.carscanner
The setup is pretty simple. Just pair the device from the simulator to the scanner.
In the simulator I can change engine values and I can see the commands and the changes in the scanner. You can see the rest of the communication as well. The simulator is $5. Very nice for that price. I can also see the complete communication which I need for my app development. I also speed up the understanding of the ELM327 commands. Here is the spec: https://www.elmelectronics.com/wp-content/uploads/2017/01/ELM327DS.pdf
Hope that helps anybody.
Yes, there is a free software simulator with simple GUI, called OBDSim. It works on Windows, Linux and OSX (among others).
There's also a hardware simulator ECUSim 2000, which isn't free and also isn't cheap.
That GitHub repo you linked to is actually an Android application, capable of acquiring OBD data from a car. It is not an OBD library, however it is based on one (by the same developer, pires).
Now to (partially) answer your second question: no, you can't get all the data OBD offers (PIDs on wiki, but there are more manufacturer specific ones) using this library. However you can get all the interesting data that you'll need if you won't be doing something really specific. I don't know if there are other similar libraries but I found this one well written, well documented and well performing.

Can you manipulate Raspberry Pi sensor data on an Android smartphone?

I am new to using the RPi and just got the A+ model which I have been using to generate different types of data from external sensors. I was wondering if it is possible to send this data it is gathering to an android device in real-time, and if so the best method? I want to be able to notify the user (through a an app made with the Ionic framework) when the data enters a particular range etc.
And also is it possible to do this whilst the user is walking around with both the devices in hand?
The short answer to the question is: Yes, you can ;-)
The longer answer is much longer, since there are many ways to do this.
The one I personally would choose as the simplest is classic Bluetooth (not LE) using the SPP profile, which basically makes the BT link a serial connection between the RPi and the phone.
On this serial link you invent you own streaming protocol suitable for the data you want to transfer.
On the RPi side you install a module such as this: https://www.sparkfun.com/products/12577
(There are many alternatives, but the RN42 module is very foolproof...)
Don't know the level of your hardware skills, you might need something more plug and play if you feel uncomfortable hooking up the 4 wires needed for 3.3V power and serial communications between the Pi and the BT Module...
On the phone side you install https://github.com/don/BluetoothSerial, which gives you an API reachable from Ionic where you can receive the BT data stream.
With that and a bit of coding on both sides you are good to go.
I've used a Raspberry Pi in combination with an Android smartphone & Lego NXT.
Communication was achieved using Bluetooth on Raspbian. I used a cheap $1 USB Bluetooth dongle. The Bluetooth stack had to be compiled for Raspi, which may not be necessary anymore. Steps can be found here: Bluetooth error: Native Library bluecove_arm not available
Bluetooth seems most logical to me.
I'm at work at the moment, hence the lightweight answer, if you'd like to discuss this further then please leave a comment and I'll be happy to provide more verbose response.
You can upload the data to any cloud services. You can use Xively/Box. Xively is specially made for real time data collection.
To connect RPi to Xively, refer this: https://xively.com/dev/tutorials/pi/
For Box, refer this: http://www.sbprojects.com/projects/raspberrypi/webdav.php
You can then use Xively API in your android app. You can see GitHub for this
Google app store already has some apps for you, if you want to use
It might look a little complex. But its really simple once you follow the above methods.

Android OBD-II Bluetooth API sample code not working

I need to develop an Android app that retrieves data from a OBD-II Bluetooth dongle. As first step, I downloaded the API from https://code.google.com/p/android-obd-reader/ and tried to run the Sample Application in it, but it didn’t work for me. Can someone tell me who used that API and where is the error on that code? There are lots of packages and classes on it. I’m unable to clarify them.
It is very difficult to know which can be your problem. I have used the library you mentioned and it includes an application example that can help you to understand how the library works.
I recommend you to use the application called obdgpslogger (http://icculus.org/obdgpslogger/) that includes an OBDSim module (http://icculus.org/obdgpslogger/obdsim.html).
This module can work as an emulator of the ELM327 device. Using it under linux you will be able to emulate a Bluetooth ELM327 dongle. Using this application you will be able to get a log the Bluetooth connection and disconnection, the configuration AT commands sent to the ELM327 device and the querying rate.
I think it will be more easy than using a real vehicle.
I know that it takes some time to understand everything, but you can do it.
I hope it helps.

RFCOMM based bluetooth communication between two android devices

For some requirement analysis I want to test a RFCOMM based bluetooth communication between two android devices.
I need to send some 1 MB of data to from Android device 1 and Android device 2 should receive it and display/save the data. I need to do this using Bluetooth SPP (RFCOMM) profile .
Can any one suggest some available app/code to do this?
Under the bluetooth documentation for Android Developers. There is the Bluetooth Chat application example which will contain an activity for facilitating the communication between two devices, as well as the service connection. This will be your best example for what you are looking to do. Here is the link to the Tutorial, you will also find a link to the BluetoothChat application under here:
http://developer.android.com/guide/topics/connectivity/bluetooth.html
To see the BluetoothChat application you will first need the Android SDKs, and then you will be able to find the source.
Generally, do some research first, as here is another question of the same sort that has a little more detail, and shows the user made a good attempt first.
Bluetooth Examples for Android
After following the BluetoothChat application, or the written tutorial on the Android Docs, if you run into bluetooth errors, and other problems with your code. Stack Overflow is definitely the way to go for receiving quality answers to your troubles!

Categories

Resources