Android蓝牙连接错误代码含义查询

这个部分的网络资料太少,在此记录一下,给有需要的人。#define GATT_SUCCESS 0x00#define GATT_INVALID_HANDLE 0x01#define GATT_READ_NOT_PERMIT 0x02#define GATT_WRITE_NOT_PERMIT 0x03#define GATT_INVALID_PDU 0x04#define GATT_INSUF_AUTHENTICATION 0x05#define GATT_REQ_NOT_SUPPORTED 0
摘要由CSDN通过智能技术生成

这个部分的网络资料太少,在此记录一下,给有需要的人。

#define GATT_SUCCESS 0x00
#define GATT_INVALID_HANDLE 0x01
#define GATT_READ_NOT_PERMIT 0x02
#define GATT_WRITE_NOT_PERMIT 0x03
#define GATT_INVALID_PDU 0x04
#define GATT_INSUF_AUTHENTICATION 0x05
#define GATT_REQ_NOT_SUPPORTED 0x06
#define GATT_INVALID_OFFSET 0x07
#define GATT_INSUF_AUTHORIZATION 0x08
#define GATT_PREPARE_Q_FULL 0x09
#define GATT_NOT_FOUND 0x0a
#define GATT_NOT_LONG 0x0b
#define GATT_INSUF_KEY_SIZE 0x0c
#define GATT_INVALID_ATTR_LEN 0x0d
#define GATT_ERR_UNLIKELY 0x0e
#define GATT_INSUF_ENCRYPTION 0x0f
#define GATT_UNSUPPORT_GRP_TYPE 0x10
#define GATT_INSUF_RESOURCE 0x11

#define GATT_ILLEGAL_PARAMETER 0x87
#define GATT_NO_RESOURCES 0x80
#define GATT_INTERNAL_ERROR 0x81
#define GATT_WRONG_STATE 0x82
#define GATT_DB_FULL 0x83
#define GATT_BUSY 0x84
#define GATT_ERROR 0x85

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
连接蓝牙设备并接收广播,您需要完成以下步骤: 1.获取BluetoothAdapter对象并确保蓝牙已启用。 2.使用BluetoothDevice对象连接到目标设备。 3.创建BluetoothSocket对象并使用BluetoothDevice对象打开连接。 4.注册BroadcastReceiver以接收蓝牙连接状态更改广播。 5.在BroadcastReceiver中处理广播,以便在设备连接或断开连接时采取适当的措施。 以下是一个简单的示例代码,用于连接蓝牙设备并接收广播: ``` // 获取BluetoothAdapter对象 BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // 确保蓝牙已启用 if (bluetoothAdapter.isEnabled()) { // 获取BluetoothDevice对象 BluetoothDevice device = bluetoothAdapter.getRemoteDevice(address); // 连接到目标设备 BluetoothSocket socket = device.createRfcommSocketToServiceRecord(uuid); socket.connect(); // 注册BroadcastReceiver以接收蓝牙连接状态更改广播 BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { // 设备已连接 } else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { // 设备已断开连接 } } }; IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); registerReceiver(receiver, filter); } ``` 请注意,上述示例仅用于说明目的,实际操作中可能需要进行更多错误处理和安全检查。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值