Doug Anson / mbedConnectorInterface

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Tue Feb 24 02:05:06 2015 +0000
Parent:
18:95c2f95a75fe
Child:
20:abfbaf524192
Commit message:
added additional 802.15.4 configuration support

Changed in this revision

api/Options.cpp Show annotated file Show diff for this revision Revisions of this file
api/Options.h Show annotated file Show diff for this revision Revisions of this file
api/OptionsBuilder.cpp Show annotated file Show diff for this revision Revisions of this file
api/OptionsBuilder.h Show annotated file Show diff for this revision Revisions of this file
api/Utils.cpp Show annotated file Show diff for this revision Revisions of this file
mbedConnectorInterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/api/Options.cpp	Wed Feb 18 19:40:13 2015 +0000
+++ b/api/Options.cpp	Tue Feb 24 02:05:06 2015 +0000
@@ -120,4 +120,14 @@
     return this->m_wifi_auth_key;
 }
 
+// 802.15.4 Network ID
+string Options::getNetworkID() {
+    return this->m_network_id;
+}
+
+// 802.15.4 Network ID
+uint8_t Options::getRadioChannel() {
+    return this->m_channel;
+}
+
 } // namespace Connector
--- a/api/Options.h	Wed Feb 18 19:40:13 2015 +0000
+++ b/api/Options.h	Tue Feb 24 02:05:06 2015 +0000
@@ -138,24 +138,41 @@
     Get the WiFi Auth Key
     */
     string getWiFiAuthKey();
+    
+    /**
+    Get the 802.15.4 Network ID
+    */
+    string getNetworkID();
+    
+    /**
+    Get the 802.15.4 Radio channel
+    */
+    uint8_t getRadioChannel();
 
 protected:
+    // mDS Resources
     char                *m_lifetime;
     string               m_domain;
     string               m_node_name;
     string               m_endpoint_type;
-    uint32_t             m_channel_list;
     int                  m_rd_update_period;
     int                  m_nsp_port;
     uint8_t              m_nsp_address[NSP_IP_ADDRESS_LENGTH];
-    uint8_t              m_mac_address[NODE_MAC_ADDRESS_LENGTH];
-    StaticResourcesList  m_static_resources;
-    DynamicResourcesList m_dynamic_resources;
     
     // WiFi Resources
     string               m_wifi_ssid;
     string               m_wifi_auth_key;
     WiFiAuthTypes        m_wifi_auth_type;
+    
+    // 802.15.4 Resources
+    string               m_network_id;
+    uint32_t             m_channel_list;
+    uint8_t              m_mac_address[NODE_MAC_ADDRESS_LENGTH];
+    uint8_t              m_channel;
+    
+    // Endpoint Resources
+    StaticResourcesList  m_static_resources;
+    DynamicResourcesList m_dynamic_resources;
 };
 
 } // namespace Connector
--- a/api/OptionsBuilder.cpp	Wed Feb 18 19:40:13 2015 +0000
+++ b/api/OptionsBuilder.cpp	Tue Feb 24 02:05:06 2015 +0000
@@ -168,6 +168,20 @@
     return *this;
 }
 
+// set 802.15.4 Network ID
+OptionsBuilder &OptionsBuilder::setNetworkID(char *network_id)
+{
+    this->m_network_id = string(network_id);
+    return *this;
+}
+
+// set 802.15.4 Radio Channel
+OptionsBuilder &OptionsBuilder::setRadioChannel(int channel)
+{
+    this->m_channel = (uint8_t)channel;
+    return *this;
+}
+
 // build out our immutable self
 Options *OptionsBuilder::build()
 {
--- a/api/OptionsBuilder.h	Wed Feb 18 19:40:13 2015 +0000
+++ b/api/OptionsBuilder.h	Tue Feb 24 02:05:06 2015 +0000
@@ -148,6 +148,18 @@
     OptionsBuilder &setWiFiAuthKey(char *auth_key);
     
     /**
+    Set the 802.15.4 Network ID
+    @param network_id input the 802.15.4 mesh Network ID
+    */
+    OptionsBuilder &setNetworkID(char *network_id);
+    
+    /**
+    Set the 802.15.4 Radio Channel
+    @param channel input the 802.15.4 radio channel
+    */
+    OptionsBuilder &setRadioChannel(int channel);
+    
+    /**
     Build our our immutable self
     */
     Options *build();
--- a/api/Utils.cpp	Wed Feb 18 19:40:13 2015 +0000
+++ b/api/Utils.cpp	Tue Feb 24 02:05:06 2015 +0000
@@ -50,6 +50,9 @@
 WiFiAuthTypes wifi_auth_type;                                          // WiFi Auth Type
 uint8_t wifi_auth_key[WIFI_AUTH_KEY_LENGTH];                           // WiFi Auth Key
 
+uint8_t mesh_network_id[MESH_NETWORK_ID_LENGTH] = MESH_DEF_NETWORK_ID; // 802.15.4 Network ID (6LowPAN)
+uint8_t rf_channel = MESH_DEF_RF_CHANNEL;                              // 802.15.4 RF Channel (6LowPAN)
+
 // ************************* NSDL Linkage - MDS CONFIGURATION (defaulted)  *********************************
 
 
@@ -76,6 +79,10 @@
     config.setWiFiAuthType(WIFI_WPA_PERSONAL);      // default: WPA Personal
     config.setWiFiAuthKey(WIFI_DEFAULT_AUTH_KEY);   // default: changeme
     
+    // 802.15.4 defaults (6LowPAN)
+    config.setNetworkID((char *)mesh_network_id);
+    config.setRadioChannel((int)mesh_network_id);
+    
     // main.cpp can override or change any of the above defaults...
     logger.log("utils_configure_endpoint: gathering configuration overrides...");
     options = configure_endpoint(config);
@@ -95,6 +102,10 @@
     memcpy(wifi_ssid,options->getWiFiSSID().c_str(),options->getWiFiSSID().size());
     wifi_auth_type = options->getWiFiAuthType();
     memcpy(wifi_auth_key,options->getWiFiAuthKey().c_str(),options->getWiFiAuthKey().size());
+    
+    // 802.15.4 Configuration
+    memcpy(mesh_network_id,options->getNetworkID().c_str(),options->getNetworkID().size());
+    rf_channel = options->getRadioChannel();
 
     // DONE
     logger.log("utils_configure_endpoint: endpoint configuration completed.");
--- a/mbedConnectorInterface.h	Wed Feb 18 19:40:13 2015 +0000
+++ b/mbedConnectorInterface.h	Tue Feb 24 02:05:06 2015 +0000
@@ -48,6 +48,12 @@
 // Logger buffer size
 #define LOGGER_BUFFER_LENGTH     300                                         // largest single print of a given debug line
 
+// 802.15.4 Network ID and RF channel defaults
+#define MESH_NETWORK_ID_LENGTH   32
+#define MESH_DEF_NETWORK_ID      "Network000000000"
+#define MESH_DEF_RF_CHANNEL      11
+
+
 // WiFi Configuration
 #define WIFI_SSID_LENGTH         128
 #define WIFI_DEFAULT_SSID        "changeme"