在进行android蓝牙开发之前必选要对其相关的基础知识有详细的了解,这里主要介绍一些基础知识点和开发流程.
一、整体基础知识框架介绍:
android 提供管理蓝牙功能的类,例如扫描设备、连接设备和管理设备之间的数据传输。
蓝牙接口支持两个“经典的蓝牙”和蓝牙低能量。
蓝牙应用程序的应用程序:
- 扫描其他蓝牙设备(包括BLE设备)。
- 查询本地蓝牙适配器,用于配对蓝牙设备。
- 建立RFCOMM串口/插座。
- 在其他设备上连接指定的插座。
- 向其他设备传送数据。
- 与BLE设备通信,如接近传感器、心率监视器,健身设备,等等。
- 作为关贸总协定GATT客户端或服务器(BLE)。
重要的是要使用这些接口来进行蓝牙通信,应用程序必须声明蓝牙权限。一些额外的功能,如请求设备发现,还需要bluetooth_admin许可。
注:并非所有的安卓系统设备提供蓝牙功能。
二、android为蓝牙提供三个接口Interfaces、
- BluetoothAdapter.LeScanCallback :用于提供扫描结果的回调接口
- BluetoothProfile : 蓝牙配置文件的公共接口。
- BluetoothProfile.ServiceListener:一个接口通知bluetoothprofile IPC客户当他们已连接或断开服务
三、11个功能类:Classes
- bluetootha2dp这类提供公共的API来控制蓝牙A2DP。
- BluetoothAdapter表示本地设备蓝牙适配器。
- bluetoothassignednumbers蓝牙分配号码。
- BluetoothClass表示蓝牙类,它描述了设备的一般特性和功能。
- BluetoothClass.Device 定义所有的设备类的常量。
- bluetoothclass.device.major定义所有主要设备类常数。
- BluetoothClass.Service定义所有的服务类的常量。
- BluetoothDevice表示远程蓝牙设备。
- bluetoothgatt公共API蓝牙GATT简介。
- bluetoothgattcallback这个抽象类来实现bluetoothgatt回调。
- bluetoothgattcharacteristic表示蓝牙关贸总协定的特点
- BluetoothGattDescriptor关贸总协定的描述符表示蓝牙描述符包含了额外的信息和属性的关贸总协定(GATT bluetoothgattcharacteristic的特性。
- bluetoothgattserver 公共API蓝牙GATT配置服务器角色。
- bluetoothgattservercallback这个抽象类来实现bluetoothgattserver回调。
- bluetoothgattservice表示一个蓝牙GATT服务关贸总协定的服务包含一组bluetoothgattcharacteristic,以及参考服务。
- bluetoothheadset公共API控制蓝牙耳机服务。
- bluetoothhealth公共API蓝牙健康档案。
- bluetoothhealthappconfiguration蓝牙健康应用程序配置,采用的是与bluetoothhealth类连词。
- bluetoothhealthcallback这个抽象类来实现bluetoothhealth回调。
- bluetoothmanager高级经理用来获得一个蓝牙适配器的实例并进行全面的蓝牙管理。
- bluetoothserversocket收听蓝牙插座。
- BluetoothSocket连接或连接蓝牙插座。
android蓝牙开发
最新推荐文章于 2024-03-07 16:15:54 发布