Skip to content

Commit

Permalink
fix: config changes after reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr authored Nov 26, 2024
1 parent d27fc8c commit ab0416d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
24 changes: 7 additions & 17 deletions sscma/server/at/callback/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ void setScoreThreshold(const std::vector<std::string>& 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:
Expand All @@ -54,13 +50,9 @@ void setNMSThreshold(const std::vector<std::string>& 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:
Expand All @@ -73,21 +65,19 @@ void setNMSThreshold(const std::vector<std::string>& argv, Transport& transport,
void getScoreThreshold(const std::vector<std::string>& 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<uint64_t>(score));
encoder.begin(MA_MSG_TYPE_RESP, ret, argv[0], static_cast<uint64_t>(std::round(static_resource->shared_threshold_score * 100)));
encoder.end();
transport.send(reinterpret_cast<const char*>(encoder.data()), encoder.size());
}

void getNMSThreshold(const std::vector<std::string>& 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<uint64_t>(nms));
encoder.begin(MA_MSG_TYPE_RESP, ret, argv[0], static_cast<uint64_t>(std::round(static_resource->shared_threshold_nms * 100)));
encoder.end();
transport.send(reinterpret_cast<const char*>(encoder.data()), encoder.size());
}
Expand Down
3 changes: 3 additions & 0 deletions sscma/server/at/callback/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ab0416d

Please sign in to comment.