/*************************************************************************************************************
 * @file    ble_central.c
 * @version V1.0
 * @date    2022-02-13
 * @brief   
 *************************************************************************************************************
 * @attention
 *
 * Firmware Disclaimer Information
 *
 * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the
 *    code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
 *    proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
 *    other intellectual property laws.
 *
 * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the
 *    code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
 *    other than HOLTEK and the customer.
 *
 * 3. The program technical documentation, including the code, is provided "as is" and for customer reference
 *    only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
 *    the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
 *    the warranties of merchantability, satisfactory quality and fitness for a particular purpose.
 *
 * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2>
 ************************************************************************************************************/


#include <stdint.h>
#include <stdbool.h>
#include <string.h>

#include "gap_api.h"

#include "app_cfg.h"
#include "utility.h"

/**
 * @brief  ble central init.
 */
void ble_central_init(void)
{
    // 1. Set scan parameters.
    stGapSetScanParameters_t stScanParam = {
        .enumScanType             = GAP_SCAN_TYPE_ACTIVE,
        .u8ScanChannelMap         = BLE_SCAN_CHANNEL,
        .u16ScanInterval625us     = BLE_SCAN_INTERVAL,
        .u16ScanWindow625us       = BLE_SCAN_WINDOW,
        .enumOwnAddressType       = GAP_OWN_ADDRESS_TYPE_PUBLIC,
        .enumScanningFilterPolicy = GAP_SCAN_FILTER_POLICY_ACCEPT_ALL,
    };
    rom_gap_api_set_scan_parameters(&stScanParam);

    // 2. Enable scan.
    rom_gap_api_set_scan_enable(true, false);
}
