Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端

低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端

作者头像
张云飞Vir
发布于 2020-03-16 08:09:02
发布于 2020-03-16 08:09:02
1.9K00
代码可运行
举报
文章被收录于专栏:写代码和思考写代码和思考
运行总次数:0
代码可运行

低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端

Android对外模模式(peripheral)的支持

从Android5.0开始才支持

关键术语和概念

以下是关键BLE术语和概念的摘要:

  • 通用属性简档(GATT) - GATT简档是用于通过BLE链路发送和接收称为“属性”的短数据块的一般规范。 所有当前的低能量应用配置文件都基于GATT。 蓝牙SIG为低能量设备定义了许多配置文件 。 配置文件是设备在特定应用程序中的工作方式的规范。 请注意,设备可以实现多个配置文件。 例如,设备可以包含心率监视器和电池水平检测器。
  • 属性协议(ATT) -GATT建立在属性协议(ATT)之上。 这也称为GATT / ATT。 ATT经过优化,可在BLE设备上运行。 为此,它使用尽可能少的字节。 每个属性由通用唯一标识符(UUID)唯一标识,UUID是用于唯一标识信息的字符串ID的标准化128位格式。 由ATT传送的属性被格式化为特征和服务 。
  • 特性 -A特性包含描述特性值的单个值和0-n个描述符。 一个特性可以被认为是一个类型,类似于类。
  • 描述符 - 描述符是描述特征值的定义属性。 例如,描述符可以指定人类可读的描述,特征值的可接受范围或特征值的特定的测量单位。
  • 服务 - 服务是一个集合的特点。 例如,您可以有一个名为“心率监视器”的服务,其中包括诸如“心率测量”的特征。 您可以在bluetooth.org上找到现有基于GATT的个人资料和服务的列表 。

角色和职责

以下是Android设备与BLE设备互动时适用的角色和职责:

中央与外围。 这适用于BLE连接本身。 处于中心角色的设备扫描,寻找广告,并且外围角色中的设备进行广告。

GATT服务器与GATT客户端。 这决定了两个设备在建立连接后如何相互通信。

BLE权限

首先,需要在manifest中声明使用蓝牙和操作蓝牙的权限

在应用程序清单文件中声明蓝牙权限。 例如: <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

如果您要声明自己的应用只适用于支持BLE的设备,请在应用清单中包含以下内容:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<uses-feature android:name =“android.hardware.bluetooth_le”android:required =true/>

不过,如果您想让应用程式适用于不支援BLE的装置,您仍应在应用的清单中加入这个元素,但required="false"设为required="false" 。 然后在运行时,您可以通过使用PackageManager.hasSystemFeature()确定BLE可用性:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 // Use this check to determine whether BLE is supported on the device.  Then
 // you can selectively disable BLE-related features.
 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
     Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
     finish();
 }

在android 6.0 以后,要想获得蓝牙扫描结果,还需要下面的权限

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 <manifest ... >
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
     ...
     <!-- Needed only if your app targets Android 5.0 (API level 21) or higher.  -->
     <uses-feature android:name="android.hardware.location.gps" />
     ...
 </manifest>

设置蓝牙

1.Get the BluetoothAdapter

获得蓝牙适配器

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 private BluetoothAdapter mBluetoothAdapter;
 ...
 // Initializes Bluetooth adapter.
 final BluetoothManager bluetoothManager =
         (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
 mBluetoothAdapter = bluetoothManager.getAdapter();

2.Enable Bluetooth

打开蓝牙

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 // Ensures Bluetooth is available on the device and it is enabled.  If not,
 // displays a dialog requesting user permission to enable Bluetooth.
 if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
     Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
     startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
 }

3.初始化BLE蓝牙广播(广告)

(1)广播的设置 (2)设置广播的数据 (3)设置响应的数据 (4)设置连接回调

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
    private void initGATTServer() {
        AdvertiseSettings settings = new AdvertiseSettings.Builder()
                .setConnectable(true)
                .build();

        AdvertiseData advertiseData = new AdvertiseData.Builder()
                .setIncludeDeviceName(true)
                .setIncludeTxPowerLevel(true)
                .build();

        AdvertiseData scanResponseData = new AdvertiseData.Builder()
                .addServiceUuid(new ParcelUuid(UUID_SERVER))
                .setIncludeTxPowerLevel(true)
                .build();


        AdvertiseCallback callback = new AdvertiseCallback() {

            @Override
            public void onStartSuccess(AdvertiseSettings settingsInEffect) {
                Log.d(TAG, "BLE advertisement added successfully");
                showText("1. initGATTServer success");
                println("1. initGATTServer success");
                initServices(getContext());
            }

            @Override
            public void onStartFailure(int errorCode) {
                Log.e(TAG, "Failed to add BLE advertisement, reason: " + errorCode);
                showText("1. initGATTServer failure");
            }
        };

        BluetoothLeAdvertiser bluetoothLeAdvertiser = mBluetoothAdapter.getBluetoothLeAdvertiser();
        bluetoothLeAdvertiser.startAdvertising(settings, advertiseData, scanResponseData, callback);
    }

在被BLE设备连接后,将触发 AdvertiseCallback 的 onStartSuccess,我们在这之后,初始化GATT的服务

4.初始化GATT的服务

(1) 通过 mBluetoothManager.openGattServer() 获得 bluetoothGattServer (2) 添加 服务,特征,描述。这些内容要让客户端知道。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
    private void initServices(Context context) {
        bluetoothGattServer = mBluetoothManager.openGattServer(context, bluetoothGattServerCallback);
        BluetoothGattService service = new BluetoothGattService(UUID_SERVER, BluetoothGattService.SERVICE_TYPE_PRIMARY);

        //add a read characteristic.
        characteristicRead = new BluetoothGattCharacteristic(UUID_CHARREAD, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ);
        //add a descriptor
        BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(UUID_DESCRIPTOR, BluetoothGattCharacteristic.PERMISSION_WRITE);
        characteristicRead.addDescriptor(descriptor);
        service.addCharacteristic(characteristicRead);

        //add a write characteristic.
        BluetoothGattCharacteristic characteristicWrite = new BluetoothGattCharacteristic(UUID_CHARWRITE,
                BluetoothGattCharacteristic.PROPERTY_WRITE |
                        BluetoothGattCharacteristic.PROPERTY_READ |
                        BluetoothGattCharacteristic.PROPERTY_NOTIFY,
                BluetoothGattCharacteristic.PERMISSION_WRITE);
        service.addCharacteristic(characteristicWrite);

        bluetoothGattServer.addService(service);
        Log.e(TAG, "2. initServices ok");
        showText("2. initServices ok");
    }

在 openGattServer 方法中,我们需要传入个回调 bluetoothGattServer = mBluetoothManager.openGattServer(context, bluetoothGattServerCallback);

5.配置数据交互回调

