【Alios-things筆記】嵌入式Linux平臺使能WIFI配網和本地通訊

概述

在Alios-things中雖然有linuxhost程序可以運行,但是這個編譯出來的程序出來的應用程序只能運行在x86平臺,如果想讓嵌入式Linux系統的設備接入阿里的物聯網平臺或者智能生活開放平臺,只能使用阿里提供的iotx-sdk-c SDK。
Link Kit SDK用戶手冊

問題

在MT7688上運行OpenWrt開源路由系統,並使用iotx-sdk-cSDK將其接入阿里智能生活開放平臺上,當使用生活開放平臺提供的公版APP,在同一個局域網下,無法發現和綁定設備。

解決方法及步驟

無法發現和綁定SDK是由於SDK中沒有WIFI配網和本地通訊的模塊,在sdk的V2.2版本之前需要提供交叉編譯工具向阿里索取libawss.a靜態庫文件,並將其添加到工程中即可,V2.2.1之後,iotx-sdk-c將WIFI配網模塊和本地通訊模塊進行了開源。同時還需要修改或添加下面的內容

  1. 修改iotx_cm_common.c文件
    在該文件中有一個awss_report_cloud()函數,將其做如下修改
    這裏寫圖片描述
  2. 增加WIFI相關的接口
    awss庫需要底層接口支持,這些接口的實現與硬件平臺密切相關,所以需要在iotx-sdk-c/src/ref-impl/hal/os/OpenWrt下實現相應的接口,接口定義位於SDK的iot_import_awss.h頭文件中。
/**
 * @brief   在設備的持久化外部存儲器比如Flash上, 從配置區域起始位置讀取數據到指定的內存緩衝區中
 *
 * @param   buffer : 存放讀取配置信息的緩衝區起始地址
 * @param   length : 將要讀取的數據長度, 單位是字節(Byte)
 * @retval  -1 : 讀取失敗
 * @retval  0 : 讀取成功
 */
int HAL_Config_Read(_IN_ char *buffer, _IN_ int length);

/**
 * @brief   在設備的持久化外部存儲器比如Flash上, 把指定的內存緩衝區向配置區域起始位置寫入
 *
 * @param   buffer : 存放要寫到外存的數據的緩衝區
 * @param   length : 將要寫入的數據長度, 單位是字節(Byte)
 * @retval  -1 : 寫入失敗
 * @retval  0 : 寫入成功
 */
int HAL_Config_Write(_IN_ const char *buffer, _IN_ int length);

/**
 * @brief   獲取Wi-Fi的接受信號強度(`RSSI`)
 *
 * @return  信號強度數值, 單位是dBm
 */
int HAL_Wifi_Get_Rssi_Dbm(void);

/**
 * @brief   使WiFi模組進入省電模式, 並持續一段時間
 *
 * @param   指定在多長時間內, WiFi模組都處於省電模式, 單位是毫秒
 * @retval  0 : 設置成功
 * @retval  -1 : 設置失敗
 *
 * @note sample code
 * int HAL_Wifi_Low_Power(int timeout_ms)
 * {
 *      wifi_enter_power_saving_mode();
 *      msleep(timeout_ms);
 *      wifi_exit_power_saving_mode();
 *
 *      return 0;
 * }
 */
int HAL_Wifi_Low_Power(_IN_ int timeout_ms);

/**
 * @brief   獲取RF433的接收信號強度(`RSSI`)
 *
 * @return  信號強度數值, 單位是dBm
 */
int HAL_RF433_Get_Rssi_Dbm(void);

/**
 * @brief   獲取Wi-Fi網口的MAC地址, 格式應當是"XX:XX:XX:XX:XX:XX"
 *
 * @param   mac_str : 用於存放MAC地址字符串的緩衝區數組
 * @return  指向緩衝區數組起始位置的字符指針
 */
char *HAL_Wifi_Get_Mac(_OU_ char mac_str[HAL_MAC_LEN]);

