From ab0416dd991a0684ba5cab2c92d99bccfdcd93c9 Mon Sep 17 00:00:00 2001 From: nullptr Date: Tue, 26 Nov 2024 08:57:20 +0000 Subject: [PATCH] fix: config changes after reboot --- sscma/server/at/callback/config.hpp | 24 +++++++----------------- sscma/server/at/callback/resource.hpp | 3 +++ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/sscma/server/at/callback/config.hpp b/sscma/server/at/callback/config.hpp index b06baeb9..6e2ec7a0 100644 --- a/sscma/server/at/callback/config.hpp +++ b/sscma/server/at/callback/config.hpp @@ -25,12 +25,8 @@ void setScoreThreshold(const std::vector& argv, Transport& transpor goto exit; } - MA_STORAGE_SET_POD(ret, static_resource->device->getStorage(), "ma#score_threshold", score); - if (ret != MA_OK) { - goto exit; - } - static_resource->shared_threshold_score = score / 100.0; + MA_STORAGE_NOSTA_SET_POD(static_resource->device->getStorage(), "ma#score_threshold", static_resource->shared_threshold_score); } exit: @@ -54,13 +50,9 @@ void setNMSThreshold(const std::vector& argv, Transport& transport, ret = MA_EINVAL; goto exit; } + static_resource->shared_threshold_nms = nms / 100.0; - MA_STORAGE_SET_POD(ret, static_resource->device->getStorage(), "ma#nms_threshold", nms); - if (ret != MA_OK) { - goto exit; - } - - static_resource->shared_threshold_nms = nms / 100.0; + MA_STORAGE_NOSTA_SET_POD(static_resource->device->getStorage(), "ma#nms_threshold", static_resource->shared_threshold_nms); } exit: @@ -73,10 +65,9 @@ void setNMSThreshold(const std::vector& argv, Transport& transport, void getScoreThreshold(const std::vector& argv, Transport& transport, Encoder& encoder) { ma_err_t ret = MA_OK; - int score = std::round(static_resource->shared_threshold_score * 100); - MA_STORAGE_GET_POD(static_resource->device->getStorage(), "ma#score_threshold", score, score); + MA_STORAGE_GET_POD(static_resource->device->getStorage(), "ma#score_threshold", static_resource->shared_threshold_score, static_resource->shared_threshold_score); - encoder.begin(MA_MSG_TYPE_RESP, ret, argv[0], static_cast(score)); + encoder.begin(MA_MSG_TYPE_RESP, ret, argv[0], static_cast(std::round(static_resource->shared_threshold_score * 100))); encoder.end(); transport.send(reinterpret_cast(encoder.data()), encoder.size()); } @@ -84,10 +75,9 @@ void getScoreThreshold(const std::vector& argv, Transport& transpor void getNMSThreshold(const std::vector& argv, Transport& transport, Encoder& encoder) { ma_err_t ret = MA_OK; - int nms = std::round(static_resource->shared_threshold_nms * 100); - MA_STORAGE_GET_POD(static_resource->device->getStorage(), "ma#nms_threshold", nms, nms); + MA_STORAGE_GET_POD(static_resource->device->getStorage(), "ma#nms_threshold", static_resource->shared_threshold_nms, static_resource->shared_threshold_nms); - encoder.begin(MA_MSG_TYPE_RESP, ret, argv[0], static_cast(nms)); + encoder.begin(MA_MSG_TYPE_RESP, ret, argv[0], static_cast(std::round(static_resource->shared_threshold_nms * 100))); encoder.end(); transport.send(reinterpret_cast(encoder.data()), encoder.size()); } diff --git a/sscma/server/at/callback/resource.hpp b/sscma/server/at/callback/resource.hpp index 32940736..5f6a475e 100644 --- a/sscma/server/at/callback/resource.hpp +++ b/sscma/server/at/callback/resource.hpp @@ -36,6 +36,9 @@ struct StaticResource final { MA_LOGD(MA_TAG, "Initializing executor"); static Executor executor_default; executor = &executor_default; + + MA_STORAGE_GET_POD(device->getStorage(), "ma#score_threshold", shared_threshold_score, shared_threshold_score); + MA_STORAGE_GET_POD(device->getStorage(), "ma#nms_threshold", shared_threshold_nms, shared_threshold_nms); } public: