m2mer / AdvancedLighting_Gateway

1 stars 0 forks source link

strange value assignment issue #1

Closed m2mer closed 6 years ago

m2mer commented 6 years ago

Very strange that sometimes 'stAgg.sequence' can't be assigned correct value, most happen when Gateway powered on for the first time.

if(sequence < _stAgg.sequence) return false; // old status, abandon else if(sequence > _stAgg.sequence) { //DEBUG_MESH.printf("in seq %d, _seq %d\n", sequence, _stAgg.sequence); _stAgg.segmentMap = 0; // new status, clear old map _stAgg.sequence = sequence; }

m2mer commented 6 years ago

init value of _stAgg.sequence is not zero, add init 0 handling

m2mer commented 6 years ago

seems ESP8266 memory issue, if re-enter a function in 40ms, memory value can't be set correctly.

m2mer commented 6 years ago

sometimes happen even when more than 100ms, and more often happen on a new malloc memory.

m2mer commented 6 years ago

found the rule is the malloced memory can't be set value after pointer used by others, and can be set correctly before used.

nodeP = new meshNode(devAddr);
nodeP->setAggBuffId(i);

/* must be at last */
this->_meshNodeList.add(*nodeP);