PROCESS_THREAD(test_process, ev, data) { PROCESS_BEGIN(); uint16_t light; light_ziglet_init(); while(1) { etimer_set(&et, SENSOR_READ_INTERVAL); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); light = light_ziglet_read(); PRINTF("Light = %u\n", light); } PROCESS_END(); }
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); /* 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 REST engine. */ rest_init_engine(); /* Activate the application-specific resources. */ #if REST_RES_HELLO rest_activate_resource(&resource_helloworld); #endif #if REST_RES_MIRROR rest_activate_resource(&resource_mirror); #endif #if REST_RES_CHUNKS rest_activate_resource(&resource_chunks); #endif #if REST_RES_PUSHING rest_activate_periodic_resource(&periodic_resource_pushing); #endif #if defined (PLATFORM_HAS_BUTTON) && REST_RES_EVENT rest_activate_event_resource(&resource_event); #endif #if defined (PLATFORM_HAS_BUTTON) && REST_RES_SEPARATE && WITH_COAP > 3 /* No pre-handler anymore, user coap_separate_accept() and coap_separate_reject(). */ rest_activate_resource(&resource_separate); #endif #if defined (PLATFORM_HAS_BUTTON) && (REST_RES_EVENT || (REST_RES_SEPARATE && WITH_COAP > 3)) SENSORS_ACTIVATE(button_sensor); #endif #if REST_RES_SUB rest_activate_resource(&resource_sub); #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_LIGHT) && REST_RES_LIGHT SENSORS_ACTIVATE(light_sensor); rest_activate_resource(&resource_light); #endif #if defined (PLATFORM_HAS_BATTERY) && REST_RES_BATTERY SENSORS_ACTIVATE(battery_sensor); rest_activate_resource(&resource_battery); #endif #if defined (PLATFORM_HAS_RADIO) && REST_RES_RADIO SENSORS_ACTIVATE(radio_sensor); rest_activate_resource(&resource_radio); #endif #if defined REST_RES_EXTLIGHT light_ziglet_init(); rest_activate_resource(&resource_extlight); #endif /* Define application-specific events here. */ while(1) { PROCESS_WAIT_EVENT(); #if defined (PLATFORM_HAS_BUTTON) if (ev == sensors_event && data == &button_sensor) { PRINTF("BUTTON\n"); #if REST_RES_EVENT /* Call the event_handler for this application-specific event. */ event_event_handler(&resource_event); #endif #if REST_RES_SEPARATE && WITH_COAP>3 /* Also call the separate response example handler. */ separate_finalize_handler(); #endif } #endif /* PLATFORM_HAS_BUTTON */ } /* while (1) */ PROCESS_END(); }