/* Handle the background events of the wifi module.  */
WIFI_Status_t WIFI_HandleAPEvents(WIFI_APSettings_t *setting)
/* Handle the background events of the wifi module.  */
WIFI_Status_t WIFI_HandleAPEvents(WIFI_APSettings_t *setting)
{
  WIFI_Status_t ret = WIFI_STATUS_OK;
  ES_WIFI_APState_t State;
  State= ES_WIFI_WaitAPStateChange(&EsWifiObj);
  switch (State)
  {
  case ES_WIFI_AP_ASSIGNED:
    memcpy(setting->IP_Addr, EsWifiObj.APSettings.IP_Addr, 4);
    memcpy(setting->MAC_Addr, EsWifiObj.APSettings.MAC_Addr, 6);
    ret = WIFI_STATUS_ASSIGNED;
    break;
  case ES_WIFI_AP_JOINED:
    strncpy((char *)setting->SSID, (char *)EsWifiObj.APSettings.SSID, WIFI_MAX_SSID_NAME);
    memcpy(setting->IP_Addr, EsWifiObj.APSettings.IP_Addr, 4);
    ret = WIFI_STATUS_JOINED;
    break;
  case ES_WIFI_AP_ERROR:
    ret = WIFI_STATUS_ERROR;
    break;
  default:
    break;
  }
  return ret;
}