Esempio n. 1
0
//Reads button presses and adds to variable for LEDs
PROCESS_THREAD(authority_process, ev, data){
	PROCESS_BEGIN();
#ifdef DEBUG
	volatile unsigned int *resetreas_reg = (unsigned int*) 0x40000400;
	if(*resetreas_reg != 1){
		printf("\n Reset reason: %d \n", *resetreas_reg);
		PROCESS_WAIT_EVENT(); //This single line made things work and not crash? What is this unstable hell-machine?
	}

	*resetreas_reg = 0xF00F;
#endif
	rest_init_engine();
	

#if WITH_IPSO
	ipso_objects_init();
#endif
  	rest_activate_resource(&res_door, "doors/door");
	while(1){
		PROCESS_WAIT_EVENT();
		//wait for requests and process data
	}

	PROCESS_END();
}
Esempio n. 2
0
PROCESS_THREAD(cetic_6lbr_process, ev, data)
{
  PROCESS_BEGIN();

  cetic_6lbr_startup = clock_seconds();

#if CONTIKI_TARGET_NATIVE
  slip_config_handle_arguments(contiki_argc, contiki_argv);
#endif

  load_nvm_config();

  platform_init();

  process_start(&eth_drv_process, NULL);

  while(!ethernet_ready) {
    PROCESS_PAUSE();
  }

  process_start(&tcpip_process, NULL);

  PROCESS_PAUSE();

#if CETIC_NODE_INFO
  node_info_init();
#endif

  packet_filter_init();
  cetic_6lbr_init();

#if WEBSERVER
  process_start(&webserver_nogui_process, NULL);
#endif
#if UDPSERVER
  process_start(&udp_server_process, NULL);
#endif

  printf("CETIC 6LBR Started\n");

#if CONTIKI_TARGET_NATIVE
  PROCESS_WAIT_EVENT();
  etimer_set(&reboot_timer, CLOCK_SECOND);
  PROCESS_WAIT_EVENT();
  printf("Exiting...\n");
  exit(0);
#endif

  PROCESS_END();
}
Esempio n. 3
0
File: shell.c Progetto: uoaerg/wise
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_server_process, ev, data)
{
  struct process *p;
  struct shell_command *c;
  static struct etimer etimer;
  PROCESS_BEGIN();

  etimer_set(&etimer, CLOCK_SECOND * 10);
  while(1) {
    PROCESS_WAIT_EVENT();
    if(ev == PROCESS_EVENT_EXITED) {
      p = data;
      /*      printf("process exited '%s' (front '%s')\n", p->name,
	      front_process->name);*/
      for(c = list_head(commands);
	  c != NULL && c->process != p;
	  c = c->next);
      while(c != NULL) {
	if(c->child != NULL && c->child->process != NULL) {
	  /*	  printf("Killing '%s'\n", c->process->name);*/
	  input_to_child_command(c->child, "", 0, "", 0);
	  /*	  process_exit(c->process);*/
	}
	c = c->child;
      }
    } else if(ev == PROCESS_EVENT_TIMER) {
      etimer_reset(&etimer);
      shell_set_time(shell_time());
    }
  }
  
  PROCESS_END();
}
Esempio n. 4
0
/*-----------------------------------------------------------------------*/
PROCESS_THREAD(udp_sender_process, ev, data)
{
	static struct etimer period_timer, wait_timer;
	PROCESS_BEGIN();
	
	set_global_address();
	PRINTF("UDP sender process started\n");
	print_local_address();

	/* new connection with remote host */
	sender_conn = udp_new(NULL, UIP_HTONS(UDP_SINK_PORT), NULL);
	udp_bind(sender_conn, UIP_HTONS(UDP_SENDER_PORT));

	PRINTF("Created a connection with the sink ");
	PRINT6ADDR(&sender_conn->ripaddr);
	PRINTF(" local/remote port %u/%u\n",
			UIP_HTONS(sender_conn->lport), UIP_HTONS(sender_conn->rport));
	
	etimer_set(&period_timer, CLOCK_SECOND * PERIOD);
	while(1) {
		PROCESS_WAIT_EVENT();
		if(ev == PROCESS_EVENT_TIMER) {
			if(data == &period_timer) {
				etimer_reset(&period_timer);
				etimer_set(&wait_timer,
							random_rand() % (CLOCK_SECOND * RANDWAIT));
			} else if(data ==&wait_timer) {
				/* Time to send a data. */
				collect_common_send();
			}
		}
	}
	PROCESS_END();
}
Esempio n. 5
0
/*---------------------------------------------------------------------------*/
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();
}
Esempio n. 6
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{
  PROCESS_BEGIN();

  dtls_init();
  init_dtls();

  print_local_addresses();

  if (!dtls_context) {
    dtls_emerg("cannot create context\n");
    PROCESS_EXIT();
  }

#ifdef ENABLE_POWERTRACE
  powertrace_start(CLOCK_SECOND * 2); 
#endif

  while(1) {
    PROCESS_WAIT_EVENT();
    if(ev == tcpip_event) {
      dtls_handle_read(dtls_context);
    }
  }

  PROCESS_END();
}
Esempio n. 7
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sensors_process, ev, data)
{
  static int i;
  static int events;

  PROCESS_BEGIN();

  sensors_event = process_alloc_event();

  for(i = 0; sensors[i] != NULL; ++i) {
    sensors_flags[i] = 0;
    sensors[i]->configure(SENSORS_HW_INIT, 0);
  }
  num_sensors = i;

  while(1) {

    PROCESS_WAIT_EVENT();

    do {
      events = 0;
      for(i = 0; i < num_sensors; ++i) {
        if(sensors_flags[i] & FLAG_CHANGED) {
          if(process_post(PROCESS_BROADCAST, sensors_event, sensors[i]) == PROCESS_ERR_OK) {
            PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);
          }
          sensors_flags[i] &= ~FLAG_CHANGED;
          events++;
        }
      }
    } while(events);
  }

  PROCESS_END();
}
Esempio n. 8
0
/*-----------------------------------------------------------------------------------*/
PROCESS_THREAD(webserver_process, ev, data)
{
  PROCESS_BEGIN();
  
  ctk_window_new(&mainwindow, LOG_WIDTH, LOG_HEIGHT+1, "Web server");
  
  CTK_WIDGET_ADD(&mainwindow, &message);
  CTK_WIDGET_ADD(&mainwindow, &loglabel);
  
  httpd_init();
  
  ctk_window_open(&mainwindow);

  while(1) {
    PROCESS_WAIT_EVENT();

    if(ev == ctk_signal_window_close ||
       ev == PROCESS_EVENT_EXIT) {
      ctk_window_close(&mainwindow);
      process_exit(&webserver_process);
      LOADER_UNLOAD();    
    } else if(ev == tcpip_event) {
      httpd_appcall(data);
    }
  }

  PROCESS_END();
}
Esempio n. 9
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(stest_process, ev, data)
{
  static struct etimer timer;
  PROCESS_BEGIN();

  clrscr_arch();
#ifdef RS232_INTR
  rs232_arch_init(serial_line_input_byte, 0);
#endif

  etimer_set(&timer, CLOCK_SECOND);

  log_message("Starting serial test process");
  while(1) {
    PROCESS_WAIT_EVENT();

    if (etimer_expired(&timer)) {
      log_message("Sending serial data now");
      rs232_print("GNU's not Unix\n");
      etimer_reset(&timer);
    }

    if(ev == serial_line_event_message) {
      log_message(data);
    }
  }

  PROCESS_END();
}
Esempio n. 10
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
  static struct etimer timer;
  static int count=0;
  etimer_set(&timer, CLOCK_CONF_SECOND);

  PROCESS_BEGIN();
  while(1)
 {
 PROCESS_WAIT_EVENT();
 
 if (ev==PROCESS_EVENT_TIMER)
   {

  // DDRB |= (1<<PORTB4);
  // PORTB ^= (1<<PORTB4);   

printf("Hello World # %i\n", count);
   count++;
//   etimer_reset(&timer);
 
  }

}

  
  PROCESS_END();
}
Esempio n. 11
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(burn_process, ev, data)
{
  PROCESS_BEGIN();

  etimer_set(&etimer, 5*CLOCK_SECOND);
  PROCESS_WAIT_UNTIL(etimer_expired(&etimer));

  watchdog_stop();
  leds_on(LEDS_RED);
#if NODEID
  printf("Burning node id %d\n", NODEID);
  node_id_burn(NODEID);
  leds_on(LEDS_BLUE);
  node_id_restore();
  printf("Restored node id %d\n", node_id);
#else
#error "burn-nodeid must be compiled with nodeid=<the ID of the node>"
  node_id_restore();
  printf("Restored node id %d\n", node_id);
#endif
  leds_off(LEDS_RED + LEDS_BLUE);
  watchdog_start();
  while(1) {
    PROCESS_WAIT_EVENT();
  }
  PROCESS_END();
}
Esempio n. 12
0
/*---------------------------------------------------------------------------*/
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();
}
Esempio n. 13
0
/* --------------------------------------------------------------- */
PROCESS_THREAD(node_process, ev, data)
{
    // All the process start with this
    PROCESS_BEGIN();
    PRINTF("# Starting...\n");

    // Configure the network
    network_config();
    if (!conn) {
         printf("E01\n");
         PROCESS_EXIT();
    }

    #if IS_RPL_ROOT
    create_dag();
    #endif

    // Main, infinite, loop of the process
    PRINTF("# Ready!\n");
    while (1) {
        // Wait, block the process, until an event happens.
        // Meanwhile, other process will continue running.
        PROCESS_WAIT_EVENT();

        // Check the type of event that unblock the process
        if (ev == tcpip_event)
            tcpip_handler();
        else if (ev == serial_line_event_message)
            input_handler((char*)data);
    }

    // All the process ends with this
    PROCESS_END();
}
Esempio n. 14
0
PROCESS_THREAD(ir_receiver_process, ev, data) {

    PROCESS_BEGIN();

    while(1) {
        PROCESS_WAIT_EVENT();

        if(ev == PROCESS_EVENT_POLL) {
            if(ir_repeat) {
                PRINTF("Got repeat signal \n");
                ir_repeat = 0;
            } else {
                if(*(int32_t*)ir_prev_data != *(int32_t*)ir_last_data || timer_expired(&ir_rep_timer) || to_be_repeated()) {
                    memcpy(ir_prev_data, ir_last_data, 4);
                    timer_restart(&ir_rep_timer);
                    PRINTF("Got new command %d,%d,%d,%d!\n", ir_last_data[0],ir_last_data[1],ir_last_data[2],ir_last_data[3]);
                    broadcast_value(30);
                } else {
                    timer_restart(&ir_rep_timer);
                }
            }
        }
    }

    PROCESS_END();
}
Esempio n. 15
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(telnetd_process, ev, data)
{
  PROCESS_BEGIN();
  
  shell_init();

#if TELNETD_CONF_GUI
  telnetd_gui_init();
#endif /* TELNETD_CONF_GUI */

  petsciiconv_toascii(telnetd_reject_text, strlen(telnetd_reject_text));

  tcp_listen(UIP_HTONS(23));

  while(1) {
    PROCESS_WAIT_EVENT();
    if(ev == tcpip_event) {
      telnetd_appcall(data);
    } else if(ev == PROCESS_EVENT_EXIT) {
      telnetd_quit();
    } else {
#if TELNETD_CONF_GUI
      telnetd_gui_eventhandler(ev, data);
#endif /* TELNETD_CONF_GUI */
    }
  }
  
  PROCESS_END();
}
Esempio n. 16
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{
  PROCESS_BEGIN();

  print_local_addresses();

  dtls_init();
  init_dtls();

  if (!dtls_context) {
    dsrv_log(LOG_EMERG, "cannot create context\n");
    PROCESS_EXIT();
  }

  while(1) {
    PROCESS_WAIT_EVENT();
    if(ev == tcpip_event) {
      dtls_handle_read(dtls_context);
    }
#if 0
    if (bytes_read > 0) {
      /* dtls_handle_message(dtls_context, &the_session, readbuf, bytes_read); */
      read_from_peer(dtls_context, &the_session, readbuf, bytes_read);
    }
    dtls_handle_message(ctx, &session, uip_appdata, bytes_read);
#endif
  }

  PROCESS_END();
}
Esempio n. 17
0
PROCESS_THREAD(button_process, ev, data)
{
  static struct etimer etimer;

  PROCESS_EXITHANDLER(goto exit);
  PROCESS_BEGIN();

  printf("button_process starting\n");

  while(1) {
    PROCESS_WAIT_EVENT();

    if(ev == PROCESS_EVENT_MSG && data != NULL
       && ((struct button_msg *)data)->type == BUTTON_MSG_TYPE) {
      printf("button press\n");

      leds_toggle(LEDS_ALL);
      etimer_set(&etimer, CLOCK_SECOND);
      PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
      leds_toggle(LEDS_ALL);
    }
  }

 exit:
  printf("button_process exiting\n");
  PROCESS_END();
}
Esempio n. 18
0
PROCESS_THREAD(rest_server_example, ev, data)
{
  PROCESS_BEGIN();

  PRINTF("Starting Erbium Example Server\n");

#ifdef RF_CHANNEL
  PRINTF("RF channel: %u\n", RF_CHANNEL);
#endif
#ifdef IEEE802154_PANID
  PRINTF("PAN ID: 0x%04X\n", IEEE802154_PANID);
#endif

  PRINTF("uIP buffer: %u\n", UIP_BUFSIZE);
  PRINTF("LL header: %u\n", UIP_LLH_LEN);
  PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
  PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);

  /* Initialize the REST engine. */
  rest_init_engine();

  /* Activate the application-specific resources. */
  rest_activate_resource(&resource_helloworld);
  rest_activate_resource(&resource_leds);
  rest_activate_resource(&resource_toggle);
  leds_on(0);
  /* Define application-specific events here. */
  while(1) {
    PROCESS_WAIT_EVENT();
  } /* while (1) */

  PROCESS_END();
}
Esempio n. 19
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sky_telnetd_process, ev, data)
{
  PROCESS_BEGIN();

  PROCESS_PAUSE();

  shell_blink_init();
  /*  shell_file_init();
      shell_netfile_init();*/
  shell_ps_init();
  shell_reboot_init();
  /*shell_rime_init();*/
  /*shell_rime_ping_init();*/
  /*shell_rime_netcmd_init();*/
  /*shell_rime_sniff_init();*/
  shell_sky_init();
  shell_text_init();
  shell_time_init();

  shell_register_command(&id_command);

  while(1) {
    PROCESS_WAIT_EVENT();
  }

  PROCESS_END();

}
Esempio n. 20
0
PROCESS_THREAD(rest_server_example, ev, data)
{
  PROCESS_BEGIN();
  PRINTF("Starting Erbium Example Server\n");
  PRINTF("uIP buffer: %u\n", UIP_BUFSIZE);
  PRINTF("LL header: %u\n", UIP_LLH_LEN);
  PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
  PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);

