void SecurityLampApplication:: boot() { os().debug("ON"); //add receiver os().dispatcher().add_receiver(this); //change channel os().radio().hardware_radio().set_channel(17); // create LisAccelerometer instance accelerometer_ = new LisAccelerometer(os()); if ((accelerometer_ != NULL)) { // ----- configure accelerometer ------ // set threshold mode, i.e. the sensor will start to // deliver data after the set threshold was exceeded accelerometer_->set_mode(MODE_THRESHOLD); // set the threshold to 5 mg accelerometer_->set_threshold(180); // set this application as the sensor event handler // --> handle_buffer_data will be called if // sensor data is available accelerometer_->set_handler(this); // switch accelerometer accelerometer_->enable(); } else os().fatal("Could not allocate accelerometer"); //Create the beacon payload echomsg[0] = 0x7f; //mksense echomsg[1] = 0x69; //mksense echomsg[2] = 100; //mksense echomsg[3] = 42; //echo beacon //Create the command payload mess[0] = 0x7f; //mksense mess[1] = 0x69; //mksense mess[2] = 105; //mksense for (int i = 3; i < 12; i++) { mess[i] = 99; //movement payload } //start periodic tasks os().add_task_in(Time(1, 0), this, NULL); }
void WISEBEDApplication::init_sensors() { #if defined (ISENSE_PACEMATE) #endif #if defined (ISENSE_MSP430) telos_->init(); #endif #if defined (ISENSE_JENNIC_JN513xR1) if (em_->temp_sensor() != NULL) { em_->temp_sensor()->enable(); } else os().fatal("Could not allocate temp sensor"); em_->enable(true); temp_ = em_->temp_sensor()->temperature(); if (temp_ == -127 ) // node with PIR and ACC { em_active_ = false; } if(em_active_ == true) { if (em_->light_sensor() != NULL) { em_->light_sensor()->enable(); } else os().fatal("Could not allocate light sensor"); } else { acc_ = new LisAccelerometer(os()); if ((acc_ != NULL) && (pir_!= NULL)) { acc_->set_mode(MODE_THRESHOLD); acc_->set_threshold(100); acc_->set_handler(this); acc_->enable(); pir_->set_sensor_handler(this); pir_->set_pir_sensor_int_interval( 2000 ); pir_->enable(); } } #endif }