Cleanup for release

This commit is contained in:
2026-03-31 23:09:11 -04:00
parent 5bcd57a5c4
commit 78bc3b4b33
34 changed files with 2263 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "libcontrol.h"
#include "rpc/RemoteDebugging.h"
#include "tabs/InformationTab.h"
#include "tabs/LoggingTab.h"
#include "tabs/FirmwareUpdateTab.h"
#include "tabs/TaskManagerTab.h"
#include "tabs/ConfigurationTab.h"
#include "tabs/CoredumpTab.h"
#include <ftxui/component/component.hpp>
using namespace ftxui;
class DeviceDetailsApp {
public:
DeviceDetailsApp(std::shared_ptr<RobotController> robot_controller, uint8_t device_id);
void run();
private:
std::shared_ptr<RobotController> robot_controller_;
std::shared_ptr<RemoteDebugging> remote_debugging_;
uint8_t device_id_;
int selected_tab_ = 0;
Component main_component_;
// Tab instances
std::unique_ptr<InformationTab> information_tab_;
std::unique_ptr<LoggingTab> logging_tab_;
std::unique_ptr<FirmwareUpdateTab> firmware_update_tab_;
std::unique_ptr<TaskManagerTab> task_manager_tab_;
std::unique_ptr<ConfigurationTab> configuration_tab_;
std::unique_ptr<CoredumpTab> coredump_tab_;
// Tab names
std::vector<std::string> tab_names_ = {"Information", "Logging", "Firmware Update", "TaskManager", "Configuration", "Core Dump"};
void setupUI();
};

31
include/DeviceListApp.h Normal file
View File

@@ -0,0 +1,31 @@
#pragma once
#include <chrono>
#include <memory>
#include <string>
#include <vector>
#include <unordered_set>
#include "libcontrol.h"
#include <ftxui/component/component.hpp>
using namespace ftxui;
class DeviceDetailsApp;
class DeviceListApp {
public:
DeviceListApp();
void run();
private:
std::shared_ptr<RobotController> robot_controller_;
std::vector<uint8_t> device_ids_;
std::vector<std::string> device_list_entries_;
int selected_device_ = 0;
Component main_component_;
void refreshDevices();
void setupUI();
void openDeviceDetails();
};

View File

View File

@@ -0,0 +1,27 @@
#ifndef OTAPACKETBUILDER_H
#define OTAPACKETBUILDER_H
#include <vector>
#include "flatbuffers/SerializedMessage.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers_generated/OTAPacket_generated.h"
namespace Flatbuffers {
class OTAPacketBuilder{
public:
OTAPacketBuilder() : builder_(1024) {}
SerializedMessage build_ota_packet(uint16_t packet_num, const std::vector<uint8_t> &packet);
static const Messaging::OTAPacket *parse_ota_packet(const uint8_t *buffer);
private:
flatbuffers::FlatBufferBuilder builder_;
};
} // namespace Flatbuffers
#endif // OTAPACKETBUILDER_H

View File

@@ -0,0 +1,15 @@
//
// Created by Johnathon Slightham on 2025-07-05.
//
#ifndef SERIALIZEDMESSAGE_H
#define SERIALIZEDMESSAGE_H
namespace Flatbuffers {
struct SerializedMessage {
void *data;
size_t size;
};
} // namespace Flatbuffers
#endif // SERIALIZEDMESSAGE_H

View File

@@ -0,0 +1,128 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_OTAPACKET_MESSAGING_H_
#define FLATBUFFERS_GENERATED_OTAPACKET_MESSAGING_H_
#include "flatbuffers/flatbuffers.h"
// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
// static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
// FLATBUFFERS_VERSION_MINOR == 2 &&
// FLATBUFFERS_VERSION_REVISION == 10,
// "Non-compatible flatbuffers version included");
namespace Messaging {
struct OTAPacket;
struct OTAPacketBuilder;
struct OTAPacket FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
typedef OTAPacketBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_SEQUENCE_NUMBER = 4,
VT_LENGTH = 6,
VT_PAYLOAD = 8
};
uint16_t sequence_number() const {
return GetField<uint16_t>(VT_SEQUENCE_NUMBER, 0);
}
uint16_t length() const {
return GetField<uint16_t>(VT_LENGTH, 0);
}
const ::flatbuffers::Vector<uint8_t> *payload() const {
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_PAYLOAD);
}
bool Verify(::flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<uint16_t>(verifier, VT_SEQUENCE_NUMBER, 2) &&
VerifyField<uint16_t>(verifier, VT_LENGTH, 2) &&
VerifyOffset(verifier, VT_PAYLOAD) &&
verifier.VerifyVector(payload()) &&
verifier.EndTable();
}
};
struct OTAPacketBuilder {
typedef OTAPacket Table;
::flatbuffers::FlatBufferBuilder &fbb_;
::flatbuffers::uoffset_t start_;
void add_sequence_number(uint16_t sequence_number) {
fbb_.AddElement<uint16_t>(OTAPacket::VT_SEQUENCE_NUMBER, sequence_number, 0);
}
void add_length(uint16_t length) {
fbb_.AddElement<uint16_t>(OTAPacket::VT_LENGTH, length, 0);
}
void add_payload(::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> payload) {
fbb_.AddOffset(OTAPacket::VT_PAYLOAD, payload);
}
explicit OTAPacketBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
::flatbuffers::Offset<OTAPacket> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = ::flatbuffers::Offset<OTAPacket>(end);
return o;
}
};
inline ::flatbuffers::Offset<OTAPacket> CreateOTAPacket(
::flatbuffers::FlatBufferBuilder &_fbb,
uint16_t sequence_number = 0,
uint16_t length = 0,
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> payload = 0) {
OTAPacketBuilder builder_(_fbb);
builder_.add_payload(payload);
builder_.add_length(length);
builder_.add_sequence_number(sequence_number);
return builder_.Finish();
}
inline ::flatbuffers::Offset<OTAPacket> CreateOTAPacketDirect(
::flatbuffers::FlatBufferBuilder &_fbb,
uint16_t sequence_number = 0,
uint16_t length = 0,
const std::vector<uint8_t> *payload = nullptr) {
auto payload__ = payload ? _fbb.CreateVector<uint8_t>(*payload) : 0;
return Messaging::CreateOTAPacket(
_fbb,
sequence_number,
length,
payload__);
}
inline const Messaging::OTAPacket *GetOTAPacket(const void *buf) {
return ::flatbuffers::GetRoot<Messaging::OTAPacket>(buf);
}
inline const Messaging::OTAPacket *GetSizePrefixedOTAPacket(const void *buf) {
return ::flatbuffers::GetSizePrefixedRoot<Messaging::OTAPacket>(buf);
}
inline bool VerifyOTAPacketBuffer(
::flatbuffers::Verifier &verifier) {
return verifier.VerifyBuffer<Messaging::OTAPacket>(nullptr);
}
inline bool VerifySizePrefixedOTAPacketBuffer(
::flatbuffers::Verifier &verifier) {
return verifier.VerifySizePrefixedBuffer<Messaging::OTAPacket>(nullptr);
}
inline void FinishOTAPacketBuffer(
::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<Messaging::OTAPacket> root) {
fbb.Finish(root);
}
inline void FinishSizePrefixedOTAPacketBuffer(
::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<Messaging::OTAPacket> root) {
fbb.FinishSizePrefixed(root);
}
} // namespace Messaging
#endif // FLATBUFFERS_GENERATED_OTAPACKET_MESSAGING_H_

View File

