QCC30XX如何查找本地地址码

查找本地地址段


/**********************************************************************
Copyright (c) 2016 - 2017 Qualcomm Technologies International, Ltd.
 
 
FILE NAME
    sink_private_data.c
 
DESCRIPTION
    This module works as a container for all private and common data that is used across sink
    qpplication. It provides API to access the data from outside. It interacts with configuration
    entities to read/write configuration data. More over this module contains module specific
    run time data (as a common runtime data for entire sink application), and those data also
    exposed using defined API's
 
 NOTES
      Module does not have any intelligence to manipulate the data, or verify the data or its
      contents ,it is the user to decide hoe to use this data and when to update the data.
*/
 
#include <stdlib.h>
#include <ps.h>
#include <vmtypes.h>
#include <bdaddr.h>
#include <byte_utils.h>
 
#include "sink_private_data.h"
#include "sink_dut.h"
#include "sink_malloc_debug.h"
#include "sink_configmanager.h"
 
#include <local_device.h>
 
#ifdef DEBUG_SINK_PRIVATE_DATA
#define SINK_DATA_DEBUG(x) DEBUG(x)
#define SINK_DATA_ERROR(x) TOLERATED_ERROR(x)
#else
#define SINK_DATA_DEBUG(x)
#define SINK_DATA_ERROR(x)
#endif
 
#ifdef DEBUG_MAIN
    #define MAIN_DEBUG(x) DEBUG(x)
#else
    #define MAIN_DEBUG(x)
#endif
/* Referance to Global Data for sink private module */
typedef struct __sinkdata_globaldata_t
{
 
    unsigned panic_reconnect:1; /* Are we using panic action? Bit to inidcate panic reconnection action is used  */
    unsigned paging_in_progress:1; /* Bit to indicate that device is curretly paging whilst in connectable state*/
    unsigned powerup_no_connection:1; /* Bit to indicate device has powered and no connections yet */
    unsigned confirmation:1; /* Bit to indicate user auth confirmation status */
    unsigned SinkInitialising:1; /* Bit to indicate sink is in initialising state */
    unsigned PowerOffIsEnabled:1; /* Bit to indicate power off is enabled */
    unsigned debug_keys_enabled:1; /* Bit to indicate debug keys enabled */
    unsigned stream_protection_state:2; /* Holds stream protection state */
    unsigned MultipointEnable:1; /* Bit to indicate multipoint enabled */
    unsigned _spare1_:6;
    unsigned gEventQueuedOnConnection:8; /* variable to hold evet queued while in connection */
    unsigned dfu_access:1;              /* Link Policy expedites DFU data transfer */
    unsigned display_link_keys:1; /* Bit used to indicate if link keys should be displayed */
    unsigned _spare2_:6;
    uint16 NoOfReconnectionAttempts; /* Holdes current number of reconnection attempts */
    uint16 connection_in_progress;  /* flag used to block role switch requests until all connections are complete or abandoned */
#ifdef ENABLE_SQIFVP
    unsigned               partitions_mounted:8;
    unsigned               unused:8;
#endif
    bdaddr                   *linkloss_bd_addr;  /** bdaddr of a2dp device that had the last link loss. */
    tp_bdaddr                *confirmation_addr;
    bdaddr local_bd_addr; /* Local BD Address of the sink device available in ps */
    power_table              *user_power_table;  /* pointer to user power table if available in ps */
}sinkdata_globaldata_t;
 
/* PSKEY for BD ADDRESS */
#define PSKEY_BDADDR   0x0001
#define LAP_MSW_OFFSET 0
#define LAP_LSW_OFFSET 1
#define UAP_OFFSET 2
#define NAP_OFFSET 3
 
/* Global data strcuture element for sink private data */
static sinkdata_globaldata_t gSinkData;
#define GSINKDATA  gSinkData
 
 
/**********************************************************************
***************  External Interface Function Implemetations  **********************
***********************************************************************/
 
