📄 av_headset_scan.c
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004
FILE NAME
headset_scan.c
DESCRIPTION
NOTES
*/
/****************************************************************************
Header files
*/
#include "av_headset_private.h"
#include "av_headset_scan.h"
#include <connection.h>
#include <hfp.h>
/* TODO: B-4398 for now hard code all scan params. */
#define SCAN_INTERVAL_NORMAL (0x800)
#define SCAN_WINDOW_NORMAL (0x12)
#define SCAN_INTERVAL_PAIRING (0x400)
#define SCAN_WINDOW_PAIRING (0x200)
/****************************************************************************
NAME
headsetEnableConnectable
DESCRIPTION
Make the device connectable
RETURNS
void
*/
void headsetEnableConnectable(avTaskData *app)
{
hci_scan_enable scan = hci_scan_enable_off;
/* Set the page scan params */
if (app->pairing_enabled)
ConnectionWritePagescanActivity(SCAN_INTERVAL_PAIRING, SCAN_WINDOW_PAIRING);
else
ConnectionWritePagescanActivity(SCAN_INTERVAL_NORMAL, SCAN_WINDOW_NORMAL);
/* 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);
/* Set the flag to indicate we're page scanning */
app->page_scan_enabled = 1;
}
/****************************************************************************
NAME
headsetDisableConnectable
DESCRIPTION
Take device out of connectable mode.
RETURNS
void
*/
void headsetDisableConnectable(avTaskData *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);
/* Set the flag to indicate we're not page scanning */
app->page_scan_enabled = 0;
}
/****************************************************************************
NAME
headsetEnableDiscoverable
DESCRIPTION
Make the device discoverable.
RETURNS
void
*/
void headsetEnableDiscoverable(avTaskData *app)
{
hci_scan_enable scan = hci_scan_enable_off;
/* Set the inquiry scan params */
ConnectionWriteInquiryscanActivity(SCAN_INTERVAL_PAIRING, SCAN_WINDOW_PAIRING);
/* 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);
/* Set the flag to indicate we're inquiry scanning */
app->inquiry_scan_enabled = 1;
}
/****************************************************************************
NAME
headsetDisableDiscoverable
DESCRIPTION
Make the device non-discoverable.
RETURNS
void
*/
void headsetDisableDiscoverable(avTaskData *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);
/* Set the flag to indicate we're not inquiry scanning */
app->inquiry_scan_enabled = 0;
}
/****************************************************************************
NAME
headsetTestForConnectablilty
DESCRIPTION
See if we should be connectable or not depending on if we are already connected
to an AG and an audio source
RETURNS
void
*/
void headsetTestForConnectablilty(avTaskData *app)
{
if ((app->a2dp_state == avHeadsetA2dpConnected) ||
(app->a2dp_state == avHeadsetA2dpStreaming))
{
/* Don't make the headset connectable and discoverable */
DEBUG(("NOT CONNECTABLE\n"));
headsetDisableConnectable(app);
}
else
{
/* Make the headset connectable and discoverable */
DEBUG(("CONNECTABLE\n"));
headsetEnableConnectable(app);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -