示例#1
0
/******************************************************************************
 * 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
}
示例#2
0
void init_system (void) {
   /* Initialize configured interfaces and applications. */

#if ETH_ENABLE == 1
   init_eth_link ();
#endif
#if PPP_ENABLE == 1
   init_ppp_link ();
#endif
#if SLIP_ENABLE == 1
   init_slip_link ();
#endif

#if (IGMP_ENABLE & ETH_ENABLE) == 1
   init_igmp ();
#endif
#if UDP_ENABLE == 1
   init_udp ();
#endif
#if TCP_ENABLE == 1
   init_tcp ();
#endif
#if HTTP_ENABLE == 1
   init_http ();
#endif
#if TNET_ENABLE == 1
   init_tnet ();
#endif
#if TFTP_ENABLE == 1
   init_tftp ();
#endif
#if (NBNS_ENABLE & ETH_ENABLE) == 1
   init_nbns ();
#endif
#if (DHCP_ENABLE & ETH_ENABLE) == 1
   init_dhcp ();
#endif
#if DNS_ENABLE == 1
   init_dns ();
#endif
#if SMTP_ENABLE == 1
   init_smtp ();
#endif
}
示例#3
0
文件: main.c 项目: tw4452852/spider
int main(int argc, const char *argv[])
{
    struct tw_hostent* p_host, *p;
    int i, j, retry = 0;
    char *pa;
    pthread_t dns_recv_pthread;

    if (argc < 2) {
        fprintf(stderr, "%s website1, website2 ...", argv[0]);
    }

    if(signal(SIGINT, sig_int) == SIG_ERR){
        perror("signal error");
    }

    init_head(&head);

    init_dns();
    epfd = epoll_create(1000);

    for (i = 0; i < argc - 1; i++) {
        p_host = (struct tw_hostent*)malloc(sizeof(struct tw_hostent));
        memcpy(p_host->name, argv[i + 1], 30);
        memcpy(p_host->file, argv[i + 1], 30);
        if ((pa = strchr(argv[i + 1], '.'))!= NULL) {
            memcpy(p_host->key_word, pa + 1, 30);
        }
        if((p_host->dns = gethostbyname(argv[i + 1])) == NULL){
            fprintf(stderr, "gethostbyname error");
            return 1;
        }
        p_host->is_dns = 1;
        p_host->first = 1;
        p_host->prev = p_host->next = NULL;
        join_list(&p_host);

        DoOnce(p_host);
        find_url(p_host);
        p_host->is_url = 1;

    }

    pthread_create(&dns_recv_pthread, NULL, dns_recv, NULL);

__again:
    for(p = head.head; p != NULL; p = p->next)
    {
        if(p->is_dns == 0) 
        {
           // printf("still in __again\n");
            goto __again; 
        }
    }
    printf("1 round is well done!\n");
    for(p = head.head; p != NULL; p = p->next)
    {
        if(p->is_url == 0){
            DoOnce(p);
            find_url(p);
            p->is_url = 1;
        }
    }
    printf("2 round is well done!\n");

//      disp_result();

    return 0;
}