标签: gatt

Android BLE API:未收到GATT通知

用于测试的设备:Nexus 4,Android 4.3

连接工作正常,但onCharacteristicChanged我的回调方法永远不会被调用.但是我正在使用setCharacteristicNotification(char, true)inside 注册通知onServicesDiscovered,该函数甚至返回true.

设备日志(当通知应该出现/通过蓝牙设备发送时,实际上根本没有消息):

07-28 18:15:06.936  16777-16809/de.ffuf.leica.sketch D/BluetoothGatt: setCharacteristicNotification() - uuid: 3ab10101-f831-4395-b29d-570977d5bf94 enable: true
07-28 18:15:06.936    4372-7645/com.android.bluetooth D/BtGatt.GattService: registerForNotification() - address=C9:79:25:34:19:6C enable: true
07-28 18:15:06.936    4372-7645/com.android.bluetooth D/BtGatt.btif: btif_gattc_reg_for_notification
07-28 18:15:06.946    4372-7645/com.android.bluetooth D/BtGatt.btif: btgattc_handle_event: Event 1018
07-28 18:15:06.946    4372-7645/com.android.bluetooth D/BtGatt.GattService: onRegisterForNotifications() - address=null, status=0, registered=1, charUuid=3ab10101-f831-4395-b29d-570977d5bf94
07-28 18:15:06.946    4372-7645/com.android.bluetooth D/BtGatt.btif: btgattc_handle_event: Event 1016
07-28 18:15:06.946    4372-7645/com.android.bluetooth D/BtGatt.btif: btgattc_handle_event: Event 1018
07-28 18:15:06.946    4372-7645/com.android.bluetooth D/BtGatt.GattService: onRegisterForNotifications() - address=null, status=0, …
Run Code Online (Sandbox Code Playgroud)

android bluetooth bluetooth-lowenergy gatt android-4.3-jelly-bean

68
推荐指数
5
解决办法
7万
查看次数

低功耗蓝牙:在linux中监听通知/指示

我正在尝试通过Linux机器与BLE模块通信(该模块正在运行心率配置文件).到目前为止,除了听取通知和指示(例如,听取心率测量通知)之外,我已经能够做我需要的一切.我正在使用内核版本3.5和bluez-5.3.

到目前为止使用的成功命令:

hcitool lescan
hcitool lecc
gatttool -b <Mac Address> --primary
gatttool -b <MAC Address> --characteristics
gatttool -b <MAC Address> --char-read
gatttool -b <MAC Address> --char-desc
gatttool -b <MAC Address> --interactive
Run Code Online (Sandbox Code Playgroud)

命令失败:

gatttool -b <MAC Address> --listen
Run Code Online (Sandbox Code Playgroud)

任何帮助是极大的赞赏.

linux bluetooth bluetooth-lowenergy bluez gatt

40
推荐指数
3
解决办法
5万
查看次数

Android BluetoothGatt - 状态133 - 注册回调

首先我读了解答:GATT回调无法注册并采取该帖子中建议的步骤来解决此问题但没有成功.如果你还没有阅读它,那里的推荐修复是直接从主线程或使用处理程序进行所有BLE调用.

我正在开发一个BLE应用程序,希望运行一项执行以下任务的服务(每10秒调用一次活动):

1)Gets list of our products available to connect to (done, works)

2)For each available device:

          2a)connect to device
          2b)discover services
          2c)read 5 characteristics in this fashion:
             2c1)read characteristic
             2c2)onCharacteristicRead parse data
             2c3)when finished with data read next characteristic
             2c4)repeat until all are read (this is done using a state var and switch statement)
         2d)disconnect from device
         2e)connect to next device
         2f)repeat until all devices are read from
         2g)stopSelf()
Run Code Online (Sandbox Code Playgroud)

所以这个问题......一切都很有效.我可以执行整个服务启动{startService(...); 在mainActivity中完成{stopSelf(); 在服务中} 6次.

在第7次我得到BluetoothGatt无法注册回调.我不知道为什么我能成功运行6次然后在第7次失败. …

android bluetooth-lowenergy gatt

39
推荐指数
3
解决办法
5万
查看次数

具有128位UUID的startLeScan在本机Android BLE实现上不起作用

我在Nexus 4上新推出的Android 4.3 BLE API上使用startLeScan(新UUID [] {MY_DESIRED_128_BIT_SERVICE_UUID},回调)时遇到问题.

回调就是没有被调用.我仍然可以在日志中看到传入的包:

08-02 15:48:57.985: I/bt-hci(1051): btu_ble_process_adv_pkt
08-02 15:48:58.636: I/bt-hci(1051): BLE HCI(id=62) event = 0x02)
Run Code Online (Sandbox Code Playgroud)

如果我不使用该参数来过滤UUID,它可以工作.我们使用制造商特定的128位UUID作为我们公司的设备.

现在,我们的设备提供的服务比我在阵列中提供的服务更多.但那应该不是问题.

有人面临同样的问题吗?有解决方案吗

编辑

有几个与扫描有关的问题,这个问题只讨论一个问题:如果您还有扫描问题,请先阅读此评论.还要记住,我的设备强加了16位和128位UUID.大多数人都使用BLE标准提供的16位UUID,如Heart rate或Speed and Cadence.

android bluetooth-lowenergy gatt android-4.3-jelly-bean

34
推荐指数
4
解决办法
3万
查看次数

Android蓝牙低能耗配对

如何将蓝牙低功耗(BLE)设备与Android 配对以读取加密数据.

使用Android BLE页面中的信息,我能够发现设备,连接设备,发现服务和读取未加密的特征.