回调时间有:连接状态变化,收发消息,通知消息

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
/**
     * 服务事件的回调
     */
    private BluetoothGattServerCallback bluetoothGattServerCallback = new BluetoothGattServerCallback() {

        /**
         * 1.连接状态发生变化时
         * @param device
         * @param status
         * @param newState
         */
        @Override
        public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
            Log.e(TAG, String.format("1.onConnectionStateChange:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("1.onConnectionStateChange:status = %s, newState =%s ", status, newState));
            super.onConnectionStateChange(device, status, newState);
        }

        @Override
        public void onServiceAdded(int status, BluetoothGattService service) {
            super.onServiceAdded(status, service);
            Log.e(TAG, String.format("onServiceAdded:status = %s", status));
        }

        @Override
        public void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic) {
            Log.e(TAG, String.format("onCharacteristicReadRequest:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("onCharacteristicReadRequest:requestId = %s, offset = %s", requestId, offset));

            bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, characteristic.getValue());
//            super.onCharacteristicReadRequest(device, requestId, offset, characteristic);
        }

        /**
         * 3. onCharacteristicWriteRequest,接收具体的字节
         * @param device
         * @param requestId
         * @param characteristic
         * @param preparedWrite
         * @param responseNeeded
         * @param offset
         * @param requestBytes
         */
        @Override
        public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] requestBytes) {
            Log.e(TAG, String.format("3.onCharacteristicWriteRequest:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("3.onCharacteristicWriteRequest:requestId = %s, preparedWrite=%s, responseNeeded=%s, offset=%s, value=%s", requestId, preparedWrite, responseNeeded, offset, OutputStringUtil.toHexString(requestBytes)));
            bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, requestBytes);
            //4.处理响应内容
            onResponseToClient(requestBytes, device, requestId, characteristic);
        }

        /**
         * 2.描述被写入时,在这里执行 bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS...  收,触发 onCharacteristicWriteRequest
         * @param device
         * @param requestId
         * @param descriptor
         * @param preparedWrite
         * @param responseNeeded
         * @param offset
         * @param value
         */
        @Override
        public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
            Log.e(TAG, String.format("2.onDescriptorWriteRequest:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("2.onDescriptorWriteRequest:requestId = %s, preparedWrite = %s, responseNeeded = %s, offset = %s, value = %s,", requestId, preparedWrite, responseNeeded, offset, OutputStringUtil.toHexString(value)));

            // now tell the connected device that this was all successfull
            bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
        }

        /**
         * 5.特征被读取。当回复响应成功后,客户端会读取然后触发本方法
         * @param device
         * @param requestId
         * @param offset
         * @param descriptor
         */
        @Override
        public void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor) {
            Log.e(TAG, String.format("onDescriptorReadRequest:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("onDescriptorReadRequest:requestId = %s", requestId));
//            super.onDescriptorReadRequest(device, requestId, offset, descriptor);
            bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
        }

        @Override
        public void onNotificationSent(BluetoothDevice device, int status) {
            super.onNotificationSent(device, status);
            Log.e(TAG, String.format("5.onNotificationSent:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("5.onNotificationSent:status = %s", status));
        }

        @Override
        public void onMtuChanged(BluetoothDevice device, int mtu) {
            super.onMtuChanged(device, mtu);
            Log.e(TAG, String.format("onMtuChanged:mtu = %s", mtu));
        }

        @Override
        public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
            super.onExecuteWrite(device, requestId, execute);
            Log.e(TAG, String.format("onExecuteWrite:requestId = %s", requestId));
        }
    };

6.处理来自客户端发来的数据和发送回复数据:

调用 bluetoothGattServer.notifyCharacteristicChanged 方法,通知数据改变。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
        /**
         * 4.处理响应内容
         *
         * @param reqeustBytes
         * @param device
         * @param requestId
         * @param characteristic
         */
        private void onResponseToClient(byte[] reqeustBytes, BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic) {
            Log.e(TAG, String.format("4.onResponseToClient:device name = %s, address = %s", device.getName(), device.getAddress()));
            Log.e(TAG, String.format("4.onResponseToClient:requestId = %s", requestId));
            String msg = OutputStringUtil.transferForPrint(reqeustBytes);
            println("4.收到:" + msg);
            showText("4.收到:" + msg);

            String str = new String(reqeustBytes) + " hello>";
            characteristicRead.setValue(str.getBytes());
            bluetoothGattServer.notifyCharacteristicChanged(device, characteristicRead, false);

            println("4.响应:" + str);
            showText("4.响应:" + str);
        }

交互流程:

(1) 当客户端开始写入数据时: 触发回调方法 onDescriptorWriteRequest (2) 在 onDescriptorWriteRequest 方法中,执行下面的方法表示 写入成功 BluetoothGatt.GATT_SUCCESS

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
       bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);

执行 sendResponse后,会触发回调方法 onCharacteristicWriteRequest

(3) 在 onCharacteristicWriteRequest方法中

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
        public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] requestBytes) {

这个里可以获得 来自客户端发来的数据 requestBytes

(4) 处理响应内容,我写了这个方法:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
    onResponseToClient(requestBytes, device, requestId, characteristic);
在这个方法中,通过 bluetoothGattServer.notifyCharacteristicChanged()方法 回复数据

通过日志,我们看看事件触发的顺序

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
1.onConnectionStateChange:device name = null, address = 74:32:DE:49:3C:28
1.onConnectionStateChange:status = 0, newState =2
2.onDescriptorWriteRequest:device name = null, address = 74:32:DE:49:3C:28
2.onDescriptorWriteRequest:requestId = 1, preparedWrite = false, responseNeeded = true, offset = 0, value = [01,00,],
3.onCharacteristicWriteRequest:device name = null, address = 74:32:DE:49:3C:28
3.onCharacteristicWriteRequest:requestId = 2, preparedWrite=false, responseNeeded=false, offset=0, value=[41,54,45,30,0D,]
4.onResponseToClient:device name = null, address = 74:32:DE:49:3C:28
4.onResponseToClient:requestId = 2
4.收到:ATE0
4.响应:ATE0 hello>
5.onNotificationSent:device name = null, address = 74:32:DE:49:3C:28
5.onNotificationSent:status = 0

代码托管到github:

https://github.com/vir56k/bluetoothDemo 找到 bleperipheraldemo 文件夹

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)
在学习BLE的过程中,积累了一些心得的DEMO,放到Github,形成本文。感兴趣的同学可以下载到源代码。 github: https://github.com/vir56k/bluetoothDemo
张云飞Vir
2020/03/16
3.6K0
一步一步实现Android低功耗蓝牙(BLE)基本开发
项目需要接入两个低功耗蓝牙设备(BLE),并且与之交互(读/写)数据,所以看了下官方对于这块儿的介绍,总结了一下BLE开发中一些需要注意的地方以及基本流程。
coderZhen
2018/10/08
2.2K0
一步一步实现Android低功耗蓝牙(BLE)基本开发
《Android BLE 开发》--初学者
本作者是一位安卓初学者,之前学过JAVA,安卓只学过三天。《BLE Tool》也是我一个安卓项目,因为作者学习安卓加开发只用了10天时间,目前只是把所有接口打通了,只提供如何怎么实现。有不对的地方,大家多指点。开发之前,最好了解一下BLE的通信原理。最终实现的界面:
Rice加饭
2022/05/09
9390
《Android BLE 开发》--初学者
android蓝牙4.0的知识要点
这次主要讲解蓝牙4.0的基本要点,作为自己的备忘录记录下来吧。首先普及一下蓝牙4.0基于Gatt协议来实现。而蓝牙4.0以下的是传统蓝牙,基于socket方式来实现。所以4.0以上的蓝牙具有传输速度更快,覆盖范围更广,安全性更高,延迟更短,耗电极低等等优点。
HelloJack
2018/08/28
1.1K0
android蓝牙4.0的知识要点
【Android应用开发】Android 蓝牙低功耗 (BLE) ( 第一篇 . 概述 . 蓝牙低功耗文档 翻译)
转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/50515359
韩曙亮
2023/03/27
6.2K0
Android BLE 蓝牙开发,连接蓝牙设备进行通讯
讲解如何通过 UUID 连接蓝牙设备。如果你针对 GATT 服务不太了解。那么这篇应该能够稍微帮助到你。
zinyan.com
2023/07/14
5.8K0
Android BLE 蓝牙开发,连接蓝牙设备进行通讯
Android低功耗蓝牙BLE开发小结
BLE是蓝牙4.0标准的一部分,旨在解决传统蓝牙连接慢、能耗大的问题,Google在Android 4.3(API 18)中引入了对BLE的支持。BLE连接使用GAP(Generic Access Profile)协议,通信使用GATT(Generic Attribute Profile)协议。GATT又以ATT为基础,所有的LE服务都以ATT作为应用层协议。以下深入地介绍这两个协议。
fdroid
2018/07/17
5.7K0
Android低功耗蓝牙BLE开发小结
MASA MAUI Plugin 安卓蓝牙低功耗(二)蓝牙通讯
MAUI的出现,赋予了广大Net开发者开发多平台应用的能力,MAUI 是Xamarin.Forms演变而来,但是相比Xamarin性能更好,可扩展性更强,结构更简单。但是MAUI对于平台相关的实现并不完整。所以MASA团队开展了一个实验性项目,意在对微软MAUI的补充和扩展
JusterZhu
2022/12/07
2.2K0
MASA MAUI Plugin 安卓蓝牙低功耗(二)蓝牙通讯
10分钟完成一个最最简单的BLE蓝牙接收数据的DEMO
这两天在研究蓝牙,网上有关蓝牙的内容非常有限,Github上的蓝牙框架也很少很复杂,为此我特地写了一个最最简单的DEMO,实现BLE蓝牙接收数据的问题,
用户3112896
2019/09/26
2.3K0
Android BlueToothBLE入门(二)——设备的连接和通讯(附Demo源码地址)
接《Android BlueToothBLE入门(一)——低功耗蓝牙介绍》上篇,这篇文章主要就是来做Demo实现Android两台设备的数据通讯。
Vaccae
2023/08/22
1.2K0
Android BlueToothBLE入门(二)——设备的连接和通讯(附Demo源码地址)
Android 原生 BLE 开发
Android 开发 BLE 用第三方库是总是出现一些问题,最后还是硬着头皮改回原生 API。 首先看官方文档:https://developer.android.com/guide/topics/connectivity/bluetooth-le 安卓4.3(API 18)为BLE的核心功能提供平台支持和API,App可以利用它来发现设备、查询服务和读写特性。相比传统的蓝牙,BLE更显著的特点是低功耗。这一优点使android App可以与具有低功耗要求的BLE设备通信,如近距离传感器、心脏速率监视器、健
iOSDevLog
2018/07/04
4.2K0
Android 低功耗蓝牙开发(数据交互)
  在上一篇低功耗蓝牙开发文章中,我讲述了扫描和连接,本篇文章讲述数据的交互。当了解了数据交互后就可以开始进行低功耗蓝牙硬件和手机App软件相结合的项目,例如蓝牙音箱、蓝牙灯、蓝牙锁等等。