/* if static routes are used rather than RPL */
#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE)
  set_global_address();
  configure_routing();
#endif

  /* Initialize the OSD Hardware. */
  hw_init();
  /* Initialize the REST engine. */
  rest_init_engine();

  /* Activate the application-specific resources. */
  rest_activate_resource(&resource_info);

  SENSORS_ACTIVATE(t4_servo_sensor);
  rest_activate_resource(&resource_t4_servo);

  /* Define application-specific events here. */
  while(1) {
    PROCESS_WAIT_EVENT();
  }

  PROCESS_END();
}
Esempio n. 21
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(interrupt_sample_process, ev, data)
{
  /* Any process must start with this. */
  PROCESS_BEGIN();

  interrupt_init(1, 1, 1, 1);
  interrupt_enable(INT0);
  interrupt_enable(INT1);

  /* Register current process with INT0 & INT1*/
  interrupt_register(INT0);
  interrupt_register(INT1);

  while(1) {
    /* Wait for an event. */
    PROCESS_WAIT_EVENT();

    /* Got the interrupt event~ */
    if (ev == PROCESS_EVENT_INTERRUPT) {
      /* Check for the int_vect. */
      if (INT0 == ((struct interrupt *)data)->int_vect) {
        /* Got an INT0 interrupt. */
        leds_toggle(LEDS_RED);
      }
      else if (INT1 == ((struct interrupt *)data)->int_vect) {
        /* Got an INT1 interrupt. */
        leds_toggle(LEDS_YELLOW);
        interrupt_disable(INT0);
      }
    }
  } // while (1)

  /* Any process must end with this, even if it is never reached. */
  PROCESS_END();
}
Esempio n. 22
0
/* Glowny program */
PROCESS_THREAD(program_UDP, ev, data) {
    static struct etimer et;

    PROCESS_BEGIN();

#if UIP_CONF_IPV6 > 0
    uip_ip6addr(&ipaddr, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]);
#else
    uip_ipaddr(&ipaddr, addr[0], addr[1], addr[2], addr[3]);
#endif

    conn = udp_new(&ipaddr, UIP_HTONS(port), &state);
    udp_bind(conn, UIP_HTONS(port + 1));
    printf("Binded\n");

    etimer_set(&et, CLOCK_CONF_SECOND * 3);

    while (1) {
        PROCESS_WAIT_EVENT();
        if (uip_newdata()) {
            str = uip_appdata;
            str[uip_datalen()] = '\0';
            printf("Received: '%s'\n", str);
        }
        etimer_reset(&et);
    }

    PROCESS_END();
}
Esempio n. 23
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(coap_server_process, ev, data)
{
  PROCESS_BEGIN();

  printf("CC26XX CoAP Server\n");

  /* Initialize the REST engine. */
  rest_init_engine();

  rest_activate_resource(&res_batmon_temp, "sen/batmon/temp");
  rest_activate_resource(&res_batmon_volt, "sen/batmon/voltage");

  rest_activate_resource(&res_device_hw, "dev/mdl/hw");
  rest_activate_resource(&res_device_sw, "dev/mdl/sw");
  rest_activate_resource(&res_device_uptime, "dev/uptime");
  rest_activate_resource(&res_device_cfg_reset, "dev/cfg_reset");

  rest_activate_resource(&res_parent_rssi, "net/parent/RSSI");
  rest_activate_resource(&res_parent_ip, "net/parent/IPv6");

#if RF_BLE_ENABLED
  rest_activate_resource(&res_ble_advd, "dev/ble_advd");
#endif

  start_board_resources();

  /* Define application-specific events here. */
  while(1) {
    PROCESS_WAIT_EVENT();
  }

  PROCESS_END();
}
Esempio n. 24
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
  PROCESS_BEGIN();

  static struct etimer et;

  etimer_set(&et, CLOCK_SECOND*4);

  while(1){

	PROCESS_WAIT_EVENT();

	if(etimer_expired(&et)){

		printf("Timer expired\n");

		etimer_reset(&et);

	}

  }

  
  PROCESS_END();
}
Esempio n. 25
0
/* This is the implementation of our process */
PROCESS_THREAD(hello_world_process, ev, data)
{
  // Variables are declared static to ensure their values are kept
  // between kernel calls.
  static struct etimer timer;  // this is an event timer
  static int count = 0; 

  // any process must start wtih this
  PROCESS_BEGIN();

  // set the etimer module to generate an event in one second
  etimer_set(&timer, CLOCK_CONF_SECOND);
 
  while (1) { 
    // Wait here for an even to happen
    PROCESS_WAIT_EVENT();
    
    // if the event is the timer event as expected...
    if (ev == PROCESS_EVENT_TIMER) { 
      // to the process work
      printf("Hello, world #%i\n", count);
      count++;

      // reset the timer so it will generate another event
      // the exact same time after it expired (periodicity quaranteed)
      etimer_reset(&timer);
    }
  } // end loop
    
  // every process must end with this, even if it is never reached
  PROCESS_END();
}
Esempio n. 26
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(usb_serial_process, ev, data)
{

  PROCESS_BEGIN();

  set_serial_number();

  usb_setup();
  usb_cdc_acm_setup();
  usb_set_global_event_process(&usb_serial_process);
  usb_cdc_acm_set_event_process(&usb_serial_process);
  usb_set_ep_event_process(EPIN, &usb_serial_process);
  usb_set_ep_event_process(EPOUT, &usb_serial_process);

  while(1) {
    PROCESS_WAIT_EVENT();
    if(ev == PROCESS_EVENT_EXIT) {
      break;
    }
    if(ev == PROCESS_EVENT_POLL) {
      do_work();
    }
  }

  PROCESS_END();
}
Esempio n. 27
0
PROCESS_THREAD(application1,ev,data)
{
	PROCESS_BEGIN();

	printf("LAUNCH SUCCESS: %d\n",
		knot_register_controller(&application1,
								 NULL, 
								 1, "BOSS", SENSOR, LIGHT));

	
	
	/* Application do something? */
	while (1){
		PROCESS_WAIT_EVENT();
		if (ev == KNOT_EVENT_SERVICE_FOUND){
			memcpy(&sc,data,sizeof(ServiceRecord));
			printf("Service found: %s\n", sc.name); 
			if (!found){
				connect_device(&sc);
				found = 1;

			}
		}
		else if (ev == KNOT_EVENT_DATA_READY){
			callback(data);
		}
		else if (ev == KNOT_EVENT_CONNECTED_DEVICE){
			handle_new_device(data);
		}
	}

	PROCESS_END();
}
Esempio n. 28
0
PROCESS_THREAD(interferer_example, ev, data)
{
 PROCESS_EXITHANDLER()  
 PROCESS_BEGIN();

 // Initial configurations on CC2420: channel and tx power
 watchdog_stop();
 cc2420_set_txpower(CC2420_TXPOWER_MAX);
 cc2420_set_channel(INTERFERED_CHANNEL);
 printf("HandyMote: interfering continuously with random power\n");
 
 // Interfering continuously with random power
 CC2420_SPI_ENABLE();
 set_jammer(CARRIER_TYPE);
 int randelay, randpower;
 while(1){
	 randpower = random_value(MIN_POWER,MAX_POWER);
	 randelay = random_value(MIN_TIME,MAX_TIME);	 
	 power_jammer(randpower);
	 clock_delay(randelay);
 }
 CC2420_SPI_DISABLE();

 PROCESS_WAIT_EVENT();  
 PROCESS_END();
}
Esempio n. 29
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(servreg_hack_process, ev, data)
{
  static struct etimer periodic;
  static struct uip_udp_conn *outconn, *inconn;
  PROCESS_BEGIN();

  /* Create outbound UDP connection. */
  outconn = udp_broadcast_new(UIP_HTONS(UDP_PORT), NULL);
  udp_bind(outconn, UIP_HTONS(UDP_PORT));

  /* Create inbound UDP connection. */
  inconn = udp_new(NULL, UIP_HTONS(UDP_PORT), NULL);
  udp_bind(inconn, UIP_HTONS(UDP_PORT));

  etimer_set(&periodic, PERIOD_TIME);
  etimer_set(&sendtimer, random_rand() % (PERIOD_TIME));
  while(1) {
    PROCESS_WAIT_EVENT();
    if(ev == PROCESS_EVENT_TIMER && data == &periodic) {
      etimer_reset(&periodic);
      etimer_set(&sendtimer, random_rand() % (PERIOD_TIME));
    } else if(ev == PROCESS_EVENT_TIMER && data == &sendtimer) {
      send_udp_packet(outconn);
    } else if(ev == tcpip_event) {
      parse_incoming_packet(uip_appdata, uip_datalen());
    }
  }
  PROCESS_END();
}
Esempio n. 30
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(telnetd_process, ev, data)
{
  PROCESS_BEGIN();
  
  tcp_listen(HTONS(23));
  buf_init(&buf);

  shell_init();

#if TELNETD_CONF_GUI
  telnetd_gui_init();
#endif /* TELNETD_CONF_GUI */

  while(1) {
    PROCESS_WAIT_EVENT();
    if(ev == tcpip_event) {
      telnetd_appcall(data);
    } else if(ev == PROCESS_EVENT_EXIT) {
      telnetd_quit();
    } else {
#if TELNETD_CONF_GUI
      telnetd_gui_eventhandler(ev, data);
#endif /* TELNETD_CONF_GUI */
    }
  }
  
  PROCESS_END();
}