中文和eps的广播地址处理

This commit is contained in:
祝发冬
2023-09-05 19:09:18 +08:00
parent ad1e90604b
commit 128c00989c
4 changed files with 13 additions and 11 deletions
+1 -5
View File
@@ -77,11 +77,7 @@
*/
- (void)connectAirKissWithSSID:(NSString *)ssidStr
password:(NSString *)password {
//处理中文的情况
if([self validateContainsChinese:ssidStr])
{
ssidStr = [ssidStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
}
NSMutableArray *dataArray = [_airKissEncoder createAirKissEncorderWithSSID:ssidStr ? :@""
password:password ? :@""];
+8 -3
View File
@@ -91,7 +91,12 @@
*/
- (void)getMagicCodeWithSSID:(NSString *)ssid
password:(NSString *)password {
UInt8 length = ssid.length + password.length + 1;
NSUInteger numberOfBytes = [ssid lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
Byte bytes[numberOfBytes];
NSRange range = NSMakeRange(0, numberOfBytes);
[ssid getBytes:bytes maxLength:numberOfBytes usedLength:nil encoding:NSUTF8StringEncoding options:0 range:range remainingRange:NULL];
UInt8 length = numberOfBytes + password.length + 1;
UInt8 magicCode[4] = {0x00,0x00,0x00,0x00};
magicCode[0] = 0x00 | (length >> 4 & 0xF);
@@ -101,8 +106,8 @@
magicCode[1] = 0x10 | (length & 0xF);
UInt8 *cipherBuffer = (UInt8*)[ssid UTF8String];
UInt8 crc8 = CRC8(cipherBuffer, (int)ssid.length);
UInt8 *cipherBuffer = (UInt8*)bytes;
UInt8 crc8 = CRC8(cipherBuffer, (int)numberOfBytes);
magicCode[2] = 0x20 | (crc8 >> 4 & 0xF);
magicCode[3] = 0x30 | (crc8 & 0xF);