accessory-setup-kit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAccessorySetupKit
AccessorySetupKit
What to open
需查看的内容
- Use for all API details and key names.
accessory-setup-kit/accessorysetupkit.md - Use for BLE-specific behavior notes and real-world details.
accessory-setup-kit/AccessorySetupKitEverythingBLEDevelopersNeedToKnow.md - Search within it for: "Discovering and configuring accessories", ,
ASAccessorySession,ASDiscoveryDescriptor,ASPickerDisplayItem,ASMigrationDisplayItem, andASPickerDisplaySettings.ASAccessoryEventType
- 所有API详情和键名请查看。
accessory-setup-kit/accessorysetupkit.md - 有关BLE特定行为说明和实际应用细节,请查看。
accessory-setup-kit/AccessorySetupKitEverythingBLEDevelopersNeedToKnow.md - 可在其中搜索以下内容:"Discovering and configuring accessories"、、
ASAccessorySession、ASDiscoveryDescriptor、ASPickerDisplayItem、ASMigrationDisplayItem和ASPickerDisplaySettings。ASAccessoryEventType
Workflow
工作流程
- Identify whether the accessory uses Bluetooth, Wi-Fi, or Wi-Fi Aware and set up matching discovery properties.
- Declare required Info.plist keys for AccessorySetupKit and any Bluetooth identifiers.
- Create and activate , then handle events on the provided queue.
ASAccessorySession - Present a picker with items that match the accessories you support.
ASPickerDisplayItem - Handle to connect to the selected device; handle
.accessoryAddedand.accessoryRemovedas needed..accessoryChanged
- 确定配件使用的是蓝牙、Wi-Fi还是Wi-Fi Aware,并设置匹配的发现属性。
- 声明AccessorySetupKit所需的Info.plist键以及任何蓝牙标识符。
- 创建并激活,然后在提供的队列上处理事件。
ASAccessorySession - 展示包含与你支持的配件匹配的项的选择器。
ASPickerDisplayItem - 处理事件以连接到所选设备;根据需要处理
.accessoryAdded和.accessoryRemoved事件。.accessoryChanged
Picker guidance
选择器指南
- A display item must include a descriptor with a Bluetooth identifier or Wi-Fi SSID/SSID prefix.
- For Bluetooth filters, provide at least a service UUID or company identifier, and optionally a name substring or manufacturer/service data mask pair.
- To do custom filtering, enable and handle
filterDiscoveryResultsby creating.accessoryDiscoveredentries, then callASDiscoveredDisplayItem.updatePicker(showing:completionHandler:) - If custom filtering needs unlimited time, set and finish discovery with
discoveryTimeout = .unbounded.finishPickerDiscovery(completionHandler:)
- 展示项必须包含带有蓝牙标识符或Wi-Fi SSID/SSID前缀的描述符。
- 对于蓝牙过滤器,至少提供一个服务UUID或公司标识符,还可选择提供名称子串或制造商/服务数据掩码对。
- 若要进行自定义过滤,请启用并通过创建
filterDiscoveryResults条目来处理ASDiscoveredDisplayItem事件,然后调用.accessoryDiscovered。updatePicker(showing:completionHandler:) - 如果自定义过滤需要无限制时间,请设置,并调用
discoveryTimeout = .unbounded来结束发现过程。finishPickerDiscovery(completionHandler:)
Migration and post-setup
迁移与设置后操作
- Use to migrate previously-configured accessories into AccessorySetupKit.
ASMigrationDisplayItem - Use setup and rename options on picker items when the user should rename or finish setup in-app.
- 使用将之前配置的配件迁移到AccessorySetupKit中。
ASMigrationDisplayItem - 当用户需要在应用内重命名或完成设置时,使用选择器项上的设置和重命名选项。
Reminders
注意事项
- Keep discovery descriptors specific to avoid broad Bluetooth access.
- For Wi-Fi Aware, set Wi-Fi Aware properties on before discovery.
ASDiscoveryDescriptor - Use the session event stream to keep app state in sync with user actions.
- 保持发现描述符的针对性,以避免广泛的蓝牙访问权限。
- 对于Wi-Fi Aware,请在开始发现前在上设置Wi-Fi Aware属性。
ASDiscoveryDescriptor - 使用会话事件流使应用状态与用户操作保持同步。