Bug 2126 - LrWpanNetDevice silently accepts no mobility on the node
authorTommaso Pecorella <tommaso.pecorella@unifi.it>
Thu, 28 May 2015 10:22:59 +0200
changeset 11421 b04cfbe73884
parent 11420 ef4dc0386e71
child 11422 82596c0df344
Bug 2126 - LrWpanNetDevice silently accepts no mobility on the node
RELEASE_NOTES
src/lr-wpan/model/lr-wpan-net-device.cc
src/sixlowpan/examples/example-ping-lr-wpan.cc
--- a/RELEASE_NOTES	Wed May 27 21:55:56 2015 +0200
+++ b/RELEASE_NOTES	Thu May 28 10:22:59 2015 +0200
@@ -24,6 +24,7 @@
 
 Bugs fixed
 ----------
+- Bug 2126 - LrWpanNetDevice silently accepts no mobility on the node
 
 Known issues
 ------------
--- a/src/lr-wpan/model/lr-wpan-net-device.cc	Wed May 27 21:55:56 2015 +0200
+++ b/src/lr-wpan/model/lr-wpan-net-device.cc	Thu May 28 10:22:59 2015 +0200
@@ -128,7 +128,12 @@
   m_mac->SetMcpsDataIndicationCallback (MakeCallback (&LrWpanNetDevice::McpsDataIndication, this));
   m_csmaca->SetMac (m_mac);
 
-  m_phy->SetMobility (m_node->GetObject<MobilityModel> ());
+  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);
--- a/src/sixlowpan/examples/example-ping-lr-wpan.cc	Wed May 27 21:55:56 2015 +0200
+++ b/src/sixlowpan/examples/example-ping-lr-wpan.cc	Thu May 28 10:22:59 2015 +0200
@@ -49,13 +49,6 @@
   NodeContainer nodes;
   nodes.Create(2);
 
-  LrWpanHelper lrWpanHelper;
-  // Add and install the LrWpanNetDevice for each node
-  NetDeviceContainer lrwpanDevices = lrWpanHelper.Install(nodes);
-
-  // Fake PAN association and short address assignment.
-  lrWpanHelper.AssociateToPan (lrwpanDevices, 0);
-
   MobilityHelper mobility;
   mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
   mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
@@ -68,6 +61,12 @@
   mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
   mobility.Install (nodes);
   
+  LrWpanHelper lrWpanHelper;
+  // Add and install the LrWpanNetDevice for each node
+  NetDeviceContainer lrwpanDevices = lrWpanHelper.Install(nodes);
+
+  // Fake PAN association and short address assignment.
+  lrWpanHelper.AssociateToPan (lrwpanDevices, 0);
 
   InternetStackHelper internetv6;
   internetv6.Install (nodes);