Libarary of sensor resources for mbed Device Service. Requires NSDL Support Libarary, etc.
Revision 4:bc54f10b3234, committed 2015-07-16
- Comitter:
- andcor02
- Date:
- Thu Jul 16 12:45:41 2015 +0000
- Parent:
- 3:a708d3686f4b
- Commit message:
- Added Serial VCOM compatibility to S2S-K64F
Changed in this revision
diff -r a708d3686f4b -r bc54f10b3234 accelerometer.cpp --- a/accelerometer.cpp Mon Feb 09 15:38:18 2015 +0000 +++ b/accelerometer.cpp Thu Jul 16 12:45:41 2015 +0000 @@ -2,7 +2,6 @@ #include "mbed.h" #include "nsdl_support.h" - #include "node_cfg.h" #define ACCELEROMETER_RES_ID "/sen/presence" @@ -19,7 +18,6 @@ static uint8_t *obs_token_ptr = NULL; static uint8_t obs_token_len = 0; - //This is to be called from main program loop... it only sends report if accelerometer. void accelerometer_report() { printf("in report"); @@ -27,9 +25,9 @@ obs_number++; snprintf(accelerometer_val,2,"%d" ,current_accelerometer_value); if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)accelerometer_val, 1, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) { - printf("accelerometer Observation Sending Failed\r\n"); + pc.printf("accelerometer Observation Sending Failed\r\n"); } else { - printf("accelerometer Observation Sent\r\n"); + pc.printf("accelerometer Observation Sent\r\n"); } } }
diff -r a708d3686f4b -r bc54f10b3234 door_trip.cpp --- a/door_trip.cpp Mon Feb 09 15:38:18 2015 +0000 +++ b/door_trip.cpp Thu Jul 16 12:45:41 2015 +0000 @@ -26,9 +26,9 @@ obs_number++; snprintf(door_trip_val,2,"%d" ,current_door_trip_value); if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)door_trip_val, 1, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) { - printf("Door Trip Observation Sending Failed\r\n"); + pc.printf("Door Trip Observation Sending Failed\r\n"); } else { - printf("Door Trip Observation Sent\r\n"); + pc.printf("Door Trip Observation Sent\r\n"); } } } @@ -40,8 +40,8 @@ { sn_coap_hdr_s *coap_res_ptr = 0; snprintf(door_trip_val,2,"%d" ,current_door_trip_value); - printf("door_trip callback\r\n"); - printf("door_trip: %s\r\n", door_trip_val); + pc.printf("door_trip callback\r\n"); + pc.printf("door_trip: %s\r\n", door_trip_val); if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET) { @@ -55,7 +55,7 @@ if(received_coap_ptr->token_ptr){ - printf(" Token included\r\n"); + pc.printf(" Token included\r\n"); if(obs_token_ptr) { free(obs_token_ptr); @@ -75,7 +75,7 @@ coap_res_ptr->options_list_ptr->observe_len = 1; obs_number++; } - printf(" Send observation %d... \r\n", obs_number); + pc.printf(" Send observation %d... \r\n", obs_number); sn_nsdl_send_coap_message(address, coap_res_ptr); nsdl_free(coap_res_ptr->options_list_ptr);
diff -r a708d3686f4b -r bc54f10b3234 height.cpp --- a/height.cpp Mon Feb 09 15:38:18 2015 +0000 +++ b/height.cpp Thu Jul 16 12:45:41 2015 +0000 @@ -26,9 +26,9 @@ obs_number++; 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"); + pc.printf("Height Observation Sending Failed\r\n"); } else { - printf("Height Observation Sent\r\n"); + pc.printf("Height Observation Sent\r\n"); } } } @@ -38,8 +38,8 @@ { sn_coap_hdr_s *coap_res_ptr = 0; snprintf(height_val,6,"%2.2f" ,current_height_value); - printf("height callback\r\n"); - printf("height: %s\r\n", height_val); + pc.printf("height callback\r\n"); + pc.printf("height: %s\r\n", height_val); if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET) { @@ -53,7 +53,7 @@ if(received_coap_ptr->token_ptr){ - printf(" Token included\r\n"); + pc.printf(" Token included\r\n"); if(obs_token_ptr) { free(obs_token_ptr); @@ -73,7 +73,7 @@ coap_res_ptr->options_list_ptr->observe_len = 1; obs_number++; } - printf(" Send observation %d... \r\n", obs_number); + pc.printf(" Send observation %d... \r\n", obs_number); sn_nsdl_send_coap_message(address, coap_res_ptr); nsdl_free(coap_res_ptr->options_list_ptr);
diff -r a708d3686f4b -r bc54f10b3234 presence_resource.cpp --- a/presence_resource.cpp Mon Feb 09 15:38:18 2015 +0000 +++ b/presence_resource.cpp Thu Jul 16 12:45:41 2015 +0000 @@ -26,9 +26,9 @@ obs_number++; snprintf(motion_val,2,"%d" ,current_presence_value); if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)motion_val, 1, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) { - printf("Presence Observation Sending Failed\r\n"); + pc.printf("Presence Observation Sending Failed\r\n"); } else { - printf("Presence Observation Sent\r\n"); + pc.printf("Presence Observation Sent\r\n"); } } } @@ -38,8 +38,8 @@ { sn_coap_hdr_s *coap_res_ptr = 0; snprintf(motion_val,2,"%d" ,current_presence_value); - printf("presence callback\r\n"); - printf("presence: %s\r\n", motion_val); + pc.printf("presence callback\r\n"); + pc.printf("presence: %s\r\n", motion_val); if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET) { @@ -53,7 +53,7 @@ if(received_coap_ptr->token_ptr){ - printf(" Token included\r\n"); + pc.printf(" Token included\r\n"); if(obs_token_ptr) { free(obs_token_ptr); @@ -73,7 +73,7 @@ coap_res_ptr->options_list_ptr->observe_len = 1; obs_number++; } - printf(" Send observation %d... \r\n", obs_number); + pc.printf(" Send observation %d... \r\n", obs_number); sn_nsdl_send_coap_message(address, coap_res_ptr); nsdl_free(coap_res_ptr->options_list_ptr);
diff -r a708d3686f4b -r bc54f10b3234 sound_level.cpp --- a/sound_level.cpp Mon Feb 09 15:38:18 2015 +0000 +++ b/sound_level.cpp Thu Jul 16 12:45:41 2015 +0000 @@ -26,12 +26,12 @@ if(obs_number != 0){// && obs_token_ptr != NULL){ obs_number++; snprintf(sound_level_val,6,"%2.2f" ,current_ambient_noise_value); - printf("sound_level report\r\n"); - printf("sound_level: %s\r\n", sound_level_val); + pc.printf("sound_level report\r\n"); + pc.printf("sound_level: %s\r\n", sound_level_val); if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)sound_level_val, strlen(sound_level_val), &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) { - printf("Sound Observation Sending Failed\r\n"); + pc.printf("Sound Observation Sending Failed\r\n"); } else { - printf("Sound Observation Sent\r\n"); + pc.printf("Sound Observation Sent\n\r"); } } } @@ -41,8 +41,8 @@ { sn_coap_hdr_s *coap_res_ptr = 0; snprintf(sound_level_val,6,"%2.2f" ,current_ambient_noise_value); - printf("sound_level callback\r\n"); - printf("sound_level: %s\r\n", sound_level_val); + pc.printf("sound_level callback\r\n"); + pc.printf("sound_level: %s\r\n", sound_level_val); if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET) { @@ -56,7 +56,7 @@ if(received_coap_ptr->token_ptr){ - printf(" Token included\r\n"); + pc.printf(" Token included\r\n"); if(obs_token_ptr) { free(obs_token_ptr); @@ -76,7 +76,7 @@ coap_res_ptr->options_list_ptr->observe_len = 1; obs_number++; } - printf(" Send observation %d... \r\n", obs_number); + pc.printf(" Send observation %d... \r\n", obs_number); sn_nsdl_send_coap_message(address, coap_res_ptr); nsdl_free(coap_res_ptr->options_list_ptr);
diff -r a708d3686f4b -r bc54f10b3234 temperature.cpp --- a/temperature.cpp Mon Feb 09 15:38:18 2015 +0000 +++ b/temperature.cpp Thu Jul 16 12:45:41 2015 +0000 @@ -24,9 +24,9 @@ obs_number++; snprintf(temperature_val,6,"%2.2f" ,current_temperature_value); if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)temperature_val, strlen(temperature_val), &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) { - printf("Temperature Observation Sending Failed\r\n"); + pc.printf("Temperature Observation Sending Failed\r\n"); } else { - printf("Temperature Observation Sent\r\n"); + pc.printf("Temperature Observation Sent\r\n"); } } } @@ -36,8 +36,8 @@ { sn_coap_hdr_s *coap_res_ptr = 0; snprintf(temperature_val,6,"%2.2f", current_temperature_value); - printf("temperature callback\r\n"); - printf("temperature: %s\r\n", temperature_val); + pc.printf("temperature callback\r\n"); + pc.printf("temperature: %s\r\n", temperature_val); if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET) { @@ -51,7 +51,7 @@ if(received_coap_ptr->token_ptr){ - printf(" Token included\r\n"); + pc.printf(" Token included\r\n"); if(obs_token_ptr) { free(obs_token_ptr); @@ -71,7 +71,7 @@ coap_res_ptr->options_list_ptr->observe_len = 1; obs_number++; } - printf(" Send observation %d... \r\n", obs_number); + pc.printf(" Send observation %d... \r\n", obs_number); sn_nsdl_send_coap_message(address, coap_res_ptr); nsdl_free(coap_res_ptr->options_list_ptr);