예제 #1
0
/*
 * In mt76xx_tcp_app.h we have defined the UIP_APPCALL macro to
 * mt7681_tcp_appcall so that this funcion is uIP's application
 * function. This function is called whenever an uIP event occurs
 * (e.g. when a new connection is established, new data arrives, sent
 * data is acknowledged, data needs to be retransmitted, etc.).
 */
void
iot_tcp_appcall(void)
{
    u16_t lport = HTONS(uip_conn->lport);

#if UIP_HTTP_CLIENT_SUPPORT
    if (lport == http_clientPort) {
        webclient_appcall();
        return;
    }
#endif

#if TCP_CLI_APP1_ENABLE
    if (lport == TCP_CLI_APP1_LOCAL_PORT) {
        handle_tcp_cli_app1();
        return;
    }
#endif

#if TCP_SRV_APP1_ENABLE
    if (lport == TCP_SRV_APP1_LOCAL_PORT) {
        handle_tcp_srv_app1();
        return;
    }
#endif

#if MY_TCP_SRV_APP_ENABLE
	if (lport == MY_TCP_SRV_APP_LOCAL_PORT) {
        handle_my_tcp_srv();
        return;
    }
#endif

#if UIP_CLOUD_SERVER_SUPPORT
    if (uip_newdata()) {
        if(lport == CLOUD_TCP_SERVER_PORT){
            if(uip_datalen()%2 == 0){
                cloud_activation_process(uip_appdata, uip_datalen());
            }else{
                printf_high("data length:%d from apk error\n", uip_datalen());
            }
            return;
        }
    }

    if(lport == http_clientPort) {
        webclient_appcall();
        return;
    }

    if(lport == TCP_cloudClientPort) {
        cloudClient_tcpAppcall();
        return;
    }
#endif

    handle_tcp_app();
}
예제 #2
0
파일: shell-wget.c 프로젝트: EDAyele/ptunes
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_wget_process, ev, data)
{
  PROCESS_BEGIN();

  strncpy(url, data, sizeof(url));
  open_url(url);

  running = 1;
  
  while(running) {
    PROCESS_WAIT_EVENT();
    
    if(ev == tcpip_event) {
      webclient_appcall(data);
    } else if(ev == resolv_event_found) {
      /* Either found a hostname, or not. */
      if((char *)data != NULL &&
	 resolv_lookup((char *)data) != NULL) {
	open_url(url);
      } else {
	shell_output_str(&wget_command, "Host not found.", "");
      }
    }
  }

  PROCESS_END();
}
예제 #3
0
파일: wget.c 프로젝트: 13416795/contiki
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(wget_process, ev, data)
{
  PROCESS_BEGIN();

  PRINTF("wget: fetching %s\n", file);
#if STATS
  fetch_counter = 0;
  fetch_started = clock_time();
#endif /* STATS */
  LEDS_ON(LEDS_YELLOW);
  if(webclient_get(server, port, file) == 0) {
    PRINTF("wget: failed to connect\n");
    LEDS_OFF(LEDS_YELLOW);
    fetch_running = 0;
    call_done(WGET_CONNECT_FAILED);
  } else {
    while(fetch_running) {
      PROCESS_WAIT_EVENT();
      if(ev == tcpip_event) {
        webclient_appcall(data);
      }
    }
  }

  PROCESS_END();
}
예제 #4
0
파일: wget.c 프로젝트: 200018171/contiki
/*-----------------------------------------------------------------------------------*/
PROCESS_THREAD(wget_process, ev, data)
{
  static char name[32];
  static unsigned char i;

  PROCESS_BEGIN();

  /* Allow other processes to initialize properly. */
  for(i = 0; i < 10; ++i) {
    PROCESS_PAUSE();
  }

  fputs("Get url:", stdout);
  if(contiki_argc > 1) {
    strcpy(url, contiki_argv[1]);
    puts(url);
  } else {
    gets(url);
  }
  fputs("Save as:", stdout);
  if(contiki_argc > 2) {
    strcpy(name, contiki_argv[2]);
    puts(name);
  } else {
    gets(name);
  }
  file = cfs_open(name, CFS_WRITE);
  if(file == -1) {
    printf("Open error with '%s'\n", name);
    app_quit();
  } else {
    petsciiconv_toascii(url, sizeof(url));
    start_get();
  }

  while(1) {

    PROCESS_WAIT_EVENT();
  
    if(ev == tcpip_event) {
      webclient_appcall(data);
#if UIP_UDP
    } else if(ev == resolv_event_found) {
      /* Either found a hostname, or not. */
      if((char *)data != NULL &&
        resolv_lookup((char *)data, NULL) == RESOLV_STATUS_CACHED) {
        start_get();
      } else {
        puts("Host not found");
        app_quit();
      }
#endif /* UIP_UDP */
    }
  }

  PROCESS_END();
}
예제 #5
0
void dispatch_tcp_appcall (void)
{
	struct sambungan_state *sb = (struct sambungan_state *) &(uip_conn->appstate2);
	
#ifdef PAKE_HTTP
	if (uip_conn->lport == HTONS (80)) 
		httpd_appcall ();
#endif

#ifdef PAKE_TELNETD
  	if (uip_conn->lport == HTONS (23))
    	telnetd_appcall ();
#endif

#ifdef BOARD_KOMON
  	if (uip_conn->lport == HTONS(PORT_MONITA))
		monita_appcall();
#endif

#if (PAKAI_KONTROL == 1)
	else if (uip_conn->lport == HTONS(PORT_KONTROL))
		kontrol_appcall();
#endif

//#ifdef CARI_SUMBERNYA
#ifdef SAMPURASUN_SERVER
	// gunakan rport untuk konek ke orang lain
	if (uip_conn->rport == HTONS(PORT_MONITA))
	{
		samb_appcall();
	}
	else if (uip_conn->rport == HTONS(PORT_DAYTIME))
	{
		daytime_appcall();
	}
#endif

#ifdef PAKAI_WEBCLIENT
	/* webclient */
	if (uip_conn->rport == HTONS(80))	{
		webclient_appcall();
	}	  
#endif

#ifdef PAKAI_KIRIM_BALIK
	//*
	if (uip_conn->rport == HTONS(PORT_KIRIM_BALIK))	{
		kirim_balik_appcall();
	}
	//*/	  
#endif
	//printf("%s(): port = %d\r\n", __FUNCTION__, uip_conn->rport);
}
예제 #6
0
void tcp_protocol_switcher_appcall(void)
{
	if( uip_conn->rport == HTONS( TELNET_SERVER_PORT ) ) { // telnet port
		telnet_client_appcall();
		return;
	}
	if( uip_conn->lport == HTONS( SIEMENS_TCP_PORT ) ) { // Siements TCPIP port
		siemensTCP_appcall();
		return;
	}
	if( uip_conn->lport == HTONS( 80 ) ) { // Web Server port
		httpd_appcall();
		return;
	}
	if( uip_conn->lport == HTONS( SPECIAL_SERVER_PORT ) ) { // Special Server port
		specserver_appcall();
		return;
	}
	webclient_appcall();	// Usually remote port 80 but can be any other one
}
예제 #7
0
파일: www.c 프로젝트: 21moons/contiki
/* www_process():
 *
 * The program's signal dispatcher function. Is called whenever a signal arrives.
 */
PROCESS_THREAD(www_process, ev, data)
{
    static struct ctk_widget *w;
#if WWW_CONF_WITH_WGET
    static char *argptr;
#endif /* WWW_CONF_WITH_WGET */

    w = (struct ctk_widget *)data;

    PROCESS_BEGIN();

    /* Create the main window. */
    memset(webpage, 0, sizeof(webpage));
    ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH,
                   WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser");
    make_window();
#ifdef WWW_CONF_HOMEPAGE
    strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl));
#endif /* WWW_CONF_HOMEPAGE */
    CTK_WIDGET_FOCUS(&mainwindow, &urlentry);

#if WWW_CONF_WITH_WGET || defined(WWW_CONF_WGET_EXEC)
#if CTK_CONF_WINDOWS
    /* Create download dialog.*/
    ctk_dialog_new(&wgetdialog, 38, 7);
    CTK_WIDGET_ADD(&wgetdialog, &wgetlabel1);
    CTK_WIDGET_ADD(&wgetdialog, &wgetlabel2);
    CTK_WIDGET_ADD(&wgetdialog, &wgetnobutton);
    CTK_WIDGET_ADD(&wgetdialog, &wgetyesbutton);
#endif /* CTK_CONF_WINDOWS */
#endif /* WWW_CONF_WITH_WGET || WWW_CONF_WGET_EXEC */

    ctk_window_open(&mainwindow);

    while(1) {

        PROCESS_WAIT_EVENT();

        if(ev == tcpip_event) {
            webclient_appcall(data);
        } else if(ev == ctk_signal_widget_activate) {
            if(w == (struct ctk_widget *)&gobutton ||
                    w == (struct ctk_widget *)&urlentry) {
                start_loading();
                firsty = 0;
#if WWW_CONF_HISTORY_SIZE > 0
                log_back();
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
                memcpy(url, editurl, WWW_CONF_MAX_URLLEN);
                petsciiconv_toascii(url, WWW_CONF_MAX_URLLEN);
                open_url();
                CTK_WIDGET_FOCUS(&mainwindow, &gobutton);
#if WWW_CONF_HISTORY_SIZE > 0
            } else if(w == (struct ctk_widget *)&backbutton) {
                firsty = 0;
                start_loading();
                --history_last;
                if(history_last > WWW_CONF_HISTORY_SIZE) {
                    history_last = WWW_CONF_HISTORY_SIZE - 1;
                }
                memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
                open_url();
                CTK_WIDGET_FOCUS(&mainwindow, &backbutton);
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
            } else if(w == (struct ctk_widget *)&downbutton) {
                firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4;
                start_loading();
                open_url();
                CTK_WIDGET_FOCUS(&mainwindow, &downbutton);
            } else if(w == (struct ctk_widget *)&stopbutton) {
                loading = 0;
                webclient_close();
#if WWW_CONF_WITH_WGET || defined(WWW_CONF_WGET_EXEC)
            } else if(w == (struct ctk_widget *)&wgetnobutton) {
#if CTK_CONF_WINDOWS
                ctk_dialog_close();
#else /* CTK_CONF_WINDOWS */
                clear_page();
#endif /* CTK_CONF_WINDOWS */
            } else if(w == (struct ctk_widget *)&wgetyesbutton) {
#if CTK_CONF_WINDOWS
                ctk_dialog_close();
#else /* CTK_CONF_WINDOWS */
                clear_page();
#endif /* CTK_CONF_WINDOWS */
#if WWW_CONF_WITH_WGET
                quit();
                argptr = arg_alloc((char)WWW_CONF_MAX_URLLEN);
                if(argptr != NULL) {
                    strncpy(argptr, url, WWW_CONF_MAX_URLLEN);
                }
                program_handler_load("wget.prg", argptr);
#else /* WWW_CONF_WITH_WGET */
                petsciiconv_topetscii(url, sizeof(url));
                /* Clear screen */
                ctk_restore();
                WWW_CONF_WGET_EXEC(url);
                redraw_window();
                show_statustext("Cannot exec wget");
#endif /* WWW_CONF_WITH_WGET */
#endif /* WWW_CONF_WITH_WGET || WWW_CONF_WGET_EXEC */
#if WWW_CONF_FORMS
            } else {
                /* Assume form widget. */
                struct inputattrib *input = (struct inputattrib *)
                                            (((char *)w) - offsetof(struct inputattrib, widget));
                formsubmit(input->formptr);
#endif /* WWW_CONF_FORMS */
            }
        } else if(ev == ctk_signal_hyperlink_activate) {
            firsty = 0;
#if WWW_CONF_HISTORY_SIZE > 0
            log_back();
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
            set_link(w->widget.hyperlink.url);
            show_url();
            open_url();
            start_loading();
            CTK_WIDGET_FOCUS(&mainwindow, &stopbutton);
        } else if(ev == ctk_signal_hyperlink_hover) {
            if(CTK_WIDGET_TYPE((struct ctk_widget *)data) == CTK_WIDGET_HYPERLINK) {
                strncpy(statustexturl, w->widget.hyperlink.url,
                        sizeof(statustexturl));
                petsciiconv_topetscii(statustexturl, sizeof(statustexturl));
                show_statustext(statustexturl);
            }
#if UIP_UDP
        } else if(ev == resolv_event_found) {
            /* Either found a hostname, or not. */
            if((char *)data != NULL &&
                    resolv_lookup((char *)data, NULL) == RESOLV_STATUS_CACHED) {
                open_url();
            } else {
                show_statustext("Host not found");
            }
#endif /* UIP_UDP */
        } else if(ev == ctk_signal_window_close ||
                  ev == PROCESS_EVENT_EXIT) {
            quit();
        }
    }
