完善连接热点udp指令

This commit is contained in:
xuemh
2018-08-06 21:37:34 +08:00
parent cdd634df71
commit 4546e0b981
7 changed files with 62 additions and 8 deletions
@@ -28,7 +28,7 @@
-(void)broadCaseUDP{
self.loopTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(sendLoopSoketdata) userInfo:nil repeats:YES];
self.loopTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(sendConnectHotspotSoketdata) userInfo:nil repeats:YES];
}
@@ -123,7 +123,7 @@
- (void)sendToDeviceWithSSIDName:(NSString *)name andSSIDPWD:(NSString *)pwd {
[IFishHotpotUDPHelper sharedInstance].delegate = self;
[[IFishHotpotUDPHelper sharedInstance] broadCaseUDPWith:name pwd:pwd];
[[IFishHotpotUDPHelper sharedInstance] broadCastHotspotConnectCommandWith:name pwd:pwd];
}
#pragma mark - IFishHotpotUDPHelperDelegate
@@ -0,0 +1,16 @@
//
// ConnectHotspotModel.h
// Ifish
//
// Created by Minghao Xue on 2018/8/6.
// Copyright © 2018年 lianlian. All rights reserved.
//
#import "baseModel.h"
@interface ConnectHotspotModel : baseModel
@property (nonatomic, copy) NSString *ssidName;
@property (nonatomic, copy) NSString *pwd;
@end
@@ -0,0 +1,28 @@
//
// ConnectHotspotModel.m
// Ifish
//
// Created by Minghao Xue on 2018/8/6.
// Copyright © 2018年 lianlian. All rights reserved.
//
#import "ConnectHotspotModel.h"
@implementation ConnectHotspotModel
- (NSString *)description{
self.messagetype=@"00";
self.massagelegth=@"48";
self.functionCode=@"12";
self.sendmacId = @"000000000000";
self.resavemacId = @"000000000000";
return [NSString stringWithFormat:@"%@%@%@%@%@%@%@%@", self.messagetype,self.functionCode,self.sendmacId,self.resavemacId,self.massagelegth,[dataContorl hexStringFromString:self.ssidName], [dataContorl hexStringFromString:self.pwd],[self crcCode]];
}
- (NSString *)crcCode {
return @"0000";
}
@end
@@ -25,6 +25,6 @@
@property (nonatomic, weak) id<IFishHotpotUDPHelperDelegate> delegate;
-(void)broadCaseUDPWith:(NSString *)ssidName pwd:(NSString *)pwd;
-(void)broadCastHotspotConnectCommandWith:(NSString *)ssidName pwd:(NSString *)pwd;
@end
@@ -9,6 +9,7 @@
#import "IFishHotpotUDPHelper.h"
#import "LxGetCurrentIp.h"
#import "AppDelegate.h"
#import "ConnectHotspotModel.h"
@interface IFishHotpotUDPHelper ()
{
@@ -31,18 +32,21 @@
return sharedInstace;
}
- (void)broadCaseUDPWith:(NSString *)ssidName pwd:(NSString *)pwd {
- (void)broadCastHotspotConnectCommandWith:(NSString *)ssidName pwd:(NSString *)pwd {
_ssidName = ssidName;
_pwd = pwd;
self.loopTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(sendLoopSoketdata) userInfo:nil repeats:YES];
self.loopTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(sendConnectHotspotSoketdata) userInfo:nil repeats:YES];
}
-(void)sendLoopSoketdata{
-(void)sendConnectHotspotSoketdata{
NSString* hostS = @"192.168.4.1";
self.clientSocket = [[AsyncUdpSocket alloc] initWithDelegate:self];
//120.55.190.56 服务器IP 指令中用
NSString *request=@"0007000000000000000000000000273132302e35352e3139302e353600000000000000bbbb0000";
ConnectHotspotModel *model = [ConnectHotspotModel new];
model.ssidName = _ssidName;
model.pwd = _pwd;
NSString *request=[NSString stringWithFormat:@"%@", model.description];
NSData *data=[dataContorl stringToHexData:request];
@@ -71,7 +75,7 @@
NSLog(@"didReceiveData%@",result);
NSLog(@"port%hu",port);
AppDelegate *app =(AppDelegate*)[UIApplication sharedApplication].delegate;
[app.window makeToast:@"切换成功"];
[app.window makeToast:[NSString stringWithFormat:@"收到答复:%@", result]];
[self.loopTimer invalidate];
return YES;