Elmo Terminal provides functionality to test Lora radio and access SX1272 chip registers delivered with Elmo board. Also contains example ping-pong application.
Dependencies: SX1272lib mbed-src
Diff: Settings/Settings.cpp
- Revision:
- 2:8d8295a51f68
- Child:
- 3:bb58d4e78e68
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Settings/Settings.cpp Thu Oct 01 09:40:30 2015 +0200 @@ -0,0 +1,75 @@ +#include <sstream> +#include <cassert> +#include "Settings.h" + +Settings::Settings(Variable* variables) + : variables_(variables) +{ +} + +Variable& Settings::find(const std::string& variableName) const +{ + Variable* p = variables_; + for (; !p->endGuard(); ++p) + { + if (p->name() == variableName) + { + return *p; + } + } + return *p; +} + +std::string Settings::describe(std::string variable) const +{ + const Variable& r = find(variable); + + std::ostringstream temp; + temp << r.name() << ": " << r.describe(); + return temp.str(); +} + +int32_t Settings::get(std::string variable) const +{ + return find(variable).get(); +} + +int32_t Settings::aget(std::string variable) const +{ + int32_t v = get(variable); + assert (v!=Variable::nonSetValue()); + return v; +} + + +bool Settings::set(std::string variable, int32_t value) +{ + return find(variable).set(value); +} + +std::string Settings::help(std::string variable) const +{ + return find(variable).help(); +} + +std::string Settings::help() const +{ + std::ostringstream temp; + for (Variable* p = variables_; !p->endGuard(); ++p) + { + temp << p->name() << ": " << p->help() << "\r\n"; + } + return temp.str(); +} + +std::string Settings::values() const +{ + std::ostringstream temp; + + for (Variable* p = variables_; !p->endGuard(); ++p) + { + temp << p->name() << ": " << p->describe() << "\r\n"; + } + return temp.str(); +} +