您的位置:首页 > 产品设计 > UI/UE

Android蓝牙4.0API-类-BluetoothHealth

2016-04-28 16:46 465 查看
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 calling
unregisterAppConfiguration(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_CONNECTED
STATE_CONNECTING
STATE_DISCONNECTED
STATE_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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: