Exemple #1
0
void start(void)
{
  app_myid = mos_node_id_get();

  is_base = 0;
 
  /* must start the net thread */
   net_init();
   
  /* start the CTP backends */
   ctp_proto_init();

  /* wait a while till the routing is possibly established */     
   mos_mdelay(10); 
  
   //net_ioctl(CTP_PROTO_ID, CTP_SET_IS_NODE);
   if(app_myid == 36 || app_myid == 112 || app_myid == 0)
     net_ioctl(CTP_PROTO_ID, CTP_SET_TESTBED);
   else //com_ioctl_IFACE_RADIO(CC2420_HIGH_POWER_MODE);
     com_ioctl_IFACE_RADIO(CC2420_TX_POWER, 35);

  /* This is the basic app thread */
   mos_thread_new(app_recv, 288, PRIORITY_NORMAL);   
   mos_thread_new(app_send, 288, PRIORITY_NORMAL);
  
}
void start(void){
   mos_set_addr(NET_LOCAL_ADDRESS);
   mos_set_net_power(NET_FULL_POWER);
   flooding_init(NET_FREQUENCY);

   mos_thread_new(mos_net_daemon, 128, PRIORITY_NORMAL);
   mos_thread_new(receiver, 128, PRIORITY_NORMAL);
}
void start(void) {
    //give us control over serial/rf
    //mos_thread_new(mos_command_daemon, 128, PRIORITY_NORMAL);
    //start this thread
    mos_thread_new(m_thread, 192, PRIORITY_NORMAL);
    mos_thread_new(net_thread, 160, PRIORITY_NORMAL);
//    mos_thread_new(net_thread, 192, PRIORITY_NORMAL);
//    mos_thread_new(stack_check, 128, PRIORITY_NORMAL);
}
Exemple #4
0
void start(void)
{

   com_mode(IFACE_RADIO, IF_LISTEN);
   com_ioctl(IFACE_RADIO, CC2420_LOW_POWER_MODE);
   
   mos_thread_new(tx_thread, 128, PRIORITY_NORMAL);
   mos_thread_new(rx_thread, 128, PRIORITY_NORMAL);
}
/* The start function is automatically called by the operating system,
   for single-threaded applications, treat start() like main(). for multi-
   threaded applications, start each thread in the start() function.*/
void start(void)
{
  /* must start the net thread */
   net_init();

  mos_thread_new(sink_thread, 128, PRIORITY_NORMAL);
  mos_thread_new(periodic_beacon, 128, PRIORITY_NORMAL);

}
void start (void)
{
    //give us control over serial/rf
    mos_thread_new (mos_command_daemon, 192, PRIORITY_NORMAL);
    //start this thread
    mos_thread_new (generator, 224, PRIORITY_NORMAL);
    mos_register_function ("ledb",ledb);
    mos_register_function ("clickb",clickb);
    mos_register_function ("beepb",beepb);
}
void start(void){

   backoff_alarm.func = backoff_alarm_func;
   
   com_mode(IFACE_RADIO, IF_LISTEN);
   //give us control over the serial/rf
   mos_thread_new(mos_command_daemon, 128, PRIORITY_NORMAL);
   //gives us start
   mos_thread_new(cca_test, 128, PRIORITY_NORMAL);
}
void start (void)
{
   mos_sem_init(&wakeup_sem, 1);
   //give us control over serial/rf
   //mos_thread_new(mos_command_daemon, 128, PRIORITY_NORMAL);
   //start this thread
   mos_thread_new(generator, 192, PRIORITY_NORMAL);
   mos_thread_new(net_thread, 256, PRIORITY_NORMAL);
//    mos_thread_new(stack_check, 128, PRIORITY_NORMAL);
}
void start (void)
{
    comBuf * ptr;

    //turn the radio and serial on
    com_mode(IFACE_RADIO, IF_LISTEN);
    com_mode(IFACE_SERIAL, IF_LISTEN);

    //change the radio power?
    //com_ioctl_IFACE_RADIO(CC1000_TX_POWER, 0x50);

    myID = mos_node_id_get();     //preset
    baseID = myID;                //I'm the base
    myParentID = 0;               //no parents
    myDTB = 0;                    //I am the base
    mySeqNo = 0;                  //start at 0

    //set timer functions
    sleep_timer.func = sleep_timer_callback;  

    //set timer times
    sleep_timer.msecs = TO_NEXT_SLEEP;
    sleep_timer.reset_to = 0;
 
    state = GO;

    //just to let us know it's on
    printf ("waiting for start signal\n");

    while (1)
    {
	ptr = com_recv(IFACE_SERIAL);
	if (strncmp(ptr->data, "startstartstartstartstartstartstart", 35) == 0)
	{
	    printf ("received start\n");  //this is for the python script
	    com_free_buf(ptr);
	    break;
	}
	else
	{
	    printf ("got %s\n", ptr->data);
            printf ("which not the start value.  Still waiting...\n");
	    com_free_buf(ptr);
	}
	
    }
    //kill the serial to save power
    com_mode(IFACE_SERIAL, IF_OFF);

    //start sleep alarm
    mos_alarm (&sleep_timer);

    mos_thread_new (send, 128, PRIORITY_NORMAL);
    mos_thread_new (recv, 128, PRIORITY_NORMAL);
}
void start(void)
{
   com_mode(IFACE_RADIO, IF_LISTEN);
   /// Send a HELLO packet //////////////////////////////
   buf.size = 5;
   buf.data[0] = PKT_HELLO;
   buf_insert_WORD(buf.data, 1, mos_node_id_get());
   buf_insert_WORD(buf.data, 3, crc_compute(buf.data, 3));
   //////////////////////////////////////////////////////
   com_send(IFACE_RADIO, &buf);
   
   mos_thread_new(sense_thread, 256, PRIORITY_NORMAL);
   mos_thread_new(recv_thread, 256, PRIORITY_NORMAL);
}
void start (void)
{
   mos_thread_new (mos_command_daemon, MOS_COMMANDER_STACK_SIZE, PRIORITY_NORMAL);
   printf ("AVR-EEPROM Test\n");
   
   mos_register_function ("write", eep_write);
   mos_register_function ("read", eep_read);   
}
Exemple #12
0
void start(void) 
{
	mos_node_id_set(6);
	transportInit(false);
	net_ioctl(CTP_PROTO_ID, CTP_SET_TESTBED);

	mos_thread_new (appSend, 384, PRIORITY_NORMAL);
}
Exemple #13
0
void start(void)
{
   //mos_thread_new(sink_thread, 128, PRIORITY_NORMAL);
   mos_thread_new(rtscts_sink_thread, 128, PRIORITY_NORMAL);
//   mos_thread_new(beacon_thread, 128, PRIORITY_NORMAL);
//   mos_thread_new(sniffer, 128, PRIORITY_NORMAL);
//   mos_thread_new(rssi_sniffer, 128, PRIORITY_NORMAL);
}
void start (void)
{
    mos_thread_new (mos_command_daemon, MOS_COMMANDER_STACK_SIZE + 60, PRIORITY_NORMAL);
    printf ("Weatherboard Accelerometer Test\n");
    mos_register_function("getval", accel_get_val);

    accel_get_val();

}
void start(void)
{
   //mos_led_on(0);
   //mos_led_on(1);
   printf("in start\n");
   
   mos_thread_new (blink_a, 128, PRIORITY_NORMAL);
   //mos_thread_new(blink_b, 128, PRIORITY_NORMAL);
}
/* The start function is automatically called by the operating system,
   for single-threaded applications, treat start() like main(). for multi-
   threaded applications, start each thread in the start() function.*/
