中文和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

View File

@ -16101,7 +16101,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 11;
DEVELOPMENT_TEAM = WFX8GD5HFX;
ENABLE_BITCODE = NO;
ENABLE_TESTABILITY = YES;
@ -16221,7 +16221,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 11;
DEVELOPMENT_TEAM = WFX8GD5HFX;
ENABLE_BITCODE = NO;
ENABLE_TESTABILITY = YES;

View File

@ -150,7 +150,8 @@ static int _datagramCount = 0;
if (self.broadcast) {
NSString *localInetAddr4 = [ESP_NetUtil getLocalIPv4];
NSArray *arr = [localInetAddr4 componentsSeparatedByString:@"."];
return [NSString stringWithFormat:@"%@.%@.%@.255",arr[0], arr[1], arr[2]];
//[NSString stringWithFormat:@"%@.%@.%@.255",arr[0], arr[1], arr[2]];
return @"255.255.255.255";
} else {
int count = [self __getNextDatagramCount];
return [NSString stringWithFormat: @"234.%d.%d.%d", count, count, count];

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 ? :@""];

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);