IOS BLE 缓存清除

在开发基于蓝牙BLE通信的智能硬件时,发现iOS存在蓝牙服务缓存问题,导致设备重启更新服务后,iOS仍扫描到旧服务。该现象遵循BLE规范中的缓存优化。解决方案包括:1)硬件端开启Generic Attribute Profile Service并发送Service Changed Indication通知;2)在iOS系统设置中关闭再开启蓝牙来清除缓存。注意,仅系统设置中的蓝牙开关操作有效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题

在做一款基于蓝牙BLE通信的智能硬件,设备的蓝牙服务是动态变化的,发现 IOS 存在蓝牙服务缓存。
具体表现是,IOS 搜索发现过硬件的蓝牙服务后,断开蓝牙连接,设备重启更新了蓝牙服务, IOS 再次搜索,扫描到的蓝牙服务仍然是旧的。

原因

事实上,缓存现象不是 IOS 独有的,在 BLE 规范中定义了缓存标准,参考 蓝牙4.0规范 vol 3, Part G, 2.5.2 Attribute Caching。这是为了优化,在客户端重新连接服务端时,可以重用上次发现的蓝牙服务信息。

Attribute caching is an optimization that allows the client to discover the Attribute information such as Attribute Handles used by the server once and use
the same Attribute information across reconnections without rediscovery. Without caching the Attribute information, the client shall rediscover the Attribute
information at each reconnection. With caching, time is saved and a significant
amount of packets exchanged between the client and server is not required.
The Attribute information that shall be cached by a client is the Attribute H

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值