Forcing Multihop
NOTE: this is a workaround for debugging purposes. This code is not intended for permanent use but only in case that you want to force a certain topology.
Forcing Multihop in OpenWSN has been simplified.
Follow this simple steps:
Edit file topology.c in 02a-MACLow folder
Modify TOPOLOGY_MOTEX by adding the 16bit UID of your motes to form a topology.
#include "openwsn.h"
#include "topology.h"
#include "idmanager.h"
//=========================== defines =========================================
#define TOPOLOGY_MOTE1 0x01
#define TOPOLOGY_MOTE2 0x02
#define TOPOLOGY_MOTE3 0x03
#define TOPOLOGY_MOTE4 0x04
//=========================== variables =======================================
//=========================== prototypes ======================================
//=========================== public ==========================================
bool topology_isAcceptablePacket(ieee802154_header_iht* ieee802514_header) {
bool returnVal;
switch (idmanager_getMyID(ADDR_64B)->addr_64b[7]) {
case TOPOLOGY_MOTE1:
if (ieee802514_header->src.addr_64b[7]==TOPOLOGY_MOTE2) {
returnVal=TRUE;
} else {
returnVal=FALSE;
}
break;
case TOPOLOGY_MOTE2:
if (ieee802514_header->src.addr_64b[7]==TOPOLOGY_MOTE1 ||
ieee802514_header->src.addr_64b[7]==TOPOLOGY_MOTE3) {
returnVal=TRUE;
} else {
returnVal=FALSE;
}
break;
case TOPOLOGY_MOTE3:
if (ieee802514_header->src.addr_64b[7]==TOPOLOGY_MOTE2 ||
ieee802514_header->src.addr_64b[7]==TOPOLOGY_MOTE4) {
returnVal=TRUE;
} else {
returnVal=FALSE;
}
break;
case TOPOLOGY_MOTE4:
if (ieee802514_header->src.addr_64b[7]==TOPOLOGY_MOTE3) {
returnVal=TRUE;
} else {
returnVal=FALSE;
}
break;
default:
returnVal=TRUE;
}
return returnVal;
}
In this example a 3 hop topology is being defined where Mote with 16bit UID = 0x01 will be the DAGroot. Mote with 16bit UID = 0x02 will be the first hop, Mote with 16bit UID = 0x03 will be the second hop and Mote with 16bit UID = 0x04 will be the third hop.