Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IoT_LED_demo ServoTest uWater_Project hackathon ... more
Revision 3:11b2f4e58378, committed 2015-01-28
- Comitter:
- ansond
- Date:
- Wed Jan 28 11:52:09 2015 +0000
- Parent:
- 2:853f9ecc12df
- Child:
- 4:84159d67d32d
- Commit message:
- updates to enable global modification of low level NSDL configuration
Changed in this revision
| 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 |
--- a/api/OptionsBuilder.h Tue Jan 27 23:41:34 2015 +0000
+++ b/api/OptionsBuilder.h Wed Jan 28 11:52:09 2015 +0000
@@ -105,7 +105,7 @@
@param nsp_address_length input the length of the NSP IPv6 address buffer
@return instance to ourself
*/
- OptionsBuilder &setNSPAddress(const uint8_t *nsp_address,const int nsp_address_length);
+ OptionsBuilder &setNSPAddress(const uint8_t *nsp_address,const int nsp_address_length = NSP_IP_ADDRESS_LENGTH);
/**
Set the MAC address
@@ -113,7 +113,7 @@
@param mac_address_length input the MAC address buffer length
@return instance to ourself
*/
- OptionsBuilder &setMACAddress(const uint8_t *mac_address,const int mac_address_length);
+ OptionsBuilder &setMACAddress(const uint8_t *mac_address,const int mac_address_length = NODE_MAC_ADDRESS_LENGTH);
/**
Add a NSDL endpoint resource (static)
--- a/api/Utils.cpp Tue Jan 27 23:41:34 2015 +0000
+++ b/api/Utils.cpp Wed Jan 28 11:52:09 2015 +0000
@@ -28,20 +28,59 @@
Connector::Options *configure_endpoint(Connector::OptionsBuilder &builder);
extern Logger logger;
+// ************************* NSDL Linkage - MDS CONFIGURATION (defaulted) *********************************
+
+uint8_t NSP_address_bytes[NSP_IP_ADDRESS_LENGTH] = NSP_IP_ADDRESS; // which MDS instance we want to bind to...
+uint8_t endpoint_name[24] = NODE_NAME; // our NODE name
+uint8_t ep_type[] = NSP_ENDPOINT_TYPE; // our NODE type
+uint8_t lifetime_ptr[] = { NSP_LIFE_TIME }; // MDS lifetime
+uint8_t app_MAC_address[NODE_MAC_ADDRESS_LENGTH] = NODE_MAC_ADDRESS; // Node MAC address
+uint32_t channel_list = NODE_CHANNEL_LIST; // Node RF Channel list
+
+// ************************* NSDL Linkage - MDS CONFIGURATION (defaulted) *********************************
+
+
// further simplifies the endpoint main() configuration by removing the final initialization details of the endpoint...
void configure_endpoint()
-{
- Connector::OptionsBuilder builder;
- Connector::Options *options = configure_endpoint(builder);
+{
+ // NSP/NSDL default configuration - see mbedConnectorInterface.h for definitions...
+ logger.log("configure_endpoint: setting defaults...");
+ Connector::OptionsBuilder config;
+ config.setNSPAddress(NSP_address_bytes);
+ config.setNSPPortNumber(NSP_COAP_UDP_PORT);
+ config.setDomain(NSP_DOMAIN);
+ config.setEndpointType(NSP_ENDPOINT_TYPE);
+ config.setLifetime(NSP_LIFE_TIME);
+
+ // Node default configuration - see mbedConnectorInterface.h for definitions...
+ config.setRadioChannelList(NODE_CHANNEL_LIST);
+ config.setReadUpdatePeriod(NSP_RD_UPDATE_PERIOD);
+ config.setEndpointNodename(NODE_NAME);
+ config.setMACAddress(app_MAC_address);
+
+ // main.cpp can override or change any of the above defaults...
+ logger.log("configure_endpoint: enabling default configuration overrides...");
+ Connector::Options *options = configure_endpoint(config);
+
+ uint8_ t *tmp = options->getNSPAddress();
+
+ // with options, lets set the underlying NSDL globals...
+ logger.log("configure_endpoint: updating external NSDL globals...");
+ NSP_address_bytes = options->getNSPAddress();
+ endpoint_name = options->getEndpointNodename();
+ ep_type = options->getEndpointType();
+ lifetime_ptr = options->getLifetime();
+ app_MAC_address = options->getMACAddress();
+ channel_list = options->getRadioChannelList();
- // alloc Endpoint resource
- logger.log("configure_endpoint: allocating endpoint...\r\n");
+ // alloc Endpoint
+ logger.log("configure_endpoint: allocating endpoint...");
Connector::Endpoint endpoint(&logger,options);
- // initialize Endpoint resource
- logger.log("configure_endpoint: initializing endpoint...\r\n");
+ // initialize Endpoint resources
+ logger.log("configure_endpoint: binding endpoint resources...");
endpoint.initialize();
// DONE
- logger.log("configure_endpoint: completed\r\n");
+ logger.log("configure_endpoint: endpoint setup complete.");
}
