This is likely a very basic question. Our device has a new Bluetooth module.
After retrieving my device from a list of bonded devices I can no longer find a UUID. I can, however, find the device and retrieve its MAC Address, which I know is commonly used to connect over BLE.
Old module:
https://www.microchip.com/wwwproducts/en/BM78#additional-features
New module:
https://www.microchip.com/wwwproducts/en/bm70#additional-features
Is this simply because my new module doesn't support communication over SPP?
My app is written using the Android Bluetooth classic library.
Does this mean I need to rewrite the Bluetooth communication portion of my app for BLE?
Yes you'll need to rewrite your app to handle BLE, just follow this guide.
You can use BLE-Scanner app to debug BLE and to see what data is being used.
Related
Can an Android device pretend and connect as a Bluetooth controller?
Can Android devices connect as a device to, say, a PC and act as a gamepad or similar device?
Is it allowed and doable in code without root access?
I tried this code: Connect Bluetooth devices. But it can not get it to pair.
Short answer, yes.
I recommend looking at Google's example project on Bluetooth communication BlueToothChat initially. Based on what you've written, I think you're missing several important steps.
You need all of the following components / steps:
General Overview
Set up Bluetooth
Set Permissions
Scan for other Bluetooth devices
Query the local Bluetooth adapter for paired Bluetooth devices
Connect to a remote device as client or server
Transfer data over Bluetooth
If you have access to the device your attempting work with as a controller, then you can create your own communication setup. Define a set of parameters to write and read on both sides that emulate the functionality you're looking for.
If you do not have access to creating your own read/write setup, or you want to use standard interaction methods for the industry, then the best bet is the Bluetooth HID Device profile mentioned by #Morrison Chang.
The HID profile basically establish an industry standard of required device features, read/write formats, combinations of features equaling a controller type (ie: "this is a keyboard"), and data mappings for what read/write numbers mean on either side of the client / server connection.
From the linked comment thread, the Kontroller project on Github has source available for your peruse.
There's also a reasonable Intro to Bluetooth HID that covers some of the topics on what Bluetooth HID is actually doing.
Finally, also recommend looking at Google's own BluetoothHidDevice page.
I'm developing an app to communicate with a BLE device (Sensor puck from Silicon labs) and get whatever it is broadcasting.
I have NO experience in developing any sort of Bluetooth application using Android.
Do I need to manually pair it to the BLE device? I downloaded Sensor puck app from Play store, it automatically started to read from the device. I don't understand how since I didn't pair it.
Do I need specific API to communicate with the device? Is it like, I connect to the device and unpack the data which the device is broadcasting?
Any other information related to BLE application development would help.
Thank you.
PS: I can't use the app from the play store as I need the data from the device for some other processing.
I have a little experience with developing BLE apps.
Do I need to manually pair it to the BLE device?
I haven't encountered use case where I needed to pair mobile device with BLE device. Basically, you can communicate with BLE devices without pairing with them. BLE devices constantly emit signals and you can read these signals. Usually, from the emitted signals, you can read name of the device (or producer name), MAC address, RSSI signal from which you can compute distance from your mobile device to BLE device. Some BLE devices emit other information like temperature read from their sensors, etc. You can read information from more than one BLE device during the single scan.
Do I need specific API to communicate with the device?
Google provides API, which you can use to communicate with BLE devices. You can read more about it at: http://developer.android.com/guide/topics/connectivity/bluetooth-le.html. You can also use some third-party libraries allowing to communicate with BLE devices. Most of them are dedicated to so called Beacons, which are simple, tiny BLE devices.
Exemplary APIs for BLE Beacons:
Estimote
Kontakt.io
AltBeacon
ReactiveBeacons - this is open-source project, which I'm currently developing, so if you have any questions regarding it, you can ask me directly
Other projects:
Android Bluetooth Demo - this is very good and simple project, which can help you to understand how to use BLE API provided in Android SDK
Other information:
To communicate with BLE devices, of course, you need to have Bluetooth enabled on your device, but regardless of this permission, you also need to have Location enabled on your device and added location permission to your app. I guess it's done due to the fact, that you can use BLE devices for creating micro-location services.
I gathered some references concerning BLE for myself. You can check them here: https://github.com/pwittchen/ReactiveBeacons#references and maybe they will be useful for you as well.
Regards,
Piotr
it might be too late, but it also might be helpful for other users. So Sensor Puck works like a simple beacon and it doesn't require any pairing. You just have to scan all bluetooth devices nerby and verify received ScanRecord object. You don't have to use any specific libs or API, Anroid sdk contain all necessary api for such case (please see BluetoothAdapter startScan, startLeScan, etc). Also you can find an example how to parse raw data in my demo project https://github.com/alexeyosminin/sensor_puck_demo
I am developing a client-server bluetooth chat app where multiple clients can connect with the server. If I have multiple servers, I want the client the choose which server it can connect nearby to but I am having problems in knowing which device has the app installed and it is a server. There are multiple bluetooth profiles and I am not sure which one to use it and how. Pre-Storing the MAC id's of the devices with server is one solution but I don't want to do that. Please suggest something. Thanks a lot :)
I assume the intention is to avoid an insecure connection attempt with listenUsingInsecureRfcommWithServiceRecord/createInsecureRfcommSocketToServiceRecord(1).
If you don't mind changing friendly name of the device, just during the device discovery period, you can rename your servers to a pattern of yours with setName(2). On device discovery, you can get the remote device name(3), followed by pattern matching before initiating the connection.
And revert the name, once you are done with discovery.
You use a UUID to create the BluetoothServerSocket. This UUID identifies YOUR application and is retrievable by the bluetooth discovery. This UUID is used to connect to your server device as well so you don't need to encode your app's name in the service name.
Check this answer for a detailed description:
How do Bluetooth SDP and UUIDs work? (specifically for Android)
I am quite new with Bluetooth communication using Android. I want to develop a sample project that is to ON and OFF different LEDs via Bluetooth by using Android phone, for this I would need a Bluetooth module to communicate with the LEDs.
Now my questions are:
1) What technical specification are required for Bluetooth module to communicate with android phones(I have two android phones having Bluetooth version V2.1 and V3.0)?
2) which company's Bluetooth module would be better for me in the above situation?
Please help me in this respect I would be very thankful to you for this act of kindness. Thanks in advance.
http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html
Use the UUID specified there for SPP
The bluetooth adapter will work as a Server by default.So you should do Client programming on android side.
My project deals with sending data continuously,so I had to use HandlerThreads so that I don't block the UIThread.Since you don't need to send much data you can work directly on UIThread.So connecting as a client section of android documentation will do.
I have an android app, it does the following:
Connects with a server to read and update a database at the same time as others.
I want to convert this to an app that does not need an internet connection. Therefore i would like to know if its possible to have an android device acting as the server with the database, whilst multiple phones connect to it via bluetooth getting and updating the information in the database?
Thanks
Yes. It possible.
However all of your devices will have to be located nearby, so they can connect to each other through bluetooth.
You can take a look at Android Bluetooth API.
However, my recommendation would be to use Wifi instead of Bluetooth. YOu will need additional WiFi router. However, you won't need to deal with Bluetooth API in such case.
You will only need to write a server on one of Android device and the rest of devices will work the same (as now)
There are a few options to doing so, that don't involve a server. Both of them require a slightly different approach than both devices connecting to a server.
Wi-fi Direct- Only available with Android 4.0+.
Bluetooth
Personally, I have been using the Bluetooth option, and not found it terribly difficult. Essentially, you have to do the following to make it work.
Have one of the devices listen for a connection. If it is unpaired, you will have to make the device discoverable.
The second device needs to initiate a connection. It can do this by looking at the known devices and trying to connect to one, or listening for a new device
After the two devices connect, they must initiate some kind of a communication protocol. The communication is essential a serial connection.
Blue-tooth requires that the devices be within about 10 m of each other. Wi-fi direct will allow somewhat further, but as mentioned, is less supported. It is possible to allow for both communication methods, but is somewhat challenging.