result_t prf_initmgr() { result_t r; /* samples */ g_prf.samples_back = prf_create_samples(); g_prf.samples_front = prf_create_samples(); if (g_prf.samples_back == NULL || g_prf.samples_front == NULL) return RET_FAIL; mt_mutex_init(&g_prf.samples_mtx); /* web server */ r = webserver_init(eng_get_params()->dev.webserver_port); if (IS_FAIL(r)) return RET_FAIL; /* commands */ r = arr_create(mem_heap(), &g_prf.cmds, sizeof(struct prf_cmd_desc), 20, 20, MID_PRF); if (IS_FAIL(r)) return RET_OUTOFMEMORY; /* register commands */ prf_register_cmd("mem-heap", prf_cmd_heapinfo); prf_register_cmd("mem-heap-sub", prf_cmd_heapsubinfo); prf_register_cmd("mem-gpu", prf_cmd_gpumem); prf_register_cmd("prf-gantt", prf_cmd_profilergantt); prf_register_cmd("mem-buffers", prf_cmd_buffersmem); prf_register_cmd("info-cam", prf_cmd_getcaminfo); MT_ATOMIC_SET(g_prf.init, TRUE); return RET_OK; }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR user_init(void) { sys_read_cfg(); if(!syscfg.cfg.b.debug_print_enable) system_set_os_print(0); uart_init(); #if USE_TMP2NET_PORT GPIO0_MUX = 0; #else GPIO0_MUX = VAL_MUX_GPIO0_SDK_DEF; #endif GPIO4_MUX = VAL_MUX_GPIO4_SDK_DEF; GPIO5_MUX = VAL_MUX_GPIO5_SDK_DEF; GPIO12_MUX = VAL_MUX_GPIO12_SDK_DEF; GPIO14_MUX = VAL_MUX_GPIO14_SDK_DEF; system_timer_reinit(); #if DEBUGSOO > 0 os_printf("\nSimple WEB version: " WEB_SVERSION "\nOpenLoaderSDK v1.2\n"); #endif if(syscfg.cfg.b.pin_clear_cfg_enable) test_pin_clr_wifi_config(); set_cpu_clk(); // select cpu frequency 80 or 160 MHz #if DEBUGSOO > 0 if(eraminfo.size > 0) os_printf("Found free IRAM: base: %p, size: %d bytes\n", eraminfo.base, eraminfo.size); os_printf("System memory:\n"); system_print_meminfo(); os_printf("Start 'heap' size: %d bytes\n", system_get_free_heap_size()); #endif #if DEBUGSOO > 0 os_printf("Set CPU CLK: %u MHz\n", ets_get_cpu_frequency()); #endif Setup_WiFi(); #if USE_TMP2NET_PORT tpm2net_init(); #endif #ifdef USE_NETBIOS if(syscfg.cfg.b.netbios_ena) netbios_init(); #endif /* #ifdef USE_SNTP if(syscfg.cfg.b.sntp_ena) sntp_init(); #endif */ #ifdef UDP_TEST_PORT if(syscfg.udp_port) udp_test_port_init(syscfg.udp_port); #endif // инициализация и запуск tcp серверa(ов) #ifdef USE_SRV_WEB_PORT if(syscfg.web_port) webserver_init(syscfg.web_port); #endif /// if(syscfg.tcp2uart_port) tcp2uart_init(syscfg.tcp2uart_port); #ifdef USE_MODBUS mdb_tcp_init(502); #endif #ifdef USE_WDRV init_wdrv(); #endif system_deep_sleep_set_option(0); system_init_done_cb(init_done_cb); }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR user_init(void) { system_init_done_cb(user_init_done); // UART Devices mod_rfid_init(); mod_finger_init(); mod_emtr_init(); devices_init(); debug("\n\nSDK version: %s\n", system_get_sdk_version()); debug("Firmware: %s\n", config_firmware_bin()); memory_info(); user_config_init(); user_config_load(); #if SSL_ENABLE user_config_load_private_key(); user_config_load_certificate(); #endif user_events_init(); // Scan webserver_register_handler_callback(DEVICES_URL, devices_handler); webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler); // Native Devices user_button_init(); user_relay_init(); user_adc_init(); // I2C Devices i2c_master_gpio_init(); mod_rgb_init(); mod_tc_mk2_init(); mod_io2_init(); mod_irda_init(); // SPI Devices mod_led_8x8_rgb_init(); webserver_init(); }
void user_init(void) { int ever_saved; if(mSpecialMode) { system_set_os_print(0); dhsettings_init(&ever_saved); dhap_init(); } else { dhdebug("*****************************"); dhsettings_init(&ever_saved); if(ever_saved == 0) { // if first run on this chip uploadable_page_delete(); } dhsender_queue_init(); dhconnector_init(dhcommands_do); dhgpio_init(); webserver_init(); dhdebug("Initialization completed"); dhterminal_init(); } }
void init() { //disable debug output while we're mounting spiffs //this has to be done because we can't access settings before mounting // system_set_os_print(0); // Serial.begin(115200); Serial.systemDebugOutput(true); system_set_os_print(1); spiffs_mount(); AppSettings.load(); webserver_init(); pinMode(RESTORE_PARAMETERS_PIN, INPUT_PULLUP); ten_hz_timer.initializeMs(100, app_settings_tick_10hz).start(); }
PROCESS_THREAD(cetic_6lbr_process, ev, data) { static struct etimer timer; static int addr_number; PROCESS_BEGIN(); /* Step 0: Basic infrastructure initialization */ LOG6LBR_NOTICE("Starting 6LBR version " CETIC_6LBR_VERSION " (" CONTIKI_VERSION_STRING ")\n"); //Turn off radio until 6LBR is properly configured NETSTACK_MAC.off(0); cetic_6lbr_restart_event = process_alloc_event(); cetic_6lbr_reload_event = process_alloc_event(); cetic_6lbr_startup = clock_seconds(); #if CETIC_6LBR_MULTI_RADIO network_itf_init(); #endif /* Step 1: Platform specific initialization */ platform_init(); /* Step 2: Register configuration hooks and set default configuration */ #if CETIC_6LBR_NODE_INFO node_info_config(); #endif /* Step 3: Load configuration from NVM and configuration file */ platform_load_config(CONFIG_LEVEL_BOOT); #if !LOG6LBR_STATIC if(nvm_data.log_level != 0xFF) { Log6lbr_level = nvm_data.log_level; Log6lbr_services = nvm_data.log_services; } LOG6LBR_NOTICE("Log level: %d (services: %x)\n", Log6lbr_level, Log6lbr_services); #else LOG6LBR_NOTICE("Log level: %d (services: %x)\n", LOG6LBR_LEVEL, LOG6LBR_SERVICE_DEFAULT); #endif /* Step 4: Initialize radio and network interfaces */ #if CETIC_6LBR_FRAMER_WRAPPER framer_wrapper_init(); #endif #if CETIC_6LBR_MAC_WRAPPER mac_wrapper_init(); #endif #if CETIC_6LBR_MULTI_RADIO CETIC_6LBR_MULTI_RADIO_DEFAULT_MAC.init(); #endif #if !CETIC_6LBR_ONE_ITF platform_radio_init(); while(!radio_ready) { PROCESS_PAUSE(); } #endif eth_drv_init(); while(!ethernet_ready) { PROCESS_PAUSE(); } //Turn on radio and keep it always on NETSTACK_MAC.off(1); /* Step 5: Initialize Network stack */ #if CETIC_6LBR_LLSEC_WRAPPER #if CETIC_6LBR_WITH_ADAPTIVESEC llsec_strategy_wrapper_init(); #endif llsec_wrapper_init(); #endif #if CETIC_6LBR_MULTICAST_WRAPPER multicast_wrapper_init(); #endif //6LoWPAN init memcpy(addr_contexts[0].prefix, nvm_data.wsn_6lowpan_context_0, sizeof(addr_contexts[0].prefix)); //clean up any early packet uip_len = 0; process_start(&tcpip_process, NULL); PROCESS_PAUSE(); /* Step 6: Configure network interfaces */ packet_filter_init(); cetic_6lbr_init(); //Wait result of DAD on 6LBR addresses addr_number = uip_ds6_get_addr_number(-1); LOG6LBR_INFO("Checking addresses duplication\n"); etimer_set(&timer, CLOCK_SECOND); while(uip_ds6_get_addr_number(ADDR_TENTATIVE) > 0) { PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); etimer_set(&timer, CLOCK_SECOND); } //Can not use equality as autoconf address could be created when running DAD if(uip_ds6_get_addr_number(-1) < addr_number) { LOG6LBR_FATAL("Addresses duplication failed\n"); cetic_6lbr_restart_type = CETIC_6LBR_RESTART; platform_restart(); } /* Step 7: Finalize configuration of network interfaces */ cetic_6lbr_init_finalize(); /* Step 8: Initialize 6LBR core and base applications */ platform_load_config(CONFIG_LEVEL_CORE); PROCESS_PAUSE(); #if CETIC_6LBR_WITH_WEBSERVER webserver_init(); #endif #if CETIC_6LBR_NODE_INFO node_info_init(); #endif #if CETIC_6LBR_NODE_CONFIG node_config_init(); #endif /* Step 9: Initialize and configure 6LBR applications */ platform_load_config(CONFIG_LEVEL_BASE); PROCESS_PAUSE(); #if CETIC_6LBR_WITH_UDPSERVER udp_server_init(); #endif #if UDPCLIENT process_start(&udp_client_process, NULL); #endif #if WITH_TINYDTLS dtls_init(); #endif #if WITH_COAPSERVER if((nvm_data.global_flags & CETIC_GLOBAL_DISABLE_COAP_SERVER) == 0) { coap_server_init(); } #endif #if WITH_DTLS_ECHO process_start(&dtls_echo_server_process, NULL); #endif #if CETIC_6LBR_WITH_NVM_PROXY nvm_proxy_init(); #endif #if CETIC_6LBR_WITH_DNS_PROXY dns_proxy_init(); #endif /* Step 10: Finalize platform configuration and load runtime configuration */ platform_finalize(); platform_load_config(CONFIG_LEVEL_APP); LOG6LBR_INFO("CETIC 6LBR Started\n"); PROCESS_WAIT_EVENT_UNTIL(ev == cetic_6lbr_restart_event); etimer_set(&timer, CLOCK_SECOND); PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); /* Shutdown 6LBR */ //Turn off radio NETSTACK_MAC.off(0); platform_restart(); PROCESS_END(); }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR user_init(void) { system_init_done_cb(user_init_done); // wifi_set_phy_mode(PHY_MODE_11N); // wifi_set_sleep_type(MODEM_SLEEP_T); #if UART0_SWAP stdout_disable(); system_uart_swap(); #endif #if UART1_ENABLE stdout_init(UART1); #endif // UART Devices #if DEVICE == PLUG user_plug_init(); #endif #if DEVICE == SWITCH1 user_switch1_init(); #endif #if DEVICE == SWITCH2 user_switch2_init(); #endif #if MOD_RFID_ENABLE mod_rfid_init(); #endif #if MOD_FINGER_ENABLE mod_finger_init(); #endif #if MOD_EMTR_ENABLE mod_emtr_init(); #endif devices_init(); debug("\n\nSDK version: %s\n", system_get_sdk_version()); debug("Firmware: %s\n", config_firmware_bin()); memory_info(); user_config_init(); user_config_load(); #if SSL_ENABLE user_config_load_private_key(); user_config_load_certificate(); #endif user_events_init(); // Scan webserver_register_handler_callback(DEVICES_URL, devices_handler); webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler); // Native Devices #if BUTTON_ENABLE user_button_init(); #endif #if RELAY_ENABLE user_relay_init(); #endif #if ADC_ENABLE user_adc_init(); #endif #if BATTERY_ENABLE user_battery_init(); #endif #if I2C_ENABLE // I2C Devices i2c_master_gpio_init(); #if MOD_RGB_ENABLE mod_rgb_init(); #endif #if MOD_TC_MK2_ENABLE mod_tc_mk2_init(); #endif #if MOD_IO2_ENABLE mod_io2_init(); #endif #if MOD_IRDA_ENABLE mod_irda_init(); #endif #if DEVICE == DIMMER user_dimmer_init(); #endif #endif // SPI Devices #if MOD_LED_8x8_RGB_ENABLE mod_led_8x8_rgb_init(); #endif #if DEVICE == BADGE badge_init(); #endif key_init(); webserver_init(); }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR user_init(void) { system_init_done_cb(user_init_done); // UART Devices #if MOD_RFID_ENABLE mod_rfid_init(); #endif #if MOD_FINGER_ENABLE mod_finger_init(); #endif #if MOD_EMTR_ENABLE mod_emtr_init(); #endif devices_init(); debug("\n\nSDK version: %s\n", system_get_sdk_version()); debug("Firmware: %s\n", config_firmware_bin()); memory_info(); user_config_init(); user_config_load(); #if SSL_ENABLE user_config_load_private_key(); user_config_load_certificate(); #endif user_events_init(); // Scan webserver_register_handler_callback(DEVICES_URL, devices_handler); webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler); // Native Devices #if BUTTON_ENABLE user_button_init(); #endif #if RELAY_ENABLE user_relay_init(); #endif #if ADC_ENABLE user_adc_init(); #endif #if BATTERY_ENABLE user_battery_init(); #endif // I2C Devices i2c_master_gpio_init(); #if MOD_RGB_ENABLE mod_rgb_init(); #endif #if MOD_TC_MK2_ENABLE mod_tc_mk2_init(); #endif #if MOD_IO2_ENABLE mod_io2_init(); #endif #if MOD_IRDA_ENABLE mod_irda_init(); #endif // SPI Devices #if MOD_LED_8x8_RGB_ENABLE mod_led_8x8_rgb_init(); #endif key_init(); webserver_init(); }