Android蓝牙4.0API-类-BluetoothGatt

Public API for the Bluetooth GATT Profile. 

适用于GATT协议,实现控制等

This class provides Bluetooth GATT functionality to enable communication with Bluetooth Smart or Smart Ready devices.

To connect to a remote peripheral device, create a BluetoothGattCallback and call connectGatt(Context, boolean, BluetoothGattCallback) to get a instance of this class.通过上述两个方法得到这个类的一个实例。 GATT capable能干的 devices can be discovered using the Bluetooth device discovery or BLE scan process.

常量

int CONNECTION_PRIORITY_BALANCED

Connection paramter参数 update - Use the connection paramters recommended推荐,介绍 by the Bluetooth SIG.

int CONNECTION_PRIORITY_HIGH

Connection paramter update - Request a high priority优先级, low latency延迟 connection.

int CONNECTION_PRIORITY_LOW_POWER

Connection paramter update - Request low power, reduced data rate connection parameters.

int GATT_CONNECTION_CONGESTED

远程设备被阻塞

int GATT_FAILURE

A GATT operation failed, errors other than the above

int GATT_INSUFFICIENT_AUTHENTICATION

Insufficient 不足authentication 认证for a given operation

int GATT_INSUFFICIENT_ENCRYPTION

Insufficient encryption加密 for a given operation

int GATT_INVALID_ATTRIBUTE_LENGTH

A write operation exceeds the maximum length of the attribute长度超出限制

int GATT_INVALID_OFFSET

A read or write operation was requested with an invalid无效的 offset补偿抵消

int GATT_READ_NOT_PERMITTED

权限不足

int GATT_REQUEST_NOT_SUPPORTED

The given request is not supported

int GATT_SUCCESS

A GATT operation completed successfully

int GATT_WRITE_NOT_PERMITTED

公有方法

void abortReliableWrite()

Cancels a reliable可靠的 write transaction事务 for a given device.

void abortReliableWrite(BluetoothDevice mDevice)

This method was deprecated in API level 19. Use abortReliableWrite()

boolean beginReliableWrite()

Initiates 启用a reliable write transaction for a given remote device.

void close()

关闭GATT客户端

boolean connect();

Connect back to remote device

void disconnect()

Disconnects an established 已建立的connection, or cancels a connection attempt currently in progress.

boolean discoverServices()

Discovers services offered by a remote device as well as their characteristics and descriptors.特征和描述

boolean executeReliableWrite()

Executes a reliable write transaction for a given remote device.执行写的命令

List<BluetoothDevicegetConnectedDevices()

Not supported - please use getConnectedDevices(int) with GATT as argument

int  getConnectionState( BluetoothDevice device)

Not supported - please use getConnectedDevices(int) with GATT as argument论证

BluetoothDevice  getDevice ()

return the remote bluetooth device this GATT client targets to

List < BluetoothDevice getDevicesMatchingConnectionStates(int[] states)

Not supported - please use getDevicesMatchingConnectionStates(int, int[]) with GATT as first argument
BluetoothGattService getService(UUID uuid)

Returns a BluetoothGattService, if the requested UUID is supported by the remote device.

List<BluetoothGattServicegetServices()

Returns a list of GATT services offered by the remote device.

boolean readCharacteristic(BluetoothGattCharacteristic characteristic)

Reads the requested characteristic from the associated关联的 remote device.

boolean readDescriptor(BluetoothGattDescriptor descriptor)

Reads the value for a given descriptor from the associated remote device.

boolean readRemoteRssi()

Read the RSSI for a connected remote device.

boolean requestConnectionPriority(int connectionPriority)

Request a connection parameter update

boolean requestMtu(int mtu)

Request an MTU size used for a given connection.

boolean setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enable)

Enable or disable notifications/indications for a given characteristic.

boolean writeCharacteristic(BluetoothGattCharacteristic characteristic)

Writes a given characteristic and its values to the associated remote device.

boolean writeDescriptor(BluetoothGattDescriptor descriptor)

Write the value of a given descriptor to the associated remote device.

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值