int application_start(int argc, char **argv) { #ifdef CSP_LINUXHOST signal(SIGPIPE, SIG_IGN); #endif #if AOS_ATCMD at.set_mode(ASYN); at.init(AT_RECV_PREFIX, AT_RECV_SUCCESS_POSTFIX, AT_RECV_FAIL_POSTFIX, AT_SEND_DELIMITER, 1000); #endif #ifdef WITH_SAL sal_init(); #endif aos_set_log_level(AOS_LL_DEBUG); netmgr_init(); aos_register_event_filter(EV_WIFI, wifi_service_event, NULL); #ifdef CONFIG_YWSS aos_register_event_filter(EV_KEY, linkkit_key_process, NULL); aos_register_event_filter(EV_YUNIO, cloud_service_event, NULL); #endif #if (defined (CONFIG_AOS_CLI) && defined (CONFIG_YWSS)) aos_cli_register_command(&resetcmd); aos_cli_register_command(&ncmd); #endif aos_task_new("netmgr", start_netmgr, NULL, 4096); aos_loop_run(); return 0; }
static void do_awss_reset() { if (linkkit_started) { aos_task_new("reset", awss_report_reset, NULL, 2048); } netmgr_clear_ap_config(); LOG("SSID cleared. Please reboot the system.\n"); aos_post_delayed_action(1000, reboot_system, NULL); }
int apppack_upgrade(char *url) { if (update_done) { update_done = 0; app_mgr_set_boneflag(0); apppack_init(write_app_pack); if (aos_task_new("appupdate", download_work, url, 1024 * 4) != 0) { update_done = 1; apppack_final(); be_warn("APP_UPDATE", "aos_task_new fail"); return -1; } } else { be_warn("APP_UPDATE", "apppack upgrading..."); } return 0; }
static int at_init(uart_dev_t *u, const char *recv_delimiter, const char *send_delimiter, int timeout) { if (!u || !recv_delimiter || !send_delimiter || (timeout < 0)) { LOGE(MODULE_NAME, "%s: invalid argument", __func__); return -1; } if (at_init_uart(u) != 0) return -1; at_set_timeout(timeout); at_set_recv_delimiter(recv_delimiter); at_set_send_delimiter(send_delimiter); if (at._mode == ASYN) { at_init_mutex(); slist_init(&at.task_l); aos_task_new("at_worker", at_worker, NULL, 4096); } return 0; }
int aos_task_new_ext(aos_task_t *task, const char *name, void (*fn)(void *), void *arg, int stack_size, int prio) { return aos_task_new(name, fn, arg, stack_size); }
int aos_work_sched(aos_work_t *work) { struct work *w = work->hdl; return aos_task_new("worker", worker_entry, w, 8192); }
static int at_init(const char *recv_prefix, const char *recv_success_postfix, const char *recv_fail_postfix, const char *send_delimiter, int timeout) { if (!recv_prefix || !recv_success_postfix || !recv_fail_postfix || !send_delimiter || (timeout < 0)) { LOGE(MODULE_NAME, "%s: invalid argument", __func__); return -1; } if (inited == 1) { LOGI(MODULE_NAME, "have already inited ,it will init again\r\n"); inited = 0; } if (at_init_uart() != 0) { LOGE(MODULE_NAME, "at uart init fail \r\n"); return -1; } memset(at._oobs, 0, sizeof(oob_t) * OOB_MAX); at_set_timeout(timeout); at_set_recv_delimiter(recv_prefix, recv_success_postfix, recv_fail_postfix); at_set_send_delimiter(send_delimiter); LOGD(MODULE_NAME, "at worker rcv prefix is %s success postfix is %s fail postfix is %s " "\r\n", recv_prefix, recv_success_postfix, recv_fail_postfix); if (at_init_at_mutex() != 0) { LOGE(MODULE_NAME, "at uart mutex init fail \r\n"); return -1; } if (at_init_task_mutex() != 0) { at_uinit_at_mutex(); LOGE(MODULE_NAME, "at mutex init fail \r\n"); return -1; } slist_init(&at.task_l); if (at_worker_uart_send_mutex_init() != 0) { at_uinit_at_mutex(); at_uinit_task_mutex(); LOGE(MODULE_NAME, "fail to creat at worker sem\r\n"); } if (aos_task_new("at_worker", at_worker, NULL, at_worker_stacksize)) { at_uinit_at_mutex(); at_uinit_task_mutex(); at_worker_uart_send_mutex_uinit(); LOGE(MODULE_NAME, "fail to creat at task\r\n"); return -1; } inited = 1; return 0; }