CarPlay 有线连接流程
一、引言1.1 目的此文档记录CarPlay 开发中有线连接开发部分详细介绍CarPlay有线连接的流程希望可以给开发CarPlay小伙伴一些帮助无线连接后续再梳理。二、架构设计2.1 架构图注此图翻译自苹果官方的开发帮助文档身份认证 AuthenticationCarPlay是一种经过认证的解决方案需要使用通过Apple获得的Apple认 证协处理器。设备只能流向授权的车机。使用Apple认证协处理器的CarPlay配件3.0只能声明与iOS 10.3或更高版本兼容。iAP2iOS Accessory Protocol II和CarPlay接口上的通信都需要身份验证每个接口都提供一个具体的身份验证API。为了加快这些双重身份验证步骤提供了X.509证书的本地缓存苹果认证协处理器。所有经过认证的配件都需要根据Apple MFi计划进行认证。CarPlay车机必须成功通过符合性测试以确保来自设备的所有数字内容将被正确解码和播放并且满足本规范中描述的所有电气要求。会话建立 Session Establishment车机检测到连接的设备上有CarPlay后必须请求会话启动并在“CarPlayStartSession”《Accessory Interface Specification CarPlay Addendum R7》第241页消息中提供所需参数。一旦建立了连接在车机通过CarPlay接口完成认证后将开始设置和内容传输。连接启用CarPlay的设备时车机不得自动发送播放命令。请参阅媒体库车机接口规范中的播放要求。有关设置CarPlay会话的更多信息请参阅“ Setup and Control”《Accessory Interface Specification CarPlay Addendum R7》第98页。车机必须能够在设备连接后3秒内建立CarPlay会话。三、连接流程3.1 配置接口描述符此功能最为复杂需要驱动层配置iAP2接口描述符和NCM接口描述符,如果作为项目Tire 2的角色开发CarPlay的话这个步骤不需要自己完成将需求提给Tire 1让他们进行适配。3.1.1 iAP2 Interface DescriptorUSB DescriptorValueDescriptionInterface Number0xNNMust be different from the USB NCM Control interface and USB NCM data interface numbers.Interface Class0xFFVendor-specific interfaceInterface Subclass0xF0MFi accessoryInterface Protocol0x00Interface StringiAP InterfaceNumber of Endpoints21 bulk IN and 1 bulk OUT endpoint descriptor shall be specifiedTable-3.13.1.2 NCM Control Interface DescriptorUSB DescriptorValueDescriptionInterface Number0xNNMust be different from the iAP2 interface and USB NCM data interface numbers. Must match the USBHostTransportCarPlayInterfaceNumber,seeAccessory Identification in the Accessory Interface SpecificationInterface Class0x02USB Communication Interface ClassInterface Subclass0x0DNetwork Control ModelInterface Protocol0x00No encapsulated commands / responsesNumber of Endpoints1Interrupt IN (optional): This is typically used to convey changes in link status. Since link is expected to be maintained at all times, we will synthesize link up if there is a read completion via the data interface.Table-3.23.1.3 NCM USB NCM Data Interface DescriptorUSB DescriptorValueDescriptionInterface Number0xNNMust be different from the iAP2 interface and USB NCM control interface numbers.Interface Class0x0AUSB Data Interface ClassInterface Subclass0x00Interface Protocol0x01NCM Data ClassNumber of Endpoints0(for Alternate Setting 0)Number of Endpoints2(for Alternate Setting 1) 1 Bulk IN; and 1 Bulk OUTTable-3.33.2 枚举设备当有USB设备插入时通过USBDevice的PID、VID判断是否是IPhone设备。Apple Vendor ID 0x05ACApple Product ID 0x12nn3.3 检查设备是否支持CarPlay检查到iphone 设备之后通过USB controlTransfer发送 请求查询设备CarPlay是否可用参数值备注bmRequestType0xC0Device-to-Host,数据由Device发给HostbRequest0x53供应商定义的USB获取启用功能请求wValue0x00N/AwIndex0x00N/AwLength4返回的数据长度为4字节Table-3.4当iphone答复0x01 表示iphone支持CarPlay。3.4 Iphone Usb角色切换当IPhone设备通过USB连接到车机时IPhone作为Device设备车机作为Host若想连接CarPlay需要先将IPhone切换为Host参数值备注bmRequestType0x40Device-to-Host,数据由Device发给HostbRequest0x51供应商定义的USB角色切换请求wValue0x010x01为切换到HostwIndex0x00N/AwLength0N/ATable-3.53.5 车机角色切换车机默认是Host模式需要切换成device模式每个车机的切换方法不同在此不做详细说明。3.6 iAP2 身份认证在USB角色切换成功后USB通道就成功建立可以接收/发送iAP2数据按照CarPlay标准流程进行IdentificationAuthentication所需数据较多且无线与有线的身份认证有差异但数据包格式相同。具体参考《Accessory Interface Specification CarPlay Addendum R7》3.7 激活NCM功能激活NCM功能设置IP路由每个项目都有差异需要与Tier 1提出此需求NCM功能激活后通过网络协议便正式开启CarPlay 会话CarPlay Session相关数据传输则通过苹果官方插件库中提供的方法进行。四、总结4.1 经验总结在3.6 iAP2 身份认证阶段中的iAP2数据包内容较多数据拼接极容易出错若在此步骤时出错可能会出现以下几种情况发送Identification/Authentication消息后未收到响应发送Identification后收到Reject消息。出现第一种情况九成概率是因为数据包拼接有问题重点检查数据包checksum。后者需要解析回复的reject中的MSG ID查看是具体是哪些信息被拒绝。4.2 辅助工具建议开发过程中使用MAC ATS软件USB分析仪辅助若没有专业工具则通过爱思助手抓取IPhone日志分析。
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2410316.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!