• AVS 端能力之蓝牙模块


    该类为蓝牙端能力处理类,主要负责蓝牙设备配对和蓝牙音频播放功能。

    功能简介

    • 实现蓝牙设备的启动发现模式、扫描蓝牙设备、建立蓝牙连接功能
    • 实现蓝牙设备音频播放、停止、上一首、下一首功能
    • 其它细节参考《AVS 端能力模块》

    UML 图集

    • 完整类图

    • 精简类图

    • 对象调用

    调用流程

    // 创建对象并更新上下文
    Bluetooth:create
    Bluetooth:init
    BlueZDeviceManager:getDiscoveredDevices
    Bluetooth:executeUpdateContext:buffer={"alexaDevice":{"friendlyName":"sprite-moon"}\,"pairedDevices":[]}
    Bluetooth:getConfiguration
    
    // 注册蓝牙指令处理
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=Previous,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=Play,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=DisconnectDevice,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=Next,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=ConnectByProfile,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=EnterDiscoverableMode,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=PairDevice,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=ScanDevices,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=ExitDiscoverableMode,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=UnpairDevice,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=Stop,handler=0x55a9c2a48000,policy=NON_BLOCKING
    DirectiveRouter:addDirectiveHandlers:action=added,namespace=Bluetooth,name=ConnectByDeviceId,handler=0x55a9c2a48000,policy=NON_BLOCKING
    
    ###########################
    #       Thinking...       #
    ###########################
    
    // 接收到ConnectByProfile指令并执行预处理
    DirectiveSequencer:onDirective:directive={"directive":{"header":{"namespace":"Bluetooth"\,"name":"ConnectByProfile"\,"messageId":"90326566-00c6-436b-93ef-a9d7e0bf8558"\,"dialogRequestId":"5a6fa9c6-bdbb-4097-9d6a-d9e8ad5d5434"}\,"payload":{"profile":{"name":"A2DP-SOURCE"}}}}
    DirectiveRouter:preHandleDirective:messageId=90326566-00c6-436b-93ef-a9d7e0bf8558,action=calling
    CapabilityAgent:addingMessageIdToMap:messageId=90326566-00c6-436b-93ef-a9d7e0bf8558
    Bluetooth:preHandleDirective
    
    // 接收到EnterDiscoverableMode指令并执行预处理
    DirectiveSequencer:onDirective:directive={"directive":{"header":{"namespace":"Bluetooth"\,"name":"EnterDiscoverableMode"\,"messageId":"2836b54f-8e68-4147-86a4-8056d98cc7fe"\,"dialogRequestId":"5a6fa9c6-bdbb-4097-9d6a-d9e8ad5d5434"}\,"payload":{}}}
    DirectiveRouter:preHandleDirective:messageId=2836b54f-8e68-4147-86a4-8056d98cc7fe,action=calling
    CapabilityAgent:addingMessageIdToMap:messageId=2836b54f-8e68-4147-86a4-8056d98cc7fe
    Bluetooth:preHandleDirective
    
    ###########################
    #       Speaking...       #
    ###########################
    
    // 处理ConnectByProfile指令
    DirectiveRouter:handleDirective:messageId=90326566-00c6-436b-93ef-a9d7e0bf8558,action=calling
    Bluetooth:handleDirective
    
    // 处理EnterDiscoverableMode指令
    DirectiveRouter:handleDirective:messageId=2836b54f-8e68-4147-86a4-8056d98cc7fe,action=calling
    Bluetooth:handleDirective
    
    // 解析ConnectByProfile指令内容连接执行后消息队列移除该消息
    Bluetooth:parseDirectivePayload
    Bluetooth:executeConnectByProfile:profileName=A2DP-SOURCE,profileVersion=
    Bluetooth:executeUpdateContext:buffer={"alexaDevice":{"friendlyName":"sprite-moon"}\,"pairedDevices":[]}
    Bluetooth:executeQueueEventAndRequestContext:eventName=ConnectByProfileFailed
    DirectiveProcessor:onHandlingCompeted:messageId=90326566-00c6-436b-93ef-a9d7e0bf8558,directiveBeingPreHandled=(nullptr)
    CapabilityAgent:removingMessageIdFromMap:messageId=90326566-00c6-436b-93ef-a9d7e0bf8558
    
    // 解析EnterDiscoverableMode指令内容连接执行后消息队列移除该消息
    Bluetooth:parseDirectivePayload
    Bluetooth:executeSetDiscoverableMode
    Bluetooth:executeQueueEventAndRequestContext:eventName=EnterDiscoverableModeSucceeded
    DirectiveProcessor:onHandlingCompeted:messageId=2836b54f-8e68-4147-86a4-8056d98cc7fe,directiveBeingPreHandled=(nullptr)
    CapabilityAgent:removingMessageIdFromMap:messageId=2836b54f-8e68-4147-86a4-8056d98cc7fe
    
    // Context可用时发送ConnectByProfileFailed事件
    Bluetooth:onContextAvailableLambda
    EventBuilder:buildJsonEventString:messageId=ab2db07c-9095-4110-bec2-59719618417d,namespace=Bluetooth,name=ConnectByProfileFailed
    Bluetooth:onContextAvailableLambda:event={"context":[{"header":{"namespace":"Bluetooth","name":"BluetoothState"},"payload":{"alexaDevice":{"friendlyName":"sprite-moon"},"pairedDevices":[]}}],"event":{"header":{"namespace":"Bluetooth","name":"ConnectByProfileFailed","messageId":"ab2db07c-9095-4110-bec2-59719618417d"},"payload":{"requester":"CLOUD","profileName":"A2DP-SOURCE"}}}
    AVSConnectionManager:sendMessage:event="报文内容同上,原始报文中的context包含所有端能力状态"
    
    // Context可用时发送EnterDiscoverableModeSucceeded事件
    Bluetooth:onContextAvailableLambda
    EventBuilder:buildJsonEventString:messageId=6dcdbdad-eba3-4fd2-805f-48b2da365a62,namespace=Bluetooth,name=EnterDiscoverableModeSucceeded
    Bluetooth:onContextAvailableLambda:event={"context":[{"header":{"namespace":"Bluetooth","name":"BluetoothState"},"payload":{"alexaDevice":{"friendlyName":"sprite-moon"},"pairedDevices":[]}}],"event":{"header":{"namespace":"Bluetooth","name":"EnterDiscoverableModeSucceeded","messageId":"6dcdbdad-eba3-4fd2-805f-48b2da365a62"},"payload":{}}}
    AVSConnectionManager:sendMessage:event="报文内容同上,原始报文中的context包含所有端能力状态"
    
  • 相关阅读:
    java 反射
    java 面试题
    Java构造和解析Json数据的两种方法详解一
    JAVA UUID 生成
    tomcat 插件
    webstorm 激活码
    maven环境搭建
    svn 安装网站
    2015.6.30 反弹的教训(想做T)
    2015.6.15 惨跌开始的反思
  • 原文地址:https://www.cnblogs.com/clxye/p/9946480.html
Copyright © 2020-2023  润新知