#define HAL_IP_LEN    (15 + 1)
/**
 * @brief   獲取Wi-Fi網口的IP地址, 點分十進制格式保存在字符串數組出參, 二進制格式則作爲返回值, 並以網絡字節序(大端)表達
 *
 * @param   ifname : 指定Wi-Fi網絡接口的名字
 * @param   ip_str : 存放點分十進制格式的IP地址字符串的數組
 * @return  二進制形式的IP地址, 以網絡字節序(大端)組織
 */
uint32_t HAL_Wifi_Get_IP(_OU_ char ip_str[HAL_IP_LEN], _IN_ const char *ifname);

/**
 * @brief   獲取Wi-Fi模塊上的操作系統版本字符串
 *
 * @param   version_str : 存放版本字符串的緩衝區數組
 * @return  指向緩衝區數組的起始地址
 */
char *HAL_Wifi_Get_Os_Version(_OU_ char version_str[STR_SHORT_LEN]);

/**
 * @brief   獲取配網服務(`AWSS`)的超時時間長度, 單位是毫秒
 *
 * @return  超時時長, 單位是毫秒
 * @note    推薦時長是60,0000毫秒
 */
int HAL_Awss_Get_Timeout_Interval_Ms(void);

/**
 * @brief   獲取配網服務(`AWSS`)超時時長到達之後, 去連接默認SSID時的超時時長, 單位是毫秒
 *
 * @return  超時時長, 單位是毫秒
 * @note    推薦時長是0毫秒, 含義是永遠持續
 */
int HAL_Awss_Get_Connect_Default_Ssid_Timeout_Interval_Ms(void);

/**
 * @brief   獲取在每個信道(`channel`)上掃描的時間長度, 單位是毫秒
 *
 * @return  時間長度, 單位是毫秒
 * @note    推薦時長是200毫秒到400毫秒
 */
int HAL_Awss_Get_Channelscan_Interval_Ms(void);

/* link type */
enum AWSS_LINK_TYPE {
    /* rtos HAL choose this type */
    AWSS_LINK_TYPE_NONE,

    /* linux HAL may choose the following type */
    AWSS_LINK_TYPE_PRISM,
    AWSS_LINK_TYPE_80211_RADIO,
    AWSS_LINK_TYPE_80211_RADIO_AVS,
    AWSS_LINK_TYPE_HT40_CTRL /* for espressif HAL, see struct ht40_ctrl */
};

struct HAL_Ht40_Ctrl {
    uint16_t    length;
    uint8_t     filter;
    signed char rssi;
};

/**
 * @brief   802.11幀的處理函數, 可以將802.11 Frame傳遞給這個函數
 *
 * @param[in] buf @n 80211 frame buffer, or pointer to struct ht40_ctrl
 * @param[in] length @n 80211 frame buffer length
 * @param[in] link_type @n AWSS_LINK_TYPE_NONE for most rtos HAL,
 *              and for linux HAL, do the following step to check
 *              which header type the driver supported.
   @verbatim
               a) iwconfig wlan0 mode monitor    #open monitor mode
               b) iwconfig wlan0 channel 6    #switch channel 6
               c) tcpdump -i wlan0 -s0 -w file.pacp    #capture 80211 frame & save
               d) open file.pacp with wireshark or omnipeek
                   check the link header type and fcs included or not
   @endverbatim
 * @param[in] with_fcs @n 80211 frame buffer include fcs(4 byte) or not
 * @param[in] rssi @n rssi of packet, range of [-127, -1]
 */
typedef int (*awss_recv_80211_frame_cb_t)(char *buf, int length,
        enum AWSS_LINK_TYPE link_type, int with_fcs, signed char rssi);

/**
 * @brief   設置Wi-Fi網卡工作在監聽(Monitor)模式, 並在收到802.11幀的時候調用被傳入的回調函數
 *
 * @param[in] cb @n A function pointer, called back when wifi receive a frame.
 */
void HAL_Awss_Open_Monitor(_IN_ awss_recv_80211_frame_cb_t cb);