当我尝试读取加密的特性(一个会导致iOS显示弹出窗口要求配对然后完成读取)时,我收到错误代码5,这对应于认证不足.

我不确定如何使设备配对或如何提供读取完成的身份验证信息.

我通过尝试添加描述符来玩弄BluetoothGattCharacteristics,但这也不起作用.
任何帮助表示赞赏!

android bluetooth bluetooth-lowenergy gatt android-4.3-jelly-bean

33
推荐指数
1
解决办法
5万
查看次数

创建一个Gatt服务器?

我在这里有一个更广泛的问题,所以如果有人能指出我可以解释这个问题的文档或文章,那就足够了.毋庸置疑,一天的谷歌搜索让我无处可去,我可以伸出援助之手.

我用BlueZ 5.9 连接到BeagleBoard,我的意图是:

  1. 创建一个Gatt服务器,
  2. 加载一些可写属性,然后
  3. 宣传该服务器以连接到Android设备.

我已经创建了将作为中心连接和操作的Android应用程序,渲染3基本完成.我不知道命令 - 键入的文字内容 - 如何在BeagleBoard上启动Gatt服务器/创建属性.我知道硬件写得很大,所以有可能我的术语完全不正确 - 也就是说,任何帮助都会在完成1和2时得到赞赏,即使它只是朝着正确的方向推进.谢谢!

bluetooth beagleboard bluetooth-lowenergy bluez gatt

21
推荐指数
2
解决办法
3万
查看次数

如何通过蓝牙低功耗(BLE)链路发送数据?

我能够发现,连接到蓝牙.

源代码 - -

通过蓝牙连接到远程设备:

//Get the device by its serial number
 bdDevice = mBluetoothAdapter.getRemoteDevice(blackBox);

 //for ble connection
 bdDevice.connectGatt(getApplicationContext(), true, mGattCallback);
Run Code Online (Sandbox Code Playgroud)

Gatt CallBack for Status:

 private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
    @Override
    public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
    //Connection established
    if (status == BluetoothGatt.GATT_SUCCESS
        && newState == BluetoothProfile.STATE_CONNECTED) {

        //Discover services
        gatt.discoverServices();

    } else if (status == BluetoothGatt.GATT_SUCCESS
        && newState == BluetoothProfile.STATE_DISCONNECTED) {

        //Handle a disconnect event

    }
    }

    @Override
    public void onServicesDiscovered(BluetoothGatt gatt, int status) …
Run Code Online (Sandbox Code Playgroud)

android bluetooth-lowenergy android-bluetooth gatt

20
推荐指数
2
解决办法
5万
查看次数

Windows UWP在发现后连接到BLE设备

我正在BluetoothLEAdvertisementWatcher寻找附近的BLE设备并且它运行良好.找到它们后,我想通过GATT连接和读/写数据.但是在获得BluetoothLEAdvertisement(https://msdn.microsoft.com/de-de/library/windows/apps/windows.devices.bluetooth.genericattributeprofile)后我无法弄清楚如何使用API .

public class Adapter
{
    private readonly BluetoothLEAdvertisementWatcher _bleWatcher = new BluetoothLEAdvertisementWatcher();

    public Adapter()
    {
        _bleWatcher.Received += BleWatcherOnReceived;
    }

    private void BleWatcherOnReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
    {       
        // how to connect?
        // I know, it's the wrong place to to this, but this is just an example
    }

    public void StartScanningForDevices(Guid[] serviceUuids)
    {
        _blewatcher.advertisementfilter.advertisement.serviceuuids.clear();
        foreach (var uuid in serviceuuids)
        {
            _blewatcher.advertisementfilter.advertisement.serviceuuids.add(uuid);
        }
        _blewatcher.start();
    }
}
Run Code Online (Sandbox Code Playgroud)

我发现使用的样品DeviceInformation.FindAllAsync代替BluetoothLEAdvertisementWatcher但是这些样品不起作用/找不到任何设备.

UPDATE

经过一段时间的挖掘,我找到了以下方法.但不幸的是,配对失败了.该设备只是一个带有BLE屏蔽的Arduino.我绝对可以与Android和iOS连接.因此必须以某种方式与UWP合作.:/

private void …
Run Code Online (Sandbox Code Playgroud)

c# bluetooth-lowenergy gatt win-universal-app windows-10-universal

19
推荐指数
2
解决办法
2万
查看次数

本机Android BLE实现本质上是同步的吗?

我记得在三星BLE API(存档页面)"指南和提示" -doc中阅读:

三星F/W和堆栈最重要的概念之一是它的同步特性.也就是说,如果我们调用例如 writeCharacteristic某个特定的特性,如果它返回 true,则在收到回调后应该对any BluetoothGattBluetoothGattServer方法进行下一次调用onCharacteristicRead.这是因为堆栈被设计为一次仅支持和处理一个GATT调用,例如,如果您在第一个调用之后很快调用 writeCharacteristicreadCharacteristic处理任何特性,则忽略它.

  1. 这也适用于Android 4.3中引入的BLE的nativ实现吗?
  2. Samsung API一次只支持一个连接的GATT设备.这在原生API中有变化吗?

android bluetooth-lowenergy gatt android-4.3-jelly-bean

15
推荐指数
1
解决办法
1万
查看次数

智能蓝牙:GATT比.ATT - 它们之间有什么区别?

任何人都可以为我定义GATT和ATT之间的区别是什么?我无法理解.
我知道它们都是处理BLE服务的通用协议.但并没有真正理解它.请解释.
谢谢!

bluetooth att bluetooth-lowenergy gatt

15
推荐指数
2
解决办法
9071
查看次数