mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[nexus] dynamically sync radio range circles with simulator parameters (#12987)
This commit exposes radio model parameters (path loss constant, exponent, and sensitivity) and the minimum link request margin from the Nexus simulator backend to the frontend. Changes in backend: - Expose constants in `RadioModel` and `Radio`. - Add `GetRadioParameters` RPC to `simulation.proto` and implement it in gRPC and WASM bindings. - Expose `OPENTHREAD_CONFIG_MLE_LINK_REQUEST_MARGIN_MIN` and `OPENTHREAD_CONFIG_MLE_PARTITION_MERGE_MARGIN_MIN` via the new RPC. Changes in config: - Set `OPENTHREAD_CONFIG_MLE_LINK_REQUEST_MARGIN_MIN` and `OPENTHREAD_CONFIG_MLE_PARTITION_MERGE_MARGIN_MIN` to 5 dB in `openthread-core-nexus-config.h`. This allows the frontend to calculate and render circles dynamically.
This commit is contained in:
@@ -109,6 +109,8 @@
|
||||
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1
|
||||
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1
|
||||
#define OPENTHREAD_CONFIG_MLE_MAX_CHILDREN 128
|
||||
#define OPENTHREAD_CONFIG_MLE_LINK_REQUEST_MARGIN_MIN 5
|
||||
#define OPENTHREAD_CONFIG_MLE_PARTITION_MERGE_MARGIN_MIN 5
|
||||
#define OPENTHREAD_CONFIG_MLR_ENABLE 1
|
||||
#define OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE 1
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF 1
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
|
||||
#include "nexus_logging.hpp"
|
||||
#include "nexus_node.hpp"
|
||||
#include "nexus_radio.hpp"
|
||||
#include "nexus_radio_model.hpp"
|
||||
#include "simulation.grpc.pb.h"
|
||||
#include "common/clearable.hpp"
|
||||
#include "common/code_utils.hpp"
|
||||
@@ -269,6 +271,18 @@ public:
|
||||
return status;
|
||||
}
|
||||
|
||||
grpc::Status GetRadioParameters(grpc::ServerContext * /* aContext */,
|
||||
const nexus::GetRadioParametersRequest * /* aRequest */,
|
||||
nexus::GetRadioParametersResponse *aResponse) override
|
||||
{
|
||||
aResponse->set_path_loss_constant(RadioModel::kPathLossConstant);
|
||||
aResponse->set_path_loss_exponent(RadioModel::kPathLossExponent);
|
||||
aResponse->set_radio_sensitivity(Radio::kRadioSensitivity);
|
||||
aResponse->set_mle_link_request_margin_min(OPENTHREAD_CONFIG_MLE_LINK_REQUEST_MARGIN_MIN);
|
||||
|
||||
return grpc::Status::OK;
|
||||
}
|
||||
|
||||
private:
|
||||
GrpcServer *mServerPtr;
|
||||
};
|
||||
|
||||
@@ -38,9 +38,6 @@ namespace Nexus {
|
||||
|
||||
int16_t RadioModel::CalculateRssi(const Node &aTxNode, const Node &aRxNode)
|
||||
{
|
||||
static constexpr double kPathLossConstant = 40.0;
|
||||
static constexpr double kPathLossExponent = 20.0;
|
||||
|
||||
// Simple path loss model
|
||||
// RSSI = TxPower - PathLoss
|
||||
// PathLoss = kPathLossExponent * log10(distance) + kPathLossConstant
|
||||
|
||||
@@ -43,6 +43,9 @@ class Node;
|
||||
class RadioModel
|
||||
{
|
||||
public:
|
||||
static constexpr double kPathLossConstant = 40.0;
|
||||
static constexpr double kPathLossExponent = 20.0;
|
||||
|
||||
RadioModel(void) = delete;
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
#include "nexus_core.hpp"
|
||||
#include "nexus_node.hpp"
|
||||
#include "nexus_radio.hpp"
|
||||
#include "nexus_radio_model.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "thread/mle.hpp"
|
||||
#include "thread/neighbor_table.hpp"
|
||||
@@ -225,6 +227,15 @@ EMSCRIPTEN_BINDINGS(nexus_simulator)
|
||||
|
||||
function("pollEvent", optional_override([]() -> val { return WasmManager::Get().PollEvent(); }));
|
||||
|
||||
function("getRadioParameters", optional_override([]() -> val {
|
||||
val params = val::object();
|
||||
params.set("pathLossConstant", RadioModel::kPathLossConstant);
|
||||
params.set("pathLossExponent", RadioModel::kPathLossExponent);
|
||||
params.set("radioSensitivity", Radio::kRadioSensitivity);
|
||||
params.set("mleLinkRequestMarginMin", OPENTHREAD_CONFIG_MLE_LINK_REQUEST_MARGIN_MIN);
|
||||
return params;
|
||||
}));
|
||||
|
||||
function("getNow", optional_override([]() -> uint32_t { return Core::Get().GetNow().GetValue(); }));
|
||||
|
||||
function("stepSimulation", optional_override([](uint32_t aElapsedMs) { Core::Get().AdvanceTime(aElapsedMs); }));
|
||||
|
||||
@@ -212,6 +212,20 @@ service NexusService {
|
||||
* Joins a node to a network.
|
||||
*/
|
||||
rpc JoinNetwork(JoinNetworkRequest) returns (JoinNetworkResponse);
|
||||
|
||||
/**
|
||||
* Retrieves the radio model parameters.
|
||||
*/
|
||||
rpc GetRadioParameters(GetRadioParametersRequest) returns (GetRadioParametersResponse);
|
||||
}
|
||||
|
||||
message GetRadioParametersRequest {}
|
||||
|
||||
message GetRadioParametersResponse {
|
||||
float path_loss_constant = 1;
|
||||
float path_loss_exponent = 2;
|
||||
float radio_sensitivity = 3;
|
||||
int32 mle_link_request_margin_min = 4;
|
||||
}
|
||||
|
||||
message StreamRequest {
|
||||
|
||||
Reference in New Issue
Block a user