晨曦_LLW
2021/09/10
2.1K0
一个Android 蓝牙GATT数据读写的小应用
2、服务特征UUID/读特征UUID 配置特征UUID/写特征UUID,这几个特征UUID 最好是找厂家确认。
呱牛笔记
2024/03/24
3510
Android蓝牙BLE低功耗相关简单总结
在看Android4.42的源码时看到有添加对BLE设备的处理,看的一头雾水,多方百度,终于有种柳暗花明的感觉。
fanfan
2022/05/07
1.1K0
Android 低功耗蓝牙开发(扫描、连接、数据交互)Kotlin版
  写这篇文章是因为有读者想看看Kotlin中怎么操作低功耗蓝牙,再加上我也想写一些关于Kotlin的内容,对于低功耗蓝牙的Java版的,我写了两篇,一个是扫描、连接,另一篇就是数据交互,而这篇Kotlin文章我会减少讲解的环节,更多的注重业务逻辑和UI以及Kotlin的语法。
晨曦_LLW
2021/09/23
3.1K0
Android 低功耗蓝牙开发(扫描、连接、数据交互)Kotlin版
Android BlueToothBLE入门(一)——低功耗蓝牙介绍
距上篇文章发布都一个多月了,先声明,我可不会停更。这么长时间没更新文章,其实原因就三点:
Vaccae
2023/08/22
1.3K0
Android BlueToothBLE入门(一)——低功耗蓝牙介绍
Android BLE 快速上手指南
本文旨在提供一个方便没接触过Android上低功耗蓝牙(Bluetooth Low Energy)的同学快速上手使用的简易教程,因此对其中的一些细节不做过分深入的探讨,此外,为了让没有Ble设备的同学也能模拟与设备的交互过程,本文还提供了中央设备(central)和外围设备(peripheral)的示例代码,只需2部手机大家就可以愉快的“左右互搏”了。
蜻蜓队长
2018/12/10
2.6K0
Android BLE 快速上手指南
Android BlueToothBLE入门(三)——数据的分包发送和接收(源码已更新)
接上篇《Android BlueToothBLE入门(二)——设备的连接和通讯(附Demo源码地址)》最后提到过蓝牙BLE通讯每次默认发送的数据为20字节,如果我们要处理大的数据时,需要修改MTU的值,还有就是分包数据发送,本篇就专门来看看怎么实现的分包数据的发送和接收。
Vaccae
2023/08/22
2.8K0
Android BlueToothBLE入门(三)——数据的分包发送和接收(源码已更新)
BLE低功耗蓝牙与经典蓝牙(持续更新)
BLE设备分单模和双模两种,双模简称BR,商标为Bluetooth Smart Ready,单模简称BLE或者LE,商标为Bluetooth Smart。低功耗蓝牙是不能兼容经典蓝牙的,需要兼容,只能选择双模蓝牙。一个蓝牙主端设备,可同时与7个蓝牙从端设备进行通讯。
木溪bo
2020/03/20
8.8K1
BLE低功耗蓝牙与经典蓝牙(持续更新)
蓝牙API介绍及基本功能实现
通过监听BluetoothAdapter.ACTION_STATE_CHANGED监听蓝牙状态的改变
fanfan
2022/05/07
1.5K0
推荐阅读
相关推荐
Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验