Beispiel #1
0
static  int do_meminfo(int argc, const char* argv[])
{
	system_set_os_print(1);
	system_print_meminfo();
	system_set_os_print(0);
	return 0;
}
Beispiel #2
0
void user_init()
{
    struct station_config conf;

    // This is used to setup the serial communication
    uart_div_modify(0, UART_CLK_FREQ / 115200);

    wifi_set_opmode(STATION_MODE);

    // os_bzero ( &conf, sizeof(struct station_config) );
    os_memset ( &conf, 0, sizeof(struct station_config) );
    os_memcpy (&conf.ssid, ssid, 32);
    os_memcpy (&conf.password, pass, 64 );
    wifi_station_set_config (&conf);

    // And this is used to print some information
    os_printf("\n");
    os_printf("SDK version:%s\n", system_get_sdk_version());
    system_print_meminfo();
    os_delay_us ( 1 );
    os_printf ( "CPU Hz = %d\n", system_get_cpu_freq() );

    show_mac ();
    show_ip ();

    /* set a callback for wifi events */
    wifi_set_event_handler_cb ( wifi_event );
}
Beispiel #3
0
LOCAL void ICACHE_FLASH_ATTR initDone_cb() {
	CFG_Load();
	os_printf("\n%s starting ...\n", sysCfg.deviceName);

	MQTT_InitConnection(&mqttClient, sysCfg.mqtt_host, sysCfg.mqtt_port, sysCfg.security);
	MQTT_InitClient(&mqttClient, sysCfg.device_id, sysCfg.mqtt_user, sysCfg.mqtt_pass,
			sysCfg.mqtt_keepalive, 1);

	char temp[100];
	os_sprintf(temp, "/Raw/%s/offline", sysCfg.device_id);
	MQTT_InitLWT(&mqttClient, temp, "offline", 0, 0);

	MQTT_OnConnected(&mqttClient, mqttConnectedCb);
	MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
	MQTT_OnData(&mqttClient, mqttDataCb);

	os_printf("SDK version is: %s\n", system_get_sdk_version());
	os_printf("Smart-Config version is: %s\n", smartconfig_get_version());
	system_print_meminfo();
	os_printf("Flash size map %d; id %lx\n", system_get_flash_size_map(), spi_flash_get_id());

	WIFI_Connect(sysCfg.sta_ssid, sysCfg.sta_pwd, sysCfg.deviceName, wifiConnectCb);

	lcdInit();
	lightOn();
	showString(1, 1, "MQTT Monitor");
}
void sysinfo(void)
{
    os_printf("SDK version: %s Chip ID=%u\n",
        system_get_sdk_version(),
        system_get_chip_id());
    system_print_meminfo();
    meminfo();
}
Beispiel #5
0
void
print_sysinfo(void)
{
    os_printf("\x0c");
    os_printf("*** Welcome to DS18B20 Temperature Reader ***\n");
    os_printf("SDK Version: %s\n", system_get_sdk_version());
    system_print_meminfo();
}
Beispiel #6
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);
}
Beispiel #7
0
LOCAL void ICACHE_FLASH_ATTR
info_cb(void *arg)
{
	wdt_feed();
	uart0_sendStr("System Info\r\n");
	os_printf("Time=%ld\r\n", system_get_time());
	os_printf("Chip id=%ld\r\n", system_get_chip_id());
	os_printf("Free heap size=%ld\r\n", system_get_free_heap_size());
	uart0_sendStr("Mem info:\r\n");
	system_print_meminfo();
	uart0_sendStr("\r\n");
}
Beispiel #8
0
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR user_init(void) {
	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());
	os_printf("Set CPU CLK: %u MHz\n", ets_get_cpu_frequency());
	system_deep_sleep_set_option(0);
	wifi_set_event_handler_cb(wifi_handle_event_cb);
	system_init_done_cb(init_done_cb);
}
Beispiel #9
0
dce_result_t SECTION_ATTR dce_handle_GMEM(dce_t* dce, void* group_ctx, int kind, size_t argc, arg_t* argv)
{
    char line[12];
    int length = sprintf(line, "%d", system_get_free_heap_size());
    dce_emit_information_response(dce, line, length);

    int debug_enabled = uart_get_debug();
    uart_set_debug(1);
    system_print_meminfo();
    uart_set_debug(debug_enabled);
    
    dce_emit_basic_result_code(dce, DCE_RC_OK);
}
void ICACHE_FLASH_ATTR show_sysinfo()
{
	uint32 chipid = system_get_chip_id();
	uint32 heepsize = system_get_free_heap_size();
	uint32 rtctime = system_get_rtc_time();
	uint32 systime = system_get_time();

	os_printf("\n\nSDK version: [%s]\n", system_get_sdk_version());

	os_printf("SYSTEM INIT OVER\n");
	os_printf("==========SYS INFO==========\n");
	system_print_meminfo();
	os_printf("CHIP   ID: [%d]\n", chipid);
	os_printf("HEAP SIZE: [%d]\n", heepsize);
	os_printf("RTC  TIME: [%d]\n", rtctime);
	os_printf("SYS  TIME: [%d]\n", systime);
	os_printf("==========SYS INFO==========\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);
}
Beispiel #12
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();
	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;
	GPIO14_MUX = VAL_MUX_GPIO14_SDK_DEF;
	system_timer_reinit();
#if (DEBUGSOO > 0 && defined(USE_WEB))
	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
#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("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();
#ifdef USE_WDRV
    init_wdrv();
#endif
	Set_WiFi(&wificonfig, Cmp_WiFi_chg(&wificonfig) & (WIFI_MASK_SLEEP|WIFI_MASK_STDHCP|WIFI_MASK_APIPDHCP));
	WEBFSInit(); // файловая система
	system_deep_sleep_set_option(0);
	system_init_done_cb(init_done_cb);
}
Beispiel #13
0
/******************************************************************************
 * FunctionName : udp_test_port_recv
 * Returns      : none
*******************************************************************************/
LOCAL void ICACHE_FLASH_ATTR
udp_test_port_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, ip_addr_t *addr, u16_t port)
{
	uint8 usrdata[32];
    if (p == NULL)  return;
    if(p->tot_len < 2) {
        pbuf_free(p);
    	return;
    }
    uint16 length = mMIN(p->tot_len, sizeof(usrdata)-1);
#if DEBUGSOO > 0
    os_printf("udp " IPSTR ":%u [%d]\n", IP2STR(addr), port, p->tot_len);
#endif
    length = pbuf_copy_partial(p, usrdata, length, 0);
    pbuf_free(p);

    uint8 *pudpbuf = (uint8 *)os_zalloc(udpbufsize+1);
    if(pudpbuf == NULL) return;
    uint16 udpbuflen = 0;
    int x = 0;
    if(length>2) x = atoi((char *)&usrdata[2]);
    if ((length>1)&&(usrdata[1]=='?')) switch(usrdata[0])
    {
      case 'M':
          system_print_meminfo();
      case 'A':
        {
          udp_puts("\nChip_id: %08x Flash_id: %08x\nsys_time:%08x ADC:%d\n", system_get_chip_id(), spi_flash_get_id(), system_get_time(), system_adc_read());
          struct softap_config wiconfig;
          wifi_softap_get_config(&wiconfig);
          udp_puts("OPMode:%u SSID:'%s' Pwd:'%s' Ch:%u Authmode:%u MaxCon:%u Phu:%u ACon:%u\n", wifi_get_opmode(), wiconfig.ssid, wiconfig.password, wiconfig.channel, wiconfig.authmode, wiconfig.max_connection, wifi_get_phy_mode(), wifi_station_get_auto_connect());
          udp_puts("Connect status:%u\n", wifi_station_get_connect_status());
        };
      case 'I':
          udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize);
          udpbuflen += print_udp_psc(pudpbuf+udpbuflen, udpbufsize-udpbuflen);
          udpbuflen += print_tcp_psc(pudpbuf+udpbuflen, udpbufsize-udpbuflen);
          udpbuflen += chow_tcp_connection_info(pudpbuf+udpbuflen, udpbufsize-udpbuflen);
          break;
      case 'H':
          udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize);
          break;
      case 'U':
          udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize);
          udpbuflen += print_udp_psc(pudpbuf+udpbuflen, udpbufsize-udpbuflen);
          break;
      case 'T':
          udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize);
          udpbuflen += print_tcp_psc(pudpbuf+udpbuflen, udpbufsize-udpbuflen);
          break;
