From ba67025db56d05881149f0d7556ffb5989a0cbce Mon Sep 17 00:00:00 2001 From: Georgii Surkov <37121527+gsurkov@users.noreply.github.com> Date: Thu, 8 Dec 2022 15:31:11 +0300 Subject: [PATCH] Property API (#139) * Update protobuf definitions * Add property messages to flipperproto0 and interface * Add ProtobufVersion messages to flipperproto0 and interface * Add ProtobufVersionOperation to backend rpc * Add ProtobufVersion to MainResponse * Improve protobuf version checking, make it unsigned * Add device info via new PropertyGet API --- backend/backend.pro | 4 + backend/flipperzero/deviceinfo.h | 4 +- .../flipperzero/helper/deviceinfohelper.cpp | 94 ++++++++++++++++++- backend/flipperzero/helper/deviceinfohelper.h | 4 + backend/flipperzero/protobufsession.cpp | 21 ++++- backend/flipperzero/protobufsession.h | 15 ++- .../flipperzero/rpc/propertygetoperation.cpp | 40 ++++++++ .../flipperzero/rpc/propertygetoperation.h | 31 ++++++ .../rpc/systemprotobufversionoperation.cpp | 45 +++++++++ .../rpc/systemprotobufversionoperation.h | 32 +++++++ plugins/flipperproto0/flipperproto0.pro | 6 ++ plugins/flipperproto0/mainresponse.cpp | 6 ++ .../flipperproto0/messages/application.pb.c | 9 ++ .../flipperproto0/messages/application.pb.h | 47 ++++++++++ plugins/flipperproto0/messages/flipper.pb.h | 37 +++++++- plugins/flipperproto0/messages/property.pb.c | 15 +++ plugins/flipperproto0/messages/property.pb.h | 65 +++++++++++++ plugins/flipperproto0/messages/storage.pb.c | 6 ++ plugins/flipperproto0/messages/storage.pb.h | 30 ++++++ plugins/flipperproto0/propertyrequest.cpp | 9 ++ plugins/flipperproto0/propertyrequest.h | 12 +++ plugins/flipperproto0/propertyresponse.cpp | 15 +++ plugins/flipperproto0/propertyresponse.h | 16 ++++ plugins/flipperproto0/protobufplugin.cpp | 15 ++- plugins/flipperproto0/protobufplugin.h | 9 +- plugins/flipperproto0/systemrequest.cpp | 4 + plugins/flipperproto0/systemrequest.h | 6 ++ plugins/flipperproto0/systemresponse.cpp | 14 +++ plugins/flipperproto0/systemresponse.h | 11 +++ .../protobufinterface/mainresponseinterface.h | 3 + .../propertyresponseinterface.h | 15 +++ .../protobufinterface/protobufinterface.pro | 1 + .../protobufplugininterface.h | 7 +- .../systemresponseinterface.h | 8 ++ 34 files changed, 629 insertions(+), 27 deletions(-) create mode 100644 backend/flipperzero/rpc/propertygetoperation.cpp create mode 100644 backend/flipperzero/rpc/propertygetoperation.h create mode 100644 backend/flipperzero/rpc/systemprotobufversionoperation.cpp create mode 100644 backend/flipperzero/rpc/systemprotobufversionoperation.h create mode 100644 plugins/flipperproto0/messages/property.pb.c create mode 100644 plugins/flipperproto0/messages/property.pb.h create mode 100644 plugins/flipperproto0/propertyrequest.cpp create mode 100644 plugins/flipperproto0/propertyrequest.h create mode 100644 plugins/flipperproto0/propertyresponse.cpp create mode 100644 plugins/flipperproto0/propertyresponse.h create mode 100644 plugins/protobufinterface/propertyresponseinterface.h diff --git a/backend/backend.pro b/backend/backend.pro index 9b19a181..53d31afd 100644 --- a/backend/backend.pro +++ b/backend/backend.pro @@ -30,6 +30,7 @@ SOURCES += \ flipperzero/rpc/guistartvirtualdisplayoperation.cpp \ flipperzero/rpc/guistopscreenstreamoperation.cpp \ flipperzero/rpc/guistopvirtualdisplayoperation.cpp \ + flipperzero/rpc/propertygetoperation.cpp \ flipperzero/rpc/startrpcoperation.cpp \ flipperzero/rpc/stoprpcoperation.cpp \ flipperzero/rpc/storageinfooperation.cpp \ @@ -43,6 +44,7 @@ SOURCES += \ flipperzero/rpc/systemdeviceinfooperation.cpp \ flipperzero/rpc/systemfactoryresetoperation.cpp \ flipperzero/rpc/systemgetdatetimeoperation.cpp \ + flipperzero/rpc/systemprotobufversionoperation.cpp \ flipperzero/rpc/systemrebootoperation.cpp \ flipperzero/rpc/systemsetdatetimeoperation.cpp \ flipperzero/rpc/skipmotdoperation.cpp \ @@ -138,6 +140,7 @@ HEADERS += \ flipperzero/rpc/guistartvirtualdisplayoperation.h \ flipperzero/rpc/guistopscreenstreamoperation.h \ flipperzero/rpc/guistopvirtualdisplayoperation.h \ + flipperzero/rpc/propertygetoperation.h \ flipperzero/rpc/startrpcoperation.h \ flipperzero/rpc/stoprpcoperation.h \ flipperzero/rpc/storageinfooperation.h \ @@ -151,6 +154,7 @@ HEADERS += \ flipperzero/rpc/systemdeviceinfooperation.h \ flipperzero/rpc/systemfactoryresetoperation.h \ flipperzero/rpc/systemgetdatetimeoperation.h \ + flipperzero/rpc/systemprotobufversionoperation.h \ flipperzero/rpc/systemrebootoperation.h \ flipperzero/rpc/systemsetdatetimeoperation.h \ flipperzero/rpc/skipmotdoperation.h \ diff --git a/backend/flipperzero/deviceinfo.h b/backend/flipperzero/deviceinfo.h index ab74bb8f..deaa18b1 100644 --- a/backend/flipperzero/deviceinfo.h +++ b/backend/flipperzero/deviceinfo.h @@ -71,8 +71,8 @@ struct StorageInfo { struct ProtobufInfo { public: - int versionMajor; - int versionMinor; + uint32_t versionMajor; + uint32_t versionMinor; }; struct DeviceInfo { diff --git a/backend/flipperzero/helper/deviceinfohelper.cpp b/backend/flipperzero/helper/deviceinfohelper.cpp index 58931594..d16011bc 100644 --- a/backend/flipperzero/helper/deviceinfohelper.cpp +++ b/backend/flipperzero/helper/deviceinfohelper.cpp @@ -14,9 +14,11 @@ #include "flipperzero/rpc/stoprpcoperation.h" #include "flipperzero/rpc/storageinfooperation.h" #include "flipperzero/rpc/storagestatoperation.h" +#include "flipperzero/rpc/propertygetoperation.h" #include "flipperzero/rpc/systemdeviceinfooperation.h" #include "flipperzero/rpc/systemgetdatetimeoperation.h" #include "flipperzero/rpc/systemsetdatetimeoperation.h" +#include "flipperzero/rpc/systemprotobufversionoperation.h" #include "device/stm32wb55.h" #include "serialfinder.h" @@ -70,6 +72,10 @@ void VCPDeviceInfoHelper::nextStateLogic() startRPCSession(); } else if(state() == VCPDeviceInfoHelper::StartingRPCSession) { + setState(VCPDeviceInfoHelper::FetchingProtobufVersion); + fetchProtobufVersion(); + + } else if(state() == VCPDeviceInfoHelper::FetchingProtobufVersion) { setState(VCPDeviceInfoHelper::FetchingDeviceInfo); fetchDeviceInfo(); @@ -120,7 +126,39 @@ void VCPDeviceInfoHelper::startRPCSession() m_rpc->startSession(); } +void VCPDeviceInfoHelper::fetchProtobufVersion() +{ + auto *operation = m_rpc->systemProtobufVersion(); + + connect(operation, &AbstractOperation::finished, this, [=]() { + if(operation->isError()) { + finishWithError(BackendError::InvalidDevice, QStringLiteral("Failed to get protobuf version: %1").arg(operation->errorString())); + return; + } + + m_deviceInfo.protobuf = { + operation->versionMajor(), + operation->versionMinor() + }; + + qCDebug(CATEGORY_DEBUG).noquote() << QStringLiteral("Detected protobuf version: %1.%2").arg(operation->versionMajor()).arg(operation->versionMinor()); + + advanceState(); + }); +} + void VCPDeviceInfoHelper::fetchDeviceInfo() +{ + const auto &protobuf = m_deviceInfo.protobuf; + + if((protobuf.versionMajor > 0) || (protobuf.versionMinor >= 14)) { + fetchDeviceInfoProperty(); + } else { + fetchDeviceInfoLegacy(); + } +} + +void VCPDeviceInfoHelper::fetchDeviceInfoLegacy() { auto *operation = m_rpc->systemDeviceInfo(); @@ -149,11 +187,6 @@ void VCPDeviceInfoHelper::fetchDeviceInfo() (Region)operation->value(QByteArrayLiteral("hardware_region")).toInt(), }; - m_deviceInfo.protobuf = { - operation->value(QByteArrayLiteral("protobuf_version_major")).toInt(), - operation->value(QByteArrayLiteral("protobuf_version_minor")).toInt() - }; - if(operation->value(QByteArrayLiteral("radio_alive")) == QByteArrayLiteral("true")) { m_deviceInfo.fusVersion = QStringLiteral("%1.%2.%3").arg( operation->value(QByteArrayLiteral("radio_fus_major")), @@ -176,6 +209,57 @@ void VCPDeviceInfoHelper::fetchDeviceInfo() }); } +void VCPDeviceInfoHelper::fetchDeviceInfoProperty() +{ + auto *operation = m_rpc->propertyGet(QByteArrayLiteral("devinfo")); + + connect(operation, &AbstractOperation::finished, this, [=]() { + if(operation->isError()) { + finishWithError(BackendError::InvalidDevice, QStringLiteral("Failed to get device information: %1").arg(operation->errorString())); + return; + } + + m_deviceInfo.name = operation->value(QByteArrayLiteral("hardware.name")); + + m_deviceInfo.firmware = { + operation->value(QByteArrayLiteral("firmware.version")), + operation->value(QByteArrayLiteral("firmware.commit.hash")), + operation->value(QByteArrayLiteral("firmware.branch.name")), + branchToChannelName(operation->value(QByteArrayLiteral("firmware.branch.name"))), + QDateTime::fromString(operation->value(QByteArrayLiteral("firmware.build.date")), "dd-MM-yyyy").date() + }; + + m_deviceInfo.hardware = { + operation->value(QByteArrayLiteral("hardware.ver")), + QByteArrayLiteral("f") + operation->value(QByteArrayLiteral("hardware.target")), + QByteArrayLiteral("b") + operation->value(QByteArrayLiteral("hardware.body")), + QByteArrayLiteral("c") + operation->value(QByteArrayLiteral("hardware.connect")), + (Color)operation->value(QByteArrayLiteral("hardware.color")).toInt(), + (Region)operation->value(QByteArrayLiteral("hardware.region.builtin")).toInt(), + }; + + if(operation->value(QByteArrayLiteral("radio.alive")) == QByteArrayLiteral("true")) { + m_deviceInfo.fusVersion = QStringLiteral("%1.%2.%3").arg( + operation->value(QByteArrayLiteral("radio.fus.major")), + operation->value(QByteArrayLiteral("radio.fus.minor")), + operation->value(QByteArrayLiteral("radio.fus.sub"))); + + m_deviceInfo.radioVersion = QStringLiteral("%1.%2.%3").arg( + operation->value(QByteArrayLiteral("radio.stack.major")), + operation->value(QByteArrayLiteral("radio.stack.minor")), + operation->value(QByteArrayLiteral("radio.stack.sub"))); + + m_deviceInfo.stackType = operation->value(QByteArrayLiteral("radio.stack.type")).toInt(); + } + + if(m_deviceInfo.name.isEmpty()) { + finishWithError(BackendError::InvalidDevice, QStringLiteral("Failed to read device information: required fields are not present")); + } else { + advanceState(); + } + }); +} + void VCPDeviceInfoHelper::checkSDCard() { auto *operation = m_rpc->storageInfo(QByteArrayLiteral("/ext")); diff --git a/backend/flipperzero/helper/deviceinfohelper.h b/backend/flipperzero/helper/deviceinfohelper.h index 02308601..223f00dd 100644 --- a/backend/flipperzero/helper/deviceinfohelper.h +++ b/backend/flipperzero/helper/deviceinfohelper.h @@ -36,6 +36,7 @@ class VCPDeviceInfoHelper : public AbstractDeviceInfoHelper enum OperationState { FindingSerialPort = AbstractOperationHelper::User, StartingRPCSession, + FetchingProtobufVersion, FetchingDeviceInfo, CheckingSDCard, CheckingManifest, @@ -52,7 +53,10 @@ class VCPDeviceInfoHelper : public AbstractDeviceInfoHelper void findSerialPort(); void startRPCSession(); + void fetchProtobufVersion(); void fetchDeviceInfo(); + void fetchDeviceInfoLegacy(); + void fetchDeviceInfoProperty(); void checkSDCard(); void checkManifest(); void getTimeSkew(); diff --git a/backend/flipperzero/protobufsession.cpp b/backend/flipperzero/protobufsession.cpp index a6c29dfd..54f64a69 100644 --- a/backend/flipperzero/protobufsession.cpp +++ b/backend/flipperzero/protobufsession.cpp @@ -28,6 +28,7 @@ #include "rpc/systemsetdatetimeoperation.h" #include "rpc/systemfactoryresetoperation.h" #include "rpc/systemupdateoperation.h" +#include "rpc/systemprotobufversionoperation.h" #include "rpc/guisendinputoperation.h" #include "rpc/guiscreenframeoperation.h" @@ -36,6 +37,8 @@ #include "rpc/guistartvirtualdisplayoperation.h" #include "rpc/guistopvirtualdisplayoperation.h" +#include "rpc/propertygetoperation.h" + #if defined(QT_STATIC) Q_IMPORT_PLUGIN(ProtobufPlugin) #endif @@ -135,6 +138,11 @@ SystemUpdateOperation *ProtobufSession::systemUpdate(const QByteArray &manifestP return enqueueOperation(new SystemUpdateOperation(getAndIncrementCounter(), manifestPath, this)); } +SystemProtobufVersionOperation *ProtobufSession::systemProtobufVersion() +{ + return enqueueOperation(new SystemProtobufVersionOperation(getAndIncrementCounter(), this)); +} + StorageListOperation *ProtobufSession::storageList(const QByteArray &path) { return enqueueOperation(new StorageListOperation(getAndIncrementCounter(), path, this)); @@ -205,6 +213,11 @@ GuiScreenFrameOperation *ProtobufSession::guiSendScreenFrame(const QByteArray &s return enqueueOperation(new GuiScreenFrameOperation(getAndIncrementCounter(), screenData, this)); } +PropertyGetOperation *ProtobufSession::propertyGet(const QByteArray &key) +{ + return enqueueOperation(new PropertyGetOperation(getAndIncrementCounter(), key, this)); +} + void ProtobufSession::startSession() { if(m_sessionState != Stopped) { @@ -420,7 +433,7 @@ void ProtobufSession::setSessionState(SessionState newState) } #if !defined(QT_STATIC) -const QString ProtobufSession::protobufPluginFileName(int versionMajor) +const QString ProtobufSession::protobufPluginFileName(uint32_t versionMajor) { #if defined(Q_OS_WINDOWS) return QStringLiteral("flipperproto%1.dll").arg(versionMajor); @@ -434,9 +447,9 @@ const QString ProtobufSession::protobufPluginFileName(int versionMajor) } #endif -QVector ProtobufSession::supportedProtobufVersions() +QVector ProtobufSession::supportedProtobufVersions() { - QVector ret; + QVector ret; #if defined(QT_STATIC) const auto staticInstances = QPluginLoader::staticInstances(); @@ -451,7 +464,7 @@ QVector ProtobufSession::supportedProtobufVersions() #else const auto libraryPaths = QCoreApplication::libraryPaths(); - for(auto i = 0;; ++i) { + for(uint32_t i = 0;; ++i) { for(const auto &path : libraryPaths) { const QDir libraryDir(path); diff --git a/backend/flipperzero/protobufsession.h b/backend/flipperzero/protobufsession.h index abb1f86a..4a84dfa7 100644 --- a/backend/flipperzero/protobufsession.h +++ b/backend/flipperzero/protobufsession.h @@ -21,6 +21,7 @@ class SystemGetDateTimeOperation; class SystemSetDateTimeOperation; class SystemFactoryResetOperation; class SystemUpdateOperation; +class SystemProtobufVersionOperation; class StorageListOperation; class StorageInfoOperation; @@ -38,6 +39,8 @@ class GuiSendInputOperation; class GuiStartVirtualDisplayOperation; class GuiStopVirtualDisplayOperation; +class PropertyGetOperation; + class ProtobufSession : public QObject, public Failable { Q_OBJECT @@ -71,6 +74,7 @@ class ProtobufSession : public QObject, public Failable SystemFactoryResetOperation *factoryReset(); SystemDeviceInfoOperation *systemDeviceInfo(); SystemUpdateOperation *systemUpdate(const QByteArray &manifestPath); + SystemProtobufVersionOperation *systemProtobufVersion(); StorageListOperation *storageList(const QByteArray &path); StorageInfoOperation *storageInfo(const QByteArray &path); @@ -88,6 +92,8 @@ class ProtobufSession : public QObject, public Failable GuiSendInputOperation *guiSendInput(int key, int type); GuiScreenFrameOperation *guiSendScreenFrame(const QByteArray &screenData); + PropertyGetOperation *propertyGet(const QByteArray &key); + signals: void sessionStateChanged(); void broadcastResponseReceived(QObject *response); @@ -109,9 +115,9 @@ private slots: private: #if !defined(QT_STATIC) - static const QString protobufPluginFileName(int versionMajor); + static const QString protobufPluginFileName(uint32_t versionMajor); #endif - static QVector supportedProtobufVersions(); + static QVector supportedProtobufVersions(); void setSessionState(SessionState newState); @@ -147,9 +153,8 @@ private slots: qint64 m_bytesToWrite; uint32_t m_counter; - - int m_versionMajor; - int m_versionMinor; + uint32_t m_versionMajor; + uint32_t m_versionMinor; }; } diff --git a/backend/flipperzero/rpc/propertygetoperation.cpp b/backend/flipperzero/rpc/propertygetoperation.cpp new file mode 100644 index 00000000..d15c1e04 --- /dev/null +++ b/backend/flipperzero/rpc/propertygetoperation.cpp @@ -0,0 +1,40 @@ +#include "propertygetoperation.h" + +#include "protobufplugininterface.h" +#include "mainresponseinterface.h" +#include "propertyresponseinterface.h" + +using namespace Flipper; +using namespace Zero; + +PropertyGetOperation::PropertyGetOperation(uint32_t id, const QByteArray &key, QObject *parent): + AbstractProtobufOperation(id, parent), + m_key(key) +{} + +const QString PropertyGetOperation::description() const +{ + return QStringLiteral("Property Get"); +} + +const QByteArray PropertyGetOperation::value(const QByteArray &key) const +{ + return m_data.value(key); +} + +const QByteArray PropertyGetOperation::encodeRequest(ProtobufPluginInterface *encoder) +{ + return encoder->propertyGet(id(), m_key); +} + +bool PropertyGetOperation::processResponse(QObject *response) +{ + const auto *msg = qobject_cast(response); + + if(msg) { + m_data.insert(msg->key(), msg->value()); + return true; + } + + return qobject_cast(response); +} diff --git a/backend/flipperzero/rpc/propertygetoperation.h b/backend/flipperzero/rpc/propertygetoperation.h new file mode 100644 index 00000000..4e510655 --- /dev/null +++ b/backend/flipperzero/rpc/propertygetoperation.h @@ -0,0 +1,31 @@ +#pragma once + +#include "abstractprotobufoperation.h" + +#include +#include + +namespace Flipper { +namespace Zero { + +class PropertyGetOperation : public AbstractProtobufOperation +{ + Q_OBJECT + +public: + PropertyGetOperation(uint32_t id, const QByteArray &key, QObject *parent = nullptr); + const QString description() const override; + const QByteArray value(const QByteArray &key) const; + + const QByteArray encodeRequest(ProtobufPluginInterface *encoder) override; + +private: + bool processResponse(QObject *response) override; + + QByteArray m_key; + QHash m_data; +}; + +} +} + diff --git a/backend/flipperzero/rpc/systemprotobufversionoperation.cpp b/backend/flipperzero/rpc/systemprotobufversionoperation.cpp new file mode 100644 index 00000000..32b8b0b2 --- /dev/null +++ b/backend/flipperzero/rpc/systemprotobufversionoperation.cpp @@ -0,0 +1,45 @@ +#include "systemprotobufversionoperation.h" + +#include "protobufplugininterface.h" +#include "systemresponseinterface.h" + +using namespace Flipper; +using namespace Zero; + +SystemProtobufVersionOperation::SystemProtobufVersionOperation(uint32_t id, QObject *parent): + AbstractProtobufOperation(id, parent), + m_versionMajor(0), + m_versionMinor(0) +{} + +const QString SystemProtobufVersionOperation::description() const +{ + return QStringLiteral("System Protobuf Version"); +} + +uint32_t SystemProtobufVersionOperation::versionMajor() const +{ + return m_versionMajor; +} + +uint32_t SystemProtobufVersionOperation::versionMinor() const +{ + return m_versionMinor; +} + +const QByteArray SystemProtobufVersionOperation::encodeRequest(ProtobufPluginInterface *encoder) +{ + return encoder->systemProtobufVersion(id()); +} + +bool SystemProtobufVersionOperation::processResponse(QObject *response) +{ + auto *msg = qobject_cast(response); + + if(msg) { + m_versionMajor = msg->versionMajor(); + m_versionMinor = msg->versionMinor(); + } + + return msg; +} diff --git a/backend/flipperzero/rpc/systemprotobufversionoperation.h b/backend/flipperzero/rpc/systemprotobufversionoperation.h new file mode 100644 index 00000000..08588030 --- /dev/null +++ b/backend/flipperzero/rpc/systemprotobufversionoperation.h @@ -0,0 +1,32 @@ +#pragma once + +#include "abstractprotobufoperation.h" + +#include + +namespace Flipper { +namespace Zero { + +class SystemProtobufVersionOperation : public AbstractProtobufOperation +{ + Q_OBJECT + +public: + SystemProtobufVersionOperation(uint32_t id, QObject *parent = nullptr); + const QString description() const override; + + uint32_t versionMajor() const; + uint32_t versionMinor() const; + + const QByteArray encodeRequest(ProtobufPluginInterface *encoder) override; + +private: + bool processResponse(QObject *response) override; + + uint32_t m_versionMajor; + uint32_t m_versionMinor; +}; + +} +} + diff --git a/plugins/flipperproto0/flipperproto0.pro b/plugins/flipperproto0/flipperproto0.pro index 1de45121..1e6427cd 100644 --- a/plugins/flipperproto0/flipperproto0.pro +++ b/plugins/flipperproto0/flipperproto0.pro @@ -23,10 +23,13 @@ HEADERS += \ messages/application.pb.h \ messages/flipper.pb.h \ messages/gui.pb.h \ + messages/property.pb.h \ messages/status.pb.h \ messages/storage.pb.h \ messages/system.pb.h \ messagewrapper.h \ + propertyrequest.h \ + propertyresponse.h \ protobufplugin.h \ regiondata.h \ statusrequest.h \ @@ -45,10 +48,13 @@ SOURCES += \ messages/flipper.pb.c \ messages/gpio.pb.c \ messages/gui.pb.c \ + messages/property.pb.c \ messages/status.pb.c \ messages/storage.pb.c \ messages/system.pb.c \ messagewrapper.cpp \ + propertyrequest.cpp \ + propertyresponse.cpp \ protobufplugin.cpp \ regiondata.cpp \ statusrequest.cpp \ diff --git a/plugins/flipperproto0/mainresponse.cpp b/plugins/flipperproto0/mainresponse.cpp index 1a3ed261..f080a177 100644 --- a/plugins/flipperproto0/mainresponse.cpp +++ b/plugins/flipperproto0/mainresponse.cpp @@ -6,6 +6,7 @@ #include "statusresponse.h" #include "systemresponse.h" #include "storageresponse.h" +#include "propertyresponse.h" MainResponse::MainResponse(MessageWrapper &wrapper, QObject *parent): QObject(parent), @@ -89,11 +90,13 @@ QObject *MainResponse::create(MessageWrapper &wrapper, QObject *parent) case SystemDeviceInfo: return new SystemDeviceInfoResponse(wrapper, parent); case SystemGetDateTime: return new SystemGetDateTimeResponse(wrapper, parent); case SystemUpdate: return new SystemUpdateResponse(wrapper, parent); + case SystemProtobufVersion: return new SystemProtobufVersionResponse(wrapper, parent); case StorageInfo: return new StorageInfoResponse(wrapper, parent); case StorageStat: return new StorageStatResponse(wrapper, parent); case StorageList: return new StorageListResponse(wrapper, parent); case StorageRead: return new StorageReadResponse(wrapper, parent); case GuiScreenFrame: return new GuiScreenFrameResponse(wrapper, parent); + case PropertyGet: return new PropertyGetResponse(wrapper, parent); case Unknown: default: return nullptr; } @@ -113,6 +116,7 @@ MainResponseInterface::ResponseType MainResponse::tagToResponseType(pb_size_t ta case PB_Main_system_device_info_response_tag: return SystemDeviceInfo; case PB_Main_system_get_datetime_response_tag: return SystemGetDateTime; case PB_Main_system_update_response_tag: return SystemUpdate; + case PB_Main_system_protobuf_version_response_tag: return SystemProtobufVersion; case PB_Main_storage_list_response_tag: return StorageList; case PB_Main_storage_read_response_tag: return StorageRead; @@ -121,6 +125,8 @@ MainResponseInterface::ResponseType MainResponse::tagToResponseType(pb_size_t ta case PB_Main_storage_info_response_tag: return StorageInfo; case PB_Main_gui_screen_frame_tag: return GuiScreenFrame; + + case PB_Main_property_get_response_tag: return PropertyGet; default: return Unknown; } } diff --git a/plugins/flipperproto0/messages/application.pb.c b/plugins/flipperproto0/messages/application.pb.c index c353e871..b0c91d73 100644 --- a/plugins/flipperproto0/messages/application.pb.c +++ b/plugins/flipperproto0/messages/application.pb.c @@ -30,5 +30,14 @@ PB_BIND(PB_App_AppButtonReleaseRequest, PB_App_AppButtonReleaseRequest, AUTO) PB_BIND(PB_App_AppStateResponse, PB_App_AppStateResponse, AUTO) +PB_BIND(PB_App_GetErrorRequest, PB_App_GetErrorRequest, AUTO) + + +PB_BIND(PB_App_GetErrorResponse, PB_App_GetErrorResponse, AUTO) + + +PB_BIND(PB_App_DataExchangeRequest, PB_App_DataExchangeRequest, AUTO) + + diff --git a/plugins/flipperproto0/messages/application.pb.h b/plugins/flipperproto0/messages/application.pb.h index c5af9bf0..10f94a16 100644 --- a/plugins/flipperproto0/messages/application.pb.h +++ b/plugins/flipperproto0/messages/application.pb.h @@ -24,6 +24,14 @@ typedef struct _PB_App_AppExitRequest { char dummy_field; } PB_App_AppExitRequest; +typedef struct _PB_App_DataExchangeRequest { + pb_bytes_array_t *data; +} PB_App_DataExchangeRequest; + +typedef struct _PB_App_GetErrorRequest { + char dummy_field; +} PB_App_GetErrorRequest; + typedef struct _PB_App_LockStatusRequest { char dummy_field; } PB_App_LockStatusRequest; @@ -45,6 +53,11 @@ typedef struct _PB_App_AppStateResponse { PB_App_AppState state; } PB_App_AppStateResponse; +typedef struct _PB_App_GetErrorResponse { + uint32_t code; + char *text; +} PB_App_GetErrorResponse; + typedef struct _PB_App_LockStatusResponse { bool locked; } PB_App_LockStatusResponse; @@ -69,6 +82,9 @@ extern "C" { #define PB_App_AppButtonPressRequest_init_default {""} #define PB_App_AppButtonReleaseRequest_init_default {0} #define PB_App_AppStateResponse_init_default {_PB_App_AppState_MIN} +#define PB_App_GetErrorRequest_init_default {0} +#define PB_App_GetErrorResponse_init_default {0, NULL} +#define PB_App_DataExchangeRequest_init_default {NULL} #define PB_App_StartRequest_init_zero {NULL, NULL} #define PB_App_LockStatusRequest_init_zero {0} #define PB_App_LockStatusResponse_init_zero {0} @@ -77,13 +93,19 @@ extern "C" { #define PB_App_AppButtonPressRequest_init_zero {""} #define PB_App_AppButtonReleaseRequest_init_zero {0} #define PB_App_AppStateResponse_init_zero {_PB_App_AppState_MIN} +#define PB_App_GetErrorRequest_init_zero {0} +#define PB_App_GetErrorResponse_init_zero {0, NULL} +#define PB_App_DataExchangeRequest_init_zero {NULL} /* Field tags (for use in manual encoding/decoding) */ +#define PB_App_DataExchangeRequest_data_tag 1 #define PB_App_StartRequest_name_tag 1 #define PB_App_StartRequest_args_tag 2 #define PB_App_AppButtonPressRequest_args_tag 1 #define PB_App_AppLoadFileRequest_path_tag 1 #define PB_App_AppStateResponse_state_tag 1 +#define PB_App_GetErrorResponse_code_tag 1 +#define PB_App_GetErrorResponse_text_tag 2 #define PB_App_LockStatusResponse_locked_tag 1 /* Struct field encoding specification for nanopb */ @@ -128,6 +150,22 @@ X(a, STATIC, SINGULAR, UENUM, state, 1) #define PB_App_AppStateResponse_CALLBACK NULL #define PB_App_AppStateResponse_DEFAULT NULL +#define PB_App_GetErrorRequest_FIELDLIST(X, a) \ + +#define PB_App_GetErrorRequest_CALLBACK NULL +#define PB_App_GetErrorRequest_DEFAULT NULL + +#define PB_App_GetErrorResponse_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, code, 1) \ +X(a, POINTER, SINGULAR, STRING, text, 2) +#define PB_App_GetErrorResponse_CALLBACK NULL +#define PB_App_GetErrorResponse_DEFAULT NULL + +#define PB_App_DataExchangeRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, BYTES, data, 1) +#define PB_App_DataExchangeRequest_CALLBACK NULL +#define PB_App_DataExchangeRequest_DEFAULT NULL + extern const pb_msgdesc_t PB_App_StartRequest_msg; extern const pb_msgdesc_t PB_App_LockStatusRequest_msg; extern const pb_msgdesc_t PB_App_LockStatusResponse_msg; @@ -136,6 +174,9 @@ extern const pb_msgdesc_t PB_App_AppLoadFileRequest_msg; extern const pb_msgdesc_t PB_App_AppButtonPressRequest_msg; extern const pb_msgdesc_t PB_App_AppButtonReleaseRequest_msg; extern const pb_msgdesc_t PB_App_AppStateResponse_msg; +extern const pb_msgdesc_t PB_App_GetErrorRequest_msg; +extern const pb_msgdesc_t PB_App_GetErrorResponse_msg; +extern const pb_msgdesc_t PB_App_DataExchangeRequest_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define PB_App_StartRequest_fields &PB_App_StartRequest_msg @@ -146,14 +187,20 @@ extern const pb_msgdesc_t PB_App_AppStateResponse_msg; #define PB_App_AppButtonPressRequest_fields &PB_App_AppButtonPressRequest_msg #define PB_App_AppButtonReleaseRequest_fields &PB_App_AppButtonReleaseRequest_msg #define PB_App_AppStateResponse_fields &PB_App_AppStateResponse_msg +#define PB_App_GetErrorRequest_fields &PB_App_GetErrorRequest_msg +#define PB_App_GetErrorResponse_fields &PB_App_GetErrorResponse_msg +#define PB_App_DataExchangeRequest_fields &PB_App_DataExchangeRequest_msg /* Maximum encoded size of messages (where known) */ /* PB_App_StartRequest_size depends on runtime parameters */ +/* PB_App_GetErrorResponse_size depends on runtime parameters */ +/* PB_App_DataExchangeRequest_size depends on runtime parameters */ #define PB_App_AppButtonPressRequest_size 515 #define PB_App_AppButtonReleaseRequest_size 0 #define PB_App_AppExitRequest_size 0 #define PB_App_AppLoadFileRequest_size 515 #define PB_App_AppStateResponse_size 2 +#define PB_App_GetErrorRequest_size 0 #define PB_App_LockStatusRequest_size 0 #define PB_App_LockStatusResponse_size 2 diff --git a/plugins/flipperproto0/messages/flipper.pb.h b/plugins/flipperproto0/messages/flipper.pb.h index aa2a6662..63ade943 100644 --- a/plugins/flipperproto0/messages/flipper.pb.h +++ b/plugins/flipperproto0/messages/flipper.pb.h @@ -9,6 +9,7 @@ #include "application.pb.h" #include "gui.pb.h" #include "gpio.pb.h" +#include "property.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -127,6 +128,13 @@ typedef struct _PB_Main { PB_Gpio_ReadPinResponse gpio_read_pin_response; PB_Gpio_WritePin gpio_write_pin; PB_App_AppStateResponse app_state_response; + PB_Storage_TimestampRequest storage_timestamp_request; + PB_Storage_TimestampResponse storage_timestamp_response; + PB_Property_GetRequest property_get_request; + PB_Property_GetResponse property_get_response; + PB_App_GetErrorRequest app_get_error_request; + PB_App_GetErrorResponse app_get_error_response; + PB_App_DataExchangeRequest app_data_exchange_request; } content; } PB_Main; @@ -221,6 +229,13 @@ extern "C" { #define PB_Main_gpio_read_pin_response_tag 56 #define PB_Main_gpio_write_pin_tag 57 #define PB_Main_app_state_response_tag 58 +#define PB_Main_storage_timestamp_request_tag 59 +#define PB_Main_storage_timestamp_response_tag 60 +#define PB_Main_property_get_request_tag 61 +#define PB_Main_property_get_response_tag 62 +#define PB_Main_app_get_error_request_tag 63 +#define PB_Main_app_get_error_response_tag 64 +#define PB_Main_app_data_exchange_request_tag 65 #define PB_Region_Band_start_tag 1 #define PB_Region_Band_end_tag 2 #define PB_Region_Band_power_limit_tag 3 @@ -295,7 +310,14 @@ X(a, STATIC, ONEOF, MSG_W_CB, (content,gpio_get_pin_mode_response,content.g X(a, STATIC, ONEOF, MSG_W_CB, (content,gpio_read_pin,content.gpio_read_pin), 55) \ X(a, STATIC, ONEOF, MSG_W_CB, (content,gpio_read_pin_response,content.gpio_read_pin_response), 56) \ X(a, STATIC, ONEOF, MSG_W_CB, (content,gpio_write_pin,content.gpio_write_pin), 57) \ -X(a, STATIC, ONEOF, MSG_W_CB, (content,app_state_response,content.app_state_response), 58) +X(a, STATIC, ONEOF, MSG_W_CB, (content,app_state_response,content.app_state_response), 58) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_timestamp_request,content.storage_timestamp_request), 59) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,storage_timestamp_response,content.storage_timestamp_response), 60) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,property_get_request,content.property_get_request), 61) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,property_get_response,content.property_get_response), 62) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,app_get_error_request,content.app_get_error_request), 63) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,app_get_error_response,content.app_get_error_response), 64) \ +X(a, STATIC, ONEOF, MSG_W_CB, (content,app_data_exchange_request,content.app_data_exchange_request), 65) #define PB_Main_CALLBACK NULL #define PB_Main_DEFAULT NULL #define PB_Main_content_empty_MSGTYPE PB_Empty @@ -353,6 +375,13 @@ X(a, STATIC, ONEOF, MSG_W_CB, (content,app_state_response,content.app_state #define PB_Main_content_gpio_read_pin_response_MSGTYPE PB_Gpio_ReadPinResponse #define PB_Main_content_gpio_write_pin_MSGTYPE PB_Gpio_WritePin #define PB_Main_content_app_state_response_MSGTYPE PB_App_AppStateResponse +#define PB_Main_content_storage_timestamp_request_MSGTYPE PB_Storage_TimestampRequest +#define PB_Main_content_storage_timestamp_response_MSGTYPE PB_Storage_TimestampResponse +#define PB_Main_content_property_get_request_MSGTYPE PB_Property_GetRequest +#define PB_Main_content_property_get_response_MSGTYPE PB_Property_GetResponse +#define PB_Main_content_app_get_error_request_MSGTYPE PB_App_GetErrorRequest +#define PB_Main_content_app_get_error_response_MSGTYPE PB_App_GetErrorResponse +#define PB_Main_content_app_data_exchange_request_MSGTYPE PB_App_DataExchangeRequest #define PB_Region_FIELDLIST(X, a) \ X(a, POINTER, SINGULAR, BYTES, country_code, 1) \ @@ -383,14 +412,14 @@ extern const pb_msgdesc_t PB_Region_Band_msg; #define PB_Region_Band_fields &PB_Region_Band_msg /* Maximum encoded size of messages (where known) */ -#if defined(PB_System_PingRequest_size) && defined(PB_System_PingResponse_size) && defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_StartRequest_size) && defined(PB_Gui_ScreenFrame_size) && defined(PB_Storage_StatRequest_size) && defined(PB_Storage_StatResponse_size) && defined(PB_Gui_StartVirtualDisplayRequest_size) && defined(PB_Storage_InfoRequest_size) && defined(PB_Storage_RenameRequest_size) && defined(PB_System_DeviceInfoResponse_size) && defined(PB_System_UpdateRequest_size) && defined(PB_Storage_BackupCreateRequest_size) && defined(PB_Storage_BackupRestoreRequest_size) && defined(PB_System_PowerInfoResponse_size) -union PB_Main_content_size_union {char f5[(6 + PB_System_PingRequest_size)]; char f6[(6 + PB_System_PingResponse_size)]; char f7[(6 + PB_Storage_ListRequest_size)]; char f8[(6 + PB_Storage_ListResponse_size)]; char f9[(6 + PB_Storage_ReadRequest_size)]; char f10[(6 + PB_Storage_ReadResponse_size)]; char f11[(6 + PB_Storage_WriteRequest_size)]; char f12[(6 + PB_Storage_DeleteRequest_size)]; char f13[(6 + PB_Storage_MkdirRequest_size)]; char f14[(6 + PB_Storage_Md5sumRequest_size)]; char f16[(7 + PB_App_StartRequest_size)]; char f22[(7 + PB_Gui_ScreenFrame_size)]; char f24[(7 + PB_Storage_StatRequest_size)]; char f25[(7 + PB_Storage_StatResponse_size)]; char f26[(7 + PB_Gui_StartVirtualDisplayRequest_size)]; char f28[(7 + PB_Storage_InfoRequest_size)]; char f30[(7 + PB_Storage_RenameRequest_size)]; char f33[(7 + PB_System_DeviceInfoResponse_size)]; char f41[(7 + PB_System_UpdateRequest_size)]; char f42[(7 + PB_Storage_BackupCreateRequest_size)]; char f43[(7 + PB_Storage_BackupRestoreRequest_size)]; char f45[(7 + PB_System_PowerInfoResponse_size)]; char f0[519];}; +#if defined(PB_System_PingRequest_size) && defined(PB_System_PingResponse_size) && defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_StartRequest_size) && defined(PB_Gui_ScreenFrame_size) && defined(PB_Storage_StatRequest_size) && defined(PB_Storage_StatResponse_size) && defined(PB_Gui_StartVirtualDisplayRequest_size) && defined(PB_Storage_InfoRequest_size) && defined(PB_Storage_RenameRequest_size) && defined(PB_System_DeviceInfoResponse_size) && defined(PB_System_UpdateRequest_size) && defined(PB_Storage_BackupCreateRequest_size) && defined(PB_Storage_BackupRestoreRequest_size) && defined(PB_System_PowerInfoResponse_size) && defined(PB_Storage_TimestampRequest_size) && defined(PB_Property_GetRequest_size) && defined(PB_Property_GetResponse_size) && defined(PB_App_GetErrorResponse_size) && defined(PB_App_DataExchangeRequest_size) +union PB_Main_content_size_union {char f5[(6 + PB_System_PingRequest_size)]; char f6[(6 + PB_System_PingResponse_size)]; char f7[(6 + PB_Storage_ListRequest_size)]; char f8[(6 + PB_Storage_ListResponse_size)]; char f9[(6 + PB_Storage_ReadRequest_size)]; char f10[(6 + PB_Storage_ReadResponse_size)]; char f11[(6 + PB_Storage_WriteRequest_size)]; char f12[(6 + PB_Storage_DeleteRequest_size)]; char f13[(6 + PB_Storage_MkdirRequest_size)]; char f14[(6 + PB_Storage_Md5sumRequest_size)]; char f16[(7 + PB_App_StartRequest_size)]; char f22[(7 + PB_Gui_ScreenFrame_size)]; char f24[(7 + PB_Storage_StatRequest_size)]; char f25[(7 + PB_Storage_StatResponse_size)]; char f26[(7 + PB_Gui_StartVirtualDisplayRequest_size)]; char f28[(7 + PB_Storage_InfoRequest_size)]; char f30[(7 + PB_Storage_RenameRequest_size)]; char f33[(7 + PB_System_DeviceInfoResponse_size)]; char f41[(7 + PB_System_UpdateRequest_size)]; char f42[(7 + PB_Storage_BackupCreateRequest_size)]; char f43[(7 + PB_Storage_BackupRestoreRequest_size)]; char f45[(7 + PB_System_PowerInfoResponse_size)]; char f59[(7 + PB_Storage_TimestampRequest_size)]; char f61[(7 + PB_Property_GetRequest_size)]; char f62[(7 + PB_Property_GetResponse_size)]; char f64[(7 + PB_App_GetErrorResponse_size)]; char f65[(7 + PB_App_DataExchangeRequest_size)]; char f0[519];}; #endif /* PB_Region_size depends on runtime parameters */ #define PB_Empty_size 0 #define PB_Region_Band_size 26 #define PB_StopSession_size 0 -#if defined(PB_System_PingRequest_size) && defined(PB_System_PingResponse_size) && defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_StartRequest_size) && defined(PB_Gui_ScreenFrame_size) && defined(PB_Storage_StatRequest_size) && defined(PB_Storage_StatResponse_size) && defined(PB_Gui_StartVirtualDisplayRequest_size) && defined(PB_Storage_InfoRequest_size) && defined(PB_Storage_RenameRequest_size) && defined(PB_System_DeviceInfoResponse_size) && defined(PB_System_UpdateRequest_size) && defined(PB_Storage_BackupCreateRequest_size) && defined(PB_Storage_BackupRestoreRequest_size) && defined(PB_System_PowerInfoResponse_size) +#if defined(PB_System_PingRequest_size) && defined(PB_System_PingResponse_size) && defined(PB_Storage_ListRequest_size) && defined(PB_Storage_ListResponse_size) && defined(PB_Storage_ReadRequest_size) && defined(PB_Storage_ReadResponse_size) && defined(PB_Storage_WriteRequest_size) && defined(PB_Storage_DeleteRequest_size) && defined(PB_Storage_MkdirRequest_size) && defined(PB_Storage_Md5sumRequest_size) && defined(PB_App_StartRequest_size) && defined(PB_Gui_ScreenFrame_size) && defined(PB_Storage_StatRequest_size) && defined(PB_Storage_StatResponse_size) && defined(PB_Gui_StartVirtualDisplayRequest_size) && defined(PB_Storage_InfoRequest_size) && defined(PB_Storage_RenameRequest_size) && defined(PB_System_DeviceInfoResponse_size) && defined(PB_System_UpdateRequest_size) && defined(PB_Storage_BackupCreateRequest_size) && defined(PB_Storage_BackupRestoreRequest_size) && defined(PB_System_PowerInfoResponse_size) && defined(PB_Storage_TimestampRequest_size) && defined(PB_Property_GetRequest_size) && defined(PB_Property_GetResponse_size) && defined(PB_App_GetErrorResponse_size) && defined(PB_App_DataExchangeRequest_size) #define PB_Main_size (10 + sizeof(union PB_Main_content_size_union)) #endif diff --git a/plugins/flipperproto0/messages/property.pb.c b/plugins/flipperproto0/messages/property.pb.c new file mode 100644 index 00000000..0668bac4 --- /dev/null +++ b/plugins/flipperproto0/messages/property.pb.c @@ -0,0 +1,15 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.6-dev */ + +#include "property.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(PB_Property_GetRequest, PB_Property_GetRequest, AUTO) + + +PB_BIND(PB_Property_GetResponse, PB_Property_GetResponse, AUTO) + + + diff --git a/plugins/flipperproto0/messages/property.pb.h b/plugins/flipperproto0/messages/property.pb.h new file mode 100644 index 00000000..14b47277 --- /dev/null +++ b/plugins/flipperproto0/messages/property.pb.h @@ -0,0 +1,65 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.6-dev */ + +#ifndef PB_PB_PROPERTY_PROPERTY_PB_H_INCLUDED +#define PB_PB_PROPERTY_PROPERTY_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +typedef struct _PB_Property_GetRequest { + char *key; +} PB_Property_GetRequest; + +typedef struct _PB_Property_GetResponse { + char *key; + char *value; +} PB_Property_GetResponse; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define PB_Property_GetRequest_init_default {NULL} +#define PB_Property_GetResponse_init_default {NULL, NULL} +#define PB_Property_GetRequest_init_zero {NULL} +#define PB_Property_GetResponse_init_zero {NULL, NULL} + +/* Field tags (for use in manual encoding/decoding) */ +#define PB_Property_GetRequest_key_tag 1 +#define PB_Property_GetResponse_key_tag 1 +#define PB_Property_GetResponse_value_tag 2 + +/* Struct field encoding specification for nanopb */ +#define PB_Property_GetRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, key, 1) +#define PB_Property_GetRequest_CALLBACK NULL +#define PB_Property_GetRequest_DEFAULT NULL + +#define PB_Property_GetResponse_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, key, 1) \ +X(a, POINTER, SINGULAR, STRING, value, 2) +#define PB_Property_GetResponse_CALLBACK NULL +#define PB_Property_GetResponse_DEFAULT NULL + +extern const pb_msgdesc_t PB_Property_GetRequest_msg; +extern const pb_msgdesc_t PB_Property_GetResponse_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define PB_Property_GetRequest_fields &PB_Property_GetRequest_msg +#define PB_Property_GetResponse_fields &PB_Property_GetResponse_msg + +/* Maximum encoded size of messages (where known) */ +/* PB_Property_GetRequest_size depends on runtime parameters */ +/* PB_Property_GetResponse_size depends on runtime parameters */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/plugins/flipperproto0/messages/storage.pb.c b/plugins/flipperproto0/messages/storage.pb.c index 6caa5552..bcb1e8b8 100644 --- a/plugins/flipperproto0/messages/storage.pb.c +++ b/plugins/flipperproto0/messages/storage.pb.c @@ -15,6 +15,12 @@ PB_BIND(PB_Storage_InfoRequest, PB_Storage_InfoRequest, AUTO) PB_BIND(PB_Storage_InfoResponse, PB_Storage_InfoResponse, AUTO) +PB_BIND(PB_Storage_TimestampRequest, PB_Storage_TimestampRequest, AUTO) + + +PB_BIND(PB_Storage_TimestampResponse, PB_Storage_TimestampResponse, AUTO) + + PB_BIND(PB_Storage_StatRequest, PB_Storage_StatRequest, AUTO) diff --git a/plugins/flipperproto0/messages/storage.pb.h b/plugins/flipperproto0/messages/storage.pb.h index 9cbdc115..9556096b 100644 --- a/plugins/flipperproto0/messages/storage.pb.h +++ b/plugins/flipperproto0/messages/storage.pb.h @@ -53,6 +53,10 @@ typedef struct _PB_Storage_StatRequest { char *path; } PB_Storage_StatRequest; +typedef struct _PB_Storage_TimestampRequest { + char *path; +} PB_Storage_TimestampRequest; + typedef struct _PB_Storage_DeleteRequest { char *path; bool recursive; @@ -74,6 +78,10 @@ typedef struct _PB_Storage_Md5sumResponse { char md5sum[33]; } PB_Storage_Md5sumResponse; +typedef struct _PB_Storage_TimestampResponse { + uint32_t timestamp; +} PB_Storage_TimestampResponse; + typedef struct _PB_Storage_ListResponse { pb_size_t file_count; PB_Storage_File file[8]; @@ -110,6 +118,8 @@ extern "C" { #define PB_Storage_File_init_default {_PB_Storage_File_FileType_MIN, NULL, 0, NULL} #define PB_Storage_InfoRequest_init_default {NULL} #define PB_Storage_InfoResponse_init_default {0, 0} +#define PB_Storage_TimestampRequest_init_default {NULL} +#define PB_Storage_TimestampResponse_init_default {0} #define PB_Storage_StatRequest_init_default {NULL} #define PB_Storage_StatResponse_init_default {false, PB_Storage_File_init_default} #define PB_Storage_ListRequest_init_default {NULL} @@ -127,6 +137,8 @@ extern "C" { #define PB_Storage_File_init_zero {_PB_Storage_File_FileType_MIN, NULL, 0, NULL} #define PB_Storage_InfoRequest_init_zero {NULL} #define PB_Storage_InfoResponse_init_zero {0, 0} +#define PB_Storage_TimestampRequest_init_zero {NULL} +#define PB_Storage_TimestampResponse_init_zero {0} #define PB_Storage_StatRequest_init_zero {NULL} #define PB_Storage_StatResponse_init_zero {false, PB_Storage_File_init_zero} #define PB_Storage_ListRequest_init_zero {NULL} @@ -153,6 +165,7 @@ extern "C" { #define PB_Storage_RenameRequest_old_path_tag 1 #define PB_Storage_RenameRequest_new_path_tag 2 #define PB_Storage_StatRequest_path_tag 1 +#define PB_Storage_TimestampRequest_path_tag 1 #define PB_Storage_DeleteRequest_path_tag 1 #define PB_Storage_DeleteRequest_recursive_tag 2 #define PB_Storage_File_type_tag 1 @@ -162,6 +175,7 @@ extern "C" { #define PB_Storage_InfoResponse_total_space_tag 1 #define PB_Storage_InfoResponse_free_space_tag 2 #define PB_Storage_Md5sumResponse_md5sum_tag 1 +#define PB_Storage_TimestampResponse_timestamp_tag 1 #define PB_Storage_ListResponse_file_tag 1 #define PB_Storage_ReadResponse_file_tag 1 #define PB_Storage_StatResponse_file_tag 1 @@ -188,6 +202,16 @@ X(a, STATIC, SINGULAR, UINT64, free_space, 2) #define PB_Storage_InfoResponse_CALLBACK NULL #define PB_Storage_InfoResponse_DEFAULT NULL +#define PB_Storage_TimestampRequest_FIELDLIST(X, a) \ +X(a, POINTER, SINGULAR, STRING, path, 1) +#define PB_Storage_TimestampRequest_CALLBACK NULL +#define PB_Storage_TimestampRequest_DEFAULT NULL + +#define PB_Storage_TimestampResponse_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, timestamp, 1) +#define PB_Storage_TimestampResponse_CALLBACK NULL +#define PB_Storage_TimestampResponse_DEFAULT NULL + #define PB_Storage_StatRequest_FIELDLIST(X, a) \ X(a, POINTER, SINGULAR, STRING, path, 1) #define PB_Storage_StatRequest_CALLBACK NULL @@ -268,6 +292,8 @@ X(a, POINTER, SINGULAR, STRING, archive_path, 1) extern const pb_msgdesc_t PB_Storage_File_msg; extern const pb_msgdesc_t PB_Storage_InfoRequest_msg; extern const pb_msgdesc_t PB_Storage_InfoResponse_msg; +extern const pb_msgdesc_t PB_Storage_TimestampRequest_msg; +extern const pb_msgdesc_t PB_Storage_TimestampResponse_msg; extern const pb_msgdesc_t PB_Storage_StatRequest_msg; extern const pb_msgdesc_t PB_Storage_StatResponse_msg; extern const pb_msgdesc_t PB_Storage_ListRequest_msg; @@ -287,6 +313,8 @@ extern const pb_msgdesc_t PB_Storage_BackupRestoreRequest_msg; #define PB_Storage_File_fields &PB_Storage_File_msg #define PB_Storage_InfoRequest_fields &PB_Storage_InfoRequest_msg #define PB_Storage_InfoResponse_fields &PB_Storage_InfoResponse_msg +#define PB_Storage_TimestampRequest_fields &PB_Storage_TimestampRequest_msg +#define PB_Storage_TimestampResponse_fields &PB_Storage_TimestampResponse_msg #define PB_Storage_StatRequest_fields &PB_Storage_StatRequest_msg #define PB_Storage_StatResponse_fields &PB_Storage_StatResponse_msg #define PB_Storage_ListRequest_fields &PB_Storage_ListRequest_msg @@ -305,6 +333,7 @@ extern const pb_msgdesc_t PB_Storage_BackupRestoreRequest_msg; /* Maximum encoded size of messages (where known) */ /* PB_Storage_File_size depends on runtime parameters */ /* PB_Storage_InfoRequest_size depends on runtime parameters */ +/* PB_Storage_TimestampRequest_size depends on runtime parameters */ /* PB_Storage_StatRequest_size depends on runtime parameters */ /* PB_Storage_StatResponse_size depends on runtime parameters */ /* PB_Storage_ListRequest_size depends on runtime parameters */ @@ -320,6 +349,7 @@ extern const pb_msgdesc_t PB_Storage_BackupRestoreRequest_msg; /* PB_Storage_BackupRestoreRequest_size depends on runtime parameters */ #define PB_Storage_InfoResponse_size 22 #define PB_Storage_Md5sumResponse_size 34 +#define PB_Storage_TimestampResponse_size 6 #ifdef __cplusplus } /* extern "C" */ diff --git a/plugins/flipperproto0/propertyrequest.cpp b/plugins/flipperproto0/propertyrequest.cpp new file mode 100644 index 00000000..4683b370 --- /dev/null +++ b/plugins/flipperproto0/propertyrequest.cpp @@ -0,0 +1,9 @@ +#include "propertyrequest.h" + +PropertyGetRequest::PropertyGetRequest(uint32_t id, const QByteArray &key): + MainRequest(id, PB_Main_property_get_request_tag), + m_key(key) +{ + auto &content = m_message.content.property_get_request; + content.key = m_key.data(); +} diff --git a/plugins/flipperproto0/propertyrequest.h b/plugins/flipperproto0/propertyrequest.h new file mode 100644 index 00000000..e6d43bfe --- /dev/null +++ b/plugins/flipperproto0/propertyrequest.h @@ -0,0 +1,12 @@ +#pragma once + +#include "mainrequest.h" + +class PropertyGetRequest : public MainRequest +{ +public: + PropertyGetRequest(uint32_t id, const QByteArray &key); +private: + QByteArray m_key; +}; + diff --git a/plugins/flipperproto0/propertyresponse.cpp b/plugins/flipperproto0/propertyresponse.cpp new file mode 100644 index 00000000..ba670d53 --- /dev/null +++ b/plugins/flipperproto0/propertyresponse.cpp @@ -0,0 +1,15 @@ +#include "propertyresponse.h" + +PropertyGetResponse::PropertyGetResponse(MessageWrapper &wrapper, QObject *parent): + MainResponse(wrapper, parent) +{} + +const QByteArray PropertyGetResponse::key() const +{ + return message().content.property_get_response.key; +} + +const QByteArray PropertyGetResponse::value() const +{ + return message().content.property_get_response.value; +} diff --git a/plugins/flipperproto0/propertyresponse.h b/plugins/flipperproto0/propertyresponse.h new file mode 100644 index 00000000..b7111620 --- /dev/null +++ b/plugins/flipperproto0/propertyresponse.h @@ -0,0 +1,16 @@ +#pragma once + +#include "mainresponse.h" +#include "propertyresponseinterface.h" + +class PropertyGetResponse : public MainResponse, public PropertyGetResponseInterface +{ + Q_OBJECT + Q_INTERFACES(PropertyGetResponseInterface) + +public: + PropertyGetResponse(MessageWrapper &wrapper, QObject *parent = nullptr); + const QByteArray key() const override; + const QByteArray value() const override; +}; + diff --git a/plugins/flipperproto0/protobufplugin.cpp b/plugins/flipperproto0/protobufplugin.cpp index cd584ba5..59b5b426 100644 --- a/plugins/flipperproto0/protobufplugin.cpp +++ b/plugins/flipperproto0/protobufplugin.cpp @@ -8,6 +8,7 @@ #include "statusrequest.h" #include "systemrequest.h" #include "storagerequest.h" +#include "propertyrequest.h" #include "regiondata.h" @@ -16,12 +17,12 @@ ProtobufPlugin::ProtobufPlugin(QObject *parent): m_versionMinor(0) {} -int ProtobufPlugin::versionMajor() const +uint32_t ProtobufPlugin::versionMajor() const { return 0; } -void ProtobufPlugin::setMinorVersion(int version) +void ProtobufPlugin::setMinorVersion(uint32_t version) { m_versionMinor = version; } @@ -73,6 +74,11 @@ const QByteArray ProtobufPlugin::systemUpdateRequest(uint32_t id, const QByteArr return SystemUpdateRequest(id, manifestPath).encode(); } +const QByteArray ProtobufPlugin::systemProtobufVersion(uint32_t id) const +{ + return SystemProtobufVersionRequest(id).encode(); +} + const QByteArray ProtobufPlugin::guiStartScreenStream(uint32_t id) const { return GuiStartScreenStreamRequest(id).encode(); @@ -143,6 +149,11 @@ const QByteArray ProtobufPlugin::storageWrite(uint32_t id, const QByteArray &pat return StorageWriteRequest(id, path, data, hasNext).encode(); } +const QByteArray ProtobufPlugin::propertyGet(uint32_t id, const QByteArray &key) const +{ + return PropertyGetRequest(id, key).encode(); +} + const QByteArray ProtobufPlugin::regionBands(const QByteArray &countryCode, const BandInfoList &bands) const { return RegionData(countryCode, bands).encode(); diff --git a/plugins/flipperproto0/protobufplugin.h b/plugins/flipperproto0/protobufplugin.h index 7a46fd21..36773afc 100644 --- a/plugins/flipperproto0/protobufplugin.h +++ b/plugins/flipperproto0/protobufplugin.h @@ -14,8 +14,8 @@ class ProtobufPlugin : public QObject, public ProtobufPluginInterface public: ProtobufPlugin(QObject *parent = nullptr); - int versionMajor() const override; - void setMinorVersion(int version) override; + uint32_t versionMajor() const override; + void setMinorVersion(uint32_t version) override; const QByteArray statusPing(uint32_t id, const QByteArray &data) const override; @@ -25,6 +25,7 @@ class ProtobufPlugin : public QObject, public ProtobufPluginInterface const QByteArray systemGetDateTime(uint32_t id) const override; const QByteArray systemSetDateTime(uint32_t id, const QDateTime &dateTime) const override; const QByteArray systemUpdateRequest(uint32_t id, const QByteArray &manifestPath) const override; + const QByteArray systemProtobufVersion(uint32_t id) const override; const QByteArray guiStartScreenStream(uint32_t id) const override; const QByteArray guiStopScreenStream(uint32_t id) const override; @@ -42,10 +43,12 @@ class ProtobufPlugin : public QObject, public ProtobufPluginInterface const QByteArray storageRead(uint32_t id, const QByteArray &path) const override; const QByteArray storageWrite(uint32_t id, const QByteArray &path, const QByteArray &data, bool hasNext) const override; + const QByteArray propertyGet(uint32_t id, const QByteArray &key) const override; + const QByteArray regionBands(const QByteArray &countryCode, const BandInfoList &bands) const override; QObject *decode(const QByteArray &buffer, QObject *parent = nullptr) const override; private: - int m_versionMinor; + uint32_t m_versionMinor; }; diff --git a/plugins/flipperproto0/systemrequest.cpp b/plugins/flipperproto0/systemrequest.cpp index bf1f2d68..cb0e8c74 100644 --- a/plugins/flipperproto0/systemrequest.cpp +++ b/plugins/flipperproto0/systemrequest.cpp @@ -46,3 +46,7 @@ SystemUpdateRequest::SystemUpdateRequest(uint32_t id, const QByteArray &manifest auto &content = m_message.content.system_update_request; content.update_manifest = m_manifestPath.data(); } + +SystemProtobufVersionRequest::SystemProtobufVersionRequest(uint32_t id): + MainRequest(id, PB_Main_system_protobuf_version_request_tag) +{} diff --git a/plugins/flipperproto0/systemrequest.h b/plugins/flipperproto0/systemrequest.h index 8a20404b..58716e18 100644 --- a/plugins/flipperproto0/systemrequest.h +++ b/plugins/flipperproto0/systemrequest.h @@ -41,3 +41,9 @@ class SystemUpdateRequest : public MainRequest private: QByteArray m_manifestPath; }; + +class SystemProtobufVersionRequest : public MainRequest +{ +public: + SystemProtobufVersionRequest(uint32_t id); +}; diff --git a/plugins/flipperproto0/systemresponse.cpp b/plugins/flipperproto0/systemresponse.cpp index 9bf5ecf5..4a848ee4 100644 --- a/plugins/flipperproto0/systemresponse.cpp +++ b/plugins/flipperproto0/systemresponse.cpp @@ -69,3 +69,17 @@ const QString SystemUpdateResponse::resultString() const return QStringLiteral("Unknown error"); } } + +SystemProtobufVersionResponse::SystemProtobufVersionResponse(MessageWrapper &wrapper, QObject *parent): + MainResponse(wrapper, parent) +{} + +uint32_t SystemProtobufVersionResponse::versionMajor() const +{ + return message().content.system_protobuf_version_response.major; +} + +uint32_t SystemProtobufVersionResponse::versionMinor() const +{ + return message().content.system_protobuf_version_response.minor; +} diff --git a/plugins/flipperproto0/systemresponse.h b/plugins/flipperproto0/systemresponse.h index 30575b55..3db25044 100644 --- a/plugins/flipperproto0/systemresponse.h +++ b/plugins/flipperproto0/systemresponse.h @@ -34,3 +34,14 @@ class SystemUpdateResponse : public MainResponse, public SystemUpdateResponseInt bool isResultOk() const; const QString resultString() const; }; + +class SystemProtobufVersionResponse : public MainResponse, public SystemProtobufVersionResponseInterface +{ + Q_OBJECT + Q_INTERFACES(SystemProtobufVersionResponseInterface) + +public: + SystemProtobufVersionResponse(MessageWrapper &wrapper, QObject *parent = nullptr); + uint32_t versionMajor() const override; + uint32_t versionMinor() const override; +}; diff --git a/plugins/protobufinterface/mainresponseinterface.h b/plugins/protobufinterface/mainresponseinterface.h index 3727de37..947d0476 100644 --- a/plugins/protobufinterface/mainresponseinterface.h +++ b/plugins/protobufinterface/mainresponseinterface.h @@ -14,6 +14,7 @@ class MainResponseInterface SystemDeviceInfo, SystemGetDateTime, SystemUpdate, + SystemProtobufVersion, StorageList, StorageRead, @@ -22,6 +23,8 @@ class MainResponseInterface StorageInfo, GuiScreenFrame, + + PropertyGet, }; virtual ~MainResponseInterface() {} diff --git a/plugins/protobufinterface/propertyresponseinterface.h b/plugins/protobufinterface/propertyresponseinterface.h new file mode 100644 index 00000000..dee89acc --- /dev/null +++ b/plugins/protobufinterface/propertyresponseinterface.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +class PropertyGetResponseInterface +{ +public: + virtual const QByteArray key() const = 0; + virtual const QByteArray value() const = 0; +}; + +QT_BEGIN_NAMESPACE +Q_DECLARE_INTERFACE(PropertyGetResponseInterface, "com.flipperdevices.PropertyGetResponseInterface/1.0") +QT_END_NAMESPACE diff --git a/plugins/protobufinterface/protobufinterface.pro b/plugins/protobufinterface/protobufinterface.pro index acb56561..dd035ece 100644 --- a/plugins/protobufinterface/protobufinterface.pro +++ b/plugins/protobufinterface/protobufinterface.pro @@ -9,6 +9,7 @@ HEADERS += \ bandinfo.h \ guiresponseinterface.h \ mainresponseinterface.h \ + propertyresponseinterface.h \ protobufplugininterface.h \ statusresponseinterface.h \ storageresponseinterface.h \ diff --git a/plugins/protobufinterface/protobufplugininterface.h b/plugins/protobufinterface/protobufplugininterface.h index b8a3b204..ed95e361 100644 --- a/plugins/protobufinterface/protobufplugininterface.h +++ b/plugins/protobufinterface/protobufplugininterface.h @@ -16,8 +16,8 @@ class ProtobufPluginInterface virtual ~ProtobufPluginInterface() {} - virtual int versionMajor() const = 0; - virtual void setMinorVersion(int version) = 0; + virtual uint32_t versionMajor() const = 0; + virtual void setMinorVersion(uint32_t version) = 0; virtual const QByteArray statusPing(uint32_t id, const QByteArray &data = QByteArray()) const = 0; virtual const QByteArray systemFactoryReset(uint32_t id) const = 0; @@ -26,6 +26,7 @@ class ProtobufPluginInterface virtual const QByteArray systemGetDateTime(uint32_t id) const = 0; virtual const QByteArray systemSetDateTime(uint32_t id, const QDateTime &dateTime) const = 0; virtual const QByteArray systemUpdateRequest(uint32_t id, const QByteArray &manifestPath) const = 0; + virtual const QByteArray systemProtobufVersion(uint32_t id) const = 0; virtual const QByteArray guiStartScreenStream(uint32_t id) const = 0; virtual const QByteArray guiStopScreenStream(uint32_t id) const = 0; @@ -43,6 +44,8 @@ class ProtobufPluginInterface virtual const QByteArray storageRead(uint32_t id, const QByteArray &path) const = 0; virtual const QByteArray storageWrite(uint32_t id, const QByteArray &path, const QByteArray &data, bool hasNext) const = 0; + virtual const QByteArray propertyGet(uint32_t id, const QByteArray &key) const = 0; + virtual const QByteArray regionBands(const QByteArray &countryCode, const BandInfoList &bands) const = 0; virtual QObject *decode(const QByteArray &buffer, QObject *parent = nullptr) const = 0; diff --git a/plugins/protobufinterface/systemresponseinterface.h b/plugins/protobufinterface/systemresponseinterface.h index 2081539e..d22c81c4 100644 --- a/plugins/protobufinterface/systemresponseinterface.h +++ b/plugins/protobufinterface/systemresponseinterface.h @@ -24,8 +24,16 @@ class SystemUpdateResponseInterface virtual const QString resultString() const = 0; }; +class SystemProtobufVersionResponseInterface +{ +public: + virtual uint32_t versionMajor() const = 0; + virtual uint32_t versionMinor() const = 0; +}; + QT_BEGIN_NAMESPACE Q_DECLARE_INTERFACE(SystemDeviceInfoResponseInterface, "com.flipperdevices.SystemDeviceInfoResponseInterface/1.0") Q_DECLARE_INTERFACE(SystemGetDateTimeResponseInterface, "com.flipperdevices.SystemGetDateTimeResponseInterface/1.0") Q_DECLARE_INTERFACE(SystemUpdateResponseInterface, "com.flipperdevices.SystemUpdateResponseInterface/1.0") +Q_DECLARE_INTERFACE(SystemProtobufVersionResponseInterface, "com.flipperdevices.SystemProtobufVersionResponseInterface/1.0") QT_END_NAMESPACE