Weather control switch for connected day. NXP LPC 1768 module. Ethernet connectivity.

Dependencies:   EthernetInterface mbed-rtos mbed nanoservice_client_1_12

Fork of Trenton_Switch_LPC1768_WIFLY by Demo Team

Files at this revision

API Documentation at this revision

Comitter:
erigow01
Date:
Wed Dec 03 09:11:47 2014 +0000
Parent:
25:cb16c5248769
Commit message:
Rollback of accidental commit.

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
MAX9814/MAX9814.cpp Show diff for this revision Revisions of this file
MAX9814/MAX9814.h Show diff for this revision Revisions of this file
MaxbotixDriver.lib Show diff for this revision Revisions of this file
PIR/PIR.cpp Show diff for this revision Revisions of this file
PIR/PIR.h Show diff for this revision Revisions of this file
RHT03.lib Show diff for this revision Revisions of this file
Resources/door_trip.cpp Show diff for this revision Revisions of this file
Resources/door_trip.h Show diff for this revision Revisions of this file
Resources/height.cpp Show diff for this revision Revisions of this file
Resources/height.h Show diff for this revision Revisions of this file
Resources/kiosk_presence.cpp Show diff for this revision Revisions of this file
Resources/kiosk_presence.h Show diff for this revision Revisions of this file
Resources/motion.cpp Show diff for this revision Revisions of this file
Resources/motion.h Show diff for this revision Revisions of this file
Resources/sound_level.cpp Show diff for this revision Revisions of this file
Resources/sound_level.h Show diff for this revision Revisions of this file
Resources/temperature.cpp Show diff for this revision Revisions of this file
Resources/temperature.h Show diff for this revision Revisions of this file
SHARPIR.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
sensor_ctl.cpp Show diff for this revision Revisions of this file
sensor_ctl.h Show diff for this revision Revisions of this file
switch.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r cb16c5248769 -r 3467812d5832 EthernetInterface.lib
--- a/EthernetInterface.lib	Wed Dec 03 09:03:29 2014 +0000
+++ b/EthernetInterface.lib	Wed Dec 03 09:11:47 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#de796e2a5e98
+http://mbed.org/users/mbed_official/code/EthernetInterface/#5887ae6c0c2c
diff -r cb16c5248769 -r 3467812d5832 MAX9814/MAX9814.cpp
--- a/MAX9814/MAX9814.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
-    MAX9814.cpp - MAX9814 sensor library
-    Developed by Andrea Corrado   
-*/
-
-#include "mbed.h"
-#include "MAX9814.h"
-
-MAX9814::MAX9814(PinName pin): _pin(pin) { //, _led1(LED1), _led2(LED2), _led3(LED3) {
-    
-}
-
-
-
-float MAX9814::sound_level() {
-
-    _t.start();
-    float peakToPeak=0, signalMax=0, signalMin=1024;
-
-    while (_t.read_ms()<50) {
-        _sample=_pin.read();
-
-        if (_sample<1024) {
-            if (_sample>signalMax)
-                signalMax=_sample;
-
-            else if (_sample<signalMin)
-                signalMin=_sample;
-        }
-    }
-    _t.stop();
-    _t.reset();
-    peakToPeak=signalMax-signalMin;
-    _value= (peakToPeak*3.3);
-    _value = floor(_value * 100) / 100;
-
-    return _value;
-}
diff -r cb16c5248769 -r 3467812d5832 MAX9814/MAX9814.h
--- a/MAX9814/MAX9814.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
-    MAX9814.h - MAX9814 sensor library
-    Developed by Andrea Corrado   
-*/
-
-/*
-    Example 'main.cpp'
-
-#include "mbed.h"
-#include "MAX9814.h"
-Serial pc (USBTX, USBRX);
-
-
-MAX9814 mic(p20);
-
-int main()
-{
-    while (1) {
-        mic.volume_indicator();
-        pc.printf("\n\r Level is %f", mic.sound_level());
-    }
-}
-
-*/
-
-#ifndef MBED_MIC_H
-#define MBED_MIC_H
-
-#include "mbed.h"
-
-class MAX9814 {
-    
-public:
-
-    MAX9814(PinName pin); //Analogue in
-    float sound_level();
-
-protected:
-    AnalogIn _pin;
-    float _value;
-    float _sample;
-    Timer _t,_t1;
-};
-
-#endif
\ No newline at end of file
diff -r cb16c5248769 -r 3467812d5832 MaxbotixDriver.lib
--- a/MaxbotixDriver.lib	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/DanielC/code/MaxbotixDriver/#7e65f5077f5a
diff -r cb16c5248769 -r 3467812d5832 PIR/PIR.cpp
--- a/PIR/PIR.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
-    PIR.cpp -  sensor library
-    Developed by Andrea Corrado   
-*/
-
-
-#include "mbed.h"
-#include "PIR.h"
-
-PIR::PIR(PinName pin):_myint(pin)
-{
-    _myint.rise(this, &PIR::pir_interrupt);
-    _detection=false;
-    debounce.start();
-
-}
-
-void PIR::pir_interrupt()
-{
-    if(debounce.read_ms() > 4000) {
-        _detection=true;
-        debounce.reset();
-    }
-}
diff -r cb16c5248769 -r 3467812d5832 PIR/PIR.h
--- a/PIR/PIR.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
-    PIR.cpp -  sensor library
-    Developed by Andrea Corrado   
-*/
-
-
-#ifndef MBED_PIR_H
-#define MBED_PIR_H
-
-#include "mbed.h"
-
-/* EXAMPLE
-
-#include "mbed.h"
-#include "PIR.h"
-
-Serial pc (USBTX,USBRX);
-
-PIR sensor(PTB2);
-
-int main()
-{
-    
-if (sensor.getdetection()) {
-pc.printf("\n\r Detection");
-  sensor.resetdetection(); 
-  }
-}
-*/
-
-class PIR {
-    
-public:
-
-    PIR (PinName pin);
-    
-    void pir_interrupt();
-    
-    bool getdetection(){return _detection;}
-    
-    void resetdetection(){_detection = false;}
-
-protected:
-    InterruptIn _myint;
-    bool _detection;
-    Timer debounce;
-    
-};
-
-#endif
\ No newline at end of file
diff -r cb16c5248769 -r 3467812d5832 RHT03.lib
--- a/RHT03.lib	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/tristanjph/code/RHT03/#153e20f26d54
diff -r cb16c5248769 -r 3467812d5832 Resources/door_trip.cpp
--- a/Resources/door_trip.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-// door_trip (from Sharpir) sensor resource implementation
- 
-#include "mbed.h"
-#include "nsdl_support.h"
-#include "sensor_ctl.h"
-//#include "node_cfg.h"
-
-#include "SHARPIR.h"
- 
-#define DOOR_TRIP_RES_ID    "/sen/door/trip"
-#define DOOR_TRIP_RES_RT    "Door Trip"
-
-
-#if NODE_DOOR_TRIP_STATION
-extern bool current_door_trip_value;
-static char door_trip_val[2];
-static uint8_t max_age = 0; 
-static uint8_t content_type = 50;
- 
-static uint8_t obs_number = 0;
-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 door tripped.
-void door_trip_report() {
-    if(obs_number != 0){
-        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");
-        } else {
-            printf("Door Trip Observation Sent\r\n");
-        }
-    }
-} 
-
-
- 
-/* Only GET method allowed */
-static uint8_t door_trip_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(door_trip_val,2,"%d" ,current_door_trip_value);
-    printf("door_trip callback\r\n");
-    printf("door_trip: %s\r\n", door_trip_val);
- 
-    if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
-    {
-        coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
- 
-        coap_res_ptr->payload_len = strlen(door_trip_val);
-        coap_res_ptr->payload_ptr = (uint8_t*)door_trip_val;
-        
-        coap_res_ptr->content_type_ptr = &content_type;
-        coap_res_ptr->content_type_len = sizeof(content_type);
-        
-        if(received_coap_ptr->token_ptr){
-            printf("   Token included\r\n");
-            if(obs_token_ptr){
-                free(obs_token_ptr);
-                obs_token_ptr = 0;
-            }
-            obs_token_ptr = (uint8_t*)malloc(received_coap_ptr->token_len);
-            if(obs_token_ptr){
-                memcpy(obs_token_ptr, received_coap_ptr->token_ptr, received_coap_ptr->token_len);
-                obs_token_len = received_coap_ptr->token_len;
-            }
-        }
-        
-        coap_res_ptr->options_list_ptr = (sn_coap_options_list_s*)nsdl_alloc(sizeof(sn_coap_options_list_s));
-        if(!coap_res_ptr->options_list_ptr)
-            {
-            printf("cant alloc option list for max-age\r\n");
-            coap_res_ptr->options_list_ptr = NULL; //FIXME report error and recover
-            }
-        memset(coap_res_ptr->options_list_ptr, 0, sizeof(sn_coap_options_list_s));
-        coap_res_ptr->options_list_ptr->max_age_ptr = &max_age;
-        coap_res_ptr->options_list_ptr->max_age_len = sizeof(max_age);
- 
-        sn_nsdl_send_coap_message(address, coap_res_ptr);
-        nsdl_free(coap_res_ptr->options_list_ptr);
-        coap_res_ptr->options_list_ptr = NULL;
-        coap_res_ptr->content_type_ptr = NULL;// parser_release below tries to free this memory
- 
-    }
- 
-    sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
- 
-    return 0;
-}
- 
-int create_door_trip_resource(sn_nsdl_resource_info_s *resource_ptr)
-{
-    obs_number++;
-    nsdl_create_dynamic_resource(resource_ptr, sizeof(DOOR_TRIP_RES_ID)-1, (uint8_t*)DOOR_TRIP_RES_ID, sizeof(DOOR_TRIP_RES_RT)-1, (uint8_t*)DOOR_TRIP_RES_RT, 1, &door_trip_resource_cb, (SN_GRS_GET_ALLOWED));
-    return 0;
-}
-#endif
diff -r cb16c5248769 -r 3467812d5832 Resources/door_trip.h
--- a/Resources/door_trip.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-// Door trip (from SHARPPIR) sensor resource implementation
-
-#ifndef DOOR_TRIP_H
-#define DOOR_TRIP_H
-
-#include "nsdl_support.h"
-
-int create_door_trip_resource(sn_nsdl_resource_info_s *resource_ptr);
-void door_trip_report();
-#endif  // DOOR_TRIP
diff -r cb16c5248769 -r 3467812d5832 Resources/height.cpp
--- a/Resources/height.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-// height (from Maxbotix) sensor resource implementation
- 
-#include "mbed.h"
-#include "nsdl_support.h"
-#include "sensor_ctl.h"
-//#include "node_cfg.h"
- 
-#define HEIGHT_RES_ID    "/sen/door/height"
-#define HEIGHT_RES_RT    "Height"
-
-#if NODE_HEIGHT_STATION
-extern float current_door_height_value;
-static char height_val[5];
-static uint8_t max_age = 0; 
-static uint8_t content_type = 50;
- 
-/* stored data for observable resource */
-static uint8_t obs_number = 0;
-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 height taken.
-void height_report() {
-    if(obs_number != 0){// && obs_token_ptr != NULL){
-        obs_number++;
-        snprintf(height_val,5,"%f" ,current_door_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) {
-            printf("Height Observation Sending Failed\r\n");
-        } else {
-            printf("Height Observation Sent\r\n");
-        }
-    }
-} 
-
-/* Only GET method allowed */
-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_door_height_value);
-    printf("height callback\r\n");
-    printf("height: %s\r\n", height_val);
- 
-    if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
-    {
-        coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
- 
-        coap_res_ptr->payload_len = strlen(height_val);
-        coap_res_ptr->payload_ptr = (uint8_t*)height_val;
-        
-        coap_res_ptr->content_type_ptr = &content_type;
-        coap_res_ptr->content_type_len = sizeof(content_type);
-        
-        if(received_coap_ptr->token_ptr){
-            printf("   Token included\r\n");
-            if(obs_token_ptr){
-                free(obs_token_ptr);
-                obs_token_ptr = 0;
-            }
-            obs_token_ptr = (uint8_t*)malloc(received_coap_ptr->token_len);
-            if(obs_token_ptr){
-                memcpy(obs_token_ptr, received_coap_ptr->token_ptr, received_coap_ptr->token_len);
-                obs_token_len = received_coap_ptr->token_len;
-            }
-        }
-        
-        coap_res_ptr->options_list_ptr = (sn_coap_options_list_s*)nsdl_alloc(sizeof(sn_coap_options_list_s));
-        if(!coap_res_ptr->options_list_ptr)
-            {
-            printf("cant alloc option list for max-age\r\n");
-            coap_res_ptr->options_list_ptr = NULL; //FIXME report error and recover
-            }
-        memset(coap_res_ptr->options_list_ptr, 0, sizeof(sn_coap_options_list_s));
-        coap_res_ptr->options_list_ptr->max_age_ptr = &max_age;
-        coap_res_ptr->options_list_ptr->max_age_len = sizeof(max_age);
- 
-        sn_nsdl_send_coap_message(address, coap_res_ptr);
-        nsdl_free(coap_res_ptr->options_list_ptr);
-        coap_res_ptr->options_list_ptr = NULL;
-        coap_res_ptr->content_type_ptr = NULL;// parser_release below tries to free this memory
- 
-    }
- 
-    sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
- 
-    return 0;
-}
- 
-int create_height_resource(sn_nsdl_resource_info_s *resource_ptr)
-{
-    obs_number++;
-    nsdl_create_dynamic_resource(resource_ptr, sizeof(HEIGHT_RES_ID)-1, (uint8_t*)HEIGHT_RES_ID, sizeof(HEIGHT_RES_RT)-1, (uint8_t*)HEIGHT_RES_RT, 1, &height_resource_cb, (SN_GRS_GET_ALLOWED));
-    return 0;
-}
-#endif
diff -r cb16c5248769 -r 3467812d5832 Resources/height.h
--- a/Resources/height.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-// Height (from Maxbotix) sensor resource implementation
-
-#ifndef HEIGHT_H
-#define HEIGHT_H
-
-#include "nsdl_support.h"
-
-int create_height_resource(sn_nsdl_resource_info_s *resource_ptr);
-void height_report();
-#endif  // HEIGHT
diff -r cb16c5248769 -r 3467812d5832 Resources/kiosk_presence.cpp
--- a/Resources/kiosk_presence.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-// kiosk_presence (from Maxbotix) sensor resource implementation
- 
-#include "mbed.h"
-#include "nsdl_support.h"
-#include "sensor_ctl.h"
-//#include "node_cfg.h"
-
-
- 
-#define KIOSK_PRESENCE_RES_ID    "/sen/presence"
-#define KIOSK_PRESENCE_RES_RT    "Presence"
-
-#if NODE_KIOSK_STATION
-extern bool current_presence_value;
-static char kiosk_presence_val[2];
-static uint8_t max_age = 0; 
-static uint8_t content_type = 50;
- 
- 
- /* stored data for observable resource */
-static uint8_t obs_number = 0;
-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 kiosk presence.
-void kiosk_presence_report() {
-    if(obs_number != 0){
-        obs_number++;
-        snprintf(kiosk_presence_val,2,"%d" ,current_presence_value);
-        if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)kiosk_presence_val, 1, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) {
-            printf("Kiosk Presence Observation Sending Failed\r\n");
-        } else {
-            printf("Kiosk Presence Observation Sent\r\n");
-        }
-    }
-}
- 
-/* Only GET method allowed */
-static uint8_t kiosk_presence_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(kiosk_presence_val,2,"%d" ,current_presence_value);
-    printf("kiosk_presence callback\r\n");
-    printf("kiosk_presence: %s\r\n", kiosk_presence_val);
- 
-    if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
-    {
-        coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
- 
-        coap_res_ptr->payload_len = strlen(kiosk_presence_val);
-        coap_res_ptr->payload_ptr = (uint8_t*)kiosk_presence_val;
-        
-        coap_res_ptr->content_type_ptr = &content_type;
-        coap_res_ptr->content_type_len = sizeof(content_type);
-        
-        if(received_coap_ptr->token_ptr){
-            printf("   Token included\r\n");
-            if(obs_token_ptr){
-                free(obs_token_ptr);
-                obs_token_ptr = 0;
-            }
-            obs_token_ptr = (uint8_t*)malloc(received_coap_ptr->token_len);
-            if(obs_token_ptr){
-                memcpy(obs_token_ptr, received_coap_ptr->token_ptr, received_coap_ptr->token_len);
-                obs_token_len = received_coap_ptr->token_len;
-            }
-        }
-                
-        coap_res_ptr->options_list_ptr = (sn_coap_options_list_s*)nsdl_alloc(sizeof(sn_coap_options_list_s));
-        if(!coap_res_ptr->options_list_ptr)
-            {
-            printf("cant alloc option list for max-age\r\n");
-            coap_res_ptr->options_list_ptr = NULL; //FIXME report error and recover
-            }
-        memset(coap_res_ptr->options_list_ptr, 0, sizeof(sn_coap_options_list_s));
-        coap_res_ptr->options_list_ptr->max_age_ptr = &max_age;
-        coap_res_ptr->options_list_ptr->max_age_len = sizeof(max_age);
- 
-        sn_nsdl_send_coap_message(address, coap_res_ptr);
-        nsdl_free(coap_res_ptr->options_list_ptr);
-        coap_res_ptr->options_list_ptr = NULL;
-        coap_res_ptr->content_type_ptr = NULL;// parser_release below tries to free this memory
- 
-    }
- 
-    sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
- 
-    return 0;
-}
- 
-int create_kiosk_presence_resource(sn_nsdl_resource_info_s *resource_ptr)
-{
-    obs_number++;
-    nsdl_create_dynamic_resource(resource_ptr, sizeof(KIOSK_PRESENCE_RES_ID)-1, (uint8_t*)KIOSK_PRESENCE_RES_ID, sizeof(KIOSK_PRESENCE_RES_RT)-1, (uint8_t*)KIOSK_PRESENCE_RES_RT, 1, &kiosk_presence_resource_cb, (SN_GRS_GET_ALLOWED));
-    return 0;
-}
-#endif
diff -r cb16c5248769 -r 3467812d5832 Resources/kiosk_presence.h
--- a/Resources/kiosk_presence.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-// Kiosk Presence (from Maxbotix) sensor resource implementation
-
-#ifndef KIOSK_PRESENCE_H
-#define KIOSK_PRESENCE_H
-
-#include "nsdl_support.h"
-
-int create_kiosk_presence_resource(sn_nsdl_resource_info_s *resource_ptr);
-void kiosk_presence_report();
-#endif  // KIOSK_PRESENCE
diff -r cb16c5248769 -r 3467812d5832 Resources/motion.cpp
--- a/Resources/motion.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-// motion (from PIR) sensor resource implementation
- 
-#include "mbed.h"
-#include "nsdl_support.h"
-
-//#include "node_cfg.h"
-
-#include "PIR.h"
- 
-#define MOTION_RES_ID    "/sen/presence"
-#define MOTION_RES_RT    "Presence"
-
-#if NODE_PIR_STATION
-extern bool current_presence_value;         //Either from Kiosk or PIR
-static char motion_val[2];
-static uint8_t max_age = 0; 
-static uint8_t content_type = 50;
-
-
-/* stored data for observable resource */
-static uint8_t obs_number = 0;
-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 motion.
-void motion_report() {
-    if(obs_number != 0){
-        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("PIR Presence Observation Sending Failed\r\n");
-        } else {
-            last_reported_motion = current_motion;
-            printf("PIR Presence Observation Sent\r\n");
-        }
-    }
-}
- 
-/* Only GET method allowed */
-static uint8_t motion_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(motion_val,2,"%d" ,current_presence_value);
-    printf("motion callback\r\n");
-    printf("motion: %s\r\n", motion_val);
- 
-    if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
-    {
-        coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
- 
-        coap_res_ptr->payload_len = strlen(motion_val);
-        coap_res_ptr->payload_ptr = (uint8_t*)motion_val;
-        
-        coap_res_ptr->content_type_ptr = &content_type;
-        coap_res_ptr->content_type_len = sizeof(content_type);
-        
-        if(received_coap_ptr->token_ptr){
-            printf("   Token included\r\n");
-            if(obs_token_ptr){
-                free(obs_token_ptr);
-                obs_token_ptr = 0;
-            }
-            obs_token_ptr = (uint8_t*)malloc(received_coap_ptr->token_len);
-            if(obs_token_ptr){
-                memcpy(obs_token_ptr, received_coap_ptr->token_ptr, received_coap_ptr->token_len);
-                obs_token_len = received_coap_ptr->token_len;
-            }
-        }
-        
-        coap_res_ptr->options_list_ptr = (sn_coap_options_list_s*)nsdl_alloc(sizeof(sn_coap_options_list_s));
-        if(!coap_res_ptr->options_list_ptr)
-            {
-            printf("cant alloc option list for max-age\r\n");
-            coap_res_ptr->options_list_ptr = NULL; //FIXME report error and recover
-            }
-        memset(coap_res_ptr->options_list_ptr, 0, sizeof(sn_coap_options_list_s));
-        coap_res_ptr->options_list_ptr->max_age_ptr = &max_age;
-        coap_res_ptr->options_list_ptr->max_age_len = sizeof(max_age);
- 
-        sn_nsdl_send_coap_message(address, coap_res_ptr);
-        nsdl_free(coap_res_ptr->options_list_ptr);
-        coap_res_ptr->options_list_ptr = NULL;
-        coap_res_ptr->content_type_ptr = NULL;// parser_release below tries to free this memory
- 
-    }
- 
-    sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
- 
-    return 0;
-}
- 
-int create_motion_resource(sn_nsdl_resource_info_s *resource_ptr)
-{
-    obs_number++;
-    nsdl_create_dynamic_resource(resource_ptr, sizeof(MOTION_RES_ID)-1, (uint8_t*)MOTION_RES_ID, sizeof(MOTION_RES_RT)-1, (uint8_t*)MOTION_RES_RT, 1, &motion_resource_cb, (SN_GRS_GET_ALLOWED));
-    return 0;
-}
-#endif
diff -r cb16c5248769 -r 3467812d5832 Resources/motion.h
--- a/Resources/motion.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-// Motion (from PIR) sensor resource implementation
-
-#ifndef MOTION_H
-#define MOTION_H
-
-#include "nsdl_support.h"
-
-int create_motion_resource(sn_nsdl_resource_info_s *resource_ptr);
-void motion_report();
-#endif  // MOTION
diff -r cb16c5248769 -r 3467812d5832 Resources/sound_level.cpp
--- a/Resources/sound_level.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-// sound_level (from barometer) sensor resource implementation
- 
-#include "mbed.h"
-#include "nsdl_support.h"
-#include "sensor_ctl.h"
-//#include "node_cfg.h"
-
- 
-#define SOUND_LEVEL_RES_ID    "/sen/sound"
-#define SOUND_LEVEL_RES_RT    "Sound Level"
-
-#if NODE_SENSOR_STATION
-static char sound_level_val[6];
-static uint8_t max_age = 0; 
-static uint8_t content_type = 50;
-
-
-/* stored data for observable resource */
-static uint8_t obs_number = 0;
-static uint8_t *obs_token_ptr = NULL;
-static uint8_t obs_token_len = 0;
-
-
-
-//This is to be called from main program loop... it sends volume on request.
-void sound_level_report() {
-    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);
-        if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)sound_level_val, 4, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) {
-            printf("Sound Observation Sending Failed\r\n");
-        } else {
-            printf("Sound Observation Sent\r\n");
-        }
-    }
-}
-
-/* Only GET method allowed */
-static uint8_t sound_level_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(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);
- 
-    if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
-    {
-        coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
- 
-        coap_res_ptr->payload_len = strlen(sound_level_val);
-        coap_res_ptr->payload_ptr = (uint8_t*)sound_level_val;
-        
-        coap_res_ptr->content_type_ptr = &content_type;
-        coap_res_ptr->content_type_len = sizeof(content_type);
-        
-        if(received_coap_ptr->token_ptr){
-            printf("   Token included\r\n");
-            if(obs_token_ptr){
-                free(obs_token_ptr);
-                obs_token_ptr = 0;
-            }
-            obs_token_ptr = (uint8_t*)malloc(received_coap_ptr->token_len);
-            if(obs_token_ptr){
-                memcpy(obs_token_ptr, received_coap_ptr->token_ptr, received_coap_ptr->token_len);
-                obs_token_len = received_coap_ptr->token_len;
-            }
-        }
-        
-        coap_res_ptr->options_list_ptr = (sn_coap_options_list_s*)nsdl_alloc(sizeof(sn_coap_options_list_s));
-        if(!coap_res_ptr->options_list_ptr){
-            printf("cant alloc option list for max-age\r\n");
-            coap_res_ptr->options_list_ptr = NULL; //FIXME report error and recover
-        }
-        memset(coap_res_ptr->options_list_ptr, 0, sizeof(sn_coap_options_list_s));
-        coap_res_ptr->options_list_ptr->max_age_ptr = &max_age;
-        coap_res_ptr->options_list_ptr->max_age_len = sizeof(max_age);
- 
-        sn_nsdl_send_coap_message(address, coap_res_ptr);
-        nsdl_free(coap_res_ptr->options_list_ptr);
-        coap_res_ptr->options_list_ptr = NULL;
-        coap_res_ptr->content_type_ptr = NULL;// parser_release below tries to free this memory
- 
-    }
- 
-    sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
- 
-    return 0;
-}
- 
-int create_sound_level_resource(sn_nsdl_resource_info_s *resource_ptr)
-{
-    obs_number++;
-    nsdl_create_dynamic_resource(resource_ptr, sizeof(SOUND_LEVEL_RES_ID)-1, (uint8_t*)SOUND_LEVEL_RES_ID, sizeof(SOUND_LEVEL_RES_RT)-1, (uint8_t*)SOUND_LEVEL_RES_RT, 1, &sound_level_resource_cb, (SN_GRS_GET_ALLOWED));
-    return 0;
-}
-#endif
diff -r cb16c5248769 -r 3467812d5832 Resources/sound_level.h
--- a/Resources/sound_level.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-// Sound Level (from MAX9814) sensor resource implementation
-
-#ifndef SOUND_LEVEL_H
-#define SOUND_LEVEL_H
-
-#include "nsdl_support.h"
-
-int create_sound_level_resource(sn_nsdl_resource_info_s *resource_ptr);
-void sound_level_report();
-#endif  // SOUND_LEVEL
diff -r cb16c5248769 -r 3467812d5832 Resources/temperature.cpp
--- a/Resources/temperature.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-// temperature (from barometer) sensor resource implementation
- 
-#include "mbed.h"
-#include "nsdl_support.h"
-#include "sensor_ctl.h"
-//#include "node_cfg.h"
-
-
-#define TEMPERATURE_RES_ID    "/sen/temp"
-#define TEMPERATURE_RES_RT    "Temperature"
-
-#if NODE_SENSOR_STATION
-static uint8_t max_age = 0; 
-static uint8_t content_type = 50;
-
-/* stored data for observable resource */
-static uint8_t obs_number = 0;
-static uint8_t *obs_token_ptr = NULL;
-static uint8_t obs_token_len = 0;
-static char temperature_val[6];
-
-//This is to be called from main program loop... sends temp on request.
-void temperature_report() {
-    if(obs_number != 0){// && obs_token_ptr != NULL){
-        obs_number++;
-        snprintf(temperature_val,3.2,"%2.2f" ,current_temperature_value);
-        if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)temperature_val, 4, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) {
-            printf("Temperature Observation Sending Failed\r\n");
-        } else {
-            printf("Temperature Observation Sent\r\n");
-        }
-    }
-}
-
-/* Only GET method allowed */
-static uint8_t temperature_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;
-    sprintf(temperature_val,"%2.2f", current_temperature_value);
-    printf("temperature callback\r\n");
-    printf("temperature: %s\r\n", temperature_val);
- 
-    if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
-    {
-        coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
- 
-        coap_res_ptr->payload_len = strlen(temperature_val);
-        coap_res_ptr->payload_ptr = (uint8_t*)temperature_val;
-        
-        coap_res_ptr->content_type_ptr = &content_type;
-        coap_res_ptr->content_type_len = sizeof(content_type);
-        
-        if(received_coap_ptr->token_ptr){
-            printf("   Token included\r\n");
-            if(obs_token_ptr){
-                free(obs_token_ptr);
-                obs_token_ptr = 0;
-            }
-            obs_token_ptr = (uint8_t*)malloc(received_coap_ptr->token_len);
-            if(obs_token_ptr){
-                memcpy(obs_token_ptr, received_coap_ptr->token_ptr, received_coap_ptr->token_len);
-                obs_token_len = received_coap_ptr->token_len;
-            }
-        }
-        
-        coap_res_ptr->options_list_ptr = (sn_coap_options_list_s*)nsdl_alloc(sizeof(sn_coap_options_list_s));
-        if(!coap_res_ptr->options_list_ptr)
-            {
-            printf("cant alloc option list for max-age\r\n");
-            coap_res_ptr->options_list_ptr = NULL; //FIXME report error and recover
-            }
-        memset(coap_res_ptr->options_list_ptr, 0, sizeof(sn_coap_options_list_s));
-        coap_res_ptr->options_list_ptr->max_age_ptr = &max_age;
-        coap_res_ptr->options_list_ptr->max_age_len = sizeof(max_age);
- 
-        sn_nsdl_send_coap_message(address, coap_res_ptr);
-        nsdl_free(coap_res_ptr->options_list_ptr);
-        coap_res_ptr->options_list_ptr = NULL;
-        coap_res_ptr->content_type_ptr = NULL;// parser_release below tries to free this memory
- 
-    }
- 
-    sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
- 
-    return 0;
-}
- 
-int create_temperature_resource(sn_nsdl_resource_info_s *resource_ptr)
-{
-    obs_number++;
-    nsdl_create_dynamic_resource(resource_ptr, sizeof(TEMPERATURE_RES_ID)-1, (uint8_t*)TEMPERATURE_RES_ID, sizeof(TEMPERATURE_RES_RT)-1, (uint8_t*)TEMPERATURE_RES_RT, 1, &temperature_resource_cb, (SN_GRS_GET_ALLOWED));
-    return 0;
-}
-#endif
diff -r cb16c5248769 -r 3467812d5832 Resources/temperature.h
--- a/Resources/temperature.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-// Temperature (from Barometer) sensor resource implementation
-
-#ifndef TEMPERATURE_H
-#define TEMPERATURE_H
-
-#include "nsdl_support.h"
-
-int create_temperature_resource(sn_nsdl_resource_info_s *resource_ptr);
-void temperature_report();
-#endif  // TEMPERATURE
-
diff -r cb16c5248769 -r 3467812d5832 SHARPIR.lib
--- a/SHARPIR.lib	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/teams/ASE/code/SHARPIR/#a2c79cfd42d1
diff -r cb16c5248769 -r 3467812d5832 main.cpp
--- a/main.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ b/main.cpp	Wed Dec 03 09:11:47 2014 +0000
@@ -17,10 +17,8 @@
 #include "EthernetInterface.h"
 #include "main.h"
 #include "nsdl_support.h"