/**
 * @brief   設置Wi-Fi網卡離開監聽(Monitor)模式, 並開始以站點(Station)模式工作
 */
void HAL_Awss_Close_Monitor(void);

/**
 * @brief   設置Wi-Fi網卡切換到指定的信道(channel)上
 *
 * @param[in] primary_channel @n Primary channel.
 * @param[in] secondary_channel @n Auxiliary channel if 40Mhz channel is supported, currently
 *              this param is always 0.
 * @param[in] bssid @n A pointer to wifi BSSID on which awss lock the channel, most HAL
 *              may ignore it.
 */
void HAL_Awss_Switch_Channel(
            _IN_ char primary_channel,
            _IN_OPT_ char secondary_channel,
            _IN_OPT_ uint8_t bssid[ETH_ALEN]);

/**
 * @brief   要求Wi-Fi網卡連接指定熱點(Access Point)的函數
 *
 * @param[in] connection_timeout_ms @n AP connection timeout in ms or HAL_WAIT_INFINITE
 * @param[in] ssid @n AP ssid
 * @param[in] passwd @n AP passwd
 * @param[in] auth @n optional(AWSS_AUTH_TYPE_INVALID), AP auth info
 * @param[in] encry @n optional(AWSS_ENC_TYPE_INVALID), AP encry info
 * @param[in] bssid @n optional(NULL or zero mac address), AP bssid info
 * @param[in] channel @n optional, AP channel info
 * @return
   @verbatim
     = 0: connect AP & DHCP success
     = -1: connect AP or DHCP fail/timeout
   @endverbatim
 * @see None.
 * @note
 *      If the STA connects the old AP, HAL should disconnect from the old AP firstly.
 *      If bssid specifies the dest AP, HAL should use bssid to connect dest AP.
 */
int HAL_Awss_Connect_Ap(
            _IN_ uint32_t connection_timeout_ms,
            _IN_ char ssid[HAL_MAX_SSID_LEN],
            _IN_ char passwd[HAL_MAX_PASSWD_LEN],
            _IN_OPT_ enum AWSS_AUTH_TYPE auth,
            _IN_OPT_ enum AWSS_ENC_TYPE encry,
            _IN_OPT_ uint8_t bssid[ETH_ALEN],
            _IN_OPT_ uint8_t channel);

/**
 * @brief check system network is ready(get ip address) or not.
 *
 * @param None.
 * @return 0, net is not ready; 1, net is ready.
 * @see None.
 * @note None.
 */
int HAL_Sys_Net_Is_Ready();

/**
 * @brief   在當前信道(channel)上以基本數據速率(1Mbps)發送裸的802.11幀(raw 802.11 frame)
 *
 * @param[in] type @n see enum HAL_Awss_frame_type, currently only FRAME_BEACON
 *                      FRAME_PROBE_REQ is used
 * @param[in] buffer @n 80211 raw frame, include complete mac header & FCS field
 * @param[in] len @n 80211 raw frame length
 * @return
   @verbatim
   =  0, send success.
   = -1, send failure.
   = -2, unsupported.
   @endverbatim
 * @see None.
 * @note awss use this API send raw frame in wifi monitor mode & station mode
 */
int HAL_Wifi_Send_80211_Raw_Frame(_IN_ enum HAL_Awss_Frame_Type type,
                                  _IN_ uint8_t *buffer, _IN_ int len);

/**
 * @brief   管理幀的處理回調函數
 *
 * @param[in] buffer @n 80211 raw frame or ie(information element) buffer
 * @param[in] len @n buffer length
 * @param[in] rssi_dbm @n rssi in dbm, range of [-127, -1], set it to -1 if not supported
 * @param[in] buffer_type @n 0 when buffer is a 80211 frame,
 *                          1 when buffer only contain IE info
 * @return None.
 * @see None.
 * @note None.
 */
