android-bluetooth

Example for subscribing for BLE indicate in android

核能气质少年 提交于 2019-12-11 03:06:24
问题 I have connected to a bluetooth device. I am able to read charectristic using mGatt.readCharacteristic(getMiliService().getCharacteristic(uuid)); But I am not able to register indicate for a characteristic. What I tried boolean flag1 = m_Gatt.setCharacteristicNotification(bluetoothgattcharacteristic, flag); BluetoothGattDescriptor descriptor= bluetoothgattcharacteristic.getDescriptor(Helper.UUID_DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION); descriptor.setValue(BluetoothGattDescriptor

Android receiving multiple BLE packets per connection interval

泪湿孤枕 提交于 2019-12-11 02:39:11
问题 I have a device that transmits data to my Android (4.4.2) over a BLE GATT characteristic. The device sends multiple 20byte packets per connection interval, where each packet has a sequence number. Lets say the device is sending 4 packets per connection interval, as shown... |sq1,sq2,sq3,sq4|sq5,sq6,sq7,sq8|.. I notice at the Android end, may calls to onCharacteristicChanged() are coming in like... |sq4,sq4,sq4,sq4|sq8,sq8,sq8,sq8|... Does Android support sending multiple packets per

How to send a text message to a paired device through bluetooth in android?

[亡魂溺海] 提交于 2019-12-10 23:47:34
问题 In my app I want to send and receive text message through bluetooth. I can see in my listview a list of paired device name and address.But when I am trying to send a text to a paired device nothing happens. In other device there is no text received. This is my Code to send message to a paired device. private void sendDataToPairedDevice(String message, String adress) { byte[] toSend = message.getBytes(); try { BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(adress); //

Change the MTU or Packet Size for Bluetooth in Android?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 21:08:40
问题 How can I change the MTU or Packet Size for Bluetooth in Android?! It is not possible in using Android's API, right? I believe I should change the native codes. How can I change it? And is it also possible to change the transmission rate, or it is hardware dependent? Thanks 回答1: Yes, You are right - it is not possible in Android API. You can only get MTU value for an interface with networkInterface.getMTU() method. Based on sources for the NetworkInterface class public int getMTU() throws

Samsung Android BLE multiple read/write

爷,独闯天下 提交于 2019-12-10 20:29:45
问题 In Samsung 4.2 to 4.3 BLE App Migration Guide (http://developer.samsung.com/ble) it says: The synchronous nature of the stack and F/W hasn’t been affected. That is, if we call for example, writeCharacteristic for a particular characteristic, if it returns true, the next call to any BluetoothGatt or BluetoothGattServer method should be done after the onCharacteristicRead callback is received. This is because the stack is designed to support and process only one GATT call at a time, and if, for

Android bluetooth connect() throwing error

我只是一个虾纸丫 提交于 2019-12-10 19:32:36
问题 I have a project requirement wherein we have a product that contains two components -an android tablet and a PCB(containing an RN42 bluetooth chip).These two components are inside a plastic casing hence always will be in close proximity to each other.Both these devices would be paired once initially, hence the pairing info is present in the tablet forever. Problem : In my code I make use of a function which initializes the bluetooth socket and gets access to the DataOut and DataIn ports using

getBluetoothService() called with no BluetoothManagerCallback for Android Nexus 5

£可爱£侵袭症+ 提交于 2019-12-10 15:23:51
问题 I am going to implemenet the module for sending commands from my Android smartphone to HC-06 via BLuetooth. WHen it comes to the execution , it show s the following exception and find no clue for the error message as title . Would you please tell the way to modifiy ? Exception Log Message : 07-29 13:51:37.701: W/BluetoothAdapter(1928): getBluetoothService() called with no BluetoothManagerCallback 07-29 13:51:37.711: D/BluetoothSocket(1928): connect(), SocketState: INIT, mPfd:

BLE BluetoothGattCallback gets a STATE_DISCONNECTED when device is still ON

眉间皱痕 提交于 2019-12-10 11:56:24
问题 I connect to the bluetooth device using this method: /** * Connects to the GATT server hosted on the Bluetooth LE device. * * @param address The device address of the destination device. * * @return Return true if the connection is initiated successfully. The connection result * is reported asynchronously through the * {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)} * callback. */ public boolean connect(final String address) { if

Android- Bluetooth: Bluetooth Service behaving unexpectedly

混江龙づ霸主 提交于 2019-12-10 11:49:08
问题 I am writing an android app that can interact with arduino. My app have 2 buttons 1. Connect 2. Dis-Connect, to start and stop bluetooth service. I have a test sketch on arduino which when receives "1" will send "404"(just to test!) back to my phone. Here's my Bluetooth service class public class BluetoothService extends Service { private BluetoothManager bluetoothManager; private ServiceHandler mSHandler; public BluetoothService(){} private final class ServiceHandler extends Handler { public

How to make Bluetooth Undiscoverable?

 ̄綄美尐妖づ 提交于 2019-12-10 11:42:30
问题 I have learned the codes to make blue-tooth discoverable in Android,like: Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300); startActivity(discoverableIntent);` = So, how can i make blue-tooth un-discoverable artificially as soon as i make it discoverable? Thanks for all help! 回答1: I have found a method,although i don't understand it yet,it works in my project! public void