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:
2:8d8295a51f68
removed sstream from radiocontext

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WGorniak 2:8d8295a51f68 1 #include "mbed.h"
WGorniak 2:8d8295a51f68 2 #include "Serial.h"
WGorniak 2:8d8295a51f68 3
WGorniak 2:8d8295a51f68 4 #include "CmdFactory.h"
WGorniak 2:8d8295a51f68 5 #include "CmdList.h"
WGorniak 2:8d8295a51f68 6
WGorniak 2:8d8295a51f68 7 CmdFactory::CmdFactory(Settings* settings, Serial *serial)
WGorniak 2:8d8295a51f68 8 : settings_(settings), serial_(serial)
WGorniak 2:8d8295a51f68 9 {
WGorniak 2:8d8295a51f68 10 }
WGorniak 2:8d8295a51f68 11
WGorniak 2:8d8295a51f68 12 CmdFactory::~CmdFactory()
WGorniak 2:8d8295a51f68 13 {
WGorniak 2:8d8295a51f68 14 }
WGorniak 2:8d8295a51f68 15
WGorniak 2:8d8295a51f68 16
WGorniak 2:8d8295a51f68 17 template <>
WGorniak 2:8d8295a51f68 18 Cmd* CmdFactory::create<int>(const std::string& cmd) const
WGorniak 2:8d8295a51f68 19 {
WGorniak 2:8d8295a51f68 20 return NULL;
WGorniak 2:8d8295a51f68 21 }
WGorniak 2:8d8295a51f68 22
WGorniak 2:8d8295a51f68 23 template <typename cmds>
WGorniak 2:8d8295a51f68 24 Cmd* CmdFactory::create(const std::string& cmd) const
WGorniak 2:8d8295a51f68 25 {
WGorniak 2:8d8295a51f68 26 typedef typename cmds::t T;
WGorniak 2:8d8295a51f68 27
WGorniak 2:8d8295a51f68 28 if (0 == cmd.compare(T::cmd()))
WGorniak 2:8d8295a51f68 29 {
WGorniak 2:8d8295a51f68 30 return new T(settings_);
WGorniak 2:8d8295a51f68 31 }
WGorniak 2:8d8295a51f68 32
WGorniak 2:8d8295a51f68 33 return create<typename cmds::tn>(cmd); // tail call recursion - optimized out (-O2)
WGorniak 2:8d8295a51f68 34 }
WGorniak 2:8d8295a51f68 35
WGorniak 2:8d8295a51f68 36 Cmd* CmdFactory::createCmd(std::string cmd) const
WGorniak 2:8d8295a51f68 37 {
WGorniak 2:8d8295a51f68 38 Cmd* command = create<CmdList>(cmd);
WGorniak 2:8d8295a51f68 39 if (!command)
WGorniak 2:8d8295a51f68 40 {
WGorniak 2:8d8295a51f68 41 serial_->printf("No such command %s\r\n", cmd.c_str());
WGorniak 2:8d8295a51f68 42 }
WGorniak 2:8d8295a51f68 43
WGorniak 2:8d8295a51f68 44 return command;
WGorniak 2:8d8295a51f68 45 }