Bluetooth Serial Communication in Android with Ubuntu - android

I am trying to build an android app that can be controlled by a laptop with ubuntu installed via Bluetooth. What I want is to develop an android app that listens for incoming messages and performs particular actions according to the message. Basically I want the app to listen for Bluetooth signal (message) in the background while camera intent is open in the foreground and snap the picture when a particular message is received.
For that, I started learning about the Bluetooth serial communication and got to know about the following library on Github:
https://github.com/harry1453/android-bluetooth-serial/tree/master/demoApplication
I have replicated the demo application and the application is sending messages successfully, however when I send the message from Linux to the Android app it is not working. Can anyone help me regarding this issue or can suggest me some good tutorial to follow in order to build the app that can communicate with raspberry pi serially?

We know Bluetooth serial configuration is poorly documented (I read many questions here without any clear results.)
I believe it's due to the Raspberry Pi Bluetooth configuration issue based on your description.
With correct Raspberry Bluetooth serial configuration, your program with serial routines (written in Python using PySerial or serial routines written in C, which you can find it in github), your requirements (sending info about camera status via serial port will work.
Please see Bluetooth Serial Configuration (see latest answer) for more details.

Related

Bluetooth-LE GATT write results in notification with same data using RN4020 MLDP protocol

I wonder if anyone else is seeing this. We have successfully used the RN4020 MLDP protocol (similar intent to SPP on Classic Bluetooth) with both iOS and a Bluetooth-LE USB module (BLED112) on Windows. Basically serial bytes coming in to the RN4020 module are sent via a characteristic, resulting in a notification on the connected device (iPhone, PC). Bytes written to the characteristic on the connected device come out of the RN4020 serial port.
But using similar API calls on Android (using C#/Xamarin low-level APIs), I occaisionally see the data I send appear as a notification. About 1 time in 5. The data sent does go to the module and then to the equipment it is attached to. I think I saw evidence that there was some sensitivity to timing.
Has anyone seen similar behavior? I do not see this on iOS or the BluetoothLED dongle (BLED112). I believe too that the Windows UWP version I started did not show this behavior.
Thanks to anyone who can help me understand this -- currently I have a hack in to discard received data that exactly matches what was sent out recently. But I would hate to release like this.

send string variable from raspberry pi 2 to android app over bluetooth

I am developing an android app using android studio to receive string(results) from raspberry pi after image processing code .
I am using python 2.7.3, opencv 3.1, numpy 1.8.
bluetooth chip RN42XVP connected to the raspberry pi 2
I read this question
Receiving data from raspberry pi in android via bluetooth
I tried it but it gave too many errors and undefined variable!
anyway I think it is not specifically what am searching for.
what i need is simply to send the content of string from a python code on raspberry pi to android application.
when a button clicked in android app it will receive and display the content
The following is the general approach: read the manual
Read the data sheet, it has all the information on how to connect and talk to the device. You need to figure out the following:
How do you want to connect to the device (the product page mentions UART or USB).
depending on your choice you figure out what hardware this module needs in order to run (Capacitors, Voltage supply, etc.).
After that you connect the device to USB- or UART-capable pins on your Raspberry Pi.
Then you want to open a device file descriptor on you raspberry pi, which talks to those pins. (Normally a open(file, "w") should be sufficient). (If you are not sure, refer to the Raspberry Pi documentation or google it.)
Everything you write into this file descriptor gets sent to the wireless module.
Figure out how to communicate with the module (what commands you need to send, how to set it up, etc.).
Write your python code.
After Googling it, it seems, that this is a very popular module and has already been used with Arduinos, maybe you can find a tutorial on how to connect it, I'm pretty sure that there also are some libraries already written, which spares you the hassle of writing everything yourself.
The following link describes how to connect the module with an Arduino, but it should be easy to do the same with your Raspberry Pi: http://dduino.blogspot.co.at/2012/03/arduino-rn-42-bluetooth-module.html

HM10/11 BLE to Android Phone connectivity

First off I would like to ask if it is possibe to send a stream of data from an arduino with HM11 to an android phone via bluetooth.
The data contains ultrasonic sensor's readings, orientation, battery level, etc.
My android phone will be displaying those data accordingly acting as a monitor.
I tried coding already using the android studio using the bluetooth guide resources but i end up unable to connect to my module with a message "read failed, closed or timeout -1". I have tried connecting while paired or unpaired. My app can discover HM11 as well as receive the data using HMBLE Terminal app i have downloaded from Play Store. So I guess the android studio guides are not meant from android to bluetooth modules.
I would also like to begin from scratch as i may have missed out some very important basic information.
Any help?

How to use android as ANCS content provider?

I'm trying to demo android side service (content provider in ANCS lingo), that communicates with embedded device that supports Apple Notification Service (ANCS) notification consumer. Reason for this is, that the embedded device only supports ANCS. As the ANCS BLE side things are publiced by Apple, this should be possible and I've already added that service + associated characterics to android side gatt server. Embedded device is nordic nRF52 and SW is nordic ANCS demo. Demo works OK with iPhone and apparently with the desktop version of nRF control panel (if added with nordic supplied config and if you have windows machine, which I don't).
However I cannot seem to be able to bond the device with android, that's required before connection. The advertisement is in limited discovery mode (before bonding) so I cannot find it via regular scanning from settings. Also bonding from java code doesn't work. With mBluetoothDevice.createBond() I get ACTION_BOND_STATE_CHANGED callback with state 10 (BluetoothDevice.BOND_NONE) with old state 11(BluetoothDevice.BOND_BONDING). Apparently I would need to exchange keys here, but no idea how to do that.
Also dunno if anyone has done this same exercise before, but any other tips would also be appreciated! Thanks!
Problem was that the phone BLE stack was corrupted or in some invalid state. REboot and removing battery solved the issue with the bonding.

packets sent via bluetooth

Is there a way to find out what packets being sent by android to paired bluteooth devices? For example what packets being sent if an incoming call is detected?
Update: Im using an Android 2.3 device, so the built-in logger of android 4.4 is not available for me. Moreover i cant find an app that logs the bluetooth traffic on my older device.
What about writing what you receive somewhere? Like on a text file? Or in the SQLite DB? Or even in a view you put somewhere in your app for debugging?
If you want to capture logs sent by one Bluetooth device to another, you will need tools like Bluetooth Protocol Analyzer tool like Sodera Analyzers (http://www.fte.com/products/sodera.aspx). But such tools are very costly.
You may also go for the logs of interaction between Bluetooth host and controller i.e. HCI(Host Controller Interface) snoop logs.
To enable HCI logs on android, Go to Dev. Options->Enable Bluetooth HCI snoop log.

Categories

Resources