typedef void (*awss_wifi_mgmt_frame_cb_t)(_IN_ uint8_t *buffer, _IN_ int len,
        _IN_ signed char rssi_dbm, _IN_ int buffer_type);

/**
 * @brief   在站點(Station)模式下使能或禁用對管理幀的過濾
 *
 * @param[in] filter_mask @n see mask macro in enum HAL_Awss_frame_type,
 *                      currently only FRAME_PROBE_REQ_MASK & FRAME_BEACON_MASK is used
 * @param[in] vendor_oui @n oui can be used for precise frame match, optional
 * @param[in] callback @n see awss_wifi_mgmt_frame_cb_t, passing 80211
 *                      frame or ie to callback. when callback is NULL
 *                      disable sniffer feature, otherwise enable it.
 * @return
   @verbatim
   =  0, success
   = -1, fail
   = -2, unsupported.
   @endverbatim
 * @see None.
 * @note awss use this API to filter specific mgnt frame in wifi station mode
 */
int HAL_Wifi_Enable_Mgmt_Frame_Filter(
            _IN_ uint32_t filter_mask,
            _IN_OPT_ uint8_t vendor_oui[3],
            _IN_ awss_wifi_mgmt_frame_cb_t callback);

typedef struct {
    enum AWSS_AUTH_TYPE auth;
    enum AWSS_ENC_TYPE encry;
    uint8_t channel;
    signed char rssi_dbm;
    char ssid[HAL_MAX_SSID_LEN];
    uint8_t mac[ETH_ALEN];
} awss_ap_info_t;

/**
 * @brief handle one piece of AP information from wifi scan result
 *
 * @param[in] ssid @n name of AP
 * @param[in] bssid @n mac address of AP
 * @param[in] channel @n AP channel
 * @param[in] rssi @n rssi range[-127, -1].
 *          the higher the RSSI number, the stronger the signal.
 * @param[in] is_last_ap @n this AP information is the last one if is_last_ap > 0.
 *          this AP information is not the last one if is_last_ap == 0.
 * @return 0 for wifi scan is done, otherwise return -1
 * @see None.
 * @note None.
 */
typedef int (*awss_wifi_scan_result_cb_t)(
            const char ssid[HAL_MAX_SSID_LEN],
            const uint8_t bssid[ETH_ALEN],
            enum AWSS_AUTH_TYPE auth,
            enum AWSS_ENC_TYPE encry,
            uint8_t channel, signed char rssi,
            int is_last_ap);

/**
 * @brief   啓動一次Wi-Fi的空中掃描(Scan)
 *
 * @param[in] cb @n pass ssid info(scan result) to this callback one by one
 * @return 0 for wifi scan is done, otherwise return -1
 * @see None.
 * @note
 *      This API should NOT exit before the invoking for cb is finished.
 *      This rule is something like the following :
 *      HAL_Wifi_Scan() is invoked...
 *      ...
 *      for (ap = first_ap; ap <= last_ap; ap = next_ap){
 *        cb(ap)
 *      }
 *      ...
 *      HAL_Wifi_Scan() exit...
 */
int HAL_Wifi_Scan(awss_wifi_scan_result_cb_t cb);

/**
 * @brief   獲取所連接的熱點(Access Point)的信息
 *
 * @param[out] ssid: array to store ap ssid. It will be null if ssid is not required.
 * @param[out] passwd: array to store ap password. It will be null if ap password is not required.
 * @param[out] bssid: array to store ap bssid. It will be null if bssid is not required.
 * @return
   @verbatim
     = 0: succeeded
     = -1: failed
   @endverbatim
 * @see None.
 * @note
 *     If the STA dosen't connect AP successfully, HAL should return -1 and not touch the ssid/passwd/bssid buffer.
 */
int HAL_Wifi_Get_Ap_Info(
            _OU_ char ssid[HAL_MAX_SSID_LEN],
            _OU_ char passwd[HAL_MAX_PASSWD_LEN],
            _OU_ uint8_t bssid[ETH_ALEN]);