#ifdef USE_SRV_WEB_PORT
      case 'S':
          udp_puts("heapsize: %d\n", system_get_free_heap_size() + udpbufsize);
          udpbuflen += chow_tcp_connection_info(pudpbuf+udpbuflen, udpbufsize-udpbuflen);
          break;
#endif
      case 'R':
          system_restart();
          break;
      case 'P':
          udp_puts("system_set_os_print(%u)\n", x);
          system_set_os_print(x);
          break;
      case 'O':
          udp_puts("wifi_set_opmode(%u):%u\n", x, wifi_set_opmode(x));
          break;
      case 'B':
          udp_puts("wifi_station_set_auto_connect(%u):%u\n", x, wifi_station_set_auto_connect(x));
          break;
      case 'D':
          switch(x) {
          case 0:
              udp_puts("wifi_station_dhcpc_start:%u\n", wifi_station_dhcpc_start());
              break;
          case 1:
              udp_puts("wifi_station_dhcpc_stop:%u\n", wifi_station_dhcpc_stop());
              break;
          case 2:
              udp_puts("wifi_softap_dhcps_start:%u\n",wifi_softap_dhcps_start());
              break;
          case 3:
              udp_puts("wifi_softap_dhcps_stop:%u\n", wifi_softap_dhcps_stop());
              break;
          default:
              udp_puts("D(%u)?\n", x);
          }
          break;
          case 'F':
        	  if(flashchip != NULL) {
        		  udp_puts("FlashID: 0x%08x\nChip size: %d\nBlock size: %d\nSector size: %d\nPage size: %d\nStatus mask: 0x%08x\n", flashchip->deviceId, flashchip->chip_size, flashchip->block_size, flashchip->sector_size, flashchip->page_size, flashchip->status_mask );
        		  udp_puts("Real Flash size: %u\n", spi_flash_real_size());
        	  }
        	  else udp_puts("Unknown Flash type!\n");
              break;
          case 'E':
        	  udp_puts("wifi_set_sleep_type(%d):%u\n", x, wifi_set_sleep_type(x));
        	  break;
          case 'G':
        	  udp_puts("g_ic = %p\n", &g_ic);
        	  break;
      default:
          udp_puts("???\n");
    }
    if(udpbuflen) {
    	struct pbuf *z = pbuf_alloc(PBUF_TRANSPORT, udpbuflen, PBUF_RAM);
    	if(z != NULL) {
        	err_t err = pbuf_take(z, pudpbuf, udpbuflen);
        	os_free(pudpbuf);
        	if(err == ERR_OK) {
        	    udp_sendto(upcb, z, addr, port);
        	}
      	    pbuf_free(z);
        	return;
    	}
    }
    os_free(pudpbuf);
}
void ICACHE_FLASH_ATTR dhserial_commands_status(const char *args) {
	uint8 mac[6];
	char digitBuff[32];
	if(!wifi_get_macaddr(STATION_IF, mac)) {
		uart_send_line("Failed to get mac address");
	} else {
		struct station_config stationConfig;
		system_print_meminfo();
		if(!wifi_station_get_config(&stationConfig)) {
			uart_send_line("Could not get station config");
			os_memset(&stationConfig, 0, sizeof(stationConfig));
		}
		uart_send_str("Network adapter ");
		sprintMac(digitBuff, mac);
		uart_send_str(digitBuff);
		switch(wifi_station_get_connect_status()) {
		case STATION_IDLE:
			uart_send_line(" is in idle");
			break;
		case STATION_CONNECTING:
			uart_send_str(" is connecting to ");
			uart_send_line(stationConfig.ssid);
			break;
		case STATION_WRONG_PASSWORD:
			uart_send_str(" has wrong password for ");
			uart_send_line(stationConfig.ssid);
			break;
		case STATION_NO_AP_FOUND:
			uart_send_str(" can not find AP with SSID ");
			uart_send_line(stationConfig.ssid);
			break;
		case STATION_CONNECT_FAIL:
			uart_send_str(" has fail while connecting to ");
			uart_send_line(stationConfig.ssid);
			break;
		case STATION_GOT_IP:
		{
			uart_send_str(" is connected to ");
			uart_send_line(stationConfig.ssid);
			struct ip_info info;
			if(!wifi_get_ip_info(STATION_IF, &info)) {
				uart_send_line("Failed to get ip info");
			} else {
				uart_send_str("IP: ");
				sprintIp(digitBuff, &info.ip);
				uart_send_str(digitBuff);
				uart_send_str(", netmask: ");
				sprintIp(digitBuff, &info.netmask);
				uart_send_str(digitBuff);
				uart_send_str(", gateway: ");
				sprintIp(digitBuff, &info.gw);
				uart_send_line(digitBuff);
			}
			break;
		}
		default:
			uart_send_line("is in unknown state");
			break;
		}
		uart_send_str("DeviceHive: ");
		switch(dhconnector_get_state()) {
		case CS_DISCONNECT:
			uart_send_line("connection is not established.");
			break;
		case CS_GETINFO:
			uart_send_line("getting info from server.");
			break;
		case CS_REGISTER:
			uart_send_line("registering device.");
			break;
		case CS_POLL:
			uart_send_line("successfully connected to server.");
			break;
		default:
			uart_send_line("unknown state");
			break;
		}
	}
	uart_send_str("Free heap size: ");
	snprintf(digitBuff, sizeof(digitBuff), "%d", system_get_free_heap_size());
	uart_send_str(digitBuff);
	uart_send_line(" bytes.");
}
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{
    os_delay_us(1000*1000);
    uart_init (BIT_RATE_115200, BIT_RATE_115200, USER_TASK_PRIO_0, 0);
    os_delay_us(100*1000);

    os_printf("Interactive Cube starting..\n");

    config_init();

    platform_i2c_setup(i2c_endpoint_id, 1, 2, PLATFORM_I2C_SPEED_SLOW);
    display_init();

    NODE_DBG("SDK version: %s\n", system_get_sdk_version());
    system_print_meminfo();

    os_printf("Heap size: %d.\n", system_get_free_heap_size());

#ifndef NODE_DEBUG
    system_set_os_print(1);
#endif

    int b;
    for(b=0; b<4; b++) {
        display_set_pixel(0, 1);
        display_update_inner();

        os_delay_us(500*1000);
        display_update_inner();

        display_set_pixel(0, 0);
        display_update_inner();

        os_delay_us(500*1000);
        display_update_inner();
    }

    if (display_is_key_down(0)) {
        // enter setup mode, show as blinking...!
        configui_init();
        return;
    }

    display_set_pixel(0, 1);
    display_set_pixel(1, 1);
    display_set_pixel(2, 1);
    display_update_inner();

    // uart_init(BIT_RATE_9600,0);
    os_delay_us(100*1000);

    os_delay_us(1000*1000);

    display_anim();
    //  os_delay_us(500*1000);

    NODE_DBG("Hello Wurst.\n");
    // os_delay_us(500*1000);

    // Set up I2C
    // Wire.begin(D1, D2); // sda, scl

    display_set_pixel(0, 0);
    display_set_pixel(1, 0);
    display_set_pixel(2, 0);
    display_set_pixel(3, 0);
    display_update();

    comm_init();
    orient_init();

    // system_init_done_cb(nodemcu_init);

    system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
    system_os_post(user_procTaskPrio, 0, 0);

    NODE_DBG("End of user_init.\n");
}
Beispiel #16
0
STATIC mp_obj_t esp_meminfo() {
    system_print_meminfo();
    return mp_const_none;
}