Im_So_Bluetooth


Bluetooth 4.0 Bluetooth low energy 

(Bluetooth LE, BLE, aka: "Bluetooth Smart")



Unfortunately there are no Android native GATT APIs simply because Android currently does not support Bluetooth Low Energy at all. This may change in upcoming Android releases, but today manufacturers instead integrate 3rd party Bluetooth stacks with Low Energy support from vendors like Qualcomm, Broadcom or CSR. Those come with their own set of APIs, obviously limiting compatibility to the set of phones using that particular vendor's stack. The good news is that on other platforms like iOS or Windows 8 there are native GATT BLE APIs, and those are well supported. For Android, we will have to wait until Google decides to integrate the Linux/BlueZ work that has been done on BLE with Android.

UUID

Universally Unique Identifier (UUID)

----------------------
It usually represents some common service (protocol) that bluetooth device supports.

The UUID is used to uniquely id info ...a service from a device.
 The standard defines a basic BASE_UUID:
00000000-0000-1000-8000-00805F9B34FB

 The devices (for example healtcare sensors) can provide some service,
substituting the first eight cyphres with a predefined code.
ex: a device that offers RFCOMM connection, it uses the short code: 0x0003
So, an android phone can connect to a device and then use
service discovery protocol
to find out what services it provides (UUID).

you can set a arbitrary/random app UUID via a UUID generators on the web


----------------------
UUID is similar in notion to internet ports
However, Bluetooth, port numbers are assigned dynamically
          by the SDP (service discovery protocol) server during runtime
where each UUID is given a port number.

Other devices will ask the SDP server, who is registered under a reserved port,
and about the available services on the device

it will reply with different services distinguishable from each other
          by being registered under different UUIDs.

GATT

gatt - intellegent peripheral inter comms


Samsung has also modified a couple of Android's classes, more especifically:
BluetoothAdapter
BluetoothDevice

BluetoothAdapter new methods:

public boolean android.bluetooth.BluetoothAdapter.leTestEnd()
public boolean android.bluetooth.BluetoothAdapter.setAvStreaming(boolean)
public boolean android.bluetooth.BluetoothAdapter.setScanLE(boolean)
public void android.bluetooth.BluetoothAdapter.setScoPathChange(int)
public boolean android.bluetooth.BluetoothAdapter.startLeDiscovery()



Usage:

BluetoothAdapter ba = new BluetoothAdapter();
Method starteLeDiscoveryMethod = null;
starteLeDiscoveryMethod = ba.class.getMethod("startLeDiscovery");
starteLeDiscoveryMethod.invoke(ba);


TODO: work with BluetoothDevice

Apps

Bluetooth spp tools pro

Very handy app (works on samsung5) ...provides easy scan for dev function
    as well as serial/terminal AT cmd interface
 https://play.google.com/store/apps/details?id=mobi.dzs.android.BLE_SPP_PRO


SENA BlueTerm

SENA BlueTerm (android app ...send/rcv serial AT commands with HC05)

https://play.google.com/store/apps/details?id=com.sena.bterm&hl=en



Toshiba Bluetooth Stack (for windows)

http://www.support.toshiba.com/support/viewContentDetail?contentId=3461138
http://cdgenp01.csd.toshiba.com/content/support/downloads/TC00442200F.exe

Notes about the HC-05 module

HC05 - rx 3.3v (NOT 5v!!!)  so reduce voltage coming into the HC05!
    (with 2 resister voltage divider or such)

I used 1k below and two 220ohm resisters above  which gave me about 3.5v for the bt rx pin (from 5v source)

i used the standard arduino tx/rx pins so I could use the built-in Serial.available and Serial.read() API methods, and I also got the benefit of the uart buffering and such

the standard tx/rx pins 1 and 2 are easier to use than the softwareSerial.h API's which require more code to handle buffering, etc (but the softwareSerial allows you to use ANY digital pin on the arduino to simulate serial comm's)

AT command if you have an ENABLE pin (instead of a KEY connector/pin)
http://www.amazon.com/gp/customer-reviews/R3G6VSAJF2DWJ9/ref=cm_cr_pr_viewpnt?ie=UTF8&ASIN=B00L083QAC#R3G6VSAJF2DWJ9

get it into AT mode,
 I had to set both the
EN pin high (or connect to same power as VCC pin on HC-05)
Flash your Arduino with the code in this review
boots up hc05, (LED flashing fast)
press/hold little button on HC-05,
then unplug the power,
wait a second,
plug it back in, and
then release the button.
LED should flashing VERY slow, (lit 2 secs, dark 2 secs)
- THIS is AT mode.
My firmeware FWIW version reported (AT+VERSION?) is :2.0-20100601

//simple command interface for arduino
//ensure "Both NL & CR" specified in serial monitor,
//when it starts, just AT and press send (it should responds OK)
SoftwareSerial BluetoothSerial(10, 11);
void setup(void){
Serial.begin(38400);
BluetoothSerial.begin(38400); /* AT mode speed */
Serial.println("Ready.");
}
void loop(void){
while(BluetoothSerial.available()) Serial.write(BluetoothSerial.read());
while(Serial.available()) BluetoothSerial.write(         Serial.read());

}


Comments

Popular Posts