/**********************************************************************
        Interfaces for accessing Configurable Items
*/
/**********************************************************************
  Interfaces for Initializing Local Address, which read the local address.
*/
bool  sinkDataInitLocalBdAddrFromPs(void)
{
 
    bool result = FALSE;
 
    uint16 size = PS_SIZE_ADJ(sizeof(GSINKDATA.local_bd_addr));
    uint16* bd_addr_data = (uint16*)PanicUnlessNew(bdaddr);
 
    BdaddrSetZero(&GSINKDATA.local_bd_addr);
 
    if(size == PsFullRetrieve(PSKEY_BDADDR, bd_addr_data, size))
    {
 
        GSINKDATA.local_bd_addr.nap = bd_addr_data[NAP_OFFSET];
        GSINKDATA.local_bd_addr.uap = bd_addr_data[UAP_OFFSET];
        GSINKDATA.local_bd_addr.lap = MAKELONG(bd_addr_data[LAP_LSW_OFFSET], bd_addr_data[LAP_MSW_OFFSET]);
 
        SINK_DATA_DEBUG(("CONF: PSKEY_BDADDR [%04x %02x %06lx]\n",
                GSINKDATA.local_bd_addr.nap, GSINKDATA.local_bd_addr.uap, GSINKDATA.local_bd_addr.lap));
        result = TRUE;
    }
    else
    {
 
        GSINKDATA.local_bd_addr = LocalDeviceGetBdAddr();
    }
    MAIN_DEBUG(("CONF: PSKEY_BDADDR [%04x %02x %06lx]\n",
            GSINKDATA.local_bd_addr.nap, GSINKDATA.local_bd_addr.uap, GSINKDATA.local_bd_addr.lap));
    free(bd_addr_data);
 
    return result;
}
 
/**********************************************************************
  Interfaces for checking reconnect on panic configuration is enabled or not
*/
bool sinkDataIsReconnectOnPanic(void)
{
 
    bool reconnect_on_panic = FALSE;
    sinkdata_readonly_config_def_t *read_configdata = NULL;
    SINK_DATA_DEBUG(("SinkData:sinkDataIsReconnectOnPanic()\n"));
 
    if (configManagerGetReadOnlyConfig(SINKDATA_READONLY_CONFIG_BLK_ID, (const void **)&read_configdata))
    {
 
        reconnect_on_panic = read_configdata->ReconnectOnPanic;
        configManagerReleaseConfig(SINKDATA_READONLY_CONFIG_BLK_ID);
    }
    SINK_DATA_DEBUG(("SinkData:reconnect_on_panic = %d \n",reconnect_on_panic));
    return (reconnect_on_panic)?TRUE : FALSE;
}
 
/**********************************************************************
  Interfaces for checking power of after PDL reset configuration is enabled or not
*/
bool sinkDataIsPowerOffAfterPDLReset(void)
{
 
    bool poweroff_pdl_reset = FALSE;
    sinkdata_readonly_config_def_t *read_configdata = NULL;
    SINK_DATA_DEBUG(("SinkData:sinkDataIsPowerOffAfterPDLReset()\n"));
 
    if (configManagerGetReadOnlyConfig(SINKDATA_READONLY_CONFIG_BLK_ID, (const void **)&read_configdata))
    {
 
        poweroff_pdl_reset = read_configdata->PowerOffAfterPDLReset;
        configManagerReleaseConfig(SINKDATA_READONLY_CONFIG_BLK_ID);
    }
    SINK_DATA_DEBUG(("SinkData: poweroff_pdl_reset = %d \n",poweroff_pdl_reset));
    return (poweroff_pdl_reset)?TRUE : FALSE;
}
 