예제 #8
0
파일: www.c 프로젝트: EDAyele/ptunes
/* www_process():
 *
 * The program's signal dispatcher function. Is called whenever a signal arrives.
 */
PROCESS_THREAD(www_process, ev, data)
{
  static struct ctk_widget *w;
  static unsigned char i;
#if WWW_CONF_WITH_WGET
  static char *argptr;
#endif /* WWW_CONF_WITH_WGET */

  w = (struct ctk_widget *)data;

  PROCESS_BEGIN();
  
  /* Create the main window. */
  memset(webpage, 0, sizeof(webpage));
  ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH,
		 WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser");
  make_window();
#ifdef WWW_CONF_HOMEPAGE
  strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl));
#endif /* WWW_CONF_HOMEPAGE */
  CTK_WIDGET_FOCUS(&mainwindow, &urlentry);
  
#if WWW_CONF_WITH_WGET
  /* Create download dialog.*/
  ctk_dialog_new(&wgetdialog, 38, 7);
  CTK_WIDGET_ADD(&wgetdialog, &wgetlabel1);
  CTK_WIDGET_ADD(&wgetdialog, &wgetlabel2);
  CTK_WIDGET_ADD(&wgetdialog, &wgetnobutton);
  CTK_WIDGET_ADD(&wgetdialog, &wgetyesbutton);
#endif /* WWW_CONF_WITH_WGET */

  ctk_window_open(&mainwindow);
  
  while(1) {

    PROCESS_WAIT_EVENT();
    
    if(ev == tcpip_event) {
      webclient_appcall(data);
    } else if(ev == ctk_signal_widget_activate) {
      if(w == (struct ctk_widget *)&backbutton) {
	firsty = 0;
	start_loading();
	
	--history_last;
	if(history_last > WWW_CONF_HISTORY_SIZE) {
	  history_last = WWW_CONF_HISTORY_SIZE - 1;
	}
	memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
	open_url();
	CTK_WIDGET_FOCUS(&mainwindow, &backbutton);
      } else if(w == (struct ctk_widget *)&downbutton) {
	firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4;
	start_loading();
	open_url();
	CTK_WIDGET_FOCUS(&mainwindow, &downbutton);
      } else if(w == (struct ctk_widget *)&gobutton ||
		w == (struct ctk_widget *)&urlentry) {
	start_loading();
	firsty = 0;
	
	log_back();
	memcpy(url, editurl, WWW_CONF_MAX_URLLEN);
	petsciiconv_toascii(url, WWW_CONF_MAX_URLLEN);
	open_url();
	CTK_WIDGET_FOCUS(&mainwindow, &gobutton);
      } else if(w == (struct ctk_widget *)&stopbutton) {
	loading = 0;
	webclient_close();
#if WWW_CONF_WITH_WGET
      } else if(w == (struct ctk_widget *)&wgetnobutton) {
	ctk_dialog_close();
      } else if(w == (struct ctk_widget *)&wgetyesbutton) {
	ctk_dialog_close();
	quit();
	argptr = arg_alloc((char)WWW_CONF_MAX_URLLEN);
	if(argptr != NULL) {
	  strncpy(argptr, url, WWW_CONF_MAX_URLLEN);
	}
	program_handler_load("wget.prg", argptr);
#endif /* WWW_CONF_WITH_WGET */
#if WWW_CONF_FORMS
      } else {
	/* Check form buttons */
	for(i = 0; i < pagewidgetptr; ++i) {
	  if(&pagewidgets[i] == w) {
	    formsubmit(&pagewidgetattribs[i].form);
	    /*	  show_statustext(pagewidgetattribs[i].form.formaction);*/
	    /*	  PRINTF(("Formaction %s formname %s inputname %s\n",
		  pagewidgetattribs[i].form.formaction,
		  pagewidgetattribs[i].form.formname,
		  pagewidgetattribs[i].form.inputname));*/
	    break;
	  }
	}
#endif /* WWW_CONF_FORMS */
      }
    } else if(ev == ctk_signal_hyperlink_activate) {
      firsty = 0;
      log_back();
      open_link(w->widget.hyperlink.url);
      CTK_WIDGET_FOCUS(&mainwindow, &stopbutton);
      /*    ctk_window_open(&mainwindow);*/
    } else if(ev == ctk_signal_hyperlink_hover) {
      if(CTK_WIDGET_TYPE((struct ctk_widget *)data) ==
	 CTK_WIDGET_HYPERLINK) {
	strncpy(statustexturl, w->widget.hyperlink.url,
		sizeof(statustexturl));
	petsciiconv_topetscii(statustexturl, sizeof(statustexturl));
	show_statustext(statustexturl);
      }
    } else if(ev == resolv_event_found) {
      /* Either found a hostname, or not. */
      if((char *)data != NULL &&
	 resolv_lookup((char *)data) != NULL) {
	open_url();
      } else {
	show_statustext("Host not found.");
      }
    } else if(ev == ctk_signal_window_close ||
	      ev == PROCESS_EVENT_EXIT) {
      quit();
    }
  }
  PROCESS_END();
}