diff --git a/Ifish/airkiss/JMAirKissEncoder.m b/Ifish/airkiss/JMAirKissEncoder.m index 9442c2e..8c9d0fb 100644 --- a/Ifish/airkiss/JMAirKissEncoder.m +++ b/Ifish/airkiss/JMAirKissEncoder.m @@ -7,6 +7,7 @@ // #import "JMAirKissEncoder.h" +#import "ESP_CRC8.h" #define kRandomChar arc4random() % 127 @@ -96,6 +97,8 @@ Byte bytes[numberOfBytes]; NSRange range = NSMakeRange(0, numberOfBytes); [ssid getBytes:bytes maxLength:numberOfBytes usedLength:nil encoding:NSUTF8StringEncoding options:0 range:range remainingRange:NULL]; + NSData *ssidData = [[NSData alloc]initWithBytes:bytes length:numberOfBytes]; + [ssidData getBytes:bytes length:[ssidData length]]; UInt8 length = numberOfBytes + password.length + 1; UInt8 magicCode[4] = {0x00,0x00,0x00,0x00}; magicCode[0] = 0x00 | (length >> 4 & 0xF); @@ -107,7 +110,12 @@ magicCode[1] = 0x10 | (length & 0xF); UInt8 *cipherBuffer = (UInt8*)bytes; - UInt8 crc8 = CRC8(cipherBuffer, (int)numberOfBytes); + ESP_CRC8 *crc = [[ESP_CRC8 alloc]init]; + [crc updateWithBuf:bytes Nbytes:(int)sizeof(bytes)]; + Byte apSsidCrc = [crc getValue]; + + [crc reset]; + UInt8 crc8 = apSsidCrc;//CRC8(cipherBuffer, (int)numberOfBytes); magicCode[2] = 0x20 | (crc8 >> 4 & 0xF); magicCode[3] = 0x30 | (crc8 & 0xF);