android-bluetooth

Android Bluetooth Low Energy: characteristic.getPermissions() returns 0?

牧云@^-^@ 提交于 2019-12-03 00:24:40
I am writing an Android BLE application, and I am trying to get the permissions of a certain characteristic. I have already managed to get the characteristic properties with characteristic.getProperties(), and it returns a non-zero value, however, when I use the getPermission() method it returns 0 even though I am sure that the characteristic has PERMISSION_WRITE_ENCRYPTED_MITM (0x00000040). Here is a code snippet // properties int properties = ch.getProperties(); DebugWrapper.infoMsg("properties: " + properties, TAG); //returns non-zero value // permissions int permissions = ch.getPermissions

Android bluetooth: Paired devices list

对着背影说爱祢 提交于 2019-12-02 21:20:20
I have a bluetooth device with SPP profile and bluetooth version 2.1. I have an app which connects to that device and communicates with it. The device uses "Just Works" pairing technique. I am facing a problem on certain phones like Samsung Galaxy tablet, Galaxy S. The problem is after the user exits from the app, I am closing the sockets and disconnecting from the device. After successful disconnection, it is observed that the device's entry is removed from the paired devices list. I haven't worked with tablets, but I did write an app that used SPP for Android phones. What I found was that in

Connect multiple devices to one device via Bluetooth

為{幸葍}努か 提交于 2019-12-02 15:12:34
I would like to create a game, where you must connect multiple devices (4+) to a main device (ex. a tablet) via Bluetooth. There would be two apps, a main one to which all data would be send from the phones, and to the phones. Is that even possible? Yes, that is possible. At its lowest level Bluetooth allows you to connect up to 7 devices to one master device. I have done this and it has worked well for me, but only on other platforms (linux) where I had lots of manual control - I've never tried that on Android and there are some possible complications so you will need to do some testing to be

How can I increase the throughput of my BLE application?

戏子无情 提交于 2019-12-02 13:23:24
问题 I have an android client that functions as a central and have an app on my MAC (peripheral) that this central connects to and sends data. At this point, I need to wait almost 100ms after I call writeCharacteristic(..) to receive the onCharacteristicWrite(..) callback. I am sending strings. If I send smaller strings, the throughput is great (understandably). When the string contains about 200 characters and I send 20 byte chunks, it takes almost a second before the entire string is seen at the

Bluetooth BLE service returns status = 10 at onCharacteristicRead

倾然丶 夕夏残阳落幕 提交于 2019-12-02 08:54:36
问题 I try to read some configurations from a device I'm connected to, but on the callback - onCharacteristicRead the parameter status=10. I noticed that status == 0 meas BluetoothGatt.GATT_SUCCESS. WHAT DOES 10 STANDS FOR???? My code is as follows: public boolean read(byte[] bytes, String action) { // is copied from android website example if (mBluetoothAdapter == null || mBluetoothGatt == null) { Log.w(TAG, "BluetoothAdapter not initialized"); return false; } BluetoothGattService mCC2540_service

Bluetooth BLE service returns status = 10 at onCharacteristicRead

狂风中的少年 提交于 2019-12-02 07:41:58
I try to read some configurations from a device I'm connected to, but on the callback - onCharacteristicRead the parameter status=10. I noticed that status == 0 meas BluetoothGatt.GATT_SUCCESS. WHAT DOES 10 STANDS FOR???? My code is as follows: public boolean read(byte[] bytes, String action) { // is copied from android website example if (mBluetoothAdapter == null || mBluetoothGatt == null) { Log.w(TAG, "BluetoothAdapter not initialized"); return false; } BluetoothGattService mCC2540_service = mBluetoothGatt.getService(UUID.fromString(mCC2540_SERVICE_UUID)); if (mCC2540_service == null){ Log

How can I increase the throughput of my BLE application?

梦想的初衷 提交于 2019-12-02 04:37:17
I have an android client that functions as a central and have an app on my MAC (peripheral) that this central connects to and sends data. At this point, I need to wait almost 100ms after I call writeCharacteristic(..) to receive the onCharacteristicWrite(..) callback. I am sending strings. If I send smaller strings, the throughput is great (understandably). When the string contains about 200 characters and I send 20 byte chunks, it takes almost a second before the entire string is seen at the peripheral. When I set the write type to NO_RESPONSE before writing the characteristic, I see no data

Obtaining a List of Available Bluetooth Devices on Android

时光毁灭记忆、已成空白 提交于 2019-12-02 03:54:44
问题 In this question, @nhoxbypass provides this method for the purpose of adding found Bluetooth devices to a list: private BroadcastReceiver myReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Message msg = Message.obtain(); String action = intent.getAction(); if(BluetoothDevice.ACTION_FOUND.equals(action)){ //Found, add to a device list } } }; However, I do not understand how a reference to the found device can be obtained, how can this be

BluetoothDevice always returns null on getName()

浪子不回头ぞ 提交于 2019-12-02 03:49:54
I'm facing this issue consistently in Android 4.4, 5 and 6. I'm performing a BLE Bluetooth devices scan and after it I can access their address (getAddress()), and other data. But if I call device.getName() it returns null EVERY TIME. This documentation is not helpful, it only says that returns null if "there was a problem" : https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#getName() Other posts that I visited unsuccessfully : https://code.google.com/p/android/issues/detail?id=34411 android BluetoothDevice.getName() return null ble device bluetoothdevice.getname()

Ble Scan service of a device without connecting to it

十年热恋 提交于 2019-12-02 02:52:07
I want to scan some device with BLE. I only want to show my device, so for know I get the name of the device and if it is the good one I put it in my list. if (device.getName().contains(DEVICE_NAME)) { mDevices.put(device.hashCode(), device); invalidateOptionsMenu(); } My problem is that if I change the name of my device this check will be false. So I look if it was possible to get some uuid of some services that I add to do the check with something that would not change. And the only way is to connect to the device doing a device.connectGatt(this, false, mGattCallback); and after with the