headset_scan.c

来自「bc5_stereo:bluetooth stereo Headset CODE」· C语言 代码 · 共 130 行

C
130
字号
/****************************************************************************
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 + =
减小字号Ctrl + -
显示快捷键?