Android蓝牙4.0API-类-BluetoothHealth

来源:互联网 发布:淘宝新店一天刷几个人? 编辑:程序博客网 时间:2024/05/16 07:28

BluetoothHealth is a proxy object for controlling the Bluetooth Service via IPC.

How to connect to a health device which is acting in the source role.

  • Use getProfileProxy(Context, BluetoothProfile.ServiceListener, int) to get the BluetoothHealth proxy object.
  • Create an BluetoothHealth callback and call registerSinkAppConfiguration(String, int, BluetoothHealthCallback) to register an application configuration
  • Pair with the remote device. This currently needs to be done manually from Bluetooth Settings
  • Connect to a health device using connectChannelToSource(BluetoothDevice, BluetoothHealthAppConfiguration). Some devices will connect the channel automatically. The BluetoothHealth callback will inform the application of channel state change.
  • Use the file descriptor描述符号 provided with a connected channel to read and write data to the health channel.
  • The received data needs to be interpreted using a health manager which implements the IEEE 11073-xxxxx specifications规格.
  • When done, close the health channel by calling disconnectChannel(BluetoothDevice, BluetoothHealthAppConfiguration, int) and unregister the application configuration callingunregisterAppConfiguration(BluetoothHealthAppConfiguration)
  • 公用方法
  • boolean connectChannelToSource(BluetoothDevice device, BluetoothHealthAppConfiguration config)链接
  • device BluetoothDevice: The remote Bluetooth device.
  • config BluetoothHealthAppConfiguration: The application configuration which has been registered using registerSinkAppConfiguration(String, int, BluetoothHealthCallback)
  • boolean disconnectChannel(BluetoothDevice device, BluetoothHealthAppConfiguration config, int channelId) 断开
  • device BluetoothDevice: The remote Bluetooth device.
  • config BluetoothHealthAppConfiguration: The application configuration which has been registered using registerSinkAppConfiguration(String, int, BluetoothHealthCallback)
  • channelId int: The channel id associated关联 with the channel

  • 获取设备列表List<BluetoothDevicegetConnectedDevices()

    int getConnectionState(BluetoothDevice device)

    List<BluetoothDevicegetDevicesMatchingConnectionStates(int[] states)

    states int: Array of states. States can be one of STATE_CONNECTEDSTATE_CONNECTINGSTATE_DISCONNECTEDSTATE_DISCONNECTING,



    ParcelFileDescriptor getMainChannelFd
    (BluetoothDevice device, BluetoothHealthAppConfiguration config)

    Get the file descriptor描述符号 of the main channel associated关联的 with the remote device and application configuration.

    boolean registerSinkAppConfiguration(String name, int dataType, BluetoothHealthCallback callback)

    boolean unregisterAppConfiguration(BluetoothHealthAppConfiguration config)


    BluetoothDevice: The remote Bluetooth device.
  • 0 0
    原创粉丝点击