示例#1
0
void osens_app_init(void) {

    //osens_init_point_db();
    //osens_mote_init();

    // prepare the resource descriptor for the /d and /s paths
    osens_desc_vars.path0len = sizeof(osens_desc_path0) -1;
    osens_desc_vars.path0val = (uint8_t*) (&osens_desc_path0);
    osens_desc_vars.path1len = 0;
    osens_desc_vars.path1val = NULL;
    osens_desc_vars.componentID = COMPONENT_SENSORS_DESC;
    osens_desc_vars.callbackRx = &osens_desc_receive;
    osens_desc_vars.callbackSendDone = &osens_desc_sendDone;

    osens_val_vars.path0len = sizeof(osens_val_path0) -1;
    osens_val_vars.path0val = (uint8_t*) (&osens_val_path0);
    osens_val_vars.path1len = 0;
    osens_val_vars.path1val = NULL;
    osens_val_vars.componentID = COMPONENT_SENSORS_VAL;
    osens_val_vars.callbackRx = &osens_val_receive;
    osens_val_vars.callbackSendDone = &osens_val_sendDone;

    osens_init();

    // register with the CoAP modules
    opencoap_register(&osens_desc_vars);
    opencoap_register(&osens_val_vars);
}
示例#2
0
/**
   \brief Initialize csensors and registers opensensors resources.
*/
void csensors_init(void) {
   uint8_t i;
   uint8_t numSensors;

   // do not run if DAGroot
   if(idmanager_getIsDAGroot()==TRUE) return;

   opensensors_init();
   memset(&csensors_vars,0,sizeof(csensors_vars_t));

   csensors_vars.desc.path0len               = sizeof(csensors_path0)-1;
   csensors_vars.desc.path0val               = (uint8_t*)(&csensors_path0);
   csensors_vars.desc.path1len               = 0;
   csensors_vars.desc.path1val               = NULL;
   csensors_vars.desc.componentID            = COMPONENT_CSENSORS;
   csensors_vars.desc.securityContext        = NULL;
   csensors_vars.desc.discoverable           = TRUE;
   csensors_vars.desc.callbackRx             = &csensors_receive;
   csensors_vars.desc.callbackSendDone       = &csensors_sendDone;
   // register with the CoAP module
   opencoap_register(&csensors_vars.desc);

   numSensors = opensensors_getNumSensors();
   csensors_vars.cb_put                      = 0;
   csensors_vars.cb_get                      = 0;
   csensors_vars.numCsensors                 = 0;

   for(i=0;i<numSensors;i++) {
      csensors_vars.csensors_resource[i].timerId               = MAX_NUM_TIMERS;
      csensors_vars.csensors_resource[i].period                = 0;
      csensors_vars.csensors_resource[i].opensensors_resource  = opensensors_getResource(i);
      csensors_register(&csensors_vars.csensors_resource[i]);
      csensors_vars.numCsensors++;
   }
}
示例#3
0
//open_addr_t address, char act
void table_update_init() {
   
   // prepare the resource descriptor for the /up path
   table_update_vars.desc.path0len             = sizeof(table_update_path0)-1;
   table_update_vars.desc.path0val             = (uint8_t*)(&table_update_path0);
   table_update_vars.desc.path1len             = 0;
   table_update_vars.desc.path1val             = NULL;
   table_update_vars.desc.componentID          = COMPONENT_TABLE_UPDATE;
   table_update_vars.desc.callbackRx           = &table_update_receive;
   table_update_vars.desc.callbackSendDone     = &table_update_sendDone;
   opencoap_register(&table_update_vars.desc);
   
}
示例#4
0
void cleds__init() {
   
   // prepare the resource descriptor for the /l path
   cleds_vars.desc.path0len            = sizeof(cleds_path0)-1;
   cleds_vars.desc.path0val            = (uint8_t*)(&cleds_path0);
   cleds_vars.desc.path1len            = 0;
   cleds_vars.desc.path1val            = NULL;
   cleds_vars.desc.componentID         = COMPONENT_CLEDS;
   cleds_vars.desc.discoverable        = TRUE;
   cleds_vars.desc.callbackRx          = &cleds_receive;
   cleds_vars.desc.callbackSendDone    = &cleds_sendDone;
   
   // register with the CoAP module
   opencoap_register(&cleds_vars.desc);
}
示例#5
0
void cwellknown_init() {
   if(idmanager_getIsDAGroot()==TRUE) return; 
   
   // prepare the resource descriptor for the /.well-known/core path
   cwellknown_vars.desc.path0len            = sizeof(cwellknown_path0)-1;
   cwellknown_vars.desc.path0val            = (uint8_t*)(&cwellknown_path0);
   cwellknown_vars.desc.path1len            = sizeof(cwellknown_path1)-1;
   cwellknown_vars.desc.path1val            = (uint8_t*)(&cwellknown_path1);
   cwellknown_vars.desc.componentID         = COMPONENT_CWELLKNOWN;
   cwellknown_vars.desc.discoverable        = FALSE;
   cwellknown_vars.desc.callbackRx          = &cwellknown_receive;
   cwellknown_vars.desc.callbackSendDone    = &cwellknown_sendDone;
   
   opencoap_register(&cwellknown_vars.desc);
}
示例#6
0
/**
   \brief Register a csensor resource into opencoap.
   \param[in] csensors_resource The resource to be registered.
*/
void csensors_register(
      csensors_resource_t* csensors_resource
   ) {
   csensors_resource->desc.path0len         = sizeof(csensors_path0)-1;
   csensors_resource->desc.path0val         = (uint8_t*)(&csensors_path0);
   switch (csensors_resource->opensensors_resource->sensorType) {
      case SENSOR_TEMPERATURE:
         csensors_resource->desc.path1len   = sizeof(csensors_temperature_path1)-1;
         csensors_resource->desc.path1val   = (uint8_t*)(&csensors_temperature_path1);
         break;
      case SENSOR_HUMIDITY:
         csensors_resource->desc.path1len   = sizeof(csensors_humidity_path1)-1;
         csensors_resource->desc.path1val   = (uint8_t*)(&csensors_humidity_path1);
         break;
      case SENSOR_LIGHT:
         csensors_resource->desc.path1len   = sizeof(csensors_light_path1)-1;
         csensors_resource->desc.path1val   = (uint8_t*)(&csensors_light_path1);
         break;
      case SENSOR_XACCELERATION:
         csensors_resource->desc.path1len   = sizeof(csensors_x_path1)-1;
         csensors_resource->desc.path1val   = (uint8_t*)(&csensors_x_path1);
         break;
      case SENSOR_YACCELERATION:
         csensors_resource->desc.path1len   = sizeof(csensors_y_path1)-1;
         csensors_resource->desc.path1val   = (uint8_t*)(&csensors_y_path1);
         break;
      case SENSOR_ZACCELERATION:
         csensors_resource->desc.path1len   = sizeof(csensors_z_path1)-1;
         csensors_resource->desc.path1val   = (uint8_t*)(&csensors_z_path1);
         break;
      case SENSOR_ADCTEMPERATURE:
         csensors_resource->desc.path1len   = sizeof(csensors_cputemp_path1)-1;
         csensors_resource->desc.path1val   = (uint8_t*)(&csensors_cputemp_path1);
         break;
      default:
         csensors_resource->desc.path1len   = sizeof(csensors_default_path1)-1;
         csensors_resource->desc.path1val   = (uint8_t*)(&csensors_default_path1);
         break;

   }
   csensors_resource->desc.componentID      = COMPONENT_CSENSORS;
   csensors_resource->desc.discoverable     = TRUE;
   csensors_resource->desc.callbackRx       = &csensors_receive;
   csensors_resource->desc.callbackSendDone = &csensors_sendDone;

   // register with the CoAP module
   opencoap_register(&csensors_resource->desc);
}
示例#7
0
/**
\brief Initialize this module.
*/
void cinfo_init(OpenMote* self) {
    // do not run if DAGroot
    if( idmanager_getIsDAGroot(self)==TRUE) return;

    // prepare the resource descriptor for the /i path
    cinfo_vars.desc.path0len             = sizeof(cinfo_path0)-1;
    cinfo_vars.desc.path0val             = (uint8_t*)(&cinfo_path0);
    cinfo_vars.desc.path1len             = 0;
    cinfo_vars.desc.path1val             = NULL;
    cinfo_vars.desc.componentID          = COMPONENT_CINFO;
    cinfo_vars.desc.callbackRx           = &cinfo_receive;
    cinfo_vars.desc.callbackSendDone     = &cinfo_sendDone;

    // register with the CoAP module
    opencoap_register(self, &cinfo_vars.desc);
}
示例#8
0
void bbk_init(){
   // prepare the resource descriptor for the /bbk path
   bbk_vars.desc.path0len             = sizeof(bbk_path0)-1;
   bbk_vars.desc.path0val             = (uint8_t*)(&bbk_path0);
   bbk_vars.desc.path1len             = 0;
   bbk_vars.desc.path1val             = NULL;
   bbk_vars.desc.componentID          = 0xcc; //just a number
   bbk_vars.desc.callbackRx           = &bbk_receive;
   bbk_vars.desc.callbackSendDone     = &bbk_sendDone;
   
   opencoap_register(&bbk_vars.desc);
   bbk_vars.timerId    = opentimers_start(BBKPERIOD,
                                                TIMER_PERIODIC,TIME_MS,
                                                bbk_timer_cb);
   bbk_vars.sequence  = 0;
}
示例#9
0
void cexample_init() {
   
   // prepare the resource descriptor for the /ex path
   cexample_vars.desc.path0len             = sizeof(cexample_path0)-1;
   cexample_vars.desc.path0val             = (uint8_t*)(&cexample_path0);
   cexample_vars.desc.path1len             = 0;
   cexample_vars.desc.path1val             = NULL;
   cexample_vars.desc.componentID          = COMPONENT_CEXAMPLE;
   cexample_vars.desc.callbackRx           = &cexample_receive;
   cexample_vars.desc.callbackSendDone     = &cexample_sendDone;
   
   
   opencoap_register(&cexample_vars.desc);
   cexample_vars.timerId    = opentimers_start(CEXAMPLEPERIOD,
                                                TIMER_PERIODIC,TIME_MS,
                                                cexample_timer_cb);
}
示例#10
0
void rex_init() {
   
   // prepare the resource descriptor for the /rex path
   rex_vars.desc.path0len             = sizeof(rex_path0)-1;
   rex_vars.desc.path0val             = (uint8_t*)(&rex_path0);
   rex_vars.desc.path1len             = 0;
   rex_vars.desc.path1val             = NULL;
   rex_vars.desc.componentID          = COMPONENT_REX;
   rex_vars.desc.callbackRx           = &rex_receive;
   rex_vars.desc.callbackSendDone     = &rex_sendDone;
   
   
   opencoap_register(&rex_vars.desc);
   rex_vars.timerId    = opentimers_start(REXPERIOD,
                                                TIMER_PERIODIC,TIME_MS,
                                                rex_timer_cb);
}
示例#11
0
void rheli_init() {
   // initialize the heli drivers
   heli_init();
   
   // prepare the resource descriptor
   rheli_vars.desc.path0len            = sizeof(rheli_path0)-1;
   rheli_vars.desc.path0val            = (uint8_t*)(&rheli_path0);
   rheli_vars.desc.path1len            = 0;
   rheli_vars.desc.path1val            = NULL;
   rheli_vars.desc.componentID         = COMPONENT_RHELI;
   rheli_vars.desc.callbackRx          = &rheli_receive;
   rheli_vars.desc.callbackSendDone    = &rheli_sendDone;
   
   opencoap_register(&rheli_vars.desc);
   rheli_vars.timerId    = opentimers_start(1000,
                                            TIMER_PERIODIC,TIME_MS,
                                            rheli_timer);
}
示例#12
0
void rreg_init() {
   // prepare the resource descriptor for the /.well-known/core path
   rreg_vars.desc.path0len             = sizeof(rreg_path0)-1;
   rreg_vars.desc.path0val             = (uint8_t*)(&rreg_path0);
   rreg_vars.desc.path1len             = 0;
   rreg_vars.desc.path1val             = NULL;
   rreg_vars.desc.componentID          = COMPONENT_RREG;
   rreg_vars.desc.callbackRx           = &rreg_receive;
   rreg_vars.desc.callbackSendDone     = &rreg_sendDone;
   

   
   opencoap_register(&rreg_vars.desc);
   // register to the RD server every 30s
   rreg_vars.timerId    = opentimers_start(RREGPERIOD,
                                          TIMER_PERIODIC,TIME_MS,
                                          rreg_timer);
}
示例#13
0
void update(debugNeighborEntry_t* entry, uint8_t ind, char act)
{
table_update_vars.desc.path0len             = sizeof(table_update_path0)-1;
   table_update_vars.desc.path0val             = (uint8_t*)(&table_update_path0);
   table_update_vars.desc.path1len             = 0;
   table_update_vars.desc.path1val             = NULL;
   table_update_vars.desc.componentID          = COMPONENT_TABLE_UPDATE;
   table_update_vars.desc.callbackRx           = &table_update_receive;
   table_update_vars.desc.callbackSendDone     = &table_update_sendDone;

   opencoap_register(&table_update_vars.desc);
   i = ind;
   action = act; 
tableEntry = entry;
//scheduler_push_task(table_update_task_cb,TASKPRIO_COAP);
  table_update_vars.timerId    = opentimers_start(WAITPERIOD,
                                                TIMER_ONESHOT,TIME_MS,
                                                table_update_timer_cb);
}
示例#14
0
文件: rt.c 项目: Adilla/openwsn-fw
void rt_init() {
   // startup the sensor
   sensitive_accel_temperature_init();
   
   // prepare the resource descriptor for the /temp path
   rt_vars.desc.path0len             = sizeof(rt_path0)-1;
   rt_vars.desc.path0val             = (uint8_t*)(&rt_path0);
   rt_vars.desc.path1len             = 0;
   rt_vars.desc.path1val             = NULL;
   rt_vars.desc.componentID          = COMPONENT_RT;
   rt_vars.desc.callbackRx           = &rt_receive;
   rt_vars.desc.callbackSendDone     = &rt_sendDone;
   

   rt_vars.timerId    = opentimers_start(openrandom_get16b()%RTPERIOD,
                                          TIMER_PERIODIC,TIME_MS,
                                          rt_timer);
   opencoap_register(&rt_vars.desc);
}
示例#15
0
void osens_app_init(void) {
    int32_t i32Res;

    // prepare the resource descriptor for the /d and /s paths
	osens_frm_vars.path0len         = sizeof(osens_frm_path0) -1;
	osens_frm_vars.path0val         = (uint8_t*) (&osens_frm_path0);
	osens_frm_vars.path1len         = sizeof(osens_frm_path1) -1;
	osens_frm_vars.path1val         = (uint8_t*) (&osens_frm_path1);
	osens_frm_vars.componentID      = COMPONENT_CINFO;
	osens_frm_vars.securityContext  = NULL;
	osens_frm_vars.discoverable     = TRUE;
	osens_frm_vars.callbackRx       = &osens_frm_receive;
	osens_frm_vars.callbackSendDone = &osens_frm_sendDone;

	memset(&osens_frm,0,sizeof(osens_frm));

	// register with the CoAP modules
    opencoap_register(&osens_frm_vars);

}