/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*----------------------------------------------------------------------------*/
/*! @file
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *
 *  @par Description:
 *       This header file contains the Bluetooth Manager specific definitions
 *       that are exported.
 */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_INET_BLUETOOTH Bluetooth Manager
 *  @ingroup  groupMW_INET
 *  @brief    Provides a unified interface for Bluetooth Manager
 *  @see      groupMW_INET
 *
 *  @{
 */
/*----------------------------------------------------------------------------*/

#ifndef _U_BLUETOOTH_H_
#define _U_BLUETOOTH_H_

/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/

#include "u_common.h"

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/

#define BLUETOOTHR_ASYNC_NFY                 ((INT32)   1)  /**< Async notification */
#define BLUETOOTHR_OK                        ((INT32)   0)  /**< Successful */
#define BLUETOOTHR_NOT_READY                 ((INT32)  -1)  /**< Not ready */
#define BLUETOOTHR_FAIL                      ((INT32)  -2)  /**< Fail */
#define BLUETOOTHR_INV_ARG                   ((INT32)  -3)  /**< Invalid arguments */
#define BLUETOOTHR_NOT_ENOUGH_MEM            ((INT32)  -4)  /**< Not enough memory*/

#define BLUETOOTH_PROFILE_CAP_HID                           MAKE_BIT_MASK_32(0)
#define BLUETOOTH_PROFILE_CAP_GENERAL_AUDIO                 MAKE_BIT_MASK_32(1)
#define BLUETOOTH_PROFILE_CAP_AVRCP                         MAKE_BIT_MASK_32(2)

#define BLUETOOTH_MAX_STR_LEN                                             (128)
#define BLUETOOTH_MAX_PINCODE_LEN                                          (16)

typedef UINT32 BLUETOOTH_NFY_REASON_T;

/* scan related */
#define BLUETOOTH_NFY_REASON_SCAN_DEVICE_FOUND         ((BLUETOOTH_NFY_REASON_T)  0)
#define BLUETOOTH_NFY_REASON_SCAN_COMPLETED            ((BLUETOOTH_NFY_REASON_T)  1)
#define BLUETOOTH_NFY_REASON_SCAN_FAILED               ((BLUETOOTH_NFY_REASON_T)  2)
#define BLUETOOTH_NFY_REASON_SCAN_ABORTED              ((BLUETOOTH_NFY_REASON_T)  3)

/* pairing related */
#define BLUETOOTH_NFY_REASON_PAIR_COMPLETED            ((BLUETOOTH_NFY_REASON_T)  4)  /**< Pair is completed */
#define BLUETOOTH_NFY_REASON_PAIR_AUTH_TIMEOUT         ((BLUETOOTH_NFY_REASON_T)  5)  /**< Authenication is timeout */
#define BLUETOOTH_NFY_REASON_PAIR_AUTH_REJECTED        ((BLUETOOTH_NFY_REASON_T)  6)  /**< Authenication is rejected by remote device */
#define BLUETOOTH_NFY_REASON_PAIR_AUTH_CANCELED        ((BLUETOOTH_NFY_REASON_T)  7)  /**< Authenication is canceled by ourself */
#define BLUETOOTH_NFY_REASON_PAIR_AUTH_FAILED          ((BLUETOOTH_NFY_REASON_T)  8)  /**< Authenication is failed, ex. pincode is incorrect */
#define BLUETOOTH_NFY_REASON_PAIR_ALREADY_PAIRED       ((BLUETOOTH_NFY_REASON_T)  9)  /**< This device is already paired */
#define BLUETOOTH_NFY_REASON_PAIR_CONN_FAILED          ((BLUETOOTH_NFY_REASON_T) 10)  /**< Connection is failed, ex. the remote device is shutdown */
#define BLUETOOTH_NFY_REASON_PAIR_FAILED_UNKNOWN       ((BLUETOOTH_NFY_REASON_T) 11)  /**< Unknown reason */

typedef struct _BLUETOOTH_DEVICE_PROPERTY_T
{
    CHAR           s_name[BLUETOOTH_MAX_STR_LEN];
    CHAR           s_address[BLUETOOTH_MAX_STR_LEN];
    UINT32         ui4_profile_cap;
    BOOL           b_paired;
    BOOL           b_connected;
} BLUETOOTH_DEVICE_PROPERTY_T;


typedef struct _BLUETOOTH_PINCODE_T
{
    CHAR           s_pincode[BLUETOOTH_MAX_PINCODE_LEN];
} BLUETOOTH_PINCODE_T;

typedef VOID (*x_bluetooth_scan_nfy_fct)(BLUETOOTH_NFY_REASON_T    t_nfy_reason,
                                               VOID*                     pv_nfy_data,
                                               VOID*                     pv_nfy_tag);

typedef VOID (*x_bluetooth_pair_nfy_fct)(BLUETOOTH_NFY_REASON_T    t_nfy_reason,
                                               VOID*                     pv_nfy_data,
                                               VOID*                     pv_nfy_tag);

/*! @} */

#endif /*  _U_BLUETOOTH_H_ */

