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

Committer:
WGorniak
Date:
Thu Oct 01 13:13:08 2015 +0000
Revision:
6:453b018a9ba0
Parent:
3:bb58d4e78e68
removed sstream from radiocontext

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WGorniak 2:8d8295a51f68 1 #include <cassert>
WGorniak 2:8d8295a51f68 2 #include "Settings.h"
WGorniak 2:8d8295a51f68 3
WGorniak 2:8d8295a51f68 4 Settings::Settings(Variable* variables)
WGorniak 2:8d8295a51f68 5 : variables_(variables)
WGorniak 2:8d8295a51f68 6 {
WGorniak 2:8d8295a51f68 7 }
WGorniak 2:8d8295a51f68 8
WGorniak 2:8d8295a51f68 9 Variable& Settings::find(const std::string& variableName) const
WGorniak 2:8d8295a51f68 10 {
WGorniak 2:8d8295a51f68 11 Variable* p = variables_;
WGorniak 2:8d8295a51f68 12 for (; !p->endGuard(); ++p)
WGorniak 2:8d8295a51f68 13 {
WGorniak 2:8d8295a51f68 14 if (p->name() == variableName)
WGorniak 2:8d8295a51f68 15 {
WGorniak 2:8d8295a51f68 16 return *p;
WGorniak 2:8d8295a51f68 17 }
WGorniak 2:8d8295a51f68 18 }
WGorniak 2:8d8295a51f68 19 return *p;
WGorniak 2:8d8295a51f68 20 }
WGorniak 2:8d8295a51f68 21
WGorniak 2:8d8295a51f68 22 std::string Settings::describe(std::string variable) const
WGorniak 2:8d8295a51f68 23 {
WGorniak 2:8d8295a51f68 24 const Variable& r = find(variable);
WGorniak 2:8d8295a51f68 25
WGorniak 3:bb58d4e78e68 26 std::string temp(r.name());
WGorniak 3:bb58d4e78e68 27 temp.append(": ");
WGorniak 3:bb58d4e78e68 28 temp.append(r.describe());
WGorniak 3:bb58d4e78e68 29
WGorniak 3:bb58d4e78e68 30 return temp;
WGorniak 2:8d8295a51f68 31 }
WGorniak 2:8d8295a51f68 32
WGorniak 2:8d8295a51f68 33 int32_t Settings::get(std::string variable) const
WGorniak 2:8d8295a51f68 34 {
WGorniak 2:8d8295a51f68 35 return find(variable).get();
WGorniak 2:8d8295a51f68 36 }
WGorniak 2:8d8295a51f68 37
WGorniak 2:8d8295a51f68 38 int32_t Settings::aget(std::string variable) const
WGorniak 2:8d8295a51f68 39 {
WGorniak 2:8d8295a51f68 40 int32_t v = get(variable);
WGorniak 2:8d8295a51f68 41 assert (v!=Variable::nonSetValue());
WGorniak 2:8d8295a51f68 42 return v;
WGorniak 2:8d8295a51f68 43 }
WGorniak 2:8d8295a51f68 44
WGorniak 2:8d8295a51f68 45
WGorniak 2:8d8295a51f68 46 bool Settings::set(std::string variable, int32_t value)
WGorniak 2:8d8295a51f68 47 {
WGorniak 2:8d8295a51f68 48 return find(variable).set(value);
WGorniak 2:8d8295a51f68 49 }
WGorniak 2:8d8295a51f68 50
WGorniak 2:8d8295a51f68 51 std::string Settings::help(std::string variable) const
WGorniak 2:8d8295a51f68 52 {
WGorniak 2:8d8295a51f68 53 return find(variable).help();
WGorniak 2:8d8295a51f68 54 }
WGorniak 2:8d8295a51f68 55
WGorniak 2:8d8295a51f68 56 std::string Settings::help() const
WGorniak 2:8d8295a51f68 57 {
WGorniak 3:bb58d4e78e68 58 std::string temp;
WGorniak 2:8d8295a51f68 59 for (Variable* p = variables_; !p->endGuard(); ++p)
WGorniak 2:8d8295a51f68 60 {
WGorniak 3:bb58d4e78e68 61 temp.append(p->name());
WGorniak 3:bb58d4e78e68 62 temp.append(": ");
WGorniak 3:bb58d4e78e68 63 temp.append(p->help());
WGorniak 3:bb58d4e78e68 64 temp.append("\r\n");
WGorniak 2:8d8295a51f68 65 }
WGorniak 3:bb58d4e78e68 66 return temp;
WGorniak 2:8d8295a51f68 67 }
WGorniak 2:8d8295a51f68 68
WGorniak 2:8d8295a51f68 69 std::string Settings::values() const
WGorniak 2:8d8295a51f68 70 {
WGorniak 3:bb58d4e78e68 71 std::string temp;
WGorniak 2:8d8295a51f68 72 for (Variable* p = variables_; !p->endGuard(); ++p)
WGorniak 2:8d8295a51f68 73 {
WGorniak 3:bb58d4e78e68 74 temp.append(p->name());
WGorniak 3:bb58d4e78e68 75 temp.append(": ");
WGorniak 3:bb58d4e78e68 76 temp.append(p->describe());
WGorniak 3:bb58d4e78e68 77 temp.append("\r\n");
WGorniak 2:8d8295a51f68 78 }
WGorniak 3:bb58d4e78e68 79 return temp;
WGorniak 2:8d8295a51f68 80 }
WGorniak 2:8d8295a51f68 81