⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 headset_scan.c

📁 bc5_stereo:bluetooth stereo Headset CODE 支持A2DP HSP 和 HSP 。可作为车载免提。BlueLab 2007环境下编译
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2005-2007

FILE NAME
    headset_scan.c

DESCRIPTION
    

NOTES

*/


/****************************************************************************
    Header files
*/

#include "headset_debug.h"
#include "headset_scan.h"

#include <connection.h>


#ifdef DEBUG_SCAN
#define SCAN_DEBUG(x) DEBUG(x)
#else
#define SCAN_DEBUG(x) 
#endif


#define HCI_PAGESCAN_INTERVAL_DEFAULT  (0x800)
#define HCI_PAGESCAN_WINDOW_DEFAULT   (0x12)
#define HCI_INQUIRYSCAN_INTERVAL_DEFAULT  (0x800)
#define HCI_INQUIRYSCAN_WINDOW_DEFAULT   (0x12)


/*****************************************************************************/
void headsetEnableConnectable(hsTaskData *app)
{
    hci_scan_enable scan = hci_scan_enable_off;

    /* Set the page scan params */
    /* TODO - Read radio from PSKeys */
    /*ConnectionWritePagescanActivity(app->radio.page_scan_interval, app->radio.page_scan_window);*/
    /*ConnectionWritePagescanActivity(HCI_PAGESCAN_INTERVAL_DEFAULT, HCI_PAGESCAN_WINDOW_DEFAULT);*/

    /* Make sure that if we're inquiry scanning we don't disable it */
    if (app->inquiry_scan_enabled)
        scan = hci_scan_enable_inq_and_page;
    else
        scan = hci_scan_enable_page;

    /* Enable scan mode */
    ConnectionWriteScanEnable(scan);
    
    SCAN_DEBUG(("Scan : %x\n",scan));

    /* Set the flag to indicate we're page scanning */
    app->page_scan_enabled = TRUE;
}


/*****************************************************************************/
void headsetDisableConnectable(hsTaskData *app)
{
    hci_scan_enable scan;

    /* Make sure that if we're inquiry scanning we don't disable it */
    if (app->inquiry_scan_enabled)
        scan = hci_scan_enable_inq;
    else
        scan = hci_scan_enable_off;

    /* Enable scan mode */
    ConnectionWriteScanEnable(scan);
    
    SCAN_DEBUG(("Scan : %x\n",scan));

    /* Set the flag to indicate we're page scanning */
    app->page_scan_enabled = FALSE;
}


/*****************************************************************************/
void headsetEnableDiscoverable(hsTaskData *app)
{
    hci_scan_enable scan = hci_scan_enable_off;

    /* Set the inquiry scan params */
    /* TODO - Read radio from PSKeys */
    /*ConnectionWriteInquiryscanActivity(app->radio.inquiry_scan_interval, app->radio.inquiry_scan_window);*/
    /*ConnectionWriteInquiryscanActivity(HCI_INQUIRYSCAN_INTERVAL_DEFAULT, HCI_INQUIRYSCAN_WINDOW_DEFAULT);*/

    /* Make sure that if we're page scanning we don't disable it */
    if (app->page_scan_enabled)
        scan = hci_scan_enable_inq_and_page;
    else
        scan = hci_scan_enable_inq;

    /* Enable scan mode */
    ConnectionWriteScanEnable(scan);
    
    SCAN_DEBUG(("Scan : %x\n",scan));

    /* Set the flag to indicate we're page scanning */
    app->inquiry_scan_enabled = TRUE;
}


/*****************************************************************************/
void headsetDisableDiscoverable(hsTaskData *app)
{
    hci_scan_enable scan;
    
    /* Make sure that if we're page scanning we don't disable it */
    if (app->page_scan_enabled)
        scan = hci_scan_enable_page;
    else
        scan = hci_scan_enable_off;

    /* Enable scan mode */
    ConnectionWriteScanEnable(scan);
    
    SCAN_DEBUG(("Scan : %x\n",scan));

    /* Set the flag to indicate we're page scanning */
    app->inquiry_scan_enabled = FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -