epptouch sdk更新,闪退修改强化
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// ESPTouchDelegate.h
|
||||
// EspTouchDemo
|
||||
//
|
||||
// Created by fby on 8/14/15.
|
||||
// Copyright (c) 2015 fby. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ESPTouchResult.h"
|
||||
|
||||
|
||||
@protocol ESPTouchDelegate <NSObject>
|
||||
|
||||
/**
|
||||
* when new esptouch result is added, the listener will call
|
||||
* onEsptouchResultAdded callback
|
||||
*
|
||||
* @param result
|
||||
* the Esptouch result
|
||||
*/
|
||||
-(void) onEsptouchResultAddedWithResult: (ESPTouchResult *) result;
|
||||
|
||||
@end
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// ESPTouchResult.h
|
||||
// EspTouchDemo
|
||||
//
|
||||
// Created by fby on 4/14/15.
|
||||
// Copyright (c) 2015 fby. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface ESPTouchResult : NSObject
|
||||
|
||||
// it is used to check whether the esptouch task is executed suc
|
||||
@property (nonatomic,assign) BOOL isSuc;
|
||||
|
||||
// it is used to store the device's bssid
|
||||
@property (nonatomic,strong) NSString * bssid;
|
||||
|
||||
// it is used to check whether the esptouch task is cancelled by user
|
||||
@property (atomic,assign) BOOL isCancelled;
|
||||
|
||||
// it is used to store the device's ip address
|
||||
@property (atomic) NSData * ipAddrData;
|
||||
|
||||
/**
|
||||
* Constructor of EsptouchResult
|
||||
*
|
||||
* @param isSuc whether the esptouch task is executed suc
|
||||
* @param bssid the device's bssid
|
||||
* @param ipAddrData the device's ip address
|
||||
*/
|
||||
- (id) initWithIsSuc: (BOOL) isSuc andBssid: (NSString *) bssid andInetAddrData: (NSData *) ipAddrData;
|
||||
|
||||
- (NSString *) getAddressString;
|
||||
|
||||
@end
|
||||
@@ -1,115 +0,0 @@
|
||||
//
|
||||
// ESPTouchTask.h
|
||||
// EspTouchDemo
|
||||
//
|
||||
// Created by fby on 4/14/15.
|
||||
// Copyright (c) 2015 fby. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ESPTouchResult.h"
|
||||
#import "ESPTouchDelegate.h"
|
||||
#import "ESPAES.h"
|
||||
|
||||
#define ESPTOUCH_VERSION @"SDK-v1.0.0"
|
||||
|
||||
#define DEBUG_ON YES
|
||||
|
||||
@interface ESPTouchTask : NSObject
|
||||
|
||||
@property (atomic,assign) BOOL isCancelled;
|
||||
|
||||
- (id)initWithApSsid:(NSString *)apSsid andApBssid:(NSString *)apBssid andApPwd:(NSString *)apPwd andAES:(ESPAES *)aes;
|
||||
|
||||
/**
|
||||
* Constructor of EsptouchTask
|
||||
*
|
||||
* @param apSsid
|
||||
* the Ap's ssid
|
||||
* @param apBssid
|
||||
* the Ap's bssid
|
||||
* @param apPwd
|
||||
* the Ap's password
|
||||
*/
|
||||
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd;
|
||||
|
||||
/**
|
||||
* Deprecated
|
||||
*/
|
||||
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andIsSsidHiden: (BOOL) isSsidHidden __deprecated_msg("Use initWithApSsid:(NSString *) andApBssid:(NSString *) andApPwd:(NSString *) instead.");
|
||||
|
||||
/**
|
||||
* Constructor of EsptouchTask
|
||||
*
|
||||
* @param apSsid
|
||||
* the Ap's ssid
|
||||
* @param apBssid
|
||||
* the Ap's bssid
|
||||
* @param apPwd
|
||||
* the Ap's password
|
||||
* @param timeoutMillisecond (it should be >= 15000+6000)
|
||||
* millisecond of total timeout
|
||||
*/
|
||||
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andTimeoutMillisecond: (int) timeoutMillisecond;
|
||||
|
||||
/**
|
||||
* Constructor of EsptouchTask
|
||||
*
|
||||
* @param apSsid
|
||||
* the Ap's ssid
|
||||
* @param apBssid
|
||||
* the Ap's bssid
|
||||
* @param apPwd
|
||||
* the Ap's password
|
||||
* @param isSsidHidden
|
||||
* whether the Ap's ssid is hidden
|
||||
* @param timeoutMillisecond (it should be >= 15000+6000)
|
||||
* millisecond of total timeout
|
||||
*/
|
||||
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andIsSsidHiden: (BOOL) isSsidHidden andTimeoutMillisecond: (int) timeoutMillisecond __deprecated_msg("Use initWithApSsid:(NSString *) andApBssid:(NSString *) andApPwd:(NSString *) andTimeoutMillisecond:(int) instead.");
|
||||
|
||||
/**
|
||||
* Interrupt the Esptouch Task when User tap back or close the Application.
|
||||
*/
|
||||
- (void) interrupt;
|
||||
|
||||
/**
|
||||
* Note: !!!Don't call the task at UI Main Thread
|
||||
*
|
||||
* Smart Config v2.4 support the API
|
||||
*
|
||||
* @return the ESPTouchResult
|
||||
*/
|
||||
- (ESPTouchResult*) executeForResult;
|
||||
|
||||
/**
|
||||
* Note: !!!Don't call the task at UI Main Thread
|
||||
*
|
||||
* Smart Config v2.4 support the API
|
||||
*
|
||||
* It will be blocked until the client receive result count >= expectTaskResultCount.
|
||||
* If it fail, it will return one fail result will be returned in the list.
|
||||
* If it is cancelled while executing,
|
||||
* if it has received some results, all of them will be returned in the list.
|
||||
* if it hasn't received any results, one cancel result will be returned in the list.
|
||||
*
|
||||
* @param expectTaskResultCount
|
||||
* the expect result count(if expectTaskResultCount <= 0,
|
||||
* expectTaskResultCount = INT32_MAX)
|
||||
* @return the NSArray of EsptouchResult
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
- (NSArray*) executeForResults:(int) expectTaskResultCount;
|
||||
|
||||
/**
|
||||
* set the esptouch delegate, when one device is connected to the Ap, it will be called back
|
||||
* @param esptouchDelegate when one device is connected to the Ap, it will be called back
|
||||
*/
|
||||
- (void) setEsptouchDelegate: (NSObject<ESPTouchDelegate> *) esptouchDelegate;
|
||||
|
||||
/**
|
||||
* Set boradcast or multicast when post config info
|
||||
* @param broadcast YES is boradcast, NO is multicast
|
||||
*/
|
||||
- (void) setPackageBroadcast: (BOOL) broadcast;
|
||||
@end
|
||||
@@ -62,20 +62,19 @@
|
||||
|
||||
- (id)initWithApSsid:(NSString *)apSsid andApBssid:(NSString *)apBssid andApPwd:(NSString *)apPwd andAES:(ESPAES *)aes
|
||||
{
|
||||
self = [super init];
|
||||
NSLog(@"Welcome Esptouch %@",ESPTOUCH_VERSION);
|
||||
if (apSsid==nil||[apSsid isEqualToString:@""])
|
||||
{
|
||||
perror("ESPTouchTask initWithApSsid() apSsid shouldn't be null or empty");
|
||||
return self;
|
||||
}
|
||||
// the apSsid should be null or empty
|
||||
assert(apSsid!=nil&&![apSsid isEqualToString:@""]);
|
||||
// assert(apSsid!=nil&&![apSsid isEqualToString:@""]);
|
||||
if (apPwd == nil)
|
||||
{
|
||||
apPwd = @"";
|
||||
}
|
||||
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
if (DEBUG_ON)
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
|
||||
/**
|
||||
* set whether the router support IPv6
|
||||
* @param isIPv6Supported whether the router support IPv6
|
||||
* @param isIPv4Supported whether the router support IPv6
|
||||
*/
|
||||
- (void) setIsIPv6Supported:(BOOL) isIPv6Supported;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "ESPTouchTaskParameter.h"
|
||||
#import "ESP_NetUtil.h"
|
||||
|
||||
@interface ESPTaskParameter()
|
||||
@property (nonatomic,assign) long intervalGuideCodeMillisecond;
|
||||
@@ -147,7 +148,9 @@ static int _datagramCount = 0;
|
||||
{
|
||||
if (_isIPv4Supported0) {
|
||||
if (self.broadcast) {
|
||||
return @"255.255.255.255";
|
||||
NSString *localInetAddr4 = [ESP_NetUtil getLocalIPv4];
|
||||
NSArray *arr = [localInetAddr4 componentsSeparatedByString:@"."];
|
||||
return [NSString stringWithFormat:@"%@.%@.%@.255",arr[0], arr[1], arr[2]];
|
||||
} else {
|
||||
int count = [self __getNextDatagramCount];
|
||||
return [NSString stringWithFormat: @"234.%d.%d.%d", count, count, count];
|
||||
|
||||
Reference in New Issue
Block a user