Skip to content

Commit f4198be

Browse files
authored
Adding rssi (#1482)
Adding rssi. Signed-off-by: Carlos Agüero <[email protected]>
1 parent 2a419fe commit f4198be

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/systems/rf_comms/RFComms.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*
1616
*/
1717

18+
#include <ignition/msgs/dataframe.pb.h>
19+
1820
#include <limits>
1921
#include <list>
2022
#include <random>
@@ -447,7 +449,18 @@ void RFComms::Step(
447449
#endif
448450

449451
if (sendPacket)
450-
_newRegistry[msg->dst_address()].inboundMsgs.push_back(msg);
452+
{
453+
// We create a copy of the outbound message because each destination
454+
// might have a different rssi value.
455+
auto inboundMsg = std::make_shared<ignition::msgs::Dataframe>(*msg);
456+
457+
// Add rssi.
458+
auto *rssiPtr = inboundMsg->mutable_header()->add_data();
459+
rssiPtr->set_key("rssi");
460+
rssiPtr->add_value(std::to_string(rssi));
461+
462+
_newRegistry[msg->dst_address()].inboundMsgs.push_back(inboundMsg);
463+
}
451464
}
452465
}
453466

test/integration/rf_comms.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ TEST_F(RFCommsTest, IGN_UTILS_TEST_DISABLED_ON_WIN32(RFComms))
6565

6666
ignition::msgs::StringMsg receivedMsg;
6767
receivedMsg.ParseFromString(_msg.data());
68+
6869
EXPECT_EQ(expected, receivedMsg.data());
70+
ASSERT_GT(_msg.header().data_size(), 0);
71+
EXPECT_EQ("rssi", _msg.header().data(0).key());
6972
msgCounter++;
7073
};
7174

0 commit comments

Comments
 (0)