void user_init(void) { // Configure the UART uart_init(BIT_RATE_115200,0); // Enable system messages system_set_os_print(1); os_printf("\r\nSDK version: %s\n", system_get_sdk_version()); os_printf("System init...\r\n"); os_printf("ESP8266 is %s mode, restarting in %s mode...\r\n", WiFiMode[wifi_get_opmode()], WiFiMode[STATION_MODE]); setup_wifi_st_mode(); if(wifi_get_phy_mode() != PHY_MODE_11N) wifi_set_phy_mode(PHY_MODE_11N); if(wifi_station_get_auto_connect() == 0) wifi_station_set_auto_connect(1); // Init DHT22 sensor DHTInit(DHT22); // Wait for Wi-Fi connection os_timer_disarm(&WiFiLinker); os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL); os_timer_arm(&WiFiLinker, 1000, 0); // Set up a timer to send the message os_timer_disarm(&dht22_timer); os_timer_setfn(&dht22_timer, (os_timer_func_t *)dht22_cb, (void *)0); os_timer_arm(&dht22_timer, DATA_SEND_DELAY, 1); os_printf("System init done.\n"); }
static int do_meminfo(int argc, const char* argv[]) { system_set_os_print(1); system_print_meminfo(); system_set_os_print(0); return 0; }
// // Lua: osprint(true/false) // Allows you to turn on the native Espressif SDK printing static int node_osprint( lua_State* L ) { if (lua_toboolean(L, 1)) { system_set_os_print(1); } else { system_set_os_print(0); } return 0; }
// Start/Stop debug, Set buffer size if size > 0 // 0 - stop, 1 - start tiny: dbg_printf(), 2 - start all: dbg_printf() + os_printf() void ICACHE_FLASH_ATTR dbg_set(uint8 level, uint32 size) { // if(Save_system_set_os_print == 0xFF) Save_system_set_os_print = system_get_os_print(); if(level == 0) { if(Debug_RAM_addr != NULL) { os_free(Debug_RAM_addr); Debug_RAM_addr = NULL; Debug_RAM_len = 0; // system_set_os_print(Save_system_set_os_print); } if(size) Debug_RAM_size = size; } else { if(Debug_RAM_addr == NULL) Debug_RAM_addr = os_malloc(Debug_RAM_size); if(Debug_RAM_addr != NULL) { os_memset(Debug_RAM_addr, 0, Debug_RAM_size); Debug_RAM_len = 0; if(level == 2) { ets_install_putc1(dbg_printf_out); system_set_os_print(1); // } else { // system_set_os_print(Save_system_set_os_print); } } } Debug_level = level; }
void user_init(void) { char * ap = "SKUNKWILLEM"; char * pass = "******"; uart_init(BIT_RATE_115200, uart_receive, false); system_set_os_print(1); os_printf("\nUart init done... \n"); wifi_softap_get_config(&apconf); memset(apconf.ssid, 0, 32); memset(apconf.password, 0, 64); os_strncpy((char*)apconf.ssid, ap, 32); os_strncpy((char*)apconf.password, pass, 64); apconf.authmode = AUTH_WPA_WPA2_PSK; apconf.max_connection = 5; apconf.ssid_hidden = 0; wifi_softap_set_config(&apconf); IP4_ADDR(&IpInfo.gw, 192, 168, 10, 1); IP4_ADDR(&IpInfo.ip, 192, 168, 10, 1); IP4_ADDR(&IpInfo.netmask, 255, 255, 255, 0); wifi_softap_dhcps_stop(); dhcps_start(&IpInfo); wifi_set_ip_info(0x01, &IpInfo); os_timer_disarm(&waitTimer); os_timer_setfn(&waitTimer, init_udp, NULL); os_timer_arm(&waitTimer, 2000, 0); }
void user_init(void) { system_set_os_print(0); uart_init(BIT_RATE_115200, BIT_RATE_115200); os_delay_us(1000000); CFG_Load(); // Initialize the GPIO subsystem. gpio_init(); //Set GPIO2 to output mode PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); //Set GPIO2 high gpio_output_set(ROOMBA_WAKEUP_PIN, 0, ROOMBA_WAKEUP_PIN, 0); MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security); //MQTT_InitConnection(&mqttClient, "192.168.11.122", 1880, 0); MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass, sysCfg.mqtt_keepalive, 1); //MQTT_InitClient(&mqttClient, "client_id", "user", "pass", 120, 1); MQTT_InitLWT(&mqttClient, "/lwt", "offline", 0, 0); MQTT_OnConnected(&mqttClient, mqttConnectedCb); MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb); MQTT_OnPublished(&mqttClient, mqttPublishedCb); MQTT_OnData(&mqttClient, mqttDataCb); WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, wifiConnectCb); INFO("\r\nSystem started ...\r\n"); }
void init_done() { system_set_os_print(1); gdb_init(); do_global_ctors(); printf("\n%08x\n", core_version); esp_schedule(); }
extern "C" void ICACHE_FLASH_ATTR user_init(void) { do_global_ctors(); system_set_os_print(0); uart_init(BIT_RATE_115200, BIT_RATE_115200); //os_delay_us(1000000); int ret = esp8266.init(2048, 2048, 1024); os_printf("\n\n\n"); //DTXT("MQTT ESP8266 Slave Firmware ver. %d.%d\n", VERSION_MAJOR, VERSION_MINOR); //DTXT("2015 Michael Jacobsen\n"); //DTXT("\n"); //system_print_meminfo(); //system_set_os_print(0); //DTXT("\n"); if(ret == 0) { wifi.init(&esp8266); dispatcher.init(&esp8266); if(dispatcher.setup(&wifi) == EOK) { wifi.setup(); //os_printf("{\"jsonrpc\":\"2.0\",\"method\":\"system\",\"params\":{\"code\":1,\"sys\":\"system\",\"msg\":\"start\",\"p1\":null,\"p2\":null,\"n1\":0,\"n2\":0}}\n"); } } else { os_printf("{\"jsonrpc\":\"2.0\",\"method\":\"jsonrpc\",\"params\":{\"code\": -10,\"error\":\"esp8266.init() returns error; %d\"}}\n", ret); } }
/** * The main entry point in an ESP8266 application. * It is where the logic of ESP8266 starts. */ void user_init() { system_timer_reinit(); // use microsecond os_timer_* // Initialize the UART devices int defaultBaudRate = 9600; #ifdef DEFAULT_CONSOLE_BAUDRATE defaultBaudRate = DEFAULT_CONSOLE_BAUDRATE; #endif uart_init(defaultBaudRate, defaultBaudRate); //uart_init(BIT_RATE_9600, BIT_RATE_9600); os_delay_us(1000); // make sure there's a gap on uart output UART_SetPrintPort(1); system_set_os_print(1); os_printf("\n\n\n\n"); os_delay_us(1000); // Dump the restart exception information. dumpRestart(); os_printf("Heap: %d\n", system_get_free_heap_size()); os_printf("Variables: %d @%dea = %dbytes\n", JSVAR_CACHE_SIZE, sizeof(JsVar), JSVAR_CACHE_SIZE * sizeof(JsVar)); os_printf("Time sys=%u rtc=%u\n", system_get_time(), system_get_rtc_time()); // Register the ESP8266 initialization callback. system_init_done_cb(initDone); os_timer_setfn(&mainLoopSuspendTimer, enableMainLoop, NULL); }
/* Init function */ void user_init() { #ifndef RTOS_TODO system_update_cpu_freq(SYS_CPU_160MHZ); system_init_done_cb(sdk_init_done_cb); #endif uart_div_modify(0, UART_CLK_FREQ / 115200); #ifndef RTOS_TODO system_set_os_print(0); #endif setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); esp_exception_handler_init(); #ifndef RTOS_TODO gpio_init(); #endif #ifdef RTOS_TODO rtos_init_dispatcher(); sdk_init_done_cb(); #endif }
/*JSON{ "type" : "staticmethod", "class" : "ESP8266WiFi", "name" : "logDebug", "generate" : "jswrap_ESP8266WiFi_logDebug", "params" : [ ["enable", "JsVar", "Enable or disable the debug logging."] ] } * Enable or disable the logging of debug information. A value of `true` enables * debug logging while a value of `false` disables debug logging. Debug output is sent * to UART1. */ void jswrap_ESP8266WiFi_logDebug( JsVar *jsDebug ) { uint8 enable = (uint8)jsvGetBool(jsDebug); os_printf("> jswrap_ESP8266WiFi_logDebug, enable=%d\n", enable); system_set_os_print((uint8)jsvGetBool(jsDebug)); os_printf("< jswrap_ESP8266WiFi_logDebug\n"); }
void ICACHE_FLASH_ATTR user_rf_pre_init(void) { /* undo upgrade, if the first boot failes * with an watchdog reset, soft watchdog reset or an exception */ cgiFlashCheckUpgradeHealthy(); //default is enabled system_set_os_print(DEBUG_SDK); }
/** * @brief System main loop called by the ETS * * This function is called by ETS after all initializations has been * finished to start periodic processing of defined ETS tasks. We * overwrite this ETS function to take over the control and to start RIOT. */ void ets_run(void) { #if ENABLE_DEBUG register uint32_t *sp __asm__ ("a1"); ets_uart_printf("_stack %p\n", sp); ets_uart_printf("_bss_start %p\n", &_bss_start); ets_uart_printf("_bss_end %p\n", &_bss_end); ets_uart_printf("_heap_start %p\n", &_sheap); ets_uart_printf("_heap_end %p\n", &_eheap); ets_uart_printf("_heap_free %lu\n", get_free_heap_size()); #endif /* init min task priority */ ets_task_min_prio = 0; #ifdef MODULE_NEWLIB_SYSCALLS_DEFAULT _init(); #endif ets_tasks_init(); /* enable interrupts used by ETS/SDK */ #ifndef MODULE_ESP_SDK_INT_HANDLING ets_isr_unmask(BIT(ETS_FRC2_INUM)); ets_isr_unmask(BIT(ETS_WDEV_INUM)); ets_isr_unmask(BIT(ETS_WDT_INUM)); #endif #ifdef MODULE_ESP_GDBSTUB gdbstub_init(); #endif #if ENABLE_DEBUG==0 /* disable SDK messages */ system_set_os_print(0); #endif #ifdef CONTEXT_SWITCH_BY_INT extern void IRAM thread_yield_isr(void* arg); ets_isr_attach(ETS_SOFT_INUM, thread_yield_isr, NULL); ets_isr_unmask(BIT(ETS_SOFT_INUM)); #endif /* initialize dummy lwIP library to link it even if esp_wifi is not used */ extern void esp_lwip_init(void); esp_lwip_init(); thread_create(ets_task_stack, sizeof(ets_task_stack), ETS_TASK_PRIORITY, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST, ets_task_func, NULL, "ets"); /* does not return */ kernel_init(); }
void ICACHE_FLASH_ATTR user_init(void) { #ifdef DEBUG_SERIAL uart_init(BIT_RATE_115200,BIT_RATE_115200); system_set_os_print(TRUE); #else system_set_os_print(FALSE); #endif gpio_init(); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5); GPIO_OUTPUT_SET(GPIO_ID_PIN(5), 0); bool status = sht21_init(); os_printf("SHT Init Status %d: \n",status); system_os_task(ost_loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0 ); }
/****************************************************************************** * 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); }
void init() { system_set_os_print(0); Serial.begin(SERIAL_BAUD_RATE); // 115200 by default Serial.systemDebugOutput(false); // Disable debug output to serial System.onReady(sysReady); }
void ICACHE_FLASH_ATTR user_init(void) { #ifdef DEBUG_SERIAL uart_init(BIT_RATE_115200,BIT_RATE_115200); system_set_os_print(TRUE); #else system_set_os_print(FALSE); #endif //Create task for main loop system_os_task(ost_loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0 ); //Create task for the WiFi setup system_os_task(ost_wifi_setup, 1,user_procTaskQueue, user_procTaskQueueLen); system_os_post(1, 0, 0 ); //Create task for the WiFi networks scan system_os_task(ost_wifi_scan, 2,user_procTaskQueue, user_procTaskQueueLen); system_os_post(2, 0, 0 ); }
void user_rf_pre_init() { // *((volatile uint32_t*) 0x60000710) = 0; volatile uint32_t* rtc_reg = (volatile uint32_t*) 0x60001000; if((rtc_reg[24] >> 16) > 4) { rtc_reg[24] &= 0xFFFF; rtc_reg[30] = 0; } system_set_os_print(0); __run_user_rf_pre_init(); }
//Init function void ICACHE_FLASH_ATTR user_init() { //uart_div_modify(0, UART_CLK_FREQ / 115200); system_set_os_print(1); uart_init(BIT_RATE_115200, BIT_RATE_115200); os_printf("Hello !\n\r"); os_printf("Chip Id: %lu\n\r", system_get_chip_id()); os_printf("SDK Version: %s\n\r", system_get_sdk_version()); system_init_done_cb(initDone); wifi_set_event_handler_cb(eventHandler); }
/* * This is entry point for user code */ void user_init(void) { // Configure the UART uart_init(BIT_RATE_9600,0); // enable some system messages system_set_os_print(1); // Set up a timer to send the message // os_timer_disarm(ETSTimer *ptimer) os_timer_disarm(&info_timer); // os_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg) os_timer_setfn(&info_timer, (os_timer_func_t *)info_cb, (void *)0); // void os_timer_arm(ETSTimer *ptimer,uint32_t milliseconds, bool repeat_flag) os_timer_arm(&info_timer, DELAY, 1); }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { #ifdef LUA_USE_MODULES_RTCTIME rtctime_late_startup (); #endif UartBautRate br = BIT_RATE_DEFAULT; input_sig = task_get_id(handle_input); uart_init (br, br, input_sig); #ifndef NODE_DEBUG system_set_os_print(0); #endif system_init_done_cb(nodemcu_init); }
void user_init(void) { uart_init(BIT_RATE_230400, BIT_RATE_230400); system_set_os_print(1); // enable/disable operating system printout os_sprintf(topic_temp, MQTT_TOPICTEMP, system_get_chip_id()); os_sprintf(topic_hum, MQTT_TOPICHUM, system_get_chip_id()); PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); ETS_GPIO_INTR_DISABLE(); // Disable gpio interrupts ETS_GPIO_INTR_ATTACH(interrupt_test, 4); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4); gpio_output_set(0, 0, 0, GPIO_ID_PIN(4)); // Set GPIO12 as input GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(4)); gpio_pin_intr_state_set(GPIO_ID_PIN(4), GPIO_PIN_INTR_ANYEDGE); ETS_GPIO_INTR_ENABLE(); // Enable gpio interrupts config_load(); DHTInit(DHT11); MQTT_InitConnection(&mqttClient, config.mqtt_host, config.mqtt_port, config.security); MQTT_InitClient(&mqttClient, config.device_id, config.mqtt_user, config.mqtt_pass, config.mqtt_keepalive, 1); MQTT_InitLWT(&mqttClient, "lwt/", "offline", 0, 0); MQTT_OnConnected(&mqttClient, mqtt_connected_cb); MQTT_OnDisconnected(&mqttClient, mqtt_disconnected_cb); MQTT_OnPublished(&mqttClient, mqtt_published_cb); MQTT_OnData(&mqttClient, mqtt_data_cb); WIFI_Connect(config.sta_ssid, config.sta_pwd, wifi_connect_cb); os_timer_disarm(&dhtTimer); os_timer_setfn(&dhtTimer, (os_timer_func_t *)dhtCb, (void *)0); os_timer_arm(&dhtTimer, DELAY, 1); os_timer_disarm(&hbTimer); os_timer_setfn(&hbTimer, (os_timer_func_t *)application_heartbeat, (void *)0); os_timer_arm(&hbTimer, 60000, 1); INFO("\r\nSystem started ...\r\n"); }
/****************************************************************************** * 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); GPIO0_MUX = VAL_MUX_GPIO0_SDK_DEF; GPIO4_MUX = VAL_MUX_GPIO4_SDK_DEF; GPIO5_MUX = VAL_MUX_GPIO5_SDK_DEF; GPIO12_MUX = VAL_MUX_GPIO12_SDK_DEF; GPIO13_MUX = VAL_MUX_GPIO13_SDK_DEF; GPIO14_MUX = VAL_MUX_GPIO14_SDK_DEF; GPIO15_MUX = VAL_MUX_GPIO15_SDK_DEF; // vad7 //power_meter_init(); // //uart_init(); // in tcp2uart.h system_timer_reinit(); #if (DEBUGSOO > 0 && defined(USE_WEB)) os_printf("\nSimple WEB version: " WEB_SVERSION "\n"); #endif //if(syscfg.cfg.b.pin_clear_cfg_enable) test_pin_clr_wifi_config(); // сброс настроек, если замкнут пин RX set_cpu_clk(); // select cpu frequency 80 or 160 MHz #ifdef USE_GDBSTUB extern void gdbstub_init(void); gdbstub_init(); #endif #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("bssi : 0x%x ~ 0x%x, len: %d\n", &_lit4_start, &_lit4_end, (uint32)(&_lit4_end) - (uint32)(&_lit4_start)); os_printf("free : 0x%x ~ 0x%x, len: %d\n", (uint32)(&_lit4_end), (uint32)(eraminfo.base) + eraminfo.size, (uint32)(eraminfo.base) + eraminfo.size - (uint32)(&_lit4_end)); 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(); WEBFSInit(); // файловая система system_deep_sleep_set_option(0); system_init_done_cb(init_done_cb); }
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(); } }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { // NODE_DBG("SDK version:%s\n", system_get_sdk_version()); // system_print_meminfo(); // os_printf("Heap size::%d.\n",system_get_free_heap_size()); // os_delay_us(50*1000); // delay 50ms before init uart #ifdef DEVELOP_VERSION uart_init(BIT_RATE_74880, BIT_RATE_74880); #else uart_init(BIT_RATE_9600, BIT_RATE_9600); #endif // uart_init(BIT_RATE_115200, BIT_RATE_115200); #ifndef NODE_DEBUG system_set_os_print(0); #endif system_init_done_cb(nodemcu_init); }
int uart_redirect_debug(int mode) { switch (mode) { case 0: debug_enabled = 0; break; case 1: case 2: debug_enabled = 1; s_system_uartno = mode - 1; break; default: return -1; } #ifndef RTOS_TODO system_set_os_print(debug_enabled); #endif return 0; }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { #ifdef LUA_USE_MODULES_RTCTIME rtctime_late_startup (); #endif // NODE_DBG("SDK version:%s\n", system_get_sdk_version()); // system_print_meminfo(); // os_printf("Heap size::%d.\n",system_get_free_heap_size()); // os_delay_us(50*1000); // delay 50ms before init uart UartBautRate br = BIT_RATE_DEFAULT; uart_init (br, br, USER_TASK_PRIO_0, SIG_UARTINPUT); #ifndef NODE_DEBUG system_set_os_print(0); #endif system_init_done_cb(nodemcu_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(); }
void ICACHE_FLASH_ATTR user_init(void) { uart_init(BIT_RATE_115200, BIT_RATE_115200); INFO("\r\nSDK version: %s\n", system_get_sdk_version()); INFO("System init...\r\n"); system_set_os_print(1); os_delay_us(1000000); INFO("Load Config\n"); config_load(); INFO("GPIO Init\n"); gpio_init(); INFO("MQTT Init"); mqtt_init(); INFO("Connect wifi %s\n", config.sta_ssid); WIFI_Connect(config.sta_ssid, config.sta_pwd, wifi_connect_cb); //WIFI_Connect("Wirelessabata", "TaLi100305", wifi_connect_cb); INFO("\r\nSystem started ...\r\n"); }
void user_init(void) { // Configure the UART uart_init(BIT_RATE_115200, BIT_RATE_115200); // Enable system messages system_set_os_print(1); DHT22_DEBUG("\n==== System info: ====\n"); DHT22_DEBUG("SDK version:%s rom %d\n", system_get_sdk_version(), system_upgrade_userbin_check()); DHT22_DEBUG("Time = %ld\n", system_get_time()); DHT22_DEBUG("Chip id = 0x%x\n", system_get_chip_id()); DHT22_DEBUG("CPU freq = %d MHz\n", system_get_cpu_freq()); DHT22_DEBUG("Flash size map = %s\n", FlashSizeMap[system_get_flash_size_map()]); DHT22_DEBUG("Free heap size = %d\n", system_get_free_heap_size()); DHT22_DEBUG("==== End System info ====\n"); os_delay_us(10000); DHT22_DEBUG("System init...\r\n"); if(wifi_get_opmode() != STATION_MODE) { DHT22_DEBUG("ESP8266 is %s mode, restarting in %s mode...\r\n", WiFiMode[wifi_get_opmode()], WiFiMode[STATION_MODE]); setup_wifi_st_mode(); } if(wifi_get_phy_mode() != PHY_MODE_11N) wifi_set_phy_mode(PHY_MODE_11N); if(wifi_station_get_auto_connect() == 0) wifi_station_set_auto_connect(1); // Wait for Wi-Fi connection os_timer_disarm(&WiFiLinker); os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL); os_timer_arm(&WiFiLinker, WIFI_CHECK_DELAY, 0); UDP_Init(); DHT22_DEBUG("System init done.\n"); }