@@ -0,0 +1,350 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_ROBOTMODULE_H_
#define FLATBUFFERS_GENERATED_ROBOTMODULE_H_
#include "flatbuffers/flatbuffers.h"
// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
// static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
// FLATBUFFERS_VERSION_MINOR == 2 &&
// FLATBUFFERS_VERSION_REVISION == 10,
// "Non-compatible flatbuffers version included");
struct MotorState;
struct MotorStateBuilder;
struct RobotModule;
struct RobotModuleBuilder;
enum ModuleType : int8_t {
ModuleType_SPLITTER = 0,
ModuleType_SERVO_1 = 1,
ModuleType_DC_MOTOR = 2,
ModuleType_BATTERY = 3,
ModuleType_SERVO_2 = 4,
ModuleType_DISPLAY = 5,
ModuleType_GRIPPER = 6,
ModuleType_SPEAKER = 7,
ModuleType_IMU = 8,
ModuleType_DISTANCE_SENSOR = 9,
ModuleType_SPLITTER_2 = 10,
ModuleType_SPLITTER_3 = 11,
ModuleType_SPLITTER_4 = 12,
ModuleType_SPLITTER_5 = 13,
ModuleType_SPLITTER_6 = 14,
ModuleType_SPLITTER_7 = 15,
ModuleType_SPLITTER_8 = 16,
ModuleType_MIN = ModuleType_SPLITTER,
ModuleType_MAX = ModuleType_SPLITTER_8
};
inline const ModuleType (&EnumValuesModuleType())[17] {
static const ModuleType values[] = {
ModuleType_SPLITTER,
ModuleType_SERVO_1,
ModuleType_DC_MOTOR,
ModuleType_BATTERY,
ModuleType_SERVO_2,
ModuleType_DISPLAY,
ModuleType_GRIPPER,
ModuleType_SPEAKER,
ModuleType_IMU,
ModuleType_DISTANCE_SENSOR,
ModuleType_SPLITTER_2,
ModuleType_SPLITTER_3,
ModuleType_SPLITTER_4,
ModuleType_SPLITTER_5,
ModuleType_SPLITTER_6,
ModuleType_SPLITTER_7,
ModuleType_SPLITTER_8
};
return values;
}
inline const char * const *EnumNamesModuleType() {
static const char * const names[18] = {
"SPLITTER",
"SERVO_1",
"DC_MOTOR",
"BATTERY",
"SERVO_2",
"DISPLAY",
"GRIPPER",
"SPEAKER",
"IMU",
"DISTANCE_SENSOR",
"SPLITTER_2",
"SPLITTER_3",
"SPLITTER_4",
"SPLITTER_5",
"SPLITTER_6",
"SPLITTER_7",
"SPLITTER_8",
nullptr
};
return names;
}
inline const char *EnumNameModuleType(ModuleType e) {
if (::flatbuffers::IsOutRange(e, ModuleType_SPLITTER, ModuleType_SPLITTER_8)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesModuleType()[index];
}
enum Orientation : int8_t {
Orientation_Deg0 = 0,
Orientation_Deg90 = 1,
Orientation_Deg180 = 2,
Orientation_Deg270 = 3,
Orientation_MIN = Orientation_Deg0,
Orientation_MAX = Orientation_Deg270
};
inline const Orientation (&EnumValuesOrientation())[4] {
static const Orientation values[] = {
Orientation_Deg0,
Orientation_Deg90,
Orientation_Deg180,
Orientation_Deg270
};
return values;
}
inline const char * const *EnumNamesOrientation() {
static const char * const names[5] = {
"Deg0",
"Deg90",
"Deg180",
"Deg270",
nullptr
};
return names;
}
inline const char *EnumNameOrientation(Orientation e) {
if (::flatbuffers::IsOutRange(e, Orientation_Deg0, Orientation_Deg270)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesOrientation()[index];
}
enum ModuleState : uint8_t {
ModuleState_NONE = 0,
ModuleState_MotorState = 1,
ModuleState_MIN = ModuleState_NONE,
ModuleState_MAX = ModuleState_MotorState
};
inline const ModuleState (&EnumValuesModuleState())[2] {
static const ModuleState values[] = {
ModuleState_NONE,
ModuleState_MotorState
};
return values;
}
inline const char * const *EnumNamesModuleState() {
static const char * const names[3] = {
"NONE",
"MotorState",
nullptr
};
return names;
}
inline const char *EnumNameModuleState(ModuleState e) {
if (::flatbuffers::IsOutRange(e, ModuleState_NONE, ModuleState_MotorState)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesModuleState()[index];
}
template<typename T> struct ModuleStateTraits {
static const ModuleState enum_value = ModuleState_NONE;
};
template<> struct ModuleStateTraits<MotorState> {
static const ModuleState enum_value = ModuleState_MotorState;
};
bool VerifyModuleState(::flatbuffers::Verifier &verifier, const void *obj, ModuleState type);
bool VerifyModuleStateVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<uint8_t> *types);
struct MotorState FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
typedef MotorStateBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_ANGLE = 4
};
int32_t angle() const {
return GetField<int32_t>(VT_ANGLE, 0);
}
bool Verify(::flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<int32_t>(verifier, VT_ANGLE, 4) &&
verifier.EndTable();
}
};
struct MotorStateBuilder {
typedef MotorState Table;
::flatbuffers::FlatBufferBuilder &fbb_;
::flatbuffers::uoffset_t start_;
void add_angle(int32_t angle) {
fbb_.AddElement<int32_t>(MotorState::VT_ANGLE, angle, 0);
}
explicit MotorStateBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
::flatbuffers::Offset<MotorState> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = ::flatbuffers::Offset<MotorState>(end);
return o;
}
};
inline ::flatbuffers::Offset<MotorState> CreateMotorState(
::flatbuffers::FlatBufferBuilder &_fbb,
int32_t angle = 0) {
MotorStateBuilder builder_(_fbb);
builder_.add_angle(angle);
return builder_.Finish();
}
struct RobotModule FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
typedef RobotModuleBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_ID = 4,
VT_MODULE_TYPE = 6,
VT_CONFIGURATION_TYPE = 8,
VT_CONFIGURATION = 10
};
uint8_t id() const {
return GetField<uint8_t>(VT_ID, 0);
}
ModuleType module_type() const {
return static_cast<ModuleType>(GetField<int8_t>(VT_MODULE_TYPE, 0));
}
ModuleState configuration_type() const {
return static_cast<ModuleState>(GetField<uint8_t>(VT_CONFIGURATION_TYPE, 0));
}
const void *configuration() const {
return GetPointer<const void *>(VT_CONFIGURATION);
}
template<typename T> const T *configuration_as() const;
const MotorState *configuration_as_MotorState() const {
return configuration_type() == ModuleState_MotorState ? static_cast<const MotorState *>(configuration()) : nullptr;
}
bool Verify(::flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<uint8_t>(verifier, VT_ID, 1) &&
VerifyField<int8_t>(verifier, VT_MODULE_TYPE, 1) &&
VerifyField<uint8_t>(verifier, VT_CONFIGURATION_TYPE, 1) &&
VerifyOffset(verifier, VT_CONFIGURATION) &&
VerifyModuleState(verifier, configuration(), configuration_type()) &&
verifier.EndTable();
}
};
template<> inline const MotorState *RobotModule::configuration_as<MotorState>() const {
return configuration_as_MotorState();
}
struct RobotModuleBuilder {
typedef RobotModule Table;
::flatbuffers::FlatBufferBuilder &fbb_;
::flatbuffers::uoffset_t start_;
void add_id(uint8_t id) {
fbb_.AddElement<uint8_t>(RobotModule::VT_ID, id, 0);
}
void add_module_type(ModuleType module_type) {
fbb_.AddElement<int8_t>(RobotModule::VT_MODULE_TYPE, static_cast<int8_t>(module_type), 0);
}
void add_configuration_type(ModuleState configuration_type) {
fbb_.AddElement<uint8_t>(RobotModule::VT_CONFIGURATION_TYPE, static_cast<uint8_t>(configuration_type), 0);
}
void add_configuration(::flatbuffers::Offset<void> configuration) {
fbb_.AddOffset(RobotModule::VT_CONFIGURATION, configuration);
}
explicit RobotModuleBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
::flatbuffers::Offset<RobotModule> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = ::flatbuffers::Offset<RobotModule>(end);
return o;
}
};
inline ::flatbuffers::Offset<RobotModule> CreateRobotModule(
::flatbuffers::FlatBufferBuilder &_fbb,
uint8_t id = 0,
ModuleType module_type = ModuleType_SPLITTER,
ModuleState configuration_type = ModuleState_NONE,
::flatbuffers::Offset<void> configuration = 0) {
RobotModuleBuilder builder_(_fbb);
builder_.add_configuration(configuration);
builder_.add_configuration_type(configuration_type);
builder_.add_module_type(module_type);
builder_.add_id(id);
return builder_.Finish();
}
inline bool VerifyModuleState(::flatbuffers::Verifier &verifier, const void *obj, ModuleState type) {
switch (type) {
case ModuleState_NONE: {
return true;
}
case ModuleState_MotorState: {
auto ptr = reinterpret_cast<const MotorState *>(obj);
return verifier.VerifyTable(ptr);
}
default: return true;
}
}
inline bool VerifyModuleStateVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<uint8_t> *types) {
if (!values || !types) return !values && !types;
if (values->size() != types->size()) return false;
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
if (!VerifyModuleState(
verifier, values->Get(i), types->GetEnum<ModuleState>(i))) {
return false;
}
}
return true;
}
inline const RobotModule *GetRobotModule(const void *buf) {
return ::flatbuffers::GetRoot<RobotModule>(buf);
}
inline const RobotModule *GetSizePrefixedRobotModule(const void *buf) {
return ::flatbuffers::GetSizePrefixedRoot<RobotModule>(buf);
}
inline bool VerifyRobotModuleBuffer(
::flatbuffers::Verifier &verifier) {
return verifier.VerifyBuffer<RobotModule>(nullptr);
}
inline bool VerifySizePrefixedRobotModuleBuffer(
::flatbuffers::Verifier &verifier) {
return verifier.VerifySizePrefixedBuffer<RobotModule>(nullptr);
}
inline void FinishRobotModuleBuffer(
::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<RobotModule> root) {
fbb.Finish(root);
}
inline void FinishSizePrefixedRobotModuleBuffer(
::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<RobotModule> root) {
fbb.FinishSizePrefixed(root);
}
#endif // FLATBUFFERS_GENERATED_ROBOTMODULE_H_

View File

@@ -0,0 +1,28 @@
//
// Created by Johnathon Slightham on 2026-02-16.
//
#ifndef NEW_DEV_TOOLS_REMOTECONFIG_H
#define NEW_DEV_TOOLS_REMOTECONFIG_H
#include <cstdint>
#include <string>
#include "libcontrol.h"
#include "flatbuffers_generated/RobotModule_generated.h"
class RemoteConfig {
public:
RemoteConfig(std::shared_ptr<RobotController> controller) : m_robot_controller(controller) {}
bool set_module_id(uint8_t current_module_id, uint16_t new_module_id);
bool set_module_type(uint8_t module_id, ModuleType module_type);
bool set_wifi_ssid(uint8_t module_id, const std::string& ssid);
bool set_wifi_password(uint8_t module_id, const std::string& password);
bool set_communication_method(uint8_t module_id, uint8_t communication_method); // only option is 0 (wireless)
void restart(uint8_t module_id);
private:
std::shared_ptr<RobotController> m_robot_controller;
};
#endif //NEW_DEV_TOOLS_REMOTECONFIG_H

View File

@@ -0,0 +1,24 @@
//
// Created by Johnathon Slightham on 2026-02-16.
//
#ifndef NEW_DEV_TOOLS_REMOTEDEBUGGING_H
#define NEW_DEV_TOOLS_REMOTEDEBUGGING_H
#include <cstdint>
#include <string>
#include "libcontrol.h"
class RemoteDebugging {
public:
RemoteDebugging(std::shared_ptr<RobotController> controller) : m_robot_controller(controller) {}
std::string get_task_manager(uint8_t module_id);
std::string get_logs(uint8_t module_id);
std::string get_coredump(uint8_t module_id);
private:
std::shared_ptr<RobotController> m_robot_controller;
};
#endif //NEW_DEV_TOOLS_REMOTEDEBUGGING_H

