Doug Anson / mbedConnectorInterface

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Sun Feb 01 14:54:18 2015 +0000
Parent:
7:09c5d9ae56cb
Child:
9:d094cfc650c3
Commit message:
renamed endpoint files due to name collisions in mbed network stack

Changed in this revision

api/ConnectorEndpoint.cpp Show annotated file Show diff for this revision Revisions of this file
api/ConnectorEndpoint.h Show annotated file Show diff for this revision Revisions of this file
api/Endpoint.cpp Show diff for this revision Revisions of this file
api/Endpoint.h Show diff for this revision Revisions of this file
api/Utils.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/ConnectorEndpoint.cpp	Sun Feb 01 14:54:18 2015 +0000
@@ -0,0 +1,131 @@
+/**
+ * @file    ConnectorEndpoint.cpp
+ * @brief   mbed CoAP Endpoint base class
+ * @author  Doug Anson/Chris Paola
+ * @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.
+ */
+
+#include "ConnectorEndpoint.h"
+
+// support for temporary mbedEndpointLib calls...
+#include "mbedEndpointLib.h"
+
+// Tasklet ID
+int main_tasklet_id = -1;
+
+// Connector namespace
+namespace Connector {
+
+// Constructor
+Endpoint::Endpoint(const Logger *logger, const Options *options)
+{
+    this->m_logger = (Logger *)logger;
+    this->m_options = (Options *)options;
+}
+
+// Copy Constructor
+Endpoint::Endpoint(const Endpoint &ep)
+{
+    this->m_logger = ep.m_logger;
+    this->m_options = ep.m_options;
+}
+
+// Destructor
+Endpoint::~Endpoint()
+{
+}
+
+// Plumb the network
+void Endpoint::plumbNetwork(bool canActAsRouterNode) {
+    // call into mbedEndpointLib directly for now... (TODO: wont be able to (re)set MAC address in OptionsBuilder as its already been plumbed here...)
+    init_network(canActAsRouterNode);
+}
+
+// initialize the endpoint
+void Endpoint::initialize()
+{
+    // Create the NSDL Resource Pointer...
+    this->logger()->log("Endpoint::initialize(): initializing NSP resource pointer...");
+    sn_nsdl_resource_info_s *resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s));
+    if(!resource_ptr) return;
+    memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s));
+
+    resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s));
+    if(!resource_ptr->resource_parameters_ptr) {
+        nsdl_free(resource_ptr);
+        return;
+    }
+    memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
+
+    // Loop through Static Resources and bind each of them...
+    this->logger()->log("Endpoint::initialize(): adding static resources...");
+    const StaticResourcesList *static_resources = this->m_options->getStaticResourceList();
+    for(int i=0; i<static_resources->size(); ++i) {
+        this->logger()->log("Endpoint::initialize(): binding static resource: [%s]...",static_resources->at(i)->getName().c_str());
+        static_resources->at(i)->bind(resource_ptr);
+    }
+
+    // Loop through Dynamic Resources and bind each of them...
+    this->logger()->log("Endpoint::initialize(): adding dynamic resources...");
+    const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
+    for(int i=0; i<dynamic_resources->size(); ++i) {
+        this->logger()->log("Endpoint::initialize(): binding dynamic resource: [%s]...",dynamic_resources->at(i)->getName().c_str());
+        dynamic_resources->at(i)->bind(resource_ptr);
+    }
+
+    // initialize the Network
+    this->initNetwork();
+
+    // clean up
+    nsdl_free(resource_ptr->resource_parameters_ptr);
+    nsdl_free(resource_ptr);
+}
+
+// initialize the NSDL Network
+void Endpoint::initNetwork()
+{
+    // register with NSP
+    this->logger()->log("Calling NSP_registration()...");
+    NSP_registration();
+    this->logger()->log("NSP_registration() completed");
+}
+
+// Finalize the endpoint's configuration and begin the endpoint's main even loop (static, not tied into Logger)
+void Endpoint::start()
+{   
+    // mbedEndpointLib tasklet creation...
+    main_tasklet_id = arm_ns_tasklet_create(&tasklet_main);
+    if(main_tasklet_id < 0) {
+        //Tasklet cerate fail
+        std::printf("startTasklet: Tasklet creation failed...\r\n");
+        return;
+    }
+
+    // mbedEndpointLib event dispatching
+    std::printf("startTasklet: Beginning event dispatch...\r\n");
+    event_dispatch();
+    return;
+}
+
+// our logger
+Logger *Endpoint::logger()
+{
+    return this->m_logger;
+}
+
+} // namespace Connector
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/ConnectorEndpoint.h	Sun Feb 01 14:54:18 2015 +0000
@@ -0,0 +1,86 @@
+/**
+ * @file    Endpoint.h
+ * @brief   mbed CoAP Endpoint base class
+ * @author  Doug Anson/Chris Paola
+ * @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 __CONNECTOR_ENDPOINT_H__
+#define __CONNECTOR_ENDPOINT_H__
+
+// Support for Logging/Debug output
+#include "Logger.h"
+
+// Options support
+#include "Options.h"
+
+// Connector namespace
+namespace Connector {
+
+/** Endpoint class
+ */
+class Endpoint
+{
+
+public:
+    /**
+    Default Constructor
+    */
+    Endpoint(const Logger *logger,const Options *ob);
+
+    /**
+    Copy Constructor
+    @param ob input endpoint instance to deep copy
+    */
+    Endpoint(const Endpoint &ep);
+
+    /**
+    Destructor
+    */
+    virtual ~Endpoint();
+
+    /**
+    Initialize the endpoint configuration
+    */
+    void initialize();
+
+    /**
+    Plumb the lower RF network stack
+    @param canActAsRouterNode input boolean indicating whether this node can act as a router node or not.
+    */
+    static void plumbNetwork(bool canActAsRouterNode = false);
+    
+    /**
+    Initialize the endpoint's configuration and begin the endpoint's main even loop
+    */
+    static void start();
+
+private:
+    Logger         *m_logger;
+    Options        *m_options;
+    
+    // initialize the NSDL network
+    void initNetwork();
+
+    // access the logger
+    Logger *logger();
+};
+
+} // namespace Connector
+
+#endif // __CONNECTOR_ENDPOINT_H__
--- a/api/Endpoint.cpp	Wed Jan 28 22:56:41 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/**
- * @file    Endpoint.cpp
- * @brief   mbed CoAP Endpoint base class
- * @author  Doug Anson/Chris Paola
- * @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.
- */
-
-#include "Endpoint.h"
-
-// support for temporary mbedEndpointLib calls...
-#include "mbedEndpointLib.h"
-
-// Tasklet ID
-int main_tasklet_id = -1;
-
-// Connector namespace
-namespace Connector {
-
-// Constructor
-Endpoint::Endpoint(const Logger *logger, const Options *options)
-{
-    this->m_logger = (Logger *)logger;
-    this->m_options = (Options *)options;
-}
-
-// Copy Constructor
-Endpoint::Endpoint(const Endpoint &ep)
-{
-    this->m_logger = ep.m_logger;
-    this->m_options = ep.m_options;
-}
-
-// Destructor
-Endpoint::~Endpoint()
-{
-}
-
-// Plumb the network
-void Endpoint::plumbNetwork(bool canActAsRouterNode) {
-    // call into mbedEndpointLib directly for now... (TODO: wont be able to (re)set MAC address in OptionsBuilder as its already been plumbed here...)
-    init_network(canActAsRouterNode);
-}
-
-// initialize the endpoint
-void Endpoint::initialize()
-{
-    // Create the NSDL Resource Pointer...
-    this->logger()->log("Endpoint::initialize(): initializing NSP resource pointer...");
-    sn_nsdl_resource_info_s *resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s));
-    if(!resource_ptr) return;
-    memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s));
-
-    resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s));
-    if(!resource_ptr->resource_parameters_ptr) {
-        nsdl_free(resource_ptr);
-        return;
-    }
-    memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
-
-    // Loop through Static Resources and bind each of them...
-    this->logger()->log("Endpoint::initialize(): adding static resources...");
-    const StaticResourcesList *static_resources = this->m_options->getStaticResourceList();
-    for(int i=0; i<static_resources->size(); ++i) {
-        this->logger()->log("Endpoint::initialize(): binding static resource: [%s]...",static_resources->at(i)->getName().c_str());
-        static_resources->at(i)->bind(resource_ptr);
-    }
-
-    // Loop through Dynamic Resources and bind each of them...
-    this->logger()->log("Endpoint::initialize(): adding dynamic resources...");
-    const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
-    for(int i=0; i<dynamic_resources->size(); ++i) {
-        this->logger()->log("Endpoint::initialize(): binding dynamic resource: [%s]...",dynamic_resources->at(i)->getName().c_str());
-        dynamic_resources->at(i)->bind(resource_ptr);
-    }
-
-    // initialize the Network
-    this->initNetwork();
-
-    // clean up
-    nsdl_free(resource_ptr->resource_parameters_ptr);
-    nsdl_free(resource_ptr);
-}
-
-// initialize the NSDL Network
-void Endpoint::initNetwork()
-{
-    // register with NSP
-    this->logger()->log("Calling NSP_registration()...");
-    NSP_registration();
-    this->logger()->log("NSP_registration() completed");
-}
-
-// Finalize the endpoint's configuration and begin the endpoint's main even loop (static, not tied into Logger)
-void Endpoint::start()
-{   
-    // mbedEndpointLib tasklet creation...
-    main_tasklet_id = arm_ns_tasklet_create(&tasklet_main);
-    if(main_tasklet_id < 0) {
-        //Tasklet cerate fail
-        std::printf("startTasklet: Tasklet creation failed...\r\n");
-        return;
-    }
-
-    // mbedEndpointLib event dispatching
-    std::printf("startTasklet: Beginning event dispatch...\r\n");
-    event_dispatch();
-    return;
-}
-
-// our logger
-Logger *Endpoint::logger()
-{
-    return this->m_logger;
-}
-
-} // namespace Connector
--- a/api/Endpoint.h	Wed Jan 28 22:56:41 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/**
- * @file    Endpoint.h
- * @brief   mbed CoAP Endpoint base class
- * @author  Doug Anson/Chris Paola
- * @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 __ENDPOINT_H__
-#define __ENDPOINT_H__
-
-// Support for Logging/Debug output
-#include "Logger.h"
-
-// Options support
-#include "Options.h"
-
-// Connector namespace
-namespace Connector {
-
-/** Endpoint class
- */
-class Endpoint
-{
-
-public:
-    /**
-    Default Constructor
-    */
-    Endpoint(const Logger *logger,const Options *ob);
-
-    /**
-    Copy Constructor
-    @param ob input endpoint instance to deep copy
-    */
-    Endpoint(const Endpoint &ep);
-
-    /**
-    Destructor
-    */
-    virtual ~Endpoint();
-
-    /**
-    Initialize the endpoint configuration
-    */
-    void initialize();
-
-    /**
-    Plumb the lower RF network stack
-    @param canActAsRouterNode input boolean indicating whether this node can act as a router node or not.
-    */
-    static void plumbNetwork(bool canActAsRouterNode = false);
-    
-    /**
-    Initialize the endpoint's configuration and begin the endpoint's main even loop
-    */
-    static void start();
-
-private:
-    Logger         *m_logger;
-    Options        *m_options;
-    
-    // initialize the NSDL network
-    void initNetwork();
-
-    // access the logger
-    Logger *logger();
-};
-
-} // namespace Connector
-
-#endif // __ENDPOINT_H__
--- a/api/Utils.cpp	Wed Jan 28 22:56:41 2015 +0000
+++ b/api/Utils.cpp	Sun Feb 01 14:54:18 2015 +0000
@@ -21,7 +21,7 @@
  */
 
 // mbed Endpoint includes
-#include "Endpoint.h"
+#include "ConnectorEndpoint.h"
 #include "OptionsBuilder.h"
 
 // External references (defined in main.cpp)