corebluetooth
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCore Bluetooth
Core Bluetooth
What to open
打开哪些文档
- Use and
corebluetooth/AboutCoreBluetooth.mdfor concepts and role orientation.corebluetooth/CoreBluetoothOverview.md - Use for step-by-step central workflows.
corebluetooth/PerformingCommonCentralRoleTasks.md - Use for step-by-step peripheral workflows.
corebluetooth/PerformingCommonPeripheralRoleTasks.md - Use and
corebluetooth/BestPracticesforInteractingwithaRemotePeripheralDevice.mdfor pitfalls and best practices.corebluetooth/BestPracticesforSettingUpYourLocalDeviceasaPeripheral.md - Use for background modes and lifecycle constraints.
corebluetooth/CoreBluetoothBackgroundProcessingforiOSApps.md - Use for state restoration app relaunch rules.
corebluetooth/BluetoothStateRestorationAppReaunchRules.md - Use for API quick maps and symbol lookup.
corebluetooth/corebluetooth.md
- 如需了解概念与角色定位,请查看和
corebluetooth/AboutCoreBluetooth.md。corebluetooth/CoreBluetoothOverview.md - 如需分步了解中心设备工作流,请查看。
corebluetooth/PerformingCommonCentralRoleTasks.md - 如需分步了解外设工作流,请查看。
corebluetooth/PerformingCommonPeripheralRoleTasks.md - 如需了解注意事项与最佳实践,请查看和
corebluetooth/BestPracticesforInteractingwithaRemotePeripheralDevice.md。corebluetooth/BestPracticesforSettingUpYourLocalDeviceasaPeripheral.md - 如需了解后台模式与生命周期限制,请查看。
corebluetooth/CoreBluetoothBackgroundProcessingforiOSApps.md - 如需了解状态恢复下的应用重启规则,请查看。
corebluetooth/BluetoothStateRestorationAppReaunchRules.md - 如需API快速映射与符号查找,请查看。
corebluetooth/corebluetooth.md
Workflow
工作流
- Identify whether the app acts as a central, a peripheral, or both.
- Wait for the manager state to be before issuing BLE operations.
poweredOn - Follow the role checklist to keep discovery and connection order correct.
- Open the role task guide and best practices first; use the API reference for exact signatures.
- 确定应用将作为中心设备、外设,还是同时承担两种角色。
- 在执行BLE操作前,需等待管理器状态变为。
poweredOn - 遵循角色检查清单,确保发现与连接顺序正确。
- 先查看角色任务指南与最佳实践;如需确切签名,请参考API文档。
Central checklist
中心设备检查清单
- Create a with a delegate and queue.
CBCentralManager - Handle and gate scanning on
centralManagerDidUpdateState(_:)..poweredOn - Scan with and stop when the target is found.
scanForPeripherals(withServices:options:) - Connect, set the delegate, and discover services and characteristics.
CBPeripheral - Read, write, or subscribe to characteristic notifications as needed.
- 创建带有代理与队列的。
CBCentralManager - 处理方法,仅在状态为
centralManagerDidUpdateState(_:)时执行扫描。.poweredOn - 使用进行扫描,找到目标设备后停止扫描。
scanForPeripherals(withServices:options:) - 连接设备,设置代理,然后发现服务与特征。
CBPeripheral - 根据需要读取、写入或订阅特征通知。
Peripheral checklist
外设检查清单
- Create a with a delegate and queue.
CBPeripheralManager - Wait for the state to become .
.poweredOn - Define services and characteristics, then add them to the manager.
- Start advertising with service UUIDs and optional local name.
- Respond to read and write requests; publish updates to subscribed centrals.
- 创建带有代理与队列的。
CBPeripheralManager - 等待状态变为。
.poweredOn - 定义服务与特征,然后将其添加至管理器。
- 使用服务UUID与可选本地名称开始广播。
- 响应读、写请求;向已订阅的中心设备发布更新。
Reminders
注意事项
- Retain discovered instances to keep them alive.
CBPeripheral - Use notifications for streaming data; use write-without-response only when is true.
canSendWriteWithoutResponse - Use L2CAP only for use cases that do not fit GATT characteristics.
- 需保留已发现的实例,以维持其活跃状态。
CBPeripheral - 流式数据请使用通知;仅当为true时,才可使用无响应写入。
canSendWriteWithoutResponse - 仅当GATT特征无法满足需求时,才使用L2CAP。