View File

@@ -0,0 +1,40 @@
//
// Created by Johnathon Slightham on 2026-02-16.
//
#ifndef REMOTEMANAGEMENT_H
#define REMOTEMANAGEMENT_H
#include <cstdint>
#include <fstream>
#include <memory>
#include "flatbuffers/OTAPacketBuilder.h"
#include "libcontrol.h"
class RemoteManagement {
public:
RemoteManagement(uint8_t module_id, const std::string &path,
std::shared_ptr<RobotController> controller)
: m_module_id(module_id), m_file(path, std::ios::binary),
m_builder(std::make_unique<Flatbuffers::OTAPacketBuilder>()),
m_robot_controller(controller) {
}
bool perform_ota();
double ota_progress(); // 0 to 1 representing % progress.
void restart();
private:
bool start_ota();
bool write_ota(std::vector<uint8_t> &transmit_buffer);
bool ota_end();
uint16_t m_sequence_num = 0;
uint16_t m_total_packets = 0;
uint8_t m_module_id;
std::ifstream m_file;
std::unique_ptr<Flatbuffers::OTAPacketBuilder> m_builder;
std::shared_ptr<RobotController> m_robot_controller;
};
#endif // REMOTEMANAGEMENT_H

View File

@@ -0,0 +1,78 @@
#pragma once
#include <memory>
#include <string>
#include "libcontrol.h"
#include "rpc/RemoteConfig.h"
#include <ftxui/component/component.hpp>
using namespace ftxui;
class ConfigurationTab {
public:
ConfigurationTab(std::shared_ptr<RobotController> robot_controller, uint8_t device_id);
Component createComponent();
private:
std::shared_ptr<RobotController> robot_controller_;
std::shared_ptr<RemoteConfig> remote_config_;
uint8_t device_id_;
// Input fields
std::string module_id_input_;
int selected_module_type_ = 0;
std::string wifi_ssid_input_;
std::string wifi_password_input_;
int selected_communication_method_ = 0;
// Status messages
std::string module_id_status_;
std::string module_type_status_;
std::string wifi_ssid_status_;
std::string wifi_password_status_;
std::string communication_method_status_;
std::string restart_status_;
// Component members
Component module_id_input_component_;
Component module_id_button_;
Component module_type_dropdown_;
Component module_type_button_;
Component wifi_ssid_input_component_;
Component wifi_ssid_button_;
Component wifi_password_input_component_;
Component wifi_password_button_;
Component comm_method_dropdown_;
Component comm_method_button_;
Component restart_button_;
// Module type options
std::vector<std::string> module_type_options_ = {
"SPLITTER",
"SERVO_1",
"DC_MOTOR",
"BATTERY",
"SERVO_2",
"DISPLAY",
"GRIPPER",
"SPEAKER",
"IMU",
"DISTANCE_SENSOR",
"SPLITTER_2",
"SPLITTER_3",
"SPLITTER_4"
};
std::vector<std::string> communication_method_options_ = {
"Wireless"
};
// Helper methods
void setModuleId();
void setModuleType();
void setWiFiSSID();
void setWiFiPassword();
void setCommunicationMethod();
void restartDevice();
std::string getModuleTypeString(ModuleType type);
};

