/* 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 c_net_wlan.h 
 *  $RCSfile: c_net_wlan.h,v $
 *  $Revision: #1 $
 *  $Date: 2015/11/10 $
 *  $Author: dtvbm11 $
 *  
 *  @par Description:
 *         This file contains the prototype of control API of Wifi Driver for Application.
 */
/*----------------------------------------------------------------------------*/

#ifndef _C_NET_WLAN_H
#define _C_NET_WLAN_H

/*----------------------------------------------------------------------------*/
/*! @addtogroup groupMW_INET_WIFI
 *  @{
 */
/*----------------------------------------------------------------------------*/

#include "u_net_wlan.h"

/*------------------------------------------------------------------*/
/*! @brief Create wlan task. This routine initializes the wlan task. 
 *              It must be called before calling c_net_network_init
 *  @return result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_task_create(void);

/*------------------------------------------------------------------*/
/*! @brief Get WPA status. This routine retrieves the WPA status.
 *  @param [out] pStatus -WPAStatus "WPA Status"
 *  @return result
 *  @retval    0 -success
 *  @retval    otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wpa_get_status(INT32 *pStatus);

/*------------------------------------------------------------------*/
/*! @brief Scan network.This routine scans infrastructure and adhoc networks.
 *  @param [in] pfNotify -callback function to notify scan completion.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_scan(x_net_wlan_notify_fct pfNotify);


/*------------------------------------------------------------------*/
/*! @brief Scan network.This routine scans infrastructure and adhoc networks with specify.
 *  @param [in] pfNotify -callback function to notify scan completion.
 *  @param [in] ssid -the ssid than you want to scan.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_scan_with_ssid(x_net_wlan_notify_fct pfNotify, char * ssid, int ssid_len );


/*------------------------------------------------------------------*/
/*! @brief Get scan result.This routine is called to get the scan result.All the found BSSs are listed in the list.
 *  @param [in,out] pScanResult -list of scan result(BSSs)
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_scan_result(NET_802_11_SCAN_RESULT_T *pScanResult);

/*------------------------------------------------------------------*/
/*! @brief Get a list of ESSs.This routine lists the ESSs enties and sorts in descending order
 *             of the signal strength. The stealth networks are attached the BSSIDs. 
 *             Adhoc networks are not listed in the table.
 *  @param [in,out]  pEssList -list of ESSs
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_ess_list(NET_802_11_ESS_LIST_T *pEssList);

/*------------------------------------------------------------------*/
/*! @brief Associate with a wireless network.
 *            This routine triggers attempts of connecting to a wireless network according
 *            to the specified settings. After calling this routine, the WLAN
 *            software continues to maintain a network connection according
 *            to the specified settings until c_net_wlan_disassociate() is called.
 *  @param [in] pAssociate -association settings
 *  @param [in] pfNotify -callback function to notify the association status.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_associate(NET_802_11_ASSOCIATE_T *pAssociate,
                                x_net_wlan_notify_fct pfNotify);

/*------------------------------------------------------------------*/
/*! @brief Disassociate a wireless network connection.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_disassociate(VOID);

/*------------------------------------------------------------------*/
/*! @brief Get the currently associated BSS information.
 *             This routine gets the information of the associated BSS.
 *             If this routine is called while connection is not established,
 *             zero-BSSID (00:00:00:00:00:00) is returned.
 *  @param [in,out] pCurrBss -associated BSS information
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_curr_bss(NET_802_11_BSS_INFO_T *pCurrBss);

/*------------------------------------------------------------------*/
/*! @brief Get WLAN MAC address.
 *	         This routine gets MAC address of WLAN interface described in binary form.
 *  @param [out] pMacAddr -buffer to store MAC address
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_mac_addr(UINT8 *pMacAddr);

/*------------------------------------------------------------------*/
/*! @brief Set WLAN MAC address.
 *  This routine sets MAC address of WLAN interface described in binary form.
 *  @param [in] pMacAddr -buffer to store MAC address
 *  @return     result
 *  @retval     0 -success 
 *  @retval     otherwise -failure
 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_set_mac_addr(UINT8 *pMacAddr);

/*------------------------------------------------------------------*/
/*! @brief Get WLAN EEPROM data.
 *             This routine gets the EEPROM data of WLAN device.
 *  @param [in,out] pEeprom -EEPROM address and data buffer.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_eeprom(NET_802_11_EEPORM_T *pEeprom);

/*------------------------------------------------------------------*/
/*! @brief Register WPA callback function.
 *  @param [in] pfNotify -callback function to notify the association status.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wpa_reg_cbk(x_net_wlan_notify_fct pfNotify);  

/*------------------------------------------------------------------*/
/*! @brief WPS registration and association.
 *	         This routine obtains association settings from a WPS registrer,
 *             save it in the disk and associate with the network.
 *  @param [in] eWpsMode -WPSOpMode "WPS Mode" WPS registration method.
 *  @param [out] pfNotify -callback function to notify WPS status.
 *  @return     result
 *  @retval     0 -success
 *  @retva      otherwise -failure  
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_associate(NET_802_11_WPS_ASSOC_MODE_T eWpsMode,
                                                x_net_wlan_notify_fct pfNotify);

/*------------------------------------------------------------------*/
/*! @brief Get the status of a WPS process.
 *             This routine gets the current WPS status.
 *  @param [out] status -WPSStatus "WPS status"
 *  @return    result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_get_status(INT32 *status);

/*------------------------------------------------------------------*/
/*! @brief Cancel WPS registration process.
 *	This routine tiriggers cancellation of WPS registration process.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_cancel(void);

/*------------------------------------------------------------------*/
/*! @brief Refresh WPS PIN code.
 *            This routine refreshes WPS PIN code.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_refresh_pin(void);

/*------------------------------------------------------------------*/
/*! @brief Get WPS PIN code.
 *	         This routine gets WPS PIN code. The PIN code is not refreshed
 *             by calling this routine.
 *  @param [in]   len -length of the buffer
 *  @param [out] pin -buffer of PIN code
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_get_pin(char *pin, UINT32 len);
/*------------------------------------------------------------------*/
/*! @brief cancel associate a wireless network connection.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_cancel_associate(VOID);

/*----------------------------------------------------------------------------*/
/*! @} */
/*----------------------------------------------------------------------------*/
 
#endif /* _C_NET_WLAN_H */
