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:
- 0:1405a58a7e8d
- Child:
- 1:5b6c5c2a33d0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ConfigurationFile.cpp Sun Apr 03 15:44:20 2016 +0000
@@ -0,0 +1,116 @@
+#include "ConfigurationFile.h"
+
+ConfigurationFile::ConfigurationFile()
+{
+ PC_Comm _pc;
+ pc = _pc.pc;
+}
+
+ConfigurationFile::~ConfigurationFile()
+{
+
+}
+
+void ConfigurationFile::setIP()
+{
+ char value[BUFSIZ];
+ if (cfg.getValue( "IP", &value[0], sizeof(value)))
+ {
+ printf("'%s'='%s'\n", "IP", value);
+ string s = value;
+ ip = s;
+ }
+ else
+ {
+ error("Failure to read IP key");
+ }
+}
+
+string ConfigurationFile::getIP()
+{
+ return ip;
+}
+
+void ConfigurationFile::setMask()
+{
+ char value[BUFSIZ];
+ if (cfg.getValue( "MASK", &value[0], sizeof(value)))
+ {
+ printf("'%s'='%s'\n", "MASK", value);
+ string s = value;
+ mask = s;
+ }
+ else
+ {
+ error("Failure to read MASK key");
+ }
+}
+
+string ConfigurationFile::getMask()
+{
+ return mask;
+}
+
+void ConfigurationFile::setGateway()
+{
+ char value[BUFSIZ];
+ if (cfg.getValue( "GATEWAY", &value[0], sizeof(value)))
+ {
+ printf("'%s'='%s'\n", "GATEWAY", value);
+ string s = value;
+ gateway = s;
+ }
+ else
+ {
+ error("Failure to read GATEWAY key");
+ }
+}
+
+string ConfigurationFile::getGateway()
+{
+ return gateway;
+}
+
+void ConfigurationFile::setURL()
+{
+ char value[BUFSIZ];
+ if (cfg.getValue( "URL", &value[0], sizeof(value)))
+ {
+ printf("'%s'='%s'\n", "URL", value);
+ string s = value;
+ url = s;
+ }
+ else
+ {
+ error("Failure to read URL key");
+ }
+}
+
+string ConfigurationFile::getURL()
+{
+ return url;
+}
+
+
+void ConfigurationFile::readServerEthernetConfiguration()
+{
+ setIP();
+ setMask();
+ setGateway();
+ setURL();
+}
+
+void ConfigurationFile::readNodeEthernetConfiguration()
+{
+ setIP();
+ setMask();
+ setGateway();
+}
+
+void ConfigurationFile::readConfigurationFile(char *pathName)
+{
+ if (!cfg.read(pathName))
+ {
+ error("Failure to read a configuration file.\n");
+ }
+}
\ No newline at end of file