lr-wpan: (fixes #745) Make sure that mobility model is found by LrWpanPhy
This commit is contained in:
committed by
Tom Henderson
parent
2c2a39f12e
commit
46b5dbd9b4
@@ -30,7 +30,6 @@
|
||||
#include <ns3/spectrum-channel.h>
|
||||
#include <ns3/pointer.h>
|
||||
#include <ns3/boolean.h>
|
||||
#include <ns3/mobility-model.h>
|
||||
#include <ns3/packet.h>
|
||||
|
||||
|
||||
@@ -133,12 +132,6 @@ LrWpanNetDevice::CompleteConfig (void)
|
||||
m_mac->SetMcpsDataIndicationCallback (MakeCallback (&LrWpanNetDevice::McpsDataIndication, this));
|
||||
m_csmaca->SetMac (m_mac);
|
||||
|
||||
Ptr<MobilityModel> mobility = m_node->GetObject<MobilityModel> ();
|
||||
if (!mobility)
|
||||
{
|
||||
NS_LOG_WARN ("LrWpanNetDevice: no Mobility found on the node, probably it's not a good idea.");
|
||||
}
|
||||
m_phy->SetMobility (mobility);
|
||||
Ptr<LrWpanErrorModel> model = CreateObject<LrWpanErrorModel> ();
|
||||
m_phy->SetErrorModel (model);
|
||||
m_phy->SetDevice (this);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <ns3/spectrum-value.h>
|
||||
#include <ns3/antenna-model.h>
|
||||
#include <ns3/mobility-model.h>
|
||||
#include <ns3/node.h>
|
||||
#include <ns3/spectrum-channel.h>
|
||||
#include <ns3/packet.h>
|
||||
#include <ns3/packet-burst.h>
|
||||
@@ -150,6 +151,29 @@ LrWpanPhy::LrWpanPhy (void)
|
||||
LrWpanPhy::~LrWpanPhy (void)
|
||||
{}
|
||||
|
||||
void
|
||||
LrWpanPhy::DoInitialize (void)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
// This method ensures that the local mobility model pointer holds
|
||||
// a pointer to the Node's aggregated mobility model (if one exists)
|
||||
// in the case that the user has not directly called SetMobility()
|
||||
// on this LrWpanPhy during simulation setup. If the mobility model
|
||||
// needs to be added or changed during simulation runtime, users must
|
||||
// call SetMobility() on this object.
|
||||
|
||||
if (!m_mobility)
|
||||
{
|
||||
NS_ABORT_MSG_UNLESS (m_device && m_device->GetNode (), "Either install a MobilityModel on this object or ensure that this object is part of a Node and NetDevice");
|
||||
m_mobility = m_device->GetNode ()->GetObject<MobilityModel> ();
|
||||
if (!m_mobility)
|
||||
{
|
||||
NS_LOG_WARN ("Mobility not found, propagation models might not work properly");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LrWpanPhy::DoDispose (void)
|
||||
{
|
||||
|
||||
@@ -547,6 +547,7 @@ private:
|
||||
typedef std::pair<Ptr<Packet>, bool> PacketAndStatus;
|
||||
|
||||
// Inherited from Object.
|
||||
virtual void DoInitialize (void);
|
||||
virtual void DoDispose (void);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user