void hw_init() { #if defined (PLATFORM_HAS_LEDS) leds_off(LEDS_RED); #endif #if PLATFORM_HAS_DS1820 ds1820_temp(); #endif #if PLATFORM_HAS_DHT11HUM DHT_Read_Data(&dht11_temp, &dht11_hum); #endif }
PROCESS_THREAD(rest_server_example, ev, data) { static struct etimer ds_periodic_timer; #if REST_RES_DS1820 static struct etimer ds_read_timer; #endif 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); /* 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. */ #if REST_RES_DS1820 rest_activate_resource(&resource_ds1820); #endif #if REST_RES_DHT11 rest_activate_resource(&resource_dht11); #endif #if REST_RES_DHT11TEMP rest_activate_resource(&resource_dht11temp); #endif #if REST_RES_INFO rest_activate_resource(&resource_info); #endif #if defined (PLATFORM_HAS_LEDS) #if REST_RES_LEDS rest_activate_resource(&resource_leds); #endif #if REST_RES_TOGGLE rest_activate_resource(&resource_toggle); #endif #endif /* PLATFORM_HAS_LEDS */ #if defined (PLATFORM_HAS_TEMPERATURE) && REST_RES_TEMPERATURE SENSORS_ACTIVATE(temperature_sensor); rest_activate_resource(&resource_temperature); #endif #if defined (PLATFORM_HAS_BATTERY) && REST_RES_BATTERY SENSORS_ACTIVATE(battery_sensor); rest_activate_resource(&resource_battery); #endif /* Define application-specific events here. */ etimer_set(&ds_periodic_timer, MESURE_INTERVAL); while(1) { PROCESS_WAIT_EVENT(); #if defined (PLATFORM_HAS_BUTTON) if (ev == sensors_event && data == &button_sensor) { PRINTF("BUTTON\n"); } #endif /* PLATFORM_HAS_BUTTON */ if(etimer_expired(&ds_periodic_timer)) { PRINTF("Periodic\n"); etimer_reset(&ds_periodic_timer); #if REST_RES_DHT11 // DHT_Read_Data(&dht11_temp, &dht11_hum); DHT_Read_Data(&dht11_temp, &dht11_hum); #endif #if REST_RES_DS1820 if(ds1820_convert()){ etimer_set(&ds_read_timer, READ_TIME); } #endif } #if REST_RES_DS1820 if(etimer_expired(&ds_read_timer)) { PRINTF("DS1820_Read\n"); ds1820_read(); } #endif } /* while (1) */ PROCESS_END(); }