/**
 * @brief   獲取`smartconfig`服務的安全等級
 *
 * @param None.
 * @return The security level:
   @verbatim
    0: open (no encrypt)
    1: aes256cfb with default aes-key and aes-iv
    2: aes128cfb with default aes-key and aes-iv
    3: aes128cfb with aes-key per product and aes-iv = 0
    4: aes128cfb with aes-key per device and aes-iv = 0
    5: aes128cfb with aes-key per manufacture and aes-iv = 0
    others: invalid
   @endverbatim
 * @see None.
 */
int HAL_Awss_Get_Encrypt_Type();

/**
 * @brief    Get Security level for wifi configuration with connection.
 *           Used for AP solution of router and App.
 *
 * @param None.
 * @return The security level:
   @verbatim
    3: aes128cfb with aes-key per product and aes-iv = random
    4: aes128cfb with aes-key per device and aes-iv = random
    5: aes128cfb with aes-key per manufacture and aes-iv = random
    others: invalid
   @endverbatim
 * @see None.
 */
int HAL_Awss_Get_Conn_Encrypt_Type();

接口實現如下所示:
或者參考Alios-things 中rhino的實現
https://github.com/alibaba/AliOS-Things/blob/master/framework/protocol/linkkit/iotkit/hal-impl/rhino/HAL_AWSS_rhino.c



/**
 * @brief   獲取Wi-Fi的接受信號強度(`RSSI`)
 *
 * @return  信號強度數值, 單位是dBm
 */
int HAL_Wifi_Get_Rssi_Dbm(void)
{
    return 0;
}


/**
 * @brief   使WiFi模組進入省電模式, 並持續一段時間
 *
 * @param   指定在多長時間內, WiFi模組都處於省電模式, 單位是毫秒
 * @retval  0 : 設置成功
 * @retval  -1 : 設置失敗
 *
 * @note sample code
 * int HAL_Wifi_Low_Power(int timeout_ms)
 * {
 *      wifi_enter_power_saving_mode();
 *      msleep(timeout_ms);
 *      wifi_exit_power_saving_mode();
 *
 *      return 0;
 * }
 */
int HAL_Wifi_Low_Power(_IN_ int timeout_ms)
{
    return 0;
}

/**
 * @brief   獲取Wi-Fi網口的MAC地址, 格式應當是"XX:XX:XX:XX:XX:XX"
 *
 * @param   mac_str : 用於存放MAC地址字符串的緩衝區數組
 * @return  指向緩衝區數組起始位置的字符指針
 */
char *HAL_Wifi_Get_Mac(_OU_ char mac_str[HAL_MAC_LEN])
{
    memcpy(mac_str,"12:34:56:78:90:1A",HAL_MAC_LEN);

    return mac_str;
}


/**
 * @brief   獲取Wi-Fi模塊上的操作系統版本字符串
 *
 * @param   version_str : 存放版本字符串的緩衝區數組
 * @return  指向緩衝區數組的起始地址
 */
#define AOS_VERSION_STR "aos1.2.0"
char *HAL_Wifi_Get_Os_Version(_OU_ char version_str[STR_SHORT_LEN])
{
    return strncpy(version_str, AOS_VERSION_STR, sizeof(AOS_VERSION_STR));
}

/**
 * @brief   獲取配網服務(`AWSS`)的超時時間長度, 單位是毫秒
 *
 * @return  超時時長, 單位是毫秒
 * @note    推薦時長是60,0000毫秒
 */
int HAL_Awss_Get_Timeout_Interval_Ms(void)
{

    return 3 * 60 * 1000;
}

/**
 * @brief   獲取配網服務(`AWSS`)超時時長到達之後, 去連接默認SSID時的超時時長, 單位是毫秒
 *
 * @return  超時時長, 單位是毫秒
 * @note    推薦時長是0毫秒, 含義是永遠持續
 */
int HAL_Awss_Get_Connect_Default_Ssid_Timeout_Interval_Ms(void)
{
    return 0;
}

