Example #1
0
enum mgos_init_result esp_mgos_init2(void) {
#ifdef CS_MMAP
  mgos_vfs_mmap_init();
#endif
  enum mgos_init_result ir = mgos_debug_uart_init();
  if (ir != MGOS_INIT_OK) return ir;
  uart_initialized = true;
  cs_log_set_level(MGOS_EARLY_DEBUG_LEVEL);
  setvbuf(stdout, NULL, _IOLBF, 256);
  setvbuf(stderr, NULL, _IOLBF, 256);
  /* Note: putc can be invoked from int handlers. */
  os_install_putc1(sdk_putc);
  fputc('\n', stderr);

  if (strcmp(MGOS_APP, "mongoose-os") != 0) {
    LOG(LL_INFO, ("%s %s (%s)", MGOS_APP, build_version, build_id));
  }
  LOG(LL_INFO, ("Mongoose OS %s (%s)", mg_build_version, mg_build_id));
  LOG(LL_INFO, ("CPU: %s, %d MHz, RAM: %u total, %u free",
                esp_chip_type_str(esp_get_chip_type()),
                (int) (mgos_get_cpu_freq() / 1000000), mgos_get_heap_size(),
                mgos_get_free_heap_size()));
  LOG(LL_INFO, ("SDK %s; flash: %uM", system_get_sdk_version(),
                esp_vfs_dev_sysflash_get_size(NULL) / 1048576));
  esp_print_reset_info();

  system_soft_wdt_stop();
  ir = mgos_init();
  if (ir != MGOS_INIT_OK) {
    LOG(LL_ERROR, ("%s init error: %d", "MG", ir));
    return ir;
  }

  return MGOS_INIT_OK;
}
Example #2
0
enum mgos_init_result mgos_init(void) {
  enum mgos_init_result r;

  mgos_uptime_init();

  r = mgos_net_init();
  if (r != MGOS_INIT_OK) return r;

  r = mgos_gpio_init();
  if (r != MGOS_INIT_OK) return r;

  r = mgos_sys_config_init();
  if (r != MGOS_INIT_OK) return r;

#if MGOS_ENABLE_MDNS
  r = mgos_mdns_init(); /* Before dns_sd init, after
                           mgos_sys_config_init_platform */
  if (r != MGOS_INIT_OK) return r;
#endif
#if MGOS_ENABLE_SNTP
  r = mgos_sntp_init();
  if (r != MGOS_INIT_OK) return r;
#endif

  if (!mgos_deps_init()) {
    return MGOS_INIT_DEPS_FAILED;
  }

  if (mgos_app_init() != MGOS_APP_INIT_SUCCESS) {
    return MGOS_INIT_APP_INIT_FAILED;
  }

  LOG(LL_INFO, ("Init done, RAM: %d total, %d free, %d min free",
                (int) mgos_get_heap_size(), (int) mgos_get_free_heap_size(),
                (int) mgos_get_min_free_heap_size()));
  mgos_set_enable_min_heap_free_reporting(true);

  /* Invoke all registered init_done hooks */
  mgos_hook_trigger(MGOS_HOOK_INIT_DONE, NULL);

  return MGOS_INIT_OK;
}
Example #3
0
enum mgos_init_result mgos_init(void) {
  if (!mgos_deps_init()) {
    return MGOS_INIT_DEPS_FAILED;
  }

  if (mgos_app_init() != MGOS_APP_INIT_SUCCESS) {
    return MGOS_INIT_APP_INIT_FAILED;
  }

  LOG(LL_INFO, ("Init done, RAM: %lu total, %lu free, %lu min free",
                (unsigned long) mgos_get_heap_size(),
                (unsigned long) mgos_get_free_heap_size(),
                (unsigned long) mgos_get_min_free_heap_size()));
  mgos_set_enable_min_heap_free_reporting(true);

  /* Invoke all registered init_done event handlers */
  mgos_event_trigger(MGOS_EVENT_INIT_DONE, NULL);

  return MGOS_INIT_OK;
}