TrailTraffic

Dependencies:   Chainable_RGB_LED mbed mbedConnectorInterface mbedEndpointNetwork

Fork of IoT_LED_demo by MBED_DEMOS

Files at this revision

API Documentation at this revision

Comitter:
cjwu15
Date:
Fri May 22 00:39:20 2015 +0000
Parent:
0:a7458d25d9c9
Commit message:
Share;

Changed in this revision

Chainable_RGB_LED.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbedEndpointNetwork.lib Show annotated file Show diff for this revision Revisions of this file
mbedEndpointResources/Motion.h Show annotated file Show diff for this revision Revisions of this file
mbedEndpointResources/Temp.h Show annotated file Show diff for this revision Revisions of this file
mbedEndpointResources/UV.h Show annotated file Show diff for this revision Revisions of this file
--- a/Chainable_RGB_LED.lib	Thu Apr 16 13:56:23 2015 +0000
+++ b/Chainable_RGB_LED.lib	Fri May 22 00:39:20 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/seeed/code/Chainable_RGB_LED/#24631ceaa38a
+http://developer.mbed.org/users/seeed/code/Chainable_RGB_LED/#50d0a66599e1
--- a/main.cpp	Thu Apr 16 13:56:23 2015 +0000
+++ b/main.cpp	Fri May 22 00:39:20 2015 +0000
@@ -19,7 +19,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 // mbed Connector Interface (configuration)
 #include "mbedConnectorInterface.h"
 
@@ -64,15 +63,27 @@
 #include "SliderResource.h"
 SliderResource slider(&logger,"3202/0/5600", true); /* true if observable */
 
+#include "UV.h"
+UVResource uv(&logger,"3311/2/5706");
+
+#include "Temp.h"
+TempResource temp(&logger, "3311/3/5706");
+
+#include "Motion.h"
+MotionResource motion(&logger, "3311/4/5706");
+
+#include "mbed.h"
+
+
 // Set our own unique endpoint name
-#define MY_ENDPOINT_NAME                       "Changeme-LED-demo"
+#define MY_ENDPOINT_NAME                       "TrailTraffic"
 
 // My NSP Domain
-#define MY_NSP_DOMAIN                          "domain2"                               
+#define MY_NSP_DOMAIN                          "trail"                               
 
 // Customization Example: My custom NSP IPv4 or IPv6 address and NSP CoAP port 
 //uint8_t my_nsp_address[NSP_IP_ADDRESS_LENGTH] = {192,168,1,199}; /* local */
-uint8_t my_nsp_address[NSP_IP_ADDRESS_LENGTH] = {108,201,184,41}; /* smartobjectservice.com */
+uint8_t my_nsp_address[NSP_IP_ADDRESS_LENGTH] = {54,191,98,247}; /* smartobjectservice.com */
 int my_nsp_coap_port                          = 5683;
 
 // called from the Endpoint::start() below to create resources and the endpoint internals...
@@ -94,11 +105,14 @@
                  .addResource(&light)
                  .addResource(&slider, 10000)
                  .addResource(&led)
-                   
+                 .addResource(&temp)
+                 .addResource(&uv)
+                 .addResource(&motion)
                  // finalize the configuration...
                  .build();
 }
 
+
 // main entry point...
 int main()
 {
@@ -110,5 +124,7 @@
      
     // starts the endpoint by finalizing its configuration (configure_endpoint() above called),creating a Thread and reading NSP events...
     logger.log("Start the endpoint to finish setup and enter the main loop...");
-    Connector::Endpoint::start();
+    Connector::Endpoint::start(); 
 }
+
+// jameco sensor motion pir 3-5VOC 120 19.5ft dist dist/hold time adj
\ No newline at end of file
--- a/mbed.bld	Thu Apr 16 13:56:23 2015 +0000
+++ b/mbed.bld	Fri May 22 00:39:20 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/dbbf35b96557
\ No newline at end of file
--- a/mbedEndpointNetwork.lib	Thu Apr 16 13:56:23 2015 +0000
+++ b/mbedEndpointNetwork.lib	Fri May 22 00:39:20 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/ansond/code/mbedEndpointNetwork/#3bec96f0e572
+http://developer.mbed.org/users/ansond/code/mbedEndpointNetwork/#5857e405e02d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedEndpointResources/Motion.h	Fri May 22 00:39:20 2015 +0000
@@ -0,0 +1,68 @@
+/**
+ * @file    LightResource.h
+ * @brief   mbed CoAP Endpoint Light resource supporting CoAP GET and PUT
+ * @author  Doug Anson, Michael Koster
+ * @version 1.0
+ * @see
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MOTION_RESOURCE_H__
+#define __MOTION_RESOURCE_H__
+
+
+// Base class
+#include "DynamicResource.h"
+#include "mbed.h"
+
+
+InterruptIn sensorMotion(D2);
+int motions = 0;
+
+void irq_handler(void)
+{
+    motions++;
+}
+
+/** LightResource class
+ */
+class MotionResource : public DynamicResource
+{
+
+public:
+    /**
+    Default constructor
+    @param logger input logger instance for this resource
+    @param name input the Light resource name
+    @param observable input the resource is Observable (default: FALSE)
+    */
+    MotionResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"Motion",SN_GRS_GET_ALLOWED,observable) {
+        sensorMotion.rise(&irq_handler);
+    }
+
+    /**
+    Get the value of the LED
+    @returns string containing the last setting
+    */
+    virtual string get() {
+        char result[4];
+        sprintf(result, "%d", motions);
+        motions = 0;
+        return(result);
+    };
+};
+
+#endif // __TEMP_RESOURCE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedEndpointResources/Temp.h	Fri May 22 00:39:20 2015 +0000
@@ -0,0 +1,65 @@
+/**
+ * @file    LightResource.h
+ * @brief   mbed CoAP Endpoint Light resource supporting CoAP GET and PUT
+ * @author  Doug Anson, Michael Koster
+ * @version 1.0
+ * @see
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TEMP_RESOURCE_H__
+#define __TEMP_RESOURCE_H__
+
+
+// Base class
+#include "DynamicResource.h"
+#include "mbed.h"
+
+
+AnalogIn sensorTemp(A0);
+
+
+/** LightResource class
+ */
+class TempResource : public DynamicResource
+{
+
+public:
+    /**
+    Default constructor
+    @param logger input logger instance for this resource
+    @param name input the Light resource name
+    @param observable input the resource is Observable (default: FALSE)
+    */
+    TempResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"Temp",SN_GRS_GET_ALLOWED,observable) {
+    }
+
+    /**
+    Get the value of the LED
+    @returns string containing the last setting
+    */
+    virtual string get() {
+        int B=3975;
+        float a = sensorTemp * 1000;
+        float resistance = (float) (1023-a) * 10000/a; //get the resistance of the sensor;
+        float temperature= 1.0f / (logf(resistance/10000)/B + 1/298.15) - 273.15;//convert to temperature via datasheet ;
+        char result[8];
+        sprintf(result, "%f", temperature);
+        return(result);
+    };
+};
+
+#endif // __TEMP_RESOURCE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedEndpointResources/UV.h	Fri May 22 00:39:20 2015 +0000
@@ -0,0 +1,64 @@
+/**
+ * @file    LightResource.h
+ * @brief   mbed CoAP Endpoint Light resource supporting CoAP GET and PUT
+ * @author  Doug Anson, Michael Koster
+ * @version 1.0
+ * @see
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UV_RESOURCE_H__
+#define __UV_RESOURCE_H__
+
+
+// Base class
+#include "DynamicResource.h"
+#include "mbed.h"
+
+
+AnalogIn sensorUV(A1);
+
+static char * uvValue = {"uv"}; //RRGGBBII
+
+/** LightResource class
+ */
+class UVResource : public DynamicResource
+{
+
+public:
+    /**
+    Default constructor
+    @param logger input logger instance for this resource
+    @param name input the Light resource name
+    @param observable input the resource is Observable (default: FALSE)
+    */
+    UVResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"UV",SN_GRS_GET_ALLOWED,observable) {
+    }
+
+    /**
+    Get the value of the LED
+    @returns string containing the last setting
+    */
+    virtual string get() {
+        float value = sensorUV;
+        char result[8];
+        sprintf(result, "%f", value);
+        return(result);
+    }
+};
+
+#endif // __UV_RESOURCE_H__
+