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!
Related
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.
We were given a bluetooth device that we were asked to connect both iOS and Android devices to a particular custom peripheral.
The demo app seems to bring up a list of devices, asking which to use, then brings up a list of protocols, which includes one defined in the info.plist under "Supported external accessory protocols" as com.(company).bt.
I looked all over and found nothing about this process being standard with Bluetooth, and the entire workflow appears to be different on Android. I've tried using the bluetooth sample app to connect to this device but the red connected LED never lights up, and depending on the UUID given, I either receive 1 byte or 7. The sample code I was given doesn't even touch the InputStream unless the stream has reached 16 bytes (Which of course, never happens)
Is there some sort of guide on how to connect to this device? Based on what I read from the code, a message isn't even sent until the user presses a button, but the LED is lit long before this is even an option in iOS.
Edit: I finally found something from clicking around - it seems that the plist entry has to do with mfi (Which I guess the documentation is only available to those in the program?) With that said, does that mean this device will only work with iOS devices?
As you mentioned connection in Android and iOS is done differently.
The protocol defined in info.plist should be the protocol you are meant to use with the particular Bluetooth chip you have.
There is a guide explaining how to connect in iOS, you should probably also check which Bluetooth version it is. If it is lower than Bluetooth 4.0 (BLE- Bluetooth Low Energy) or not. I assume it isn't BLE since you mentioned it is MFI...
1)If it is BLE use Core Bluetooth
2)Otherwise have a look at the following link: Introduction to Stream Programming Guide for Cocoa.
It is a bit hard to understand what you mean about the red LED because we don't know what device you are using. Considering you are receiving some bytes from the device it means that the communication was established. You can start debugging and perhaps understand better the code by changing it to "touch" the InputStream even if 1 byte is received...
Hope this helps.
Cheers!
EDIT: Just read the title again, I am not sure what you mean by saying you want to convert the code to Android? You only described your attempt to connect in iOS.
A quick Google search would give you the following links for Android guide:
1) Bluetooth (not BLE)
2) BLE
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?
I am making an App based on the Sample Bluetooth Chat given on the Official Android Developer website. My App works fine whilst chatting with another Android Phone. However, it does not work when I connect it to a non-Android Device (namely some electronic circuit that my team has made).
Internet Research has shown that the Sample Code is only meant to communicate between two Android Devices.
So, how do I change the Sample Code to make it work with other non-Android Devices as well.
I figured out the Answer through analysing the source-code of the BlueTerm App. Effectively, I only needed to change the UUID that I was setting in the App from fa87c0d0-afac-11de-8a39-0800200c9a66 to 00001101-0000-1000-8000-00805F9B34FB"
I'm not an expert on this area so I can't say WHY that is the case, but it does help solve my problem. The BlueTerm SourceCode is available on Official Download Website of Pymasde
the UUID is specifically for serial port connection and it's a standard.
I am creating app in which I had to send data to phone via embedded device.
Is it possible to send file via embedded device to Android phone with Bluetooth?
I don't find any of example of it and I think I need another embedded device like dongle for implementing obex protocol.
You need to read in the bytes of the file that is being submitted by your device. Sample code that connects the android to a separate device can be found in this SO post. There is also a robust documentation of the API as well as a specific sample application. Be aware that many people are finding issues when using the sample application to try and connect the android to a separate device. The issue is explained in this SO post (see the accepted answer), but essentially the connectivity problem is caused by calling listenUsingRfcommWithServiceRecord.
I myself ran into problems with Bluetooth, but using the above resources have been able to quite successfully connect my android with an embedded device. Hopefully this aggregate of information will be of use to you.
You can use the very common UUID for SPP devices: ("00001101-0000-1000-8000-00805F9B34FB");