/**
 * @brief   獲取在每個信道(`channel`)上掃描的時間長度, 單位是毫秒
 *
 * @return  時間長度, 單位是毫秒
 * @note    推薦時長是200毫秒到400毫秒
 */
int HAL_Awss_Get_Channelscan_Interval_Ms(void)
{
    return 200;
}



/**
 * @brief   設置Wi-Fi網卡工作在監聽(Monitor)模式, 並在收到802.11幀的時候調用被傳入的回調函數
 *
 * @param[in] cb @n A function pointer, called back when wifi receive a frame.
 */

void HAL_Awss_Open_Monitor(_IN_ awss_recv_80211_frame_cb_t cb)
{


}

/**
 * @brief   設置Wi-Fi網卡離開監聽(Monitor)模式, 並開始以站點(Station)模式工作
 */
void HAL_Awss_Close_Monitor(void)
{

}

/**
 * @brief   設置Wi-Fi網卡切換到指定的信道(channel)上
 *
 * @param[in] primary_channel @n Primary channel.
 * @param[in] secondary_channel @n Auxiliary channel if 40Mhz channel is supported, currently
 *              this param is always 0.
 * @param[in] bssid @n A pointer to wifi BSSID on which awss lock the channel, most HAL
 *              may ignore it.
 */
void HAL_Awss_Switch_Channel(
            _IN_ char primary_channel,
            _IN_OPT_ char secondary_channel,
            _IN_OPT_ uint8_t bssid[ETH_ALEN])
            {


            }

/**
 * @brief   要求Wi-Fi網卡連接指定熱點(Access Point)的函數
 *
 * @param[in] connection_timeout_ms @n AP connection timeout in ms or HAL_WAIT_INFINITE
 * @param[in] ssid @n AP ssid
 * @param[in] passwd @n AP passwd
 * @param[in] auth @n optional(AWSS_AUTH_TYPE_INVALID), AP auth info
 * @param[in] encry @n optional(AWSS_ENC_TYPE_INVALID), AP encry info
 * @param[in] bssid @n optional(NULL or zero mac address), AP bssid info
 * @param[in] channel @n optional, AP channel info
 * @return
   @verbatim
     = 0: connect AP & DHCP success
     = -1: connect AP or DHCP fail/timeout
   @endverbatim
 * @see None.
 * @note
 *      If the STA connects the old AP, HAL should disconnect from the old AP firstly.
 *      If bssid specifies the dest AP, HAL should use bssid to connect dest AP.
 */
int HAL_Awss_Connect_Ap(
            _IN_ uint32_t connection_timeout_ms,
            _IN_ char ssid[HAL_MAX_SSID_LEN],
            _IN_ char passwd[HAL_MAX_PASSWD_LEN],
            _IN_OPT_ enum AWSS_AUTH_TYPE auth,
            _IN_OPT_ enum AWSS_ENC_TYPE encry,
            _IN_OPT_ uint8_t bssid[ETH_ALEN],
            _IN_OPT_ uint8_t channel)
            {

                return -1;
            }

/**
 * @brief check system network is ready(get ip address) or not.
 *
 * @param None.
 * @return 0, net is not ready; 1, net is ready.
 * @see None.
 * @note None.
 */
int HAL_Sys_Net_Is_Ready()
{
    return 1;

}

/**
 * @brief   在當前信道(channel)上以基本數據速率(1Mbps)發送裸的802.11幀(raw 802.11 frame)
 *
 * @param[in] type @n see enum HAL_Awss_frame_type, currently only FRAME_BEACON
 *                      FRAME_PROBE_REQ is used
 * @param[in] buffer @n 80211 raw frame, include complete mac header & FCS field
 * @param[in] len @n 80211 raw frame length
 * @return
   @verbatim
   =  0, send success.
   = -1, send failure.
   = -2, unsupported.
   @endverbatim
 * @see None.
 * @note awss use this API send raw frame in wifi monitor mode & station mode
 */
