android-bluetooth

GATT over SPP profile for bluetooth communication?

烈酒焚心 提交于 2019-12-07 05:17:34
问题 This is confusing me for days. In the beginning when I was implementing the functionality, I used GATT profile for BLE bluetooth communication. Then I came up with BluetoothSocket. This uses the SPP profile for bluetooth communication. There is mentioned: The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs. RFCOMM is a connection-oriented, streaming transport over Bluetooth. It is also known as the Serial Port Profile (SPP). My requirement is -

BLE Scan Record Explanation

守給你的承諾、 提交于 2019-12-07 04:10:05
问题 I am trying to get the UUID , Major , Minor IDs from the BLE advertisement received in the form of a byte[] . I have used the suggested code here but the i am unable to understand the output of the parser. Here is the output i get for one of the BLE devices Length: 2 Type : 1 Data : 6, Length: 26 Type : -1 Data : 76 0 2 21 -9 -126 109 -90 79 -94 78 -104 -128 36 -68 91 113 -32 -119 62 12 -121 -79 52 -77, Length: 8 Type : 9 Data : 75 111 110 116 97 107 116, Length: 2 Type : 10 Data : -12,

Capture Audio through Bluetooth Headset paired with Android Device

旧时模样 提交于 2019-12-06 16:46:27
问题 I am trying to capture audio from a Bluetooth Headset paired with an Android Device. Following is the relevant code: Intent in=null; final int bufferSize=BufferElements2Rec*BytesPerElement; final BroadcastReceiver brr=new BroadcastReceiver() { @Override public void onReceive(Context context,Intent intent) { int state=intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE,-1); Log.d(labelApp,"Audio SCO State = "+state); if(AudioManager.SCO_AUDIO_STATE_CONNECTED==state) { Log.d(labelApp,"Entered

NoClassDefFoundError during class load for BLE scanning callback

戏子无情 提交于 2019-12-06 16:23:45
I am keep on getting the NoClassDefFoundError when my class is loaded. The code is taken from BluetoothLeGatt project - http://developer.android.com/samples/BluetoothLeGatt/project.html My code: // Device scan callback. private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { //java.lang.NoClassDefFoundError... @Override public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) { runOnUiThread(new Runnable() { @Override public void run() { String msg= device.getAddress(); Log.d(TAG,msg); addItems(msg); } }); } };

How to send command to BLE device and show result

孤人 提交于 2019-12-06 15:12:51
@Override public void onServicesDiscovered(final BluetoothGatt gatt, int status) { super.onServicesDiscovered(gatt, status); if (status == BluetoothGatt.GATT_SUCCESS) { List<BluetoothGattCharacteristic> characteristics = null; List<BluetoothGattService> services = gatt.getServices(); //I am getting all services for (final BluetoothGattService service : services) { characteristics = service.getCharacteristics(); //I am getting all characteristics for each services } } } I am able to connect with BLE device and I am getting all services and characteristics, now I have send some commands, like to

How to send the text data to CC2541 keyfob via Android 4.3?

百般思念 提交于 2019-12-06 12:57:49
I am developing an application where I have to connect to Bluetooth device on Android 4.3. And I want to change the name of CC2541 Keyfob via the Android application. My ideas is: 1.There has a Plain Text that I can type the name what I want in my Android application. 2.After I type the name, I push the button to send this text. 3.If the CC2541 receive this text from Android application , it will change the text in the deviceName[] of the following code in keyfobdemo.c: static uint8 deviceName[] = { // complete name 0x0b, // length of first data structure (11 bytes excluding length byte) 0x09,

getBluetoothLeAdvertiser() returns null

坚强是说给别人听的谎言 提交于 2019-12-06 12:43:53
BluetoothLeAdvertiser advertiser = BluetoothAdapter.getDefaultAdapter().getBluetoothLeAdvertiser(); This returns null. I have tried on an API 21 and on an API 23 device, but with the same result. I have no idea what I am missing? The app builds and runs just fine, until of course the advertiser is used and the app crashes. I appreciate any help provided! :) If you check the developer docs, link here . You'll see that the null object is returned in the following case: Returns a BluetoothLeAdvertiser object for Bluetooth LE Advertising operations. Will return null if Bluetooth is turned off or

Android BLE - Peripheral | onCharacteristicRead return wrong value or part of it (but repeated)

[亡魂溺海] 提交于 2019-12-06 12:35:49
问题 i'm losing my mind with this issue. The fact is, one android device which is advertising a string value: "78d89537-4309-4728-87f6-3ab2bbe231d8" (36 bytes). I'm using a characteristic defined as anonIdCharacteristic = new BluetoothGattCharacteristic(TippeeBluetoothManager.UUID_READ_CHARACTERISTIC, BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_BROADCAST, BluetoothGattCharacteristic.PERMISSION_READ ); anonIdCharacteristic.setValue(idToAdvertise); as you can see

BLE: Read Long Characteristics Value using Android / iOS

谁都会走 提交于 2019-12-06 11:01:18
With a normal Characteristics Read only the MTU Size (20bytes) of data will be read. My customer will offer a characteristics with a larger size (about 100bytes). I saw that BLE offers a "Long Read" feature which reads until the size of the characteristics is reached. ( https://bluegiga.zendesk.com/entries/25053373--REFERENCE-BLE-master-slave-GATT-client-server-and-data-RX-TX-basics ) attclient_read_long command - Starts a procedure where the client first sends normal read request to the server, and if the server returns an attribute value with a length equal to the BLE MTU (22 bytes), then

How to restart BluetoothLeScanner?

不打扰是莪最后的温柔 提交于 2019-12-06 06:37:01
问题 I'm connecting Android device to iOS using BluetoothLeScanner on Android side. It all works perfectly for the first time. The thing is that after I connect to one of the discovered iOS devices I stop the scan (stopScan(scanCallback)) to preserve energy. If later previously connected device for some reason disconnects I again start the scan again... but it seems after the 'restart' scan does not work anymore - it does not discover any more devices... not sure why but I'm forced to restart the