Brian Daniels / Mbed 2 deprecated nespresso_demo

Dependencies:   EthernetInterface mbed-rtos mbed nsdl rgb_sensor_buffer

Fork of mbed_nsdl by Nespresso RGB Sensor

Files at this revision

API Documentation at this revision

Comitter:
bjblazkowicz
Date:
Mon Sep 15 14:14:44 2014 +0000
Parent:
7:4d873b7d187b
Child:
9:9d5b0c43579b
Child:
12:ad05fe84b4ff
Commit message:
Removed unused files.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
resources/nespresso.cpp Show diff for this revision Revisions of this file
resources/nespresso.h Show diff for this revision Revisions of this file
rgb_sensor_buffer.lib Show annotated file Show diff for this revision Revisions of this file
rgb_sensor_detection.lib Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Aug 01 15:25:35 2014 +0000
+++ b/main.cpp	Mon Sep 15 14:14:44 2014 +0000
@@ -2,7 +2,6 @@
 #include "EthernetInterface.h"
 #include "nsdl_support.h"
 #include "dbg.h"
-#include "nespresso.h"
 #include "buffered_rgb_resource.h"
 
 Serial pc(USBTX, USBRX); // tx, rx
--- a/resources/nespresso.cpp	Fri Aug 01 15:25:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-#include "mbed.h"
-#include "rtos.h"
-#include "nsdl_support.h"
-#include "nespresso.h"
-#include "detection.h"
-
-#define NESPRESSO_RES_ID    "sensor/capsule"
-
-extern Serial pc;
-/* 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 const char* g_name = "no_capsule";
-
-//static RGB_Detection g_detector(p23,p24,p25,p20);
-
-/* Thread for calling libNsdl exec function (cleanup, resendings etc..) */
-/* Node updates nespresso value every 10 seconds. Notification sending is done here. */
-static void exec_call_thread(void const *args)
-{
-    pc.printf("Entering thread\r\n");
-    int32_t time = 0;
-    while (true)
-    {
-        time++;
-        sn_nsdl_exec(time);
-        pc.printf("obs_number: %d, obs_token_ptr: %0x%08x\r\n", obs_number, obs_token_ptr);
-        // if (obs_number != 0 && obs_token_ptr != NULL)
-        {
-            obs_number++;        
-            pc.printf("Waiting for detector...\r\n");    
-            g_name = ""; // g_detector.run();
-            int len = strlen(g_name);
-            pc.printf("Detected %s\r\n", g_name);
-            if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)g_name, len, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) 
-            {
-                pc.printf("Failed to send observation\r\n");
-            }
-            else 
-            {
-                pc.printf("Sent observation successfully\r\n");
-            }
-        }
-    }
-}
-
-#if 0
-static void exec_call_thread(void const *args)
-{
-    int32_t time = 0;
-    while (true)
-    {
-        time++;
-        sn_nsdl_exec(time);
-        if((!(time % 10)) && obs_number != 0 && obs_token_ptr != NULL)
-        {
-            obs_number++;
-            if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)g_res_nespresso_val, (strlen(res_nespresso_val)-1), &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) 
-            {
-                pc.printf("Observation sending failed\r\n");
-            }
-            else 
-            {
-                pc.printf("Observation\r\n");
-            }
-        }
-    }
-}
-#endif
-
-
-
-/* Only GET method allowed */
-static uint8_t nespresso_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;
-
-    pc.printf("nespresso callback\r\n");
-
-    coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
-
-    coap_res_ptr->payload_len = strlen(g_name)-1;
-    coap_res_ptr->payload_ptr = (uint8_t*)g_name;
-
-    if(received_coap_ptr->token_ptr)
-    {
-        pc.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;
-        }
-    }
-
-    if(received_coap_ptr->options_list_ptr->observe)
-    {
-        coap_res_ptr->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s));
-        memset(coap_res_ptr->options_list_ptr, 0, sizeof(sn_coap_options_list_s));
-        coap_res_ptr->options_list_ptr->observe_ptr = &obs_number;
-        coap_res_ptr->options_list_ptr->observe_len = 1;
-        obs_number++;
-    }
-
-    sn_nsdl_send_coap_message(address, coap_res_ptr);
-
-    coap_res_ptr->options_list_ptr->observe_ptr = 0;
-    sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
-
-    return 0;
-}
-
-int create_nespresso_resource(sn_nsdl_resource_info_s *resource_ptr)
-{
-    static Thread exec_thread(exec_call_thread);
-    pc.printf("Created thread\r\n");
-    nsdl_create_dynamic_resource(resource_ptr, sizeof(NESPRESSO_RES_ID)-1, (uint8_t*)NESPRESSO_RES_ID, 0, 0, 1, &nespresso_resource_cb, SN_GRS_GET_ALLOWED);
-    pc.printf("Created resource\r\n");
-    return 0;
-}
\ No newline at end of file
--- a/resources/nespresso.h	Fri Aug 01 15:25:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-// Nespresso resource implementation
-
-#ifndef NESPRESSO_H
-#define NESPRESSO_H
-
-#include "nsdl_support.h"
-
-int create_nespresso_resource(sn_nsdl_resource_info_s *resource_ptr);
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rgb_sensor_buffer.lib	Mon Sep 15 14:14:44 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/meriac/code/rgb_sensor_buffer/#8fbb1cd0c2d9
--- a/rgb_sensor_detection.lib	Fri Aug 01 15:25:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/bjblazkowicz/code/rgb_sensor_detection/#9a7aff86a323