int is_wps_stopped(void) { int status, ret = 1; status = getWscStatus(); if (status != 1) count = 0; else count++; // dbG("wps status: %d, count: %d\n", status, count); switch (status) { case 1: /* Idle */ if (count < 5) ret = 0; break; case 34: /* Configured */ dbG("\nWPS Configured\n"); break; case 0x109: /* PBC_SESSION_OVERLAP */ dbG("\nWPS PBC SESSION OVERLAP\n"); break; case 2: /* Failed */ if (!g_isEnrollee) { dbG("\nWPS Failed\n"); break; } default: ret = 0; break; } return ret; // TODO: handle enrollee }
int is_wps_stopped(void) { int i, ret = 1; char status[16], tmp[128], prefix[] = "wlXXXXXXXXXX_", word[256], *next, ifnames[128]; int wps_band = nvram_get_int("wps_band"), multiband = get_wps_multiband(); i = 0; strcpy(ifnames, nvram_safe_get("wl_ifnames")); foreach (word, ifnames, next) { if (i >= MAX_NR_WL_IF) break; if (!multiband && wps_band != i) { ++i; continue; } snprintf(prefix, sizeof(prefix), "wl%d_", i); if (!__need_to_start_wps_band(prefix) || nvram_match(strcat_r(prefix, "radio", tmp), "0")) { ret = 0; ++i; continue; } #ifdef RTCONFIG_WPS_ENROLLEE if (nvram_match("wps_enrollee", "1")) strcpy(status, getWscStatus_enrollee(i)); else #endif strcpy(status, getWscStatus(i)); //dbG("band %d wps status: %s\n", i, status); if (!strcmp(status, "Success") #ifdef RTCONFIG_WPS_ENROLLEE || !strcmp(status, "COMPLETED") #endif ) { dbG("\nWPS %s\n", status); #ifdef RTCONFIG_WPS_LED nvram_set("wps_success", "1"); #endif #if (defined(RTCONFIG_WPS_ENROLLEE) && defined(RTCONFIG_WIFI_CLONE)) if (nvram_match("wps_enrollee", "1")) { nvram_set("wps_e_success", "1"); #if defined(PLN12) set_wifiled(4); #endif wifi_clone(i); } #endif ret = 1; } else if (!strcmp(status, "Failed") #ifdef RTCONFIG_WPS_ENROLLEE || !strcmp(status, "INACTIVE") #endif ) { dbG("\nWPS %s\n", status); ret = 1; } else ret = 0; if (ret) break; ++i; } return ret; }
void btn_check(void) { #ifdef BTN_SETUP if (btn_pressed_setup == BTNSETUP_NONE) { #endif #ifdef SR3 if (!ralink_gpio_read_bit(BTN_RESET)) // reset button is on low phase #else if (0) #endif { /*--------------- Add BTN_RST MFG test ------------------------*/ if (!nvram_match("asus_mfg", "0")) { nvram_set("btn_rst", "1"); } else { if (!btn_pressed) { btn_pressed = 1; btn_count = 0; alarmtimer(0, URGENT_PERIOD); } else { /* Whenever it is pushed steady */ if (++btn_count > RESET_WAIT_COUNT) { dbg("You can release RESET button now!\n"); btn_pressed = 2; } if (btn_pressed == 2) { /* 0123456789 */ /* 0011100111 */ if ((btn_count % 10) < 1 || ((btn_count % 10) > 4 && (btn_count % 10) < 7)) LED_CONTROL(LED_POWER, LED_OFF); else LED_CONTROL(LED_POWER, LED_ON); } } } // end BTN_RST MFG test } else { if (btn_pressed == 1) { btn_count = 0; btn_pressed = 0; LED_CONTROL(LED_POWER, LED_ON); alarmtimer(NORMAL_PERIOD, 0); } else if (btn_pressed == 2) { LED_CONTROL(LED_POWER, LED_OFF); alarmtimer(0, 0); system("erase /dev/mtd1"); // kill(1, SIGTERM); sys_exit(); } } #ifdef BTN_SETUP } if (btn_pressed != 0) return; if (btn_pressed_setup < BTNSETUP_START) { if (!ralink_gpio_read_bit(BTN_WPS) && !no_need_to_start_wps(0)) { /* Add BTN_EZ MFG test */ if (!nvram_match("asus_mfg", "0")) { nvram_set("btn_ez", "1"); } else { if (btn_pressed_setup == BTNSETUP_NONE) { btn_pressed_setup = BTNSETUP_DETECT; btn_count_setup = 0; alarmtimer(0, RUSHURGENT_PERIOD); } else { /* Whenever it is pushed steady */ if (++btn_count_setup > SETUP_WAIT_COUNT) { if (!nvram_match("sw_mode_ex", "3")) { stop_wsc(); stop_wsc_2g(); nvram_set("wps_enable", "0"); #if (!defined(W7_LOGO) && !defined(WIFI_LOGO)) nvram_set("wps_triggered", "1"); // psp fix #endif btn_pressed_setup = BTNSETUP_START; btn_count_setup = 0; btn_count_setup_second = 0; #if defined (W7_LOGO) || defined (WIFI_LOGO) if (nvram_match("wps_band", "0")) start_wsc_pbc(); else start_wsc_pbc_2g(); #else #if 0 start_wsc_pbc_both(); #else nvram_set("wps_band", "1"); start_wsc_pbc_2g(); #endif #endif WscStatus_old = -1; WscStatus_old_2g = -1; wsc_timeout = 120*20; } } } } // end BTN_EZ MFG test } else if (btn_pressed_setup == BTNSETUP_DETECT) { btn_pressed_setup = BTNSETUP_NONE; btn_count_setup = 0; LED_CONTROL(LED_POWER, LED_ON); alarmtimer(NORMAL_PERIOD, 0); } } else { if (!ralink_gpio_read_bit(BTN_WPS) && !no_need_to_start_wps(0)) { /* Whenever it is pushed steady, again... */ if (++btn_count_setup_second > SETUP_WAIT_COUNT) { if (!nvram_match("sw_mode_ex", "3")) { stop_wsc(); stop_wsc_2g(); nvram_set("wps_enable", "0"); #if (!defined(W7_LOGO) && !defined(WIFI_LOGO)) nvram_set("wps_triggered", "1"); // psp fix #endif dbg("pushed again...\n"); btn_pressed_setup = BTNSETUP_START; btn_count_setup_second = 0; #if defined (W7_LOGO) || defined (WIFI_LOGO) if (nvram_match("wps_band", "0")) start_wsc_pbc(); else start_wsc_pbc_2g(); #else #if 0 start_wsc_pbc_both(); #else nvram_set("wps_band", "1"); start_wsc_pbc_2g(); #endif #endif WscStatus_old = -1; WscStatus_old_2g = -1; wsc_timeout = 120*20; } #if 0 else { dbg("pushed again... do nothing...\n"); /* btn_pressed_setup = BTNSETUP_START; btn_count_setup_second = 0; sta_wps_pbc(); wsc_timeout = 120*20; */ } #endif } } struct _WSC_CONFIGURED_VALUE wsc_value; int int_stop_wps_led = 0; int WscStatus = -1; int WscStatus_2g = -1; if (nvram_match("wps_mode", "1")) // PIN { if (nvram_match("wps_band", "0")) WscStatus = getWscStatus(); else WscStatus = getWscStatus_2g(); } else // PBC { WscStatus = getWscStatus(); WscStatus_2g = getWscStatus_2g(); } if (WscStatus_old != WscStatus) { WscStatus_old = WscStatus; dbg("WscStatus: %d\n", WscStatus); } if (nvram_match("wps_mode", "2") && WscStatus_old_2g != WscStatus_2g) { WscStatus_old_2g = WscStatus_2g; dbg("WscStatus_2g: %d\n", WscStatus_2g); } if (WscStatus == 2 || WscStatus_2g == 2)// Wsc Process failed { if (g_isEnrollee) ; // go on monitoring else { int_stop_wps_led = 1; dbg("%s", "Error occured. Is the PIN correct?\n"); } } // Driver 1.9 supports AP PBC Session Overlapping Detection. if (WscStatus == 0x109 /* PBC_SESSION_OVERLAP */ || WscStatus_2g == 0x109) { dbg("PBC_SESSION_OVERLAP\n"); int_stop_wps_led = 1; } if (nvram_match("wps_mode", "1")) // PIN { if (WscStatus == 34 /* Configured*/) { /* dbg("getWscProfile()\n"); getWscProfile(WIF, &wsc_value, sizeof(WSC_CONFIGURED_VALUE)); */ if (!g_wsc_configured) g_wsc_configured = 1; int_stop_wps_led = 1; g_isEnrollee = 0; } } else // PBC { if (WscStatus == 34 /* Configured*/ || WscStatus_2g == 34) { if (!g_wsc_configured) g_wsc_configured = 1; int_stop_wps_led = 1; g_isEnrollee = 0; } } if (int_stop_wps_led || --wsc_timeout == 0) { if(!nvram_match("sw_mode_ex", "3")) // not AP mode { #if (!defined(W7_LOGO) && !defined(WIFI_LOGO)) nvram_set("wps_triggered", "1");// psp fix #endif wsc_timeout = 0; btn_pressed_setup = BTNSETUP_NONE; btn_count_setup = 0; LED_CONTROL(LED_POWER, LED_ON); alarmtimer(NORMAL_PERIOD, 0); #if (!defined(W7_LOGO) && !defined(WIFI_LOGO)) // if (nvram_match("wps_band", "0")) stop_wsc(); // psp fix // else stop_wsc_2g(); // psp fix nvram_set("wps_enable", "0"); // psp fix #endif } return; } ++btn_count_setup; btn_count_setup = (btn_count_setup % 20); /* 0123456789 */ /* 1010101010 */ if ((btn_count_setup % 2) == 0 && (btn_count_setup > 10)) LED_CONTROL(LED_POWER, LED_ON); else LED_CONTROL(LED_POWER, LED_OFF); } #endif }