/**********************************************************************
  Interfaces  for checking does sink shoule be in discoverable mode all time
  configuration is enabled or not
*/
bool sinkDataIsDiscoverableAtAllTimes(void)
{
 
    bool discoverable_alltime = FALSE;
    sinkdata_readonly_config_def_t *read_configdata = NULL;
    SINK_DATA_DEBUG(("SinkData:sinkDataIsDiscoverableAtAllTimes()\n"));
 
    if (configManagerGetReadOnlyConfig(SINKDATA_READONLY_CONFIG_BLK_ID, (const void **)&read_configdata))
    {
 
        discoverable_alltime = read_configdata->RemainDiscoverableAtAllTimes;
        configManagerReleaseConfig(SINKDATA_READONLY_CONFIG_BLK_ID);
    }
    SINK_DATA_DEBUG(("SinkData: discoverable_alltime = %d\n",discoverable_alltime));
    return (discoverable_alltime)?TRUE : FALSE;
}
 
/**********************************************************************
  Interfaces  for checking DisablePowerOffAfterPowerOn configuration is enabled or not
*/
bool sinkDataCheckDisablePowerOffAfterPowerOn(void)
{
 
    bool disable_poweroff = FALSE;
    sinkdata_readonly_config_def_t *read_configdata = NULL;
    SINK_DATA_DEBUG(("SinkData:sinkDataCheckDisablePowerOffAfterPowerOn()\n"));
 
    if (configManagerGetReadOnlyConfig(SINKDATA_READONLY_CONFIG_BLK_ID, (const void **)&read_configdata))
    {
 
        disable_poweroff = read_configdata->DisablePowerOffAfterPowerOn;
        configManagerReleaseConfig(SINKDATA_READONLY_CONFIG_BLK_ID);
    }
    SINK_DATA_DEBUG(("SinkData: disable_poweroff = %d\n",disable_poweroff));
    return (disable_poweroff)?TRUE : FALSE;
}
 
/**********************************************************************
  Interfaces  for checking pairing mode on connection failure configuration is enabled or not
*/
bool sinkDataEntrePairingModeOnConFailure(void)
{
 
    bool failuretoconnect = FALSE;
    sinkdata_readonly_config_def_t *read_configdata = NULL;
    SINK_DATA_DEBUG(("SinkData:sinkDataPairingModeOnConnectionFailure()\n"));
 
    if (configManagerGetReadOnlyConfig(SINKDATA_READONLY_CONFIG_BLK_ID, (const void **)&read_configdata))
    {
 
        failuretoconnect = read_configdata->EnterPairingModeOnFailureToConn;
        configManagerReleaseConfig(SINKDATA_READONLY_CONFIG_BLK_ID);
    }
    SINK_DATA_DEBUG(("SinkData: failuretoconnect = %d\n",failuretoconnect));
    return (failuretoconnect)?TRUE : FALSE;
}
 
/**********************************************************************
  Interfaces for checking Power Off OnlyIf VReg Enble is low configuration is enabled or not
*/
bool sinkDataIsPowerOffOnlyIfVRegEnlow(void)
{
 
    bool vreg_enlow = FALSE;
    sinkdata_readonly_config_def_t *read_configdata = NULL;
    SINK_DATA_DEBUG(("SinkData:sinkDataIsPowerOffOnlyIfVRegEnlow()\n"));
 
    if (configManagerGetReadOnlyConfig(SINKDATA_READONLY_CONFIG_BLK_ID, (const void **)&read_configdata))
    {
 
        vreg_enlow = read_configdata->PowerOffOnlyIfVRegEnLow;
        configManagerReleaseConfig(SINKDATA_READONLY_CONFIG_BLK_ID);
    }
    SINK_DATA_DEBUG(("SinkData: vreg_enlow = %d\n",vreg_enlow));
    return (vreg_enlow)?TRUE : FALSE;
}
 
/**********************************************************************/
bool sinkDataAllowAutomaticPowerOffWhenCharging(void)
{
 
    bool power_off_when_charging = FALSE;
    sinkdata_readonly_config_def_t *read_configdata = NULL;
    SINK_DATA_DEBUG(("SinkData:sinkDataAllowAutomaticPowerOffWhenCharging()\n"));
 
    if (configManagerGetReadOnlyConfig(SINKDATA_READONLY_CONFIG_BLK_ID, (const void **)&read_configdata))
    {
 
        power_off_when_charging = read_configdata->AllowAutomaticPowerOffWhenCharging;
        configManagerReleaseC
  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值