-#include "sensor_ctl.h"
 #include "switch.h"
 
-
 //Serial pc(USBTX, USBRX);
 
 // ****************************************************************************
@@ -192,10 +190,8 @@
             n = 0;
         }
         
-
         //Check if need to send pressure mat update...
-       handle_microphone_sample_timer();
-
+        switch_report();
         
         //NSDL Tick
         if(nsdlTickTimer.read() >= NSDL_TICK_PERIOD) {
@@ -220,7 +216,6 @@
 }
 
 
-
 /**
  *  \param none
  *  \return int
diff -r cb16c5248769 -r 3467812d5832 mbed-rtos.lib
--- a/mbed-rtos.lib	Wed Dec 03 09:03:29 2014 +0000
+++ b/mbed-rtos.lib	Wed Dec 03 09:11:47 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad
+http://mbed.org/users/mbed_official/code/mbed-rtos/#bd07334df5b1
diff -r cb16c5248769 -r 3467812d5832 mbed-src.lib
--- a/mbed-src.lib	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/mbed_official/code/mbed-src/#ee28a0bed4ad
diff -r cb16c5248769 -r 3467812d5832 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 03 09:11:47 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file
diff -r cb16c5248769 -r 3467812d5832 sensor_ctl.cpp
--- a/sensor_ctl.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/** Implements Sensor Control for CES Instrumented Booth */
-
-#include "mbed.h"
-#include "sensor_ctl.h"
-//#include "node_cfg.h"
-
-//Sensor Drivers
-#include "RHT03.h"
-#include "MAX9814.h"
-#include "sonar.h"
-#include "PIR.h"
-#include "SHARPIR.h"
-
-//Sensor MDS Resources
-#include "door_trip.h"
-#include "height.h"
-#include "kiosk_presence.h"
-#include "motion.h"
-#include "sound_level.h"
-#include "temperature.h"
-
-//Common Sensors
-RHT03 temperature(PTB2);
-MAX9814 microphone(PTB3); //Analogue in required.
-Timer sonarTimer;
-Sonar Sonar(PTB10, sonarTimer); //(AnalogIn required, Leave as SW2.)
-PIR pir(PTB2); //(InterruptPin), for PIR sensor, 
-SHARPIR sharpir(PTB11); //(AnalogIn required), for IR door trip
-
-
-//Variables provided to rest of applications
-float    current_temperature_value;
-float  current_ambient_noise_value;
-//Either height XOR kiosk presence XOR PIR station...
-float    current_door_height_value;
-bool     current_presence_value;         //Either from Kiosk or PIR
-#define KIOSK_MAX_RANGE 200; //Max range, centimetres...
-//And it might have a door trip..
-bool     current_door_trip_value;
-
-//Initialisation
-void init_sensors() {
-    //TODO Initiate sensors, interrupts, etc.
-    //Start the sonar pulse width timer...
-    #if NODE_HEIGHT_STATION
-    sonarTimer.start();
-    #elif NODE_KIOSK_STATION
-    sonarTimer.start();
-    #endif
-}
-
-//timer handler functions
-void handle_temperature_report_timer() {
-    if(temperature.readData() == RHT_ERROR_NONE) { 
-        //Only report valid data...
-        current_temperature_value = temperature.getTemperatureC();
-        printf("Temperature Sample: %2.2f\r\n", current_temperature_value);
-//        temperature_report();
-    } else {
-        printf("Temperature Sampleing Failure\r\n");
-    }
-}
-
-void handle_microphone_sample_timer()
-{
-    float sample = microphone.sound_level();
-    printf("Sound Sample: %2.2f\r\n", sample);
-    if (sample > current_ambient_noise_value){
-        current_ambient_noise_value = sample;
-    }
-}
-
-void handle_microphone_report_timer()
-{
-    //Report.
-    //sound_level_report();
-    //Reset noise...
-    current_ambient_noise_value = 0;
-}
-
-void handle_door_height_sample_timer()
-{
-
-}
-
-void drive_height()
-{
-//    current_height_value=/*obj*/.data_conversion_m();
-//    
-//    if(current_height_value>1) {
-//         if (current_height_value>maxValue){
-//            maxValue = current_height_value;   
-//         }   
-//        set=true;
-//    }
-//    
-//    if(current_height_value<1 && set) {
-//        current_height_value=maxValue;
-//        height_report();
-//        maxValue=0,set=false;
-//    }
-
-}
-
-void drive_door_trip()
-{
-////    wait_ms(50);
-//    value=.volt();
-//
-//    if (value>min+0.15) {
-//        current_door_trip_value=1;
-//    }
-//
-//    else if (value<min+0.15) {
-//        current_door_trip_value=0;
-//    }
-//    
-//    if (last_reported_door_trip != current_door_trip)
-//        door_trip_report();
-}
-
-
-void drive_kiosk_presence()
-{
-//
-//    if (kiosk.getdetection()) {
-//        current_kiosk_presence_value=1;
-//    }
-//
-//    else current_kiosk_presence_value=0;
-//    
-//    if (last_reported_kiosk_presence != current_kiosk_presence)
-//        kiosk_presence_report();
-}
-
-void drive_motion()
-{
-//
-//    if (pir.getdetection()) {
-//        current_motion_value=1;
-//    }
-//
-//    else current_motion_value=0;
-//    
-//    if (last_reported_motion!= current_door_motion)
-//        motion_report();
-}
\ No newline at end of file
diff -r cb16c5248769 -r 3467812d5832 sensor_ctl.h
--- a/sensor_ctl.h	Wed Dec 03 09:03:29 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#ifndef SENSOR_CTL_H_
-#define SENSOR_CTL_H_
-/** Defines sensor control functionality for CES Instrumented Booth demonstrations */
-
-
-
-/*******  Sensor Timer/Debounce Periods (ms) **********/
-#define TEMPERATURE_REPORT_PERIOD   60000       // Every Minute
-#define SOUND_SAMPLE_PERIOD           100       // Every 500 ms
-#define SOUND_REPORT_PERIOD         10000       // Every 10 seconds
-#define DOOR_HEIGHT_PERIOD            100       // Every 100 ms
-#define PIR_DEBOUNCE_PERIOD         30000       // 30 seconds
-#define KIOSK_DEBOUNCE_PERIOD       60000       // Every minute
-
-
-//Externally visible values.
-extern float    current_temperature_value;
-extern float  current_ambient_noise_value;
-extern float    current_door_height_value;
-extern bool     current_presence_value;         //Either from Kiosk or PIR
-extern bool     current_door_trip_value;
-
-
-//Initialisation
-void init_sensors();
-
-//Handle timers/interrupts/etc
-void handle_temperature_report_timer();
-void handle_microphone_sample_timer();
-void handle_microphone_report_timer();
-void handle_door_height_sample_timer();
-
-void drive_height();
-void drive_kiosk_presence();
-void drive_motion();
-void drive_door_trip();
-
-
-//Drive functions
-
-
-
-
-
-#endif  // SENSOR_CTL_H_
\ No newline at end of file
diff -r cb16c5248769 -r 3467812d5832 switch.cpp
--- a/switch.cpp	Wed Dec 03 09:03:29 2014 +0000
+++ b/switch.cpp	Wed Dec 03 09:11:47 2014 +0000
@@ -11,7 +11,7 @@
 #define MINIMUM_DEBOUNCE_PERIOD 200  //ms
 
 DigitalOut led1(LED1);
-InterruptIn switch_in(PTA1);
+InterruptIn switch_in(p21);
 Timer debounceTimer;
 Timer reportTimer;
 Timer pollTimer;