diff --git a/qcbadge/Controllers/HomeController.cs b/qcbadge/Controllers/HomeController.cs index 2a8e6ff..214ff56 100644 --- a/qcbadge/Controllers/HomeController.cs +++ b/qcbadge/Controllers/HomeController.cs @@ -185,7 +185,20 @@ namespace qcbadge.Controllers //http://tomeko.net/online_tools/hex_to_base64.php?lang=en //for base64 convert - + + String crcData = advertData.Substring(24, 18); + System.Diagnostics.Debug.WriteLine("CRC to check: " + crcData.ToString()); + ushort crcrsp = CCITT_CRC16(crcData); + System.Diagnostics.Debug.WriteLine("CRC resp: " + crcrsp.ToString()); + byte[] recbytes = new byte[2]; + recbytes[0] = BitConverter.GetBytes(crcrsp)[0]; + recbytes[1] = BitConverter.GetBytes(crcrsp)[1]; + System.Diagnostics.Debug.WriteLine("CRC 1st byte: " + recbytes[0].ToString()); + System.Diagnostics.Debug.WriteLine("CRC 2nd byte: " + recbytes[1].ToString()); + byte crc8res = (byte)(recbytes[0] ^ recbytes[1]); + System.Diagnostics.Debug.WriteLine("CRC the byte: " + crc8res.ToString()); + + String qcData = advertData.Substring(24, 20); System.Diagnostics.Debug.WriteLine(qcData); @@ -246,6 +259,38 @@ namespace qcbadge.Controllers } } + + private ushort CCITT_CRC16(string strInput) + { + ushort data; + ushort crc = 0xFFFF; + byte[] bytes = StringToByteArray(strInput); + for (int j = 0; j < bytes.Length; j++) + { + crc = (ushort)(crc ^ bytes[j]); + for (int i = 0; i < 8; i++) + { + if ((crc & 0x0001) == 1) + crc = (ushort)((crc >> 1) ^ 0x8408); + else + crc >>= 1; + } + } + crc = (ushort)~crc; + data = crc; + crc = (ushort)((crc << 8) ^ (data >> 8 & 0xFF)); + return crc; + } + + public static byte[] StringToByteArray(String hex) + { + int NumberChars = hex.Length; + byte[] bytes = new byte[NumberChars / 2]; + for (int i = 0; i < NumberChars; i += 2) + bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16); + return bytes; + } + public IActionResult Error() { return View(); diff --git a/qcbadge/wwwroot/images/1-eb466664-61c2-11e7-a8e6-876b73c3292d.png b/qcbadge/wwwroot/images/1-eb466664-61c2-11e7-a8e6-876b73c3292d.png index 01d1044..94d4e62 100644 Binary files a/qcbadge/wwwroot/images/1-eb466664-61c2-11e7-a8e6-876b73c3292d.png and b/qcbadge/wwwroot/images/1-eb466664-61c2-11e7-a8e6-876b73c3292d.png differ diff --git a/qcbadge/wwwroot/images/10-eb469e40-61c2-11e7-a8ef-aff04cd092f4.png b/qcbadge/wwwroot/images/10-eb469e40-61c2-11e7-a8ef-aff04cd092f4.png index c9f3a5f..67f2227 100644 Binary files a/qcbadge/wwwroot/images/10-eb469e40-61c2-11e7-a8ef-aff04cd092f4.png and b/qcbadge/wwwroot/images/10-eb469e40-61c2-11e7-a8ef-aff04cd092f4.png differ diff --git a/qcbadge/wwwroot/images/11-eb46ccc6-61c2-11e7-a8f0-2ba14a609735.png b/qcbadge/wwwroot/images/11-eb46ccc6-61c2-11e7-a8f0-2ba14a609735.png index 9990d79..ec1a7d8 100644 Binary files a/qcbadge/wwwroot/images/11-eb46ccc6-61c2-11e7-a8f0-2ba14a609735.png and b/qcbadge/wwwroot/images/11-eb46ccc6-61c2-11e7-a8f0-2ba14a609735.png differ diff --git a/qcbadge/wwwroot/images/12-eb46e54e-61c2-11e7-a8f1-ffed42a32cd8.png b/qcbadge/wwwroot/images/12-eb46e54e-61c2-11e7-a8f1-ffed42a32cd8.png index 8c8f7d9..19cf225 100644 Binary files a/qcbadge/wwwroot/images/12-eb46e54e-61c2-11e7-a8f1-ffed42a32cd8.png and b/qcbadge/wwwroot/images/12-eb46e54e-61c2-11e7-a8f1-ffed42a32cd8.png differ diff --git a/qcbadge/wwwroot/images/13-eb473be8-61c2-11e7-a8f2-97169bffdcdc.png b/qcbadge/wwwroot/images/13-eb473be8-61c2-11e7-a8f2-97169bffdcdc.png new file mode 100644 index 0000000..a87273b Binary files /dev/null and b/qcbadge/wwwroot/images/13-eb473be8-61c2-11e7-a8f2-97169bffdcdc.png differ diff --git a/qcbadge/wwwroot/images/14-eb4757ea-61c2-11e7-a8f3-a758b83c2fd9.png b/qcbadge/wwwroot/images/14-eb4757ea-61c2-11e7-a8f3-a758b83c2fd9.png new file mode 100644 index 0000000..c5a71dd Binary files /dev/null and b/qcbadge/wwwroot/images/14-eb4757ea-61c2-11e7-a8f3-a758b83c2fd9.png differ diff --git a/qcbadge/wwwroot/images/15-eb476f3c-61c2-11e7-a8f4-0bc4085c363a.png b/qcbadge/wwwroot/images/15-eb476f3c-61c2-11e7-a8f4-0bc4085c363a.png new file mode 100644 index 0000000..f23f3d7 Binary files /dev/null and b/qcbadge/wwwroot/images/15-eb476f3c-61c2-11e7-a8f4-0bc4085c363a.png differ diff --git a/qcbadge/wwwroot/images/17-eb479746-61c2-11e7-a8f6-1b0d93caff33.png b/qcbadge/wwwroot/images/17-eb479746-61c2-11e7-a8f6-1b0d93caff33.png new file mode 100644 index 0000000..f41e74a Binary files /dev/null and b/qcbadge/wwwroot/images/17-eb479746-61c2-11e7-a8f6-1b0d93caff33.png differ diff --git a/qcbadge/wwwroot/images/18-eb47a9b6-61c2-11e7-a8f7-9f3b1ad0a5a8.png b/qcbadge/wwwroot/images/18-eb47a9b6-61c2-11e7-a8f7-9f3b1ad0a5a8.png new file mode 100644 index 0000000..06ec063 Binary files /dev/null and b/qcbadge/wwwroot/images/18-eb47a9b6-61c2-11e7-a8f7-9f3b1ad0a5a8.png differ diff --git a/qcbadge/wwwroot/images/19-eb48481c-61c2-11e7-a8f8-6f45fa8c1975.png b/qcbadge/wwwroot/images/19-eb48481c-61c2-11e7-a8f8-6f45fa8c1975.png new file mode 100644 index 0000000..5fc3992 Binary files /dev/null and b/qcbadge/wwwroot/images/19-eb48481c-61c2-11e7-a8f8-6f45fa8c1975.png differ diff --git a/qcbadge/wwwroot/images/20-eb48689c-61c2-11e7-a8f9-539d89786ce3.png b/qcbadge/wwwroot/images/20-eb48689c-61c2-11e7-a8f9-539d89786ce3.png new file mode 100644 index 0000000..4acbe2b Binary files /dev/null and b/qcbadge/wwwroot/images/20-eb48689c-61c2-11e7-a8f9-539d89786ce3.png differ diff --git a/qcbadge/wwwroot/images/21-eb4883fe-61c2-11e7-a8fa-afd62b20ce4e.png b/qcbadge/wwwroot/images/21-eb4883fe-61c2-11e7-a8fa-afd62b20ce4e.png new file mode 100644 index 0000000..3993aca Binary files /dev/null and b/qcbadge/wwwroot/images/21-eb4883fe-61c2-11e7-a8fa-afd62b20ce4e.png differ diff --git a/qcbadge/wwwroot/images/22-eb489934-61c2-11e7-a8fb-5bfa98429be6.png b/qcbadge/wwwroot/images/22-eb489934-61c2-11e7-a8fb-5bfa98429be6.png new file mode 100644 index 0000000..14891f2 Binary files /dev/null and b/qcbadge/wwwroot/images/22-eb489934-61c2-11e7-a8fb-5bfa98429be6.png differ diff --git a/qcbadge/wwwroot/images/23-eb48afbe-61c2-11e7-a8fc-afcec996e426.png b/qcbadge/wwwroot/images/23-eb48afbe-61c2-11e7-a8fc-afcec996e426.png new file mode 100644 index 0000000..66a1c54 Binary files /dev/null and b/qcbadge/wwwroot/images/23-eb48afbe-61c2-11e7-a8fc-afcec996e426.png differ diff --git a/qcbadge/wwwroot/images/24-eb48c526-61c2-11e7-a8fd-83245fd2c36f.png b/qcbadge/wwwroot/images/24-eb48c526-61c2-11e7-a8fd-83245fd2c36f.png new file mode 100644 index 0000000..6f2dda2 Binary files /dev/null and b/qcbadge/wwwroot/images/24-eb48c526-61c2-11e7-a8fd-83245fd2c36f.png differ diff --git a/qcbadge/wwwroot/images/25-eb48dc0a-61c2-11e7-a8fe-cb747a657a8b.png b/qcbadge/wwwroot/images/25-eb48dc0a-61c2-11e7-a8fe-cb747a657a8b.png new file mode 100644 index 0000000..6c65219 Binary files /dev/null and b/qcbadge/wwwroot/images/25-eb48dc0a-61c2-11e7-a8fe-cb747a657a8b.png differ diff --git a/qcbadge/wwwroot/images/27-eb4908e2-61c2-11e7-a900-637b158b5adf.png b/qcbadge/wwwroot/images/27-eb4908e2-61c2-11e7-a900-637b158b5adf.png new file mode 100644 index 0000000..29e16ad Binary files /dev/null and b/qcbadge/wwwroot/images/27-eb4908e2-61c2-11e7-a900-637b158b5adf.png differ diff --git a/qcbadge/wwwroot/images/29-eb4955b8-61c2-11e7-a902-0b0d12e5a8f4.png b/qcbadge/wwwroot/images/29-eb4955b8-61c2-11e7-a902-0b0d12e5a8f4.png new file mode 100644 index 0000000..4a62725 Binary files /dev/null and b/qcbadge/wwwroot/images/29-eb4955b8-61c2-11e7-a902-0b0d12e5a8f4.png differ diff --git a/qcbadge/wwwroot/images/30-eb4a1fa2-61c2-11e7-a903-f7eca7a7f055.png b/qcbadge/wwwroot/images/30-eb4a1fa2-61c2-11e7-a903-f7eca7a7f055.png new file mode 100644 index 0000000..e1db0d9 Binary files /dev/null and b/qcbadge/wwwroot/images/30-eb4a1fa2-61c2-11e7-a903-f7eca7a7f055.png differ diff --git a/qcbadge/wwwroot/images/31-eb4a3b68-61c2-11e7-a904-63fa9e2c47b0.png b/qcbadge/wwwroot/images/31-eb4a3b68-61c2-11e7-a904-63fa9e2c47b0.png new file mode 100644 index 0000000..34a3637 Binary files /dev/null and b/qcbadge/wwwroot/images/31-eb4a3b68-61c2-11e7-a904-63fa9e2c47b0.png differ diff --git a/qcbadge/wwwroot/images/32-eb4a4f9a-61c2-11e7-a905-dbe0daf1a7ce.png b/qcbadge/wwwroot/images/32-eb4a4f9a-61c2-11e7-a905-dbe0daf1a7ce.png new file mode 100644 index 0000000..a92c73c Binary files /dev/null and b/qcbadge/wwwroot/images/32-eb4a4f9a-61c2-11e7-a905-dbe0daf1a7ce.png differ diff --git a/qcbadge/wwwroot/images/37-eb4ac600-61c2-11e7-a90a-c7db722031cf.png b/qcbadge/wwwroot/images/37-eb4ac600-61c2-11e7-a90a-c7db722031cf.png new file mode 100644 index 0000000..855e006 Binary files /dev/null and b/qcbadge/wwwroot/images/37-eb4ac600-61c2-11e7-a90a-c7db722031cf.png differ diff --git a/qcbadge/wwwroot/images/38-eb4addf2-61c2-11e7-a90b-17d8801a3416.png b/qcbadge/wwwroot/images/38-eb4addf2-61c2-11e7-a90b-17d8801a3416.png new file mode 100644 index 0000000..11a1e16 Binary files /dev/null and b/qcbadge/wwwroot/images/38-eb4addf2-61c2-11e7-a90b-17d8801a3416.png differ diff --git a/qcbadge/wwwroot/images/39-eb4af26a-61c2-11e7-a90c-1300b2d20958.png b/qcbadge/wwwroot/images/39-eb4af26a-61c2-11e7-a90c-1300b2d20958.png new file mode 100644 index 0000000..6db0797 Binary files /dev/null and b/qcbadge/wwwroot/images/39-eb4af26a-61c2-11e7-a90c-1300b2d20958.png differ diff --git a/qcbadge/wwwroot/images/4-eb468036-61c2-11e7-a8e9-8fa59b75eeab.png b/qcbadge/wwwroot/images/4-eb468036-61c2-11e7-a8e9-8fa59b75eeab.png index 121a55b..8d251f0 100644 Binary files a/qcbadge/wwwroot/images/4-eb468036-61c2-11e7-a8e9-8fa59b75eeab.png and b/qcbadge/wwwroot/images/4-eb468036-61c2-11e7-a8e9-8fa59b75eeab.png differ diff --git a/qcbadge/wwwroot/images/5-eb4683ce-61c2-11e7-a8ea-2fb6e98c9f95.png b/qcbadge/wwwroot/images/5-eb4683ce-61c2-11e7-a8ea-2fb6e98c9f95.png index ec07149..f12ba80 100644 Binary files a/qcbadge/wwwroot/images/5-eb4683ce-61c2-11e7-a8ea-2fb6e98c9f95.png and b/qcbadge/wwwroot/images/5-eb4683ce-61c2-11e7-a8ea-2fb6e98c9f95.png differ diff --git a/qcbadge/wwwroot/images/6-eb4689c8-61c2-11e7-a8eb-b7408fd42ab8.png b/qcbadge/wwwroot/images/6-eb4689c8-61c2-11e7-a8eb-b7408fd42ab8.png index f2f5e4f..3793d1f 100644 Binary files a/qcbadge/wwwroot/images/6-eb4689c8-61c2-11e7-a8eb-b7408fd42ab8.png and b/qcbadge/wwwroot/images/6-eb4689c8-61c2-11e7-a8eb-b7408fd42ab8.png differ diff --git a/qcbadge/wwwroot/images/7-eb468e50-61c2-11e7-a8ec-1f2ea9f0ab82.png b/qcbadge/wwwroot/images/7-eb468e50-61c2-11e7-a8ec-1f2ea9f0ab82.png index 7230a20..60f1226 100644 Binary files a/qcbadge/wwwroot/images/7-eb468e50-61c2-11e7-a8ec-1f2ea9f0ab82.png and b/qcbadge/wwwroot/images/7-eb468e50-61c2-11e7-a8ec-1f2ea9f0ab82.png differ diff --git a/qcbadge/wwwroot/images/8-eb46929c-61c2-11e7-a8ed-8b3acc903f02.png b/qcbadge/wwwroot/images/8-eb46929c-61c2-11e7-a8ed-8b3acc903f02.png index ab2a725..3802aee 100644 Binary files a/qcbadge/wwwroot/images/8-eb46929c-61c2-11e7-a8ed-8b3acc903f02.png and b/qcbadge/wwwroot/images/8-eb46929c-61c2-11e7-a8ed-8b3acc903f02.png differ diff --git a/qcbadge/wwwroot/images/9-eb469634-61c2-11e7-a8ee-c739d63aed77.png b/qcbadge/wwwroot/images/9-eb469634-61c2-11e7-a8ee-c739d63aed77.png index d0fb640..eb97c5f 100644 Binary files a/qcbadge/wwwroot/images/9-eb469634-61c2-11e7-a8ee-c739d63aed77.png and b/qcbadge/wwwroot/images/9-eb469634-61c2-11e7-a8ee-c739d63aed77.png differ