int HAL_Wifi_Send_80211_Raw_Frame(_IN_ enum HAL_Awss_Frame_Type type,
                                  _IN_ uint8_t *buffer, _IN_ int len)
{
    return 0;

}

/**
 * @brief   在站點(Station)模式下使能或禁用對管理幀的過濾
 *
 * @param[in] filter_mask @n see mask macro in enum HAL_Awss_frame_type,
 *                      currently only FRAME_PROBE_REQ_MASK & FRAME_BEACON_MASK is used
 * @param[in] vendor_oui @n oui can be used for precise frame match, optional
 * @param[in] callback @n see awss_wifi_mgmt_frame_cb_t, passing 80211
 *                      frame or ie to callback. when callback is NULL
 *                      disable sniffer feature, otherwise enable it.
 * @return
   @verbatim
   =  0, success
   = -1, fail
   = -2, unsupported.
   @endverbatim
 * @see None.
 * @note awss use this API to filter specific mgnt frame in wifi station mode
 */
int HAL_Wifi_Enable_Mgmt_Frame_Filter(
            _IN_ uint32_t filter_mask,
            _IN_OPT_ uint8_t vendor_oui[3],
            _IN_ awss_wifi_mgmt_frame_cb_t callback)
            {
                return 0;
            }
/**
 * @brief   啓動一次Wi-Fi的空中掃描(Scan)
 *
 * @param[in] cb @n pass ssid info(scan result) to this callback one by one
 * @return 0 for wifi scan is done, otherwise return -1
 * @see None.
 * @note
 *      This API should NOT exit before the invoking for cb is finished.
 *      This rule is something like the following :
 *      HAL_Wifi_Scan() is invoked...
 *      ...
 *      for (ap = first_ap; ap <= last_ap; ap = next_ap){
 *        cb(ap)
 *      }
 *      ...
 *      HAL_Wifi_Scan() exit...
 */
int HAL_Wifi_Scan(awss_wifi_scan_result_cb_t cb)
{

    return 0;
}
/**
 * @brief   獲取所連接的熱點(Access Point)的信息
 *
 * @param[out] ssid: array to store ap ssid. It will be null if ssid is not required.
 * @param[out] passwd: array to store ap password. It will be null if ap password is not required.
 * @param[out] bssid: array to store ap bssid. It will be null if bssid is not required.
 * @return
   @verbatim
     = 0: succeeded
     = -1: failed
   @endverbatim
 * @see None.
 * @note
 *     If the STA dosen't connect AP successfully, HAL should return -1 and not touch the ssid/passwd/bssid buffer.
 */
int HAL_Wifi_Get_Ap_Info(
            _OU_ char ssid[HAL_MAX_SSID_LEN],
            _OU_ char passwd[HAL_MAX_PASSWD_LEN],
            _OU_ uint8_t bssid[ETH_ALEN])
            {
                return 0;

            }

/**
 * @brief   獲取`smartconfig`服務的安全等級
 *
 * @param None.
 * @return The security level:
   @verbatim
    0: open (no encrypt)
    1: aes256cfb with default aes-key and aes-iv
    2: aes128cfb with default aes-key and aes-iv
    3: aes128cfb with aes-key per product and aes-iv = 0
    4: aes128cfb with aes-key per device and aes-iv = 0
    5: aes128cfb with aes-key per manufacture and aes-iv = 0
    others: invalid
   @endverbatim
 * @see None.
 */
int HAL_Awss_Get_Encrypt_Type()
{
    return 3;

}

/**
 * @brief    Get Security level for wifi configuration with connection.
 *           Used for AP solution of router and App.
 *
 * @param None.
 * @return The security level:
   @verbatim
    3: aes128cfb with aes-key per product and aes-iv = random
    4: aes128cfb with aes-key per device and aes-iv = random
    5: aes128cfb with aes-key per manufacture and aes-iv = random
    others: invalid
   @endverbatim
 * @see None.
 */
int HAL_Awss_Get_Conn_Encrypt_Type()
{
    return 4;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章