bluetooth-lowenergy

getBluetoothLeAdvertiser() returns null

别等时光非礼了梦想. 提交于 2019-12-22 14:17:11
问题 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! :) 回答1: If you check the developer docs, link here. You'll see that the null object is returned in the following case: Returns a

Is it allowed to include the battery state (0x2A1A) in the battery service?

牧云@^-^@ 提交于 2019-12-22 10:49:01
问题 The specification for the BLE GATT battery service only lists the battery level characteristic although the descriptive text mentions "battery level and state ". I would like to indicate the battery charging/discharging state, however the characteristic that allows that (2A1A) is not included in any defined service. It seems this is an oversight by Bluetooth SIG. Will including an additional characteristic in the battery service for battery state be flagged as non-compliant with the

BLE peripheral support Android-L example [closed]

老子叫甜甜 提交于 2019-12-22 10:17:26
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I would appreciate an example of BLE peripheral mode for Android-L. The code that I have gives me strange errors (i.e too many advertisers) which makes no sense as there are no advertisers that i can see from scanner like Lightblue on ios. 回答1: https://github.com/geoaxis/BluetoothTest works on my nexus 5 running

Reading RSSI value of connected Bluetooth Low Energy device in Android Studio

爷,独闯天下 提交于 2019-12-22 10:09:03
问题 I am working on a BLE project in Android Studio and would like to read the RSSI value of a device which I have already connected to. So far I was able to discover new devices via LE Scan and get their RSSI from there. However, once I connect to a device I can no longer run a scan and get the RSSI. This is the code for discovering new devices before connecting to one of them. Not sure how relevant it is to my question though: private BluetoothAdapter.LeScanCallback mLeScanCallback = new

bluetoothGatt writeCharacteristic returns false

南楼画角 提交于 2019-12-22 09:01:33
问题 I created a peripheral with a WRITE_TYPE_NO_RESPONSE characteristic. With another application, I wrote on characteristic, but I have an occasional problem with samsung galaxy nexus i9250 with lollipop 5.1.1: sometimes the function BluetoothGatt.writeCharacteristic returns false and the write is not done. What could it be ? Can it be cyanogenmod's fault ? And in what way can I patch this problem ? On peripherall : new BluetoothGattCharacteristic( UUID.fromString(characteristic),

Bluetooth LE : Address Type

别等时光非礼了梦想. 提交于 2019-12-22 06:37:28
问题 I am working on the iBeacon technology and I can't find any answer to a particular point concerning the address type. I found the documenation (bluetooth specification) explaining what are the address types but I can't seem to find how to chose between the two types (public and random). Here is an example where I found it (it is a sniffed packet transmitted by an iBeacon on a Raspberry PI) : http://i.stack.imgur.com/QF5gf.png and http://i.stack.imgur.com/NHY6x.png (sorry I can't post images

Reading multiple characteristics from a BLE device synchronously (Recommended Method for Android)

早过忘川 提交于 2019-12-22 06:26:35
问题 I am working on an android application which reads data from a BLE device. I came across plenty of solutions here on how to read multiple characteristics and most of them suggested Queues. I did implement the Queue method and everything is working fine in my code as expected. The reason why i started this thread is to find the best possible and most efficient solution and also to clear some of my doubts regarding how certain BLE service characteristics work. I have taken the below two links

Programmatically, How to identify if a beacon belongs to Eddystone or iBeacon?

一笑奈何 提交于 2019-12-22 05:57:07
问题 I have created an android application to scan for BLE using Bluetooth LEscanner. Now that I need my app to identify if a beacon belongs to iBeacon or Eddystone. So far, I'm successful in determining UUID,MajorId,MinorId of ibeacon by parsing the AD frame. 回答1: It's relatively easy to read the bytes of the advertisements if you know the byte offsets of all the fields. Two code snippets below show you how you can parse these out. The first shows how you can do this in your own onLeScan callback

Bluetooth 4.0 with older Bluetooth

心不动则不痛 提交于 2019-12-22 05:24:06
问题 i'm trying to implement an application using a Bluetooth 4.0 module, and I wonder if using this application with an Iphone 3GS containing a simple Bluetooth 2.1 EDR module is going to enable me take advantage of the the low energy in my 4.0 module. Thank you for your answers 回答1: Bluetooth 4.0 is the standard, which includes both classical Bluetooth Basic Rate/Enhanced Data Rate (BR/EDR) and Bluetooth Low Energy (BLE, or Bluetooth Smart, which is a marketing name). Compatibility depends on

Totally Disconnect a Bluetooth Low Energy Device

◇◆丶佛笑我妖孽 提交于 2019-12-22 05:13:41
问题 I connect to a BLE device with the connectGatt() method in Android. This works great. When I disconnect I use the following: private void disconnectDevice() { gatt.disconnect(); } When I receive the callback I do a close. private BluetoothGattCallback gattCallback = new BluetoothGattCallback() { @Override public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { switch (newState) { case BluetoothProfile.STATE_CONNECTED: Log.d("BLED-GATT", "STATE_CONNECTED");