mbed Sensor node for Instrumented Booth over ETH.
Dependencies: EthernetInterface-1 MaxbotixDriver Presence HTU21D_TEMP_HUMID_SENSOR_SAMPLE Resources SHARPIR mbed-rtos mbed-src WDT_K64F nsdl_lib
Fork of Trenton_Switch_LPC1768_ETH by
Revision 31:389416beb4c3, committed 2014-12-09
- Comitter:
- erigow01
- Date:
- Tue Dec 09 11:41:28 2014 +0000
- Parent:
- 30:b74aa0729b07
- Child:
- 32:c957a1948ac1
- Commit message:
- Updates.
Changed in this revision
--- a/MaxbotixDriver.lib Fri Dec 05 16:45:56 2014 +0000 +++ b/MaxbotixDriver.lib Tue Dec 09 11:41:28 2014 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/andcor02/code/MaxbotixDriver/#455334cc71d5 +http://developer.mbed.org/teams/ASE/code/MaxbotixDriver/#01c215cac993
--- a/Resources/height.cpp Fri Dec 05 16:45:56 2014 +0000 +++ b/Resources/height.cpp Tue Dec 09 11:41:28 2014 +0000 @@ -5,12 +5,12 @@ #include "sensor_ctl.h" #include "node_cfg.h" -#define HEIGHT_RES_ID "/sen/door/height" +#define HEIGHT_RES_ID "/sen/height" #define HEIGHT_RES_RT "Height" #if NODE_HEIGHT_STATION extern float current_height_value; -static char height_val[5]; +static char height_val[6]; static uint8_t max_age = 0; static uint8_t content_type = 50; @@ -25,8 +25,8 @@ void height_report() { if(obs_number != 0){// && obs_token_ptr != NULL){ obs_number++; - snprintf(height_val,5,"%f" ,current_height_value); - if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)height_val, 5, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) { + snprintf(height_val,6,"%2.2f" ,current_height_value); + if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)height_val, strlen(height_val), &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) { printf("Height Observation Sending Failed\r\n"); } else { printf("Height Observation Sent\r\n"); @@ -38,7 +38,7 @@ static uint8_t height_resource_cb(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto) { sn_coap_hdr_s *coap_res_ptr = 0; - snprintf(height_val,5,"%f" ,current_height_value); + snprintf(height_val,6,"%2.2f" ,current_height_value); printf("height callback\r\n"); printf("height: %s\r\n", height_val);
--- a/sensor_ctl.cpp Fri Dec 05 16:45:56 2014 +0000 +++ b/sensor_ctl.cpp Tue Dec 09 11:41:28 2014 +0000 @@ -46,17 +46,14 @@ //And it might have a door trip.. bool current_door_trip_value = false; +//Door trip... float door_trip_starting_volts = 0; - float maxValue=0; - bool set=0; +float maxValue=0; +bool set=0; + + //Initialisation void init_sensors() { - - //Start the sonar pulse width timer... - #if NODE_HEIGHT_STATION - - #endif - #if NODE_DOOR_TRIP_STATION door_trip_starting_volts = sharpir.volt(); #endif @@ -136,19 +133,19 @@ #if NODE_HEIGHT_STATION void handle_door_height_sample_timer(){ - - current_height_value=Sonar.data_conversion_m(); - - if(current_height_value>1) { - if (current_height_value>maxValue) { - maxValue = current_height_value; + float height_sample = Sonar.data_conversion_m(); + printf("Height Sample: %2.2f \r\n", height_sample); + if(height_sample>1) { + if (height_sample>maxValue) { + maxValue = height_sample; } set=true; } - if(current_height_value<1 && set) { + if(height_sample<1 && set) { current_height_value=maxValue; maxValue=0,set=false; + printf("Height Update: %2.2f \r\n", current_height_value); height_report(); }
--- a/sensor_ctl.h Fri Dec 05 16:45:56 2014 +0000 +++ b/sensor_ctl.h Tue Dec 09 11:41:28 2014 +0000 @@ -8,14 +8,15 @@ #define TEMPERATURE_REPORT_PERIOD_MS 60000 // Every Minute #define SOUND_SAMPLE_PERIOD_MS 100 // Every 500 ms #define SOUND_REPORT_PERIOD_MS 10000 // Every 10 seconds -#define DOOR_HEIGHT_PERIOD_MS 100 // Every 100 ms +#define DOOR_HEIGHT_PERIOD_MS 50 // Every 50 ms #define MOTION_REPORT_PERIOD_MS 1000 // Every Second. -#define DOOR_TRIP_REPORT_PERIOD_MS 1000 // Every Second. +#define DOOR_TRIP_REPORT_PERIOD_MS 500 // Every half second. #define KIOSK_REPORT_PERIOD_MS 1000 // Every Second #define KIOSK_SENSOR_DEBOUNCE_MS 500 #define PIR_SENSOR_DEBOUNCE_MS 5000 + //Externally visible values. extern float current_temperature_value; extern float current_ambient_noise_value;