libuavcan passive mode support

This commit is contained in:
Pavel Kirienko
2014-07-12 16:52:17 +04:00
parent 93f861ad60
commit c9c9a16e94
6 changed files with 47 additions and 4 deletions
@@ -62,10 +62,15 @@ int NodeStatusProvider::startAndPublish()
return -ErrNotInited;
}
int res = publish(); // Initial broadcast
if (res < 0)
int res = -1;
if (!getNode().isPassiveMode())
{
goto fail;
res = publish(); // Initial broadcast
if (res < 0)
{
goto fail;
}
}
res = gdr_sub_.start(GlobalDiscoveryRequestCallback(this, &NodeStatusProvider::handleGlobalDiscoveryRequest));
@@ -80,7 +85,10 @@ int NodeStatusProvider::startAndPublish()
goto fail;
}
TimerBase::startPeriodic(MonotonicDuration::fromMSec(protocol::NodeStatus::PUBLICATION_PERIOD_MS));
if (!getNode().isPassiveMode())
{
TimerBase::startPeriodic(MonotonicDuration::fromMSec(protocol::NodeStatus::PUBLICATION_PERIOD_MS));
}
return res;
@@ -19,6 +19,11 @@ int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime
MonotonicTime blocking_deadline, TransferType transfer_type, NodeID dst_node_id,
TransferID tid)
{
if (dispatcher_.isPassiveMode())
{
return -ErrPassiveMode;
}
dispatcher_.getTransferPerfCounter().addTxTransfer();
Frame frame(data_type_.getID(), transfer_type, dispatcher_.getNodeID(), dst_node_id, 0, tid);