View File

@@ -0,0 +1,32 @@
#pragma once
#include <memory>
#include <string>
#include <chrono>
#include <atomic>
#include "libcontrol.h"
#include "rpc/RemoteDebugging.h"
#include <ftxui/component/component.hpp>
using namespace ftxui;
class CoredumpTab {
public:
CoredumpTab(std::shared_ptr<RemoteDebugging> remote_debugging, uint8_t device_id);
Component createComponent();
private:
std::shared_ptr<RemoteDebugging> remote_debugging_;
uint8_t device_id_;
// Caching for coredump data to avoid frequent RPC calls
mutable std::string cached_coredump_;
mutable std::chrono::time_point<std::chrono::system_clock> coredump_last_updated_;
mutable std::atomic<bool> coredump_loading_{false};
mutable bool coredump_initial_load_done_{false};
static constexpr std::chrono::seconds cache_duration_{10}; // 10 seconds
std::string getCachedCoredump() const;
std::string sanitizeData(const std::string& raw_data);
std::vector<std::string> splitLines(const std::string& data);
};

View File

@@ -0,0 +1,28 @@
#pragma once
#include <memory>
#include <string>
#include <atomic>
#include "libcontrol.h"
#include "rpc/RemoteManagement.h"
#include <ftxui/component/component.hpp>
using namespace ftxui;
class FirmwareUpdateTab {
public:
FirmwareUpdateTab(std::shared_ptr<RobotController> robot_controller, uint8_t device_id);
Component createComponent();
private:
std::shared_ptr<RobotController> robot_controller_;
std::shared_ptr<RemoteManagement> remote_management_;
uint8_t device_id_;
// Firmware update state
std::string firmware_file_path_;
bool update_in_progress_ = false;
int progress_ = 0;
std::string update_status_message_;
bool update_success_ = false;
};