void start(void)
{
  /* must start the net thread */
   net_init();

   mos_thread_new(mos_command_daemon, MOS_COMMANDER_STACK_SIZE,
		  PRIORITY_NORMAL);

  /* Initialize the MST backend */
   mst_proto_init();

   uint8_t myaddr = mos_node_id_get();
   
   net_ioctl(MST_PROTO_ID, SET_ADDR, (uint8_t)myaddr);
   net_ioctl(MST_PROTO_ID, SET_DTB, 20);

   //This is the basic app thread
   mos_thread_new(recv, 128, PRIORITY_NORMAL);
   mos_thread_new(send, 128, PRIORITY_NORMAL);
}
void start(void)
{
   clock_app_init();
   //start the command daemon..
   mos_thread_new(mos_command_daemon, 128, PRIORITY_NORMAL);
   mos_register_function("set_time", set_time);
   mos_register_function("show_time", print_time);
   mos_register_function("constant", set_constant_update);
   mos_register_function("stop", stop_constant_update);

}
Exemple #18
0
uint8_t terminal_init(void)
{
   // get initial buffer
   com_swap_bufs(IFACE_TERMINAL, (comBuf *)NULL, &packetBuf);
   packetBuf->size = 0;

   /* Create a thread to constantly listen on the serial port and
      save packets if we are in listen mode. */
   mos_thread_new(term_listen, 128, PRIORITY_NORMAL);
   
   return 0;
}
void start(void)
{
  mos_led_on(1);
  #ifdef PLATFORM_MICA_ANY
  dev_mode(DEV_MICA2_LIGHT, DEV_MODE_ON);  
  dev_read(DEV_MICA2_LIGHT,&seed,1);
  dev_read(DEV_MICA2_LIGHT,(&seed)+1,1);
  dev_mode(DEV_MICA2_LIGHT, DEV_MODE_OFF);  
#elif PLATFORM_TELOSB
  seed = adc_get_conversion16(4);
#endif
  printf("SEED: %x\n", seed);
  mos_led_off(1);
  

  srand(seed);
  
  producer1_alarm.func = sem_alarm_func;
  consumer1_alarm.func = sem_alarm_func;
  producer2_alarm.func = sem_alarm_func;
  consumer2_alarm.func = sem_alarm_func;


  producer1_alarm.data = (void*)&full1;
  consumer1_alarm.data = (void*)&empty1;
  producer2_alarm.data = (void*)&full2;
  consumer2_alarm.data = (void*)&empty2;
  
  mos_sem_init(&empty1,5);
  mos_sem_init(&full1,0);
  mos_sem_init(&mux1,1);
  mos_sem_init(&empty2,5);
  mos_sem_init(&full2,0);
  mos_sem_init(&mux2,1);
  mos_thread_new(consumer2, 128, PRIORITY_NORMAL);
  mos_thread_new(consumer1, 128, PRIORITY_NORMAL);
  mos_thread_new(producer2, 128, PRIORITY_NORMAL);
  mos_thread_new(producer1, 128, PRIORITY_NORMAL);
}
void start (void)
{

    //turn the radio on
    com_mode(IFACE_RADIO, IF_LISTEN);
    mos_mdelay(200);
    found = 0;
    rate = 0;

    //com_ioctl_IFACE_RADIO(CC1000_TX_POWER, 0x01);

    myID = mos_node_id_get();     //preset
    baseID = 0;                   //updated with the first packet.. should be 0
    myParentID = 0;               //updated with the first packet
    myDTB = 255;                  //lost value -- updated with the first packet
    mySeqNo = 0;                  //start on 0
    state = INIT;                 //initial state

    //initialize timer callbacks 
    wind_timer.func = wind_timer_callback;  
    sleep_timer.func = sleep_timer_callback;
    reconnect_timer.func = reconnect_timer_callback;  
   
    //set timer values
    wind_timer.msecs = WIND_DELAY;
    reconnect_timer.msecs = RECONNECT_DELAY;  
    sleep_timer.msecs = TO_NEXT_SLEEP;

    //we set the timers manually
    wind_timer.reset_to = 0;
    reconnect_timer.reset_to = 0;
    sleep_timer.reset_to = 0;

    mos_thread_new (send, 128, PRIORITY_NORMAL);
    mos_thread_new (recv, 128, PRIORITY_NORMAL);
}
void start (void) 
{
	mos_command_daemon_init();
   mos_register_function("DR", reprogram);
   mos_register_function("VDR", verify);
   //mos_register_function("RR", radio_reprogram);
   mos_register_function("get_cb", get_cb);
   mos_register_function("set_cb", set_cb);
   mos_register_function("clear_cb", clear_cb);

	net_init();
	simple_fs_init();
	deluge_init();
   mos_thread_new (mos_command_daemon, 192, PRIORITY_NORMAL);
}
void start(void)
{
   mos_thread_new(mos_command_daemon,512,PRIORITY_NORMAL);
   mos_register_function("defaults", (void *)defaults);
   mos_register_function("add",      (void *)add_node);
   mos_register_function("delete",   (void *)del_node);
   mos_register_function("print",    (void *)printtree);
   mos_register_function("splay",    (void *)splay_node_local);
   mos_register_function("min",      (void *)get_min_local);
   mos_register_function("max",      (void *)get_max_local);
   mos_register_function("find",     (void *)find_node_local);
   mos_register_function("clear",    (void *)clear_tree_local);
   mos_register_function("count",    (void *)count_nodes_local);
   mos_register_function("total",    (void *)get_total_local);
   mos_register_function("average",  (void *)get_avg_local);
}
void start (void)
{
   mos_thread_new (mos_command_daemon, MOS_COMMANDER_STACK_SIZE + 60, PRIORITY_NORMAL);
   printf ("AVR-I2C Test\n");
   
   mos_register_function ("i2c_write", i2c_write);
   mos_register_function ("i2c_read", i2c_read);
   mos_register_function ("i2c_setbrr",i2c_setbrr);
   mos_register_function ("i2c_setbrr",i2c_setbrr);
   mos_register_function ("i2c_dest",i2c_dest);
   mos_register_function ("i2c_slave",i2c_slave);
   mos_register_function ("i2c_enable_ack",i2c_enable_ack);
   mos_register_function ("i2c_disable_ack",i2c_disable_ack);
   mos_register_function ("setup",setup);
   mos_register_function ("poll",poll);
//   setup ();
}
Exemple #24
0
uint8_t serial_init ()
{
   serial_init_fd();
   //initialize the serial mutex
   //mos_mutex_init(&serial_mutex);
   
   current_mode = IF_OFF;
   
   // get initial buffer
   com_swap_bufs (IFACE_SERIAL, NULL, &packetBuf);
   packetBuf->size = 0;

   // Create a thread to constantly listen on the serial port and
   // save packets if we are in listen mode
   if(serial_tid == 0)
      mos_thread_new (serial_listen, 128, PRIORITY_NORMAL);
   
   return 0;
}
void start(void)
{
   // intialize our semaphore.
   // a value of 0 means that any mos_sem_wait() will block
   // until at least one mos_sem_post() occurs.
   mos_sem_init(&alarm_sem, 0);
   // create our consumer thread, which will wait for our
   // alarm to expire.
   mos_thread_new(consumer_thread, 128, PRIORITY_NORMAL);

   // finally, create our alarm.
   alarm.func = alarm_callback;
   // our initial period is 1 second.
   alarm.msecs = 1000;
   
   // add our alarm to the system.
   mos_alarm(&alarm);
   
}
Exemple #26
0
uint8_t tcp_mode(uint8_t mode)
{
    current_mode = mode;

    switch(mode) {
    case IF_OFF:
    case IF_STANDBY:
    case IF_IDLE:
        break;
    case IF_LISTEN:
        /* Create a thread to constantly listen on the socket and
        save packets. */
        mos_thread_new(listenTo, 128, PRIORITY_NORMAL);
        break;
    default:
        break;
    }

    return 0;
}
Exemple #27
0
void start(void) {
	uint16_t power = 31;
	uint8_t retVal = 0;
	
	mos_node_id_set(NODE_ID);
	transportInit(false);
	net_ioctl(CTP_PROTO_ID, CTP_SET_TESTBED);
	// net_ioctl(CTP_PROTO_ID, CTP_SET_POWER, power);
	
	// Sleep for 30 sec to allow CTP++ routing to stabilize
	mos_thread_sleep(30000);
	
	printf("Starting appSend thread... \n");
	retVal = mos_thread_new(appSend, 384, PRIORITY_NORMAL);
	if (retVal != THREAD_OK) {
		printf("mos_thread_new retval = %d \n", retVal);
	}
	
	printf("_end = %d \n", (int)&_end);
}
Exemple #28
0
int main(int argc, char *argv[])
{
    arg_init(argc,argv);
#else
int main(void)
{
#endif
    sched_init(); //init scheduler--THIS MUST BE FIRST
    mos_led_init(); //init leds early, to allow led debugging elsewhere
    com_init(); //init com system

#ifdef MOS_DEBUG
    mos_debug_init();
#endif
    mos_thread_new(pre_start, START_STACK_SIZE, PRIORITY_NORMAL);

    //start the scheduler (never returns)
    mos_sched_start();

    return 0;
}
Exemple #29
0
uint8_t udp_init (void)
{
   if((send_fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
      perror("socket");
      exit(1);
   }

   // Have to set broadcast permissions or we get permission denied
   //setsockopt(send_fd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
   
   current_mode = IF_OFF;
   
   // get initial buffer
   com_swap_bufs(IFACE_RADIO, (comBuf *)NULL, &packetBuf);
   packetBuf->size = 0;

   /* Create a thread to constantly listen on the socket and
      save packets. */
   mos_thread_new(listenTo, 128, PRIORITY_NORMAL);
   
   return 0;
}
void start(void){
  mos_thread_new(receiver, 512, PRIORITY_NORMAL);
}