Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓蓝牙获取心率测量_Android_Android Bluetooth_Android Ble - Fatal编程技术网

Android 安卓蓝牙获取心率测量

Android 安卓蓝牙获取心率测量,android,android-bluetooth,android-ble,Android,Android Bluetooth,Android Ble,我想得到“A&D UA-651BLE”设备的人力资源管理价值。 这是写入该设备数据表以获取HRM值的内容: 将应用程序设置为配对模式以开始扫描 按照每个说明手册开始A&D BLE设备的配对 在配对模式下,应用程序应设置时间和日期以及任何其他设备设置 到A&D可编程设备。配对成功后,A&D BLE设备在屏幕上显示“结束” 进行测量并完成测量,然后a&D BLE设备启动BLE 与广告有关。应用程序以适当的间隔开始扫描,以便 该应用程序会尽快捕获A&D设备的广告 在初始连接或配对时,应用程序将“2”设

我想得到“A&D UA-651BLE”设备的人力资源管理价值。 这是写入该设备数据表以获取HRM值的内容:

  • 将应用程序设置为配对模式以开始扫描
  • 按照每个说明手册开始A&D BLE设备的配对
  • 在配对模式下,应用程序应设置时间和日期以及任何其他设备设置 到A&D可编程设备。配对成功后,A&D BLE设备在屏幕上显示“结束”
  • 进行测量并完成测量,然后a&D BLE设备启动BLE 与广告有关。应用程序以适当的间隔开始扫描,以便 该应用程序会尽快捕获A&D设备的广告
  • 在初始连接或配对时,应用程序将“2”设置为CCCD(客户端特征 配置描述符),以便A&D BLE设备使用 指示
  • A&D设备识别后,将CCCD设置为“2”,并同步时间和日期 在连接后5秒内,发送带有指示的数据
  • 如果超时设置为CCCD且时间和日期已过期,A&D BLE设备将不发送数据 并将数据存储在内存中。A&D BLE设备中存储的数据可以在下一步发送 成功连接
  • 这是我的服务代码:

    public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
                                                  boolean enabled) {
            if (mBluetoothAdapter == null || mBluetoothGatt == null) {
                Log.w(TAG, "BluetoothAdapter not initialized");
                return;
            }
    
            mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
    
            // This is specific to Heart Rate Measurement.
            if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
                BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
                        UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
                descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
                mBluetoothGatt.writeDescriptor(descriptor);
            }
        }
    
    这是读取数据的方法:

    final byte[] data = characteristic.getValue();
                if (data != null && data.length > 0) {
                    final StringBuilder stringBuilder = new StringBuilder(data.length);
                    for(byte byteChar : data)
                        stringBuilder.append(String.format("%02X ", byteChar));
                    Log.e("HRM value",stringBuilder.toString());
                    dataComposition.put(characteristic.getUuid().toString(),stringBuilder.toString());
                    intent.putExtra(EXTRA_DATA,dataComposition);
                }
    

    问题是这段代码不返回任何数据

    有一种方法可以做到这一点,最简单的方法是克隆、构建并将其与您自己的进行比较。如果您无法发现差异/问题,只需部署两个应用程序并逐步完成两组代码。拥有一些已知的工作代码也有助于排除人力资源管理功能不正常的可能性

    你有没有这样的例子,我用同样的设备试了一下,但我无法获得信息

    public String response() {
    if (mConnected) {
        mBluetoothLeService.readCharacteristic(characteristica);
        byte response[] = characteristica.getValue();
        String respuesta = ReadBytes(response);
        mBluetoothLeService.disconnect();
        return respuesta;
    } else {
        return null;
    }
    }
    

    感谢这个链接,我看到了这个项目,问题是我正在使用的设备需要写操作,而这个项目没有显示我们可以写值和描述符