View File

@@ -0,0 +1,23 @@
#pragma once
#include <memory>
#include <string>
#include <chrono>
#include "libcontrol.h"
#include <ftxui/component/component.hpp>
using namespace ftxui;
class InformationTab {
public:
InformationTab(std::shared_ptr<RobotController> robot_controller, uint8_t device_id);
Component createComponent();
private:
std::shared_ptr<RobotController> robot_controller_;
uint8_t device_id_;
std::string getModuleTypeString(ModuleType type);
std::string getConnectionTypeString(Messaging::ConnectionType type);
std::string formatTimeSince(const std::chrono::time_point<std::chrono::system_clock>& time_point);
};

32
include/tabs/LoggingTab.h Normal file
View File

@@ -0,0 +1,32 @@
#pragma once
#include <memory>
#include <string>
#include <chrono>
#include <atomic>
#include "libcontrol.h"
#include "rpc/RemoteDebugging.h"
#include <ftxui/component/component.hpp>
using namespace ftxui;
class LoggingTab {
public:
LoggingTab(std::shared_ptr<RemoteDebugging> remote_debugging, uint8_t device_id);
Component createComponent();
private:
std::shared_ptr<RemoteDebugging> remote_debugging_;
uint8_t device_id_;
// Caching for RemoteDebugging data to avoid frequent RPC calls
mutable std::string cached_logs_;
mutable std::chrono::time_point<std::chrono::system_clock> logs_last_updated_;
mutable std::atomic<bool> logs_loading_{false};
mutable bool logs_initial_load_done_{false};
static constexpr std::chrono::seconds cache_duration_{4}; // 4 seconds
std::string getCachedLogs() const;
std::string sanitizeLogData(const std::string& raw_data);
std::vector<std::string> splitLogLines(const std::string& log_data);
};

View File

@@ -0,0 +1,30 @@
#pragma once
#include <memory>
#include <string>
#include <chrono>
#include <atomic>
#include "libcontrol.h"
#include "rpc/RemoteDebugging.h"
#include <ftxui/component/component.hpp>
using namespace ftxui;
class TaskManagerTab {
public:
TaskManagerTab(std::shared_ptr<RemoteDebugging> remote_debugging, uint8_t device_id);
Component createComponent();
private:
std::shared_ptr<RemoteDebugging> remote_debugging_;
uint8_t device_id_;
// Caching for RemoteDebugging data to avoid frequent RPC calls
mutable std::string cached_task_data_;
mutable std::chrono::time_point<std::chrono::system_clock> task_data_last_updated_;
mutable std::atomic<bool> task_data_loading_{false};
mutable bool task_data_initial_load_done_{false};
static constexpr std::chrono::seconds cache_duration_{4}; // 4 seconds
std::string getCachedTaskData() const;
};