예제 #1
0
static void reset_prov(os_timer_arg_t arg)
{
    wmprintf("start deprovisioning\r\n");
    if(is_provisioned()) {
        app_reset_saved_network();
    }
    else{
        pm_reboot_soc(); //reset again,just reboot
    }
}
예제 #2
0
/**********************************************************
 config cfg struct from otp
**********************************************************/
static void config_cfg_struct()
{
    bool * flag = get_read_otp_flag();

    if(false == (*flag)) {
        
        wlan_set_mac_addr(get_wlan_mac_address());
    
    } else {
    
        int ret;
        //get mac address 
        uint8_t mac[MLAN_MAC_ADDR_LENGTH];
        wlan_get_mac_address((uint8_t *)mac);
        memcpy(cfg_struct.mac_address,mac,MLAN_MAC_ADDR_LENGTH);

        //get key & did,lengthof(key) + lengthof(did) = 24  
        uint8_t buffer[24];
        ret = wlan_get_otp_user_data(buffer,24);
        if(WM_SUCCESS == ret) {
            //copy did & key to cfg_struct
            memcpy(cfg_struct.device_id,buffer,sizeof(cfg_struct.device_id));
            
            memcpy(cfg_struct.key,buffer+sizeof(cfg_struct.device_id),sizeof(buffer) - sizeof(cfg_struct.device_id));
        } else {
            LOG_ERROR("read otp fail \r\n");
            pm_reboot_soc();
        }
    }

    if(WM_SUCCESS != get_model_in_psm(cfg_struct.model,sizeof(cfg_struct.model))) {
        //cfg_struct.url is useless now, define module only
        strcpy(cfg_struct.model,DEFAULT_MODULE);
#if defined(CONFIG_CPU_MC200) && defined (CONFIG_WiFi_8801)
        strcat(cfg_struct.model,"1");
#elif defined(CONFIG_CPU_MC200) && defined (CONFIG_WiFi_878x)
        strcat(cfg_struct.model,"3");
#elif defined(CONFIG_CPU_MW300) && defined(MW300_68PIN)
        strcat(cfg_struct.model,"4");
#elif defined(CONFIG_CPU_MW300)
        strcat(cfg_struct.model,"2");
#endif
        set_model_in_psm(cfg_struct.model);
    
    }

}
예제 #3
0
VOID set_gw_prodinfo(IN CONST CHAR *prod_idx,IN CONST CHAR *mac)
{
    PROD_IF_REC_S prod_if;
    memset(&prod_if,0,sizeof(prod_if));
    ws_db_get_prod_if(&prod_if);
    if(prod_idx) {
        strcpy(prod_if.prod_idx,prod_idx);
    }

    if(mac) {
        strcpy(prod_if.mac,mac);
    }
    ws_db_set_prod_if(&prod_if);

    // reboot
    pm_reboot_soc();
}
예제 #4
0
static int reboot_warpper()
{
    pm_reboot_soc();
    return 0;
}
예제 #5
0
파일: main.c 프로젝트: caoguanqiu/midir
int main()
{
    int ret;

    	
	modules_init();//模块的初始化
    
	user_init();
    /* system tag data  */
    store_or_retrive_taged_config();
    
    get_mcu_version_from_psm();

    LOG_DEBUG("rst cause is %x\r\n", boot_reset_cause());

#ifdef MIIO_COMMANDS
    mcmd_enqueue_raw("MIIO_model_req");
    mcmd_enqueue_raw("MIIO_mcu_version_req");
#endif

    ret = os_mutex_create(&network_state_mutex,"network_state",OS_MUTEX_INHERIT);
    if(WM_SUCCESS != ret) {
        LOG_ERROR("create network_state_mutex fail");
        goto main_error;
    }

    register_device_network_state_observer(led_network_state_observer);
    
    /*set wifi calbration data*/
    product_set_wifi_cal_data();

    /* Start the application framework */
    if ((ret = app_framework_start(common_event_handler)) != WM_SUCCESS) {
        LOG_ERROR("Failed to start application framework.\r\n");
#if defined(CONFIG_CPU_MC200)
        if (-WLAN_ERROR_FW_DNLD_FAILED == ret || -WLAN_ERROR_FW_NOT_DETECTED == ret
                || -WLAN_ERROR_FW_NOT_READY == ret) {
            LOG_WARN("Wifi firmware broken, trying to recover.\r\n");
            if (recover_wifi_fw() != WM_SUCCESS) {
                LOG_FATAL("Recovering wifi fw failed!!!\r\n");
            } else {
                LOG_WARN("Recovering wifi fw success.\r\n");
                pm_reboot_soc();
            }
        }
#endif
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    ret = is_factory_mode_enable();
    LOG_DEBUG("factory mode magic is %x\r\n" ,get_factory_mode_enable());
    if (0 == ret) {
        // user mode
        static xTaskHandle task_handle;
        if (app_thread) {
            xTaskCreate(app_thread, (signed char*) "app", 2000, NULL, APPLICATION_PRIORITY,
                    &task_handle);
            xTaskCreate(app_uart_thread, (signed char*) "app_uart", 2000, NULL, APPLICATION_PRIORITY,
                    &task_handle);
            LOG_INFO("App thread and App uart thread started.\r\n");
        }
    } else {
        // factory mode
        static xTaskHandle task_handle;
        if (app_test_thread) {
            xTaskCreate(app_test_thread, (signed char*) "test", 2000, NULL, 2,
                    &task_handle);
            LOG_INFO("Test thread started.\r\n");
        }
    }
    
    // Initialize power management
	hp_pm_init();
    
    //enter main loop, main loop will be used as a worker thread
    main_loop_run();

    //main loop return means error
main_error: 
    pm_reboot_soc(); //error occure on main thread , reboot
	return 1;
}
예제 #6
0
VOID set_gw_data_fac_reset(VOID)
{
    ws_db_reset();
    // reboot
    pm_reboot_soc();
}
예제 #7
0
void event_normal_reset_prov(void *data) {
    pm_reboot_soc();
}