BES2700源码解析之蓝牙的状态显示和流程

发布于:2025-03-21 ⋅ 阅读:(21) ⋅ 点赞:(0)

一 概述

  bes2700凭借着超低的功耗,强大的性能,在很多可穿戴产品上有着广泛的应用。团队使用该芯片开发产品的机会,梳理一下源码做个总结。

二 源码解析

1.蓝牙的配对:这里即可实现双耳的配对,也可以和手机实现配对。上面两行分别显示灯和提示音:

                case APP_POWERON_CASE_BOTHSCAN:
                    app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN);
#ifdef MEDIA_PLAYER_SUPPORT
                    media_PlayAudio(AUD_ID_BT_PAIR_ENABLE, 0);
#endif
                    // bes_bt_me_write_access_mode(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR, 1);
                     app_ibrt_internal_enter_freeman_pairing();

2.蓝牙的连接:这个是代码:

        profile_mgr->profile_connected = true;
        DEBUG_INFO(0,"BT connected!!!");

#ifndef IBRT
        app_bt_get_remote_device_name(&curr_device->remote);
#endif
#if defined(MEDIA_PLAYER_SUPPORT)
        audio_player_play_prompt(AUD_ID_BT_CONNECTED, id);
#endif

3.蓝牙的断开函数:


    if (profile_mgr->profile_connected &&
        (profile_mgr->hfp_connect != bt_profile_connect_status_success &&
         profile_mgr->a2dp_connect != bt_profile_connect_status_success))
    {

        profile_mgr->profile_connected = false;
        DEBUG_INFO(0,"BT disconnected!!!");

#ifdef GFPS_ENABLED
        if (gfps_is_last_response_pending())
        {
            gfps_enter_connectable_mode_req_handler(gfps_get_last_response());
        }
#endif

#if defined(MEDIA_PLAYER_SUPPORT)&& !defined(IBRT)
        audio_player_play_prompt(AUD_ID_BT_DIS_CONNECT, id);
#endif
#ifdef __INTERCONNECTION__
        app_interconnection_disconnected_callback();
#endif

        app_set_disconnecting_all_bt_connections(false);
    }

三 总结

  1.看源码,找准接口部分,知道代码的流程,接下来就是逐个击破了。