public static IEnumerable <ushort> Encode(int passwordLength) { var frames = new ushort[4]; var blen = (byte)passwordLength; var lenCrc8 = Crc8.ComputeOnceOnly(blen); frames[0] = BytesHelper.CombineUshort(0x04, blen.Bisect().high); frames[1] = BytesHelper.CombineUshort(0x05, blen.Bisect().low); frames[2] = BytesHelper.CombineUshort(0x06, lenCrc8.Bisect().high); frames[3] = BytesHelper.CombineUshort(0x07, lenCrc8.Bisect().low); return(frames); }
public static IEnumerable <ushort> Encode(int totalLength, byte ssidCrc) { ushort[] frames = new ushort[4]; var blen = (byte)totalLength; var firstFrame = BytesHelper.CombineUshort(0x00, blen.Bisect().high); frames[0] = firstFrame != 0 ? firstFrame : (ushort)0x08; frames[1] = BytesHelper.CombineUshort(0x01, blen.Bisect().low); frames[2] = BytesHelper.CombineUshort(0x02, ssidCrc.Bisect().high); frames[3] = BytesHelper.CombineUshort(0x03, ssidCrc.Bisect().low); return(frames); }
public void CombineUshortShouldWorks() { Assert.AreEqual((ushort)0x43, BytesHelper.CombineUshort(0x4, 0x3)); }