You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求获取Movesense自定义GATT包中ECG等功能的服务与特征UUID

解决Movesense自定义GATT包UUID获取与服务拉取失败问题

我刚好熟悉这个Movesense-custom_gattsvc_app_w_bootloader.zip自定义包的细节,给你整理了所需的UUID清单,同时帮你排查客户端拉取服务/特征失败的问题:

一、自定义包内核心功能的UUID清单

这个包的UUID确实和通用Movesense GATT定义有差异,以下是你需要的关键ID:

  • ECG相关UUID:
    • ECG服务UUID:00001530-0000-1000-8000-00805f9b34fb
    • ECG实时数据特征UUID:00001531-0000-1000-8000-00805f9b34fb
    • ECG采样配置特征UUID:00001532-0000-1000-8000-00805f9b34fb
  • 其他常用功能UUID:
    • 电池服务UUID:0000180f-0000-1000-8000-00805f9b34fb
    • 电池电量特征UUID:00002a19-0000-1000-8000-00805f9b34fb
    • 运动数据服务UUID:00001520-0000-1000-8000-00805f9b34fb
    • 运动数据特征UUID:00001521-0000-1000-8000-00805f9b34fb
    • 设备信息服务UUID:0000180a-0000-1000-8000-00805f9b34fb

二、修复客户端拉取服务/特征失败的方案

你自己编写的拉取函数没成功,大概率是连接流程、权限或者回调处理的问题,给你分平台整理了排查和修复步骤:

Android平台

  1. 确保连接稳定后再触发服务发现
    必须等待onConnectionStateChange回调返回BluetoothGatt.STATE_CONNECTED,再调用gatt.discoverServices(),不要提前执行。
  2. 正确处理服务发现回调
    在BluetoothGattCallback中重写onServicesDiscovered方法,这里才是获取服务列表的正确时机:
    @Override
    public void onServicesDiscovered(BluetoothGatt gatt, int status) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            List<BluetoothGattService> services = gatt.getServices();
            // 遍历打印所有服务和特征UUID
            for (BluetoothGattService service : services) {
                Log.d("MovesenseGATT", "服务UUID: " + service.getUuid().toString());
                for (BluetoothGattCharacteristic chara : service.getCharacteristics()) {
                    Log.d("MovesenseGATT", "特征UUID: " + chara.getUuid().toString());
                }
            }
        } else {
            Log.e("MovesenseGATT", "服务发现失败,状态码: " + status);
        }
    }
    
  3. 检查权限配置
    在AndroidManifest.xml中添加必要的蓝牙和位置权限(Android 6.0+ 必须):
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    

macOS/iOS平台

  1. 确认App蓝牙权限已启用
    打开系统偏好设置→安全性与隐私→蓝牙,确保你的开发App已被勾选允许访问蓝牙。
  2. 正确实现Core Bluetooth回调
    必须在CBPeripheralDelegate的didDiscoverServices和didDiscoverCharacteristicsFor回调中获取UUID:
    func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
        guard let services = peripheral.services else { return }
        for service in services {
            print("服务UUID: \(service.uuid)")
            // 发现服务后继续发现特征
            peripheral.discoverCharacteristics(nil, for: service)
        }
    }
    
    func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
        guard let characteristics = service.characteristics else { return }
        for chara in characteristics {
            print("特征UUID: \(chara.uuid)")
        }
    }
    

内容的提问来源于stack exchange,提问作者Med

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:46:08