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.
Dependencies: ConfigFile
Diff: ConfigurationFile.cpp
- Revision:
- 3:7177e463ac52
- Parent:
- 2:5af11ca8e085
- Child:
- 4:c8f6d3677937
--- a/ConfigurationFile.cpp Wed Apr 06 15:46:53 2016 +0000
+++ b/ConfigurationFile.cpp Wed Apr 06 20:20:25 2016 +0000
@@ -1,7 +1,17 @@
#include "ConfigurationFile.h"
-ConfigurationFile::ConfigurationFile()
+ConfigurationFile::ConfigurationFile(char *pathName)
{
+ readConfigurationFile(pathName);
+ readUnitConfiguration();
+}
+
+void ConfigurationFile::readConfigurationFile(char *pathName)
+{
+ if (!cfg.read(pathName))
+ {
+ error("Failure to read a configuration file.\n");
+ }
}
ConfigurationFile::~ConfigurationFile()
@@ -88,14 +98,14 @@
return url;
}
-void ConfigurationFile::setBroadcastAddress()
+void ConfigurationFile::setBroadcastPort()
{
char value[BUFSIZ];
if (cfg.getValue( "BROADCAST", &value[0], sizeof(value)))
{
printf("'%s'='%s'\n", "Broadcast Address", value);
string s = value;
- broadcastAddress = s;
+ broadcastPort = s;
}
else
{
@@ -103,50 +113,26 @@
}
}
-string ConfigurationFile::getBroadcastAddress()
+int ConfigurationFile::getBroadcastPort()
{
- return broadcastAddress;
+ return atoi(broadcastPort.c_str());
}
-void ConfigurationFile::readServerEthernetConfiguration()
+void ConfigurationFile::readUnitConfiguration()
{
setIP();
setMask();
setGateway();
setURL();
- setBroadcastAddress();
-}
-
-void ConfigurationFile::readNodeEthernetConfiguration()
-{
- setIP();
- setMask();
- setGateway();
- setBroadcastAddress();
+ setBroadcastPort();
}
-void ConfigurationFile::getServerConfiguration()
-{
- getIP();
- getMask();
- getGateway();
- getURL();
- getBroadcastAddress();
-}
-
-void ConfigurationFile::getNodeConfiguration()
+void ConfigurationFile::getUnitConfiguration()
{
- getIP();
- getMask();
- getGateway();
- getBroadcastAddress();
-}
-
-void ConfigurationFile::readConfigurationFile(char *pathName)
-{
- if (!cfg.read(pathName))
- {
- error("Failure to read a configuration file.\n");
- }
+ printf("IP : %s,\n",getIP());
+ printf("Mask : %s,\n",getMask());
+ printf("Gateway : %s,\n",getGateway());
+ printf("URL : %s,\n",getURL());
+ printf("BroadcastPort : %i,\n",getBroadcastPort());
}
\ No newline at end of file