bugfix: only write to infomem if empty
This commit is contained in:
parent
7c125ced9a
commit
96968cb35e
|
@ -84,7 +84,18 @@ public class MspMoteID extends MoteID {
|
|||
moteID = newID;
|
||||
|
||||
/* Write node-unique infomem entry, used to configure node_id and node_mac */
|
||||
if (mote.getMemory().getMemorySegment(0x1980, 10) != null) {
|
||||
byte[] infomemCurrent = mote.getMemory().getMemorySegment(0x1980, 10);
|
||||
if (infomemCurrent != null) {
|
||||
/* Only write to infomem is nothing else resides there */
|
||||
boolean ffOnly = true;
|
||||
for (byte b: infomemCurrent) {
|
||||
if (b != (byte) 0xff) {
|
||||
ffOnly = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ffOnly) {
|
||||
byte[] infomem = new byte[10];
|
||||
infomem[0] = (byte) 0xab; /* magic */
|
||||
infomem[1] = (byte) 0xcd; /* magic */
|
||||
|
@ -98,6 +109,7 @@ public class MspMoteID extends MoteID {
|
|||
infomem[9] = (byte) (newID & 0xFF);
|
||||
mote.getMemory().setMemorySegment(0x1980, infomem);
|
||||
}
|
||||
}
|
||||
|
||||
if (moteMem.variableExists("node_id")) {
|
||||
moteMem.setIntValueOf("node_id", moteID);
|
||||
|
|
Loading…
Reference in a new issue