2016-09-26 09:37:39 -04:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009-2013 Broadcom Corporation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2018-04-08 00:10:50 -04:00
|
|
|
#include "common/bt_target.h"
|
2016-09-26 09:37:39 -04:00
|
|
|
//#include "bt_utils.h"
|
|
|
|
#include "gap_int.h"
|
2018-11-06 02:34:38 -05:00
|
|
|
#include "osi/allocator.h"
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2018-11-06 02:34:38 -05:00
|
|
|
#if GAP_DYNAMIC_MEMORY == FALSE
|
2016-09-26 09:37:39 -04:00
|
|
|
tGAP_CB gap_cb;
|
2018-11-06 02:34:38 -05:00
|
|
|
#else
|
|
|
|
tGAP_CB *gap_cb_ptr;
|
|
|
|
#endif
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function GAP_SetTraceLevel
|
|
|
|
**
|
|
|
|
** Description This function sets the trace level for GAP. If called with
|
|
|
|
** a value of 0xFF, it simply returns the current trace level.
|
|
|
|
**
|
|
|
|
** Returns The new or current trace level
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
UINT8 GAP_SetTraceLevel (UINT8 new_level)
|
|
|
|
{
|
2016-11-24 13:10:15 -05:00
|
|
|
if (new_level != 0xFF) {
|
2016-09-26 09:37:39 -04:00
|
|
|
gap_cb.trace_level = new_level;
|
2016-11-24 13:10:15 -05:00
|
|
|
}
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
return (gap_cb.trace_level);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function GAP_Init
|
|
|
|
**
|
|
|
|
** Description Initializes the control blocks used by GAP.
|
|
|
|
**
|
|
|
|
** This routine should not be called except once per
|
|
|
|
** stack invocation.
|
|
|
|
**
|
2019-06-20 23:55:45 -04:00
|
|
|
** Returns status
|
2016-09-26 09:37:39 -04:00
|
|
|
**
|
|
|
|
*******************************************************************************/
|
2019-06-20 23:55:45 -04:00
|
|
|
bt_status_t GAP_Init(void)
|
2016-09-26 09:37:39 -04:00
|
|
|
{
|
2018-11-06 02:34:38 -05:00
|
|
|
#if GAP_DYNAMIC_MEMORY == TRUE
|
|
|
|
gap_cb_ptr = (tGAP_CB *)osi_malloc(sizeof(tGAP_CB));
|
2019-06-20 23:55:45 -04:00
|
|
|
if (!gap_cb_ptr) {
|
|
|
|
return BT_STATUS_NOMEM;
|
|
|
|
}
|
2018-11-06 02:34:38 -05:00
|
|
|
#endif
|
|
|
|
|
2016-09-26 09:37:39 -04:00
|
|
|
memset (&gap_cb, 0, sizeof (tGAP_CB));
|
|
|
|
|
|
|
|
#if defined(GAP_INITIAL_TRACE_LEVEL)
|
|
|
|
gap_cb.trace_level = GAP_INITIAL_TRACE_LEVEL;
|
|
|
|
#else
|
|
|
|
gap_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GAP_CONN_INCLUDED == TRUE
|
|
|
|
gap_conn_init();
|
|
|
|
#endif
|
|
|
|
|
2017-04-20 07:18:05 -04:00
|
|
|
#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE
|
2016-09-26 09:37:39 -04:00
|
|
|
gap_attr_db_init();
|
|
|
|
#endif
|
2019-06-20 23:55:45 -04:00
|
|
|
|
|
|
|
return BT_STATUS_SUCCESS;
|
2016-09-26 09:37:39 -04:00
|
|
|
}
|
|
|
|
|
2018-11-06 02:34:38 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function GAP_Deinit
|
|
|
|
**
|
|
|
|
** Description This function is called to deinitialize the control block
|
|
|
|
** for this layer.
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void GAP_Deinit(void)
|
|
|
|
{
|
|
|
|
#if GAP_DYNAMIC_MEMORY == TRUE
|
2019-06-20 23:55:45 -04:00
|
|
|
if (gap_cb_ptr) {
|
|
|
|
osi_free(gap_cb_ptr);
|
|
|
|
gap_cb_ptr = NULL;
|
|
|
|
}
|
2018-11-06 02:34:38 -05:00
|
|
|
#endif
|
|
|
|
}
|