Compare commits
1 Commits
master
...
server/api
| Author | SHA1 | Date |
|---|---|---|
|
|
181b4eee2b |
143
src/PiScan.h
143
src/PiScan.h
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
|
||||
#include "messages/context.h"
|
||||
#include "Configuration.h"
|
||||
|
|
@ -15,6 +16,13 @@ class DemodInterface;
|
|||
namespace piscan {
|
||||
namespace app {
|
||||
|
||||
enum ReturnStatus {
|
||||
SUCCESS,
|
||||
INVALID,
|
||||
NOT_IMPLEMENTED,
|
||||
};
|
||||
typedef std::tuple<ReturnStatus, void*> BasicReturnTuple;
|
||||
|
||||
struct ManualEntryData {
|
||||
public:
|
||||
ManualEntryData(ManualEntryData& copy) : freq(copy.freq), modulation(copy.modulation){};
|
||||
|
|
@ -65,5 +73,140 @@ namespace audio {
|
|||
AudioThread* getAudioController();
|
||||
}
|
||||
|
||||
/* database */
|
||||
namespace data {
|
||||
/*
|
||||
Retrieve the entire System tree
|
||||
*/
|
||||
BasicReturnTuple getScanList(); //TODO
|
||||
|
||||
/*
|
||||
Retrieve list of Systems and their indices, tags, and types
|
||||
*/
|
||||
BasicReturnTuple getSystemList();
|
||||
|
||||
/*
|
||||
Retrieve tree of System and its Entries at index
|
||||
*/
|
||||
BasicReturnTuple getSystemByIndex(size_t sys_index); //TODO
|
||||
|
||||
/*
|
||||
Retrieve list of Entries within indexed System and their indices and descriptors
|
||||
*/
|
||||
BasicReturnTuple getEntryList(size_t sys_index);
|
||||
|
||||
/*
|
||||
Retrieve Entry at index
|
||||
*/
|
||||
BasicReturnTuple getEntryByIndex(size_t sys_index, size_t entry_index); //TODO
|
||||
|
||||
namespace system {
|
||||
/*
|
||||
Create a new Radio System
|
||||
*/
|
||||
BasicReturnTuple create(/*TODO data*/);
|
||||
|
||||
/*
|
||||
Replace the Radio System header at index. Entries will be retained unless the system type is changed.
|
||||
*/
|
||||
BasicReturnTuple replace(size_t sys_index /*, TODO new*/);
|
||||
|
||||
/*
|
||||
Remove the Radio System and its Entries at index. Indices of succeeding Systems will be updated upon success
|
||||
*/
|
||||
BasicReturnTuple remove(size_t sys_index);
|
||||
|
||||
/*
|
||||
Set lockout status of System at index.
|
||||
- '0' for unlocked
|
||||
- '-1' for persistent lock
|
||||
- '>1' lock for duration in seconds
|
||||
*/
|
||||
BasicReturnTuple setLockout(size_t sys_index, int duration_seconds);
|
||||
|
||||
/*
|
||||
Move Radio System from original index to new index. All other indices are updated upon success
|
||||
*/
|
||||
BasicReturnTuple setIndex(size_t original_sys_index, size_t new_sys_index);
|
||||
|
||||
namespace entry {
|
||||
/*
|
||||
Create a new Entry within the indexed System
|
||||
*/
|
||||
BasicReturnTuple create(size_t sys_index /*,TODO data*/);
|
||||
|
||||
/*
|
||||
Replace the Entry at index
|
||||
*/
|
||||
BasicReturnTuple replace(size_t sys_index, size_t entry_index /*, TODO new*/);
|
||||
|
||||
/*
|
||||
Remove the Entry at index. Succeeding indices within the System are updated upon success
|
||||
*/
|
||||
BasicReturnTuple remove(size_t sys_index, size_t entry_index);
|
||||
|
||||
/*
|
||||
Set lockout status of Entry at index.
|
||||
- '0' for unlocked
|
||||
- '-1' for persistent lock
|
||||
- '>1' lock for duration in seconds
|
||||
*/
|
||||
BasicReturnTuple setLockout(size_t sys_index, size_t entry_index, int duration_seconds);
|
||||
|
||||
/*
|
||||
Move Entry within System from original index to new index. All other indices are updated upon success
|
||||
*/
|
||||
BasicReturnTuple setIndex(size_t sys_index, size_t original_entry_index, size_t new_entry_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace configuration {
|
||||
/*
|
||||
Retrieve the full system configuration
|
||||
*/
|
||||
BasicReturnTuple getFullConfig();
|
||||
|
||||
/*
|
||||
Set the full system configuration. Requires restart
|
||||
*/
|
||||
BasicReturnTuple setConfig(/*TODO*/);
|
||||
|
||||
/*
|
||||
Retrieve general configuration
|
||||
*/
|
||||
BasicReturnTuple getGeneralConfig();
|
||||
|
||||
/*
|
||||
Set the general configuration
|
||||
*/
|
||||
BasicReturnTuple setGeneralConfig(/*TODO*/);
|
||||
|
||||
/*
|
||||
Retrieve configuration for demodulators
|
||||
*/
|
||||
BasicReturnTuple getDemodConfig();
|
||||
|
||||
/*
|
||||
Set the configuration for demodulators. Restart bit required
|
||||
*/
|
||||
BasicReturnTuple setDemodConfig(/*TODO*/);
|
||||
|
||||
/*
|
||||
Retrieve configuration for RTSP server
|
||||
*/
|
||||
BasicReturnTuple getAudioServerConfig();
|
||||
|
||||
/*
|
||||
Set the configuration for RTSP server. Requires restart
|
||||
*/
|
||||
BasicReturnTuple setAudioServerConfig(/*TODO*/);
|
||||
|
||||
/*
|
||||
Retrieve a list of configured tuners
|
||||
*/
|
||||
BasicReturnTuple getTunerList();
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
} // namespace piscan
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
add_library(common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/config_api.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Configuration.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/State.cpp
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
#include "PiScan.h"
|
||||
|
||||
namespace piscan::app::configuration {
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple getFullConfig()
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple setConfig(/*TODO*/)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple getGeneralConfig()
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple setGeneralConfig(/*TODO*/)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple getDemodConfig()
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple setDemodConfig(/*TODO*/)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple getAudioServerConfig()
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple setAudioServerConfig(/*TODO*/)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
BasicReturnTuple getTunerList()
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
add_library(scan
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Entry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/RadioSystem.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SystemList.cpp
|
||||
|
|
|
|||
|
|
@ -0,0 +1,138 @@
|
|||
#include <tuple>
|
||||
|
||||
#include "PiScan.h"
|
||||
|
||||
namespace piscan::app::data
|
||||
{
|
||||
/*
|
||||
Retrieve the entire System tree
|
||||
*/
|
||||
BasicReturnTuple getScanList()
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Retrieve list of Systems and their indices, tags, and types
|
||||
*/
|
||||
BasicReturnTuple getSystemList()
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Retrieve tree of System and its Entries at index
|
||||
*/
|
||||
BasicReturnTuple getSystemByIndex(size_t sys_index)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
} //TODO
|
||||
|
||||
/*
|
||||
Retrieve list of Entries within indexed System and their indices and descriptors
|
||||
*/
|
||||
BasicReturnTuple getEntryList(size_t sys_index)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Retrieve Entry at index
|
||||
*/
|
||||
BasicReturnTuple getEntryByIndex(size_t sys_index, size_t entry_index)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
} //TODO
|
||||
|
||||
namespace system
|
||||
{
|
||||
/*
|
||||
Create a new Radio System
|
||||
*/
|
||||
BasicReturnTuple create(/*TODO data*/)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Replace the Radio System header at index. Entries will be retained unless the system type is changed.
|
||||
*/
|
||||
BasicReturnTuple replace(size_t sys_index /*, TODO new*/)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Remove the Radio System and its Entries at index. Indices of succeeding Systems will be updated upon success
|
||||
*/
|
||||
BasicReturnTuple remove(size_t sys_index)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Set lockout status of System at index.
|
||||
- '0' for unlocked
|
||||
- '-1' for persistent lock
|
||||
- '>1' lock for duration in seconds
|
||||
*/
|
||||
BasicReturnTuple setLockout(size_t sys_index, int duration_seconds)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Move Radio System from original index to new index. All other indices are updated upon success
|
||||
*/
|
||||
BasicReturnTuple setIndex(size_t original_sys_index, size_t new_sys_index)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
namespace entry
|
||||
{
|
||||
/*
|
||||
Create a new Entry within the indexed System
|
||||
*/
|
||||
BasicReturnTuple create(size_t sys_index /*,TODO data*/)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Replace the Entry at index
|
||||
*/
|
||||
BasicReturnTuple replace(size_t sys_index, size_t entry_index /*, TODO new*/)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Remove the Entry at index. Succeeding indices within the System are updated upon success
|
||||
*/
|
||||
BasicReturnTuple remove(size_t sys_index, size_t entry_index)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Set lockout status of Entry at index.
|
||||
- '0' for unlocked
|
||||
- '-1' for persistent lock
|
||||
- '>1' lock for duration in seconds
|
||||
*/
|
||||
BasicReturnTuple setLockout(size_t sys_index, size_t entry_index, int duration_seconds)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
Move Entry within System from original index to new index. All other indices are updated upon success
|
||||
*/
|
||||
BasicReturnTuple setIndex(size_t sys_index, size_t original_entry_index, size_t new_entry_index)
|
||||
{
|
||||
return std::make_tuple(NOT_IMPLEMENTED, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "PiScan.h"
|
||||
#include "DebugServer.h"
|
||||
#include "loguru.hpp"
|
||||
#include "threadname.h"
|
||||
|
|
@ -24,6 +25,7 @@ namespace connection {
|
|||
#define DS_THREAD_NAME "DebugConsole"
|
||||
|
||||
using namespace piscan;
|
||||
using piscan::app::BasicReturnTuple;
|
||||
|
||||
bool DebugConsole::connect(){
|
||||
std::cerr << "\nConnecting...\n";
|
||||
|
|
@ -49,6 +51,37 @@ void DebugConsole::_consoleInputFunc() {
|
|||
std::string intermediate;
|
||||
std::cerr << "\nConsole connected\n";
|
||||
|
||||
std::map<app::ReturnStatus, std::string> friendlyReturnCodes;
|
||||
friendlyReturnCodes[app::SUCCESS] = "Success";
|
||||
friendlyReturnCodes[app::INVALID] = "Invalid parameters";
|
||||
friendlyReturnCodes[app::NOT_IMPLEMENTED] = "Function not yet implemented";
|
||||
|
||||
std::map<std::string, std::function<piscan::app::BasicReturnTuple()>> apiMap;
|
||||
apiMap["scanlist"] = []() { return app::data::getScanList(); };
|
||||
apiMap["systems"] = []() { return app::data::getSystemList(); };
|
||||
apiMap["systemat"] = [tokens]() { return app::data::getSystemByIndex(std::stoi(tokens[1])); };
|
||||
apiMap["entrylist"] = [tokens]() { return app::data::getEntryList(std::stoi(tokens[1])); };
|
||||
apiMap["entryat"] = [tokens]() { return app::data::getEntryByIndex(std::stoi(tokens[1]), std::stoi(tokens[2])); };
|
||||
apiMap["createsystem"] = [tokens]() { return app::data::system::create(/*TODO*/); };
|
||||
apiMap["replacesystem"] = [tokens]() { return app::data::system::replace(std::stoi(tokens[1])/*, TODO*/); };
|
||||
apiMap["removesystem"] = [tokens]() { return app::data::system::remove(std::stoi(tokens[1])); };
|
||||
apiMap["locksystem"] = [tokens]() { return app::data::system::setLockout(std::stoi(tokens[1]), std::stoi(tokens[2])); };
|
||||
apiMap["setsystemindex"] = [tokens]() { return app::data::system::setIndex(std::stoi(tokens[1]), std::stoi(tokens[2])); };
|
||||
apiMap["createentry"] = [tokens]() { return app::data::system::entry::create(std::stoi(tokens[1])/*,TODO*/); };
|
||||
apiMap["replaceentry"] = [tokens]() { return app::data::system::entry::replace(std::stoi(tokens[1]), std::stoi(tokens[2])/*, TODO*/); };
|
||||
apiMap["removeentry"] = [tokens]() { return app::data::system::entry::remove(std::stoi(tokens[1]), std::stoi(tokens[2])); };
|
||||
apiMap["lockentry"] = [tokens]() { return app::data::system::entry::setLockout(std::stoi(tokens[1]), std::stoi(tokens[2]), std::stoi(tokens[3])); };
|
||||
apiMap["setentryindex"] = [tokens]() { return app::data::system::entry::setIndex(std::stoi(tokens[1]), std::stoi(tokens[2]), std::stoi(tokens[3])); };
|
||||
apiMap["config"] = []() { return app::configuration::getFullConfig(); };
|
||||
apiMap["setconfig"] = [tokens]() { return app::configuration::setConfig(); };
|
||||
apiMap["generalcfg"] = []() { return app::configuration::getGeneralConfig(); };
|
||||
apiMap["setgeneralcfg"] = [tokens]() { return app::configuration::setGeneralConfig(); };
|
||||
apiMap["demodcfg"] = []() { return app::configuration::getDemodConfig(); };
|
||||
apiMap["setdemodcfg"] = [tokens]() { return app::configuration::setDemodConfig(); };
|
||||
apiMap["rtspcfg"] = []() { return app::configuration::getAudioServerConfig(); };
|
||||
apiMap["setrtspcfg"] = [tokens]() { return app::configuration::setAudioServerConfig(); };
|
||||
apiMap["tunerlist"] = []() { return app::configuration::getTunerList(); };
|
||||
|
||||
getSystemInfo();
|
||||
getScannerContext();
|
||||
getDemodContext();
|
||||
|
|
@ -122,8 +155,16 @@ void DebugConsole::_consoleInputFunc() {
|
|||
<< "\n\tget [subcommand]"
|
||||
<< "\n\t\tcontext\t\tReturns scanner status"
|
||||
<< "\n";
|
||||
for (auto cmd = apiMap.begin(); cmd != apiMap.end(); cmd++) {
|
||||
std::cerr << "\t" << cmd->first << "\n";
|
||||
}
|
||||
} else
|
||||
try {
|
||||
auto ret = apiMap[tokens[0]]();
|
||||
std::cerr << "Status: " << friendlyReturnCodes[std::get<0>(ret)] << "\n";
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "Invalid command\n";
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "Argument missing or typo in the command\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue