public void decode(RadioLog.Common.SafeBitArray message, int start, int end) { /* load each of the nodes with deinterleaved constellations */ for (int index = 0; index < 49; index++) { Constellation c = getConstellation(message, index * 4); mConstellationNodes[index].setConstellation(c); } /* test to see if constellations are correct - otherwise correct them */ ConstellationNode firstNode = mConstellationNodes[0]; if (!firstNode.startsWith(Dibit.D0) || !firstNode.isCorrect()) { firstNode.correctTo(Dibit.D0); } /* clear constellations from original message */ message.ClearRange(start, end - start); /* replace with decoded values from the nodes */ for (int index = 0; index < 49; index++) { ConstellationNode node = mConstellationNodes[index]; if (node.firstBit()) { message.SetBit(start + (index * 2)); } if (node.secondBit()) { message.SetBit(start + (index * 2) + 1); } } }
public static RadioLog.Common.SafeBitArray interleave(RadioLog.Common.SafeBitArray message, int start, int end) { RadioLog.Common.SafeBitArray original = message.CloneFromIndexToIndex(start, end); /* Clear block bits in source message */ message.ClearRange(start, end); /* Iterate only the set bits in the original message and apply * the deinterleave -- we don't have to evaluate the 0 bits */ for (int i = original.nextSetBit(0); i >= 0 && i < INTERLEAVE.Length; i = original.nextSetBit(i + 1)) { message.SetBit(start + INTERLEAVE[i]); } return(message); }
public void Receive(bool softBit) { if (mSampleCounter >= 0) { if (softBit) { mBitSet.SetBit(mSampleCounter); } else { mBitSet.ClearBit(mSampleCounter); } } mSampleCounter++; if (mSampleCounter >= mSymbolLength) { bool decision = mBitSet.Cardinality() >= mDecisionThreshold; send(decision); /* Shift timing left if the left bit in the bitset is opposite * the decision and the right bit is the same */ if ((mBitSet[0] ^ decision) && (!(mBitSet[mSymbolLength - 1] ^ decision))) { sendTapEvent(mBitSet, Shift.LEFT, decision); reset(); mSampleCounter--; } /* Shift timing right if the left bit is the same as the * decision and the right bit is opposite */ else if ((!(mBitSet[0] ^ decision)) && (mBitSet[mSymbolLength - 1] ^ decision)) { sendTapEvent(mBitSet, Shift.RIGHT, decision); /* Last bit from previous symbol to pre-fill next symbol */ bool previousSoftBit = mBitSet[mSymbolLength - 1]; reset(); if (previousSoftBit) { mBitSet.SetBit(0); } mSampleCounter++; } /* No shift */ else { sendTapEvent(mBitSet, Shift.NONE, decision); reset(); } } }