/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { system_update_cpu_freq(160); //overclock :) uart_init(BIT_RATE_115200,BIT_RATE_115200); NODE_DBG("User Init"); uint32_t size = flash_get_size_byte(); NODE_DBG("Flash size %d",size); config_wifi(); relay_init(); init_dns(); init_http_server(); //uncomment to send data to mqtt broker //mqtt_app_init(); //uncomment if you have sensors intalled //sensors_init(); #ifdef DEVELOP_VERSION //arm timer os_memset(&heapTimer,0,sizeof(os_timer_t)); os_timer_disarm(&heapTimer); os_timer_setfn(&heapTimer, (os_timer_func_t *)heapTimerCb, NULL); os_timer_arm(&heapTimer, 5000, 1); #endif }
static struct afb_hsrv *start_http_server(struct afb_config * config) { int rc; struct afb_hsrv *hsrv; if (afb_hreq_init_download_path("/tmp")) { /* TODO: sessiondir? */ ERROR("unable to set the tmp directory"); return NULL; } hsrv = afb_hsrv_create(); if (hsrv == NULL) { ERROR("memory allocation failure"); return NULL; } if (!afb_hsrv_set_cache_timeout(hsrv, config->cacheTimeout) || !init_http_server(hsrv, config)) { ERROR("initialisation of httpd failed"); afb_hsrv_put(hsrv); return NULL; } NOTICE("Waiting port=%d rootdir=%s", config->httpdPort, config->rootdir); NOTICE("Browser URL= http:/*localhost:%d", config->httpdPort); rc = afb_hsrv_start(hsrv, (uint16_t) config->httpdPort, 15); if (!rc) { ERROR("starting of httpd failed"); afb_hsrv_put(hsrv); return NULL; } return hsrv; }