标签: characteristics

Android BLE,无法真正写出特性

我正在开发一个 Android 项目,该项目通过 BLE 链接连接 Nexus 7 和生物传感器。问题是,我可以成功检测并获取传感器的服务和特征列表。当我写一些数据到特定的特性时,onCharacteristicWrite会自动调用并显示我写操作成功。但是,传感器永远不会从平板电脑接收任何信息。如果我在 iPhone 上使用类似的应用程序,一切正常。所以设备没有问题。有没有人知道这个问题?

这是我的写代码:

 private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
    @Override
    public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
        if (newState == BluetoothProfile.STATE_CONNECTED) {
            mConnected = true;
            Log.i(TAG, "Connected to GATT server.");
            // Attempts to discover services after successful connection.
            Log.i(TAG, "Attempting to start service discovery:" +
                    mBluetoothGatt.discoverServices());

        } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
            mConnected = false;
            Log.i(TAG, "Disconnected from GATT server.");
        }
    }

    @Override
    public void …
Run Code Online (Sandbox Code Playgroud)

android characteristics bluetooth-lowenergy

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

Android蓝牙在更改UUID后未发现该特性

我正在使用Android 5.0.1 Lollipop并开发蓝牙低功耗服务器 - 客户端通信.我有三星Galaxy s4.我的自定义服务中有三个特征.我将特性的属性之一作为只写和加密写入.然后我将其更改为非加密写入.写操作不再适用于此特性.我知道我必须从设置重新启动蓝牙适配器并取消配对设备,但它根本不起作用.然后我改变了特征的UUID.它发现了旧UUID的特性.我不懂.如何从蓝牙适配器中删除与某个特定设备相关的所有蓝牙数据?

编辑:我用iPhone和iPhone设备加倍检查.iPhone发现新UUID的特性,而Android发现旧UUID.

android characteristics bluetooth-lowenergy gatt

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

使用 Android BLE 读取特征值

我对 BLE、android 开发和 java 比较陌生。我正在尝试通过 BLE 从微控制器向我的 android 手机发送 20 条数据。使用 nRF 连接应用程序,我知道服务和值是从微控制器正确创建的。

为了在 android 应用程序上阅读它们,我使用了 Android Studio 中提供的模板 BluetoothLeGatt 应用程序。它向我显示了服务和特征(出于某种原因,它显示的服务比我实际创建的服务多),但是只有一个服务向我显示了一个最终不为 NULL 的值。我已经在我的微控制器中对值 0x22 进行了编码,Android 日志说给了我以下内容

03-24 17:13:29.498 23696-23696/com.example.android.bluetoothlegatt D/BLE_VALUE_READ: [B@b95cc24

而不是 0x22。这是使用该功能

Log.d("BLE_VALUE_READ", String.valueOf(characteristic.getValue()));

我已将命令放置在模板应用程序的此函数中。

public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
    if (mBluetoothAdapter == null || mBluetoothGatt == null) {
        Log.w(TAG, "BluetoothAdapter not initialized");
        return;
    }
    mBluetoothGatt.readCharacteristic(characteristic);
    Log.d("CharacteristicRead", String.valueOf(characteristic)); // try to get characteristic uuid?
    Log.d("BLE_VALUE_READ", String.valueOf(characteristic.getValue())); // Try to read value
}
Run Code Online (Sandbox Code Playgroud)

如何获得服务/特性中的实际值,即 0x22?我想总共读取 20 个值,然后将它们作为浮点值存储在数组中,以便最终将它们用于图像重建。

任何帮助将不胜感激。

谢谢!

android bluetooth characteristics bluetooth-lowenergy

4
推荐指数
1
解决办法
9136
查看次数

在 Android BLE 中自定义 UUID 有问题

我在使用自己生成的 UUID(不使用蓝牙 SIG 保留的 16 位 UUID)在 Android BLE 中进行通信时遇到问题。

目标设备有两个 - 一个作为外围设备(三星 Galaxy Note 4/android 5.1.1),另一个作为中央设备(三星 Galaxy S5/android 5.0.1)。我将自己的服务的 UUID 和特性的 UUID 放在外围设备端。在中心一侧,它找不到特色,但找到服务。

这似乎是由于不使用这些特征 UUID 之一而是使用自定义生成的 UUID 引起的。下面是我自己生成的 UUID。

private static final UUID CUSTOM_SERVICE_UUID = UUID.fromString("abcd1111-0000-1000-8000-00805f9b34fb");
private static final UUID CUSTOM_CHARACTERISTIC_UUID = UUID.fromString("abcd1112-0000-1000-8000-00805f9b34fb");
Run Code Online (Sandbox Code Playgroud)

服务,发现很好,但有特色,没有。你有什么主意吗?

android bluetooth characteristics bluetooth-lowenergy gatt

3
推荐指数
1
解决办法
5302
查看次数

蓝牙LE收听多个特征通知

我在Android手机上使用BLE应用程序与自定义BLE传感器板通信.电路板提供两个特性,加速和心电图.在电话方面,我想从传感器板接收两个特征的通知.我设置通知的代码:

mGatt.setCharacteristicNotification(ecgChar, true);
            BluetoothGattDescriptor descriptor = ecgChar.getDescriptor(
                    UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            mGatt.writeDescriptor(descriptor);
            mGatt.setCharacteristicNotification(accelChar, true);
            descriptor = ecgChar.getDescriptor(
                    UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            mGatt.writeDescriptor(descriptor);
Run Code Online (Sandbox Code Playgroud)

但是,我只能收到第一个特征的通知.当我只注册一个特征的通知时,它运作良好.ECG和加速度的采样频率均为100Hz.那么如何从这两个特征中接收通知?谢谢.

notifications android bluetooth characteristics

2
推荐指数
1
解决办法
3509
查看次数

每个软件框架的特征和特征

我今天试图使用谷歌和StackOverflow搜索引擎找到我的问题的答案...但没有运气:)

我想知道最终用户的每个框架的主要特征是什么,以及如何从最终用户的角度来描述每个框架(我已经查看了K. Cwalina的框架设计指南,但我发现只有框架架构师的概念和指南),对我来说:

  • 它应该是可扩展的
  • 应该让构建可扩展和可重用的组件
  • 当然:简单的事情应该是简单的,复杂的事情应该是可能的.(http://en.wikiquote.org/wiki/Alan_Kay)

我认为还有更多.

请分享您的知识.

frameworks characteristics

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

BLE 从特征接收 GATT 通知

我希望在该特性发生更改时收到通知Micro:Bit

\n\n

我正在做的事情基本上如下:

\n\n

1)检查系统是否兼容BLE

\n\n

2) 启用蓝牙以防其被禁用

\n\n

3) 连接到唯一一个配对设备 (Micro:Bit)

\n\n

4) 当连接发生变化时激活此代码(\xc2\xbfConnected/Disconnected?)

\n\n

5) 当特性更新时激活此代码\xc2\xbf?

\n\n
public class MainActivity extends Activity {\n\nBluetoothAdapter bleAdapter;\n\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_main);\n\n    **(1)**\n\n    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {\n        Toast.makeText(this, "BLE Not Supported", Toast.LENGTH_SHORT).show();\n        finish();\n    }\n\n    **(2)**\n\n    bleAdapter = ((BluetoothManager) getSystemService(BLUETOOTH_SERVICE)).getAdapter();\n\n    if (bleAdapter == null || !bleAdapter.isEnabled()) {\n        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);\n        startActivityForResult(enableBtIntent, 1);\n    }\n\n    Set<BluetoothDevice> pairedDevices = bleAdapter.getBondedDevices();\n\n    for (BluetoothDevice device : pairedDevices) {\n\n        **(3)**\n\n        device.connectGatt(this, true, new BluetoothGattCallback() …
Run Code Online (Sandbox Code Playgroud)

uuid android characteristics bluetooth-lowenergy gatt

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