更新EsptouchForIOS

This commit is contained in:
kai60 2020-06-10 20:27:25 +08:00
parent 1f69653c19
commit b8d6ad08ea
42 changed files with 1625 additions and 853 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -2175,19 +2175,6 @@
88F23F2D1EA9D18700E4D298 /* live_label_v.png in Resources */ = {isa = PBXBuildFile; fileRef = 88F23F211EA9D18700E4D298 /* live_label_v.png */; };
88F23F2E1EA9D18700E4D298 /* live_label_v@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 88F23F221EA9D18700E4D298 /* live_label_v@2x.png */; };
88F23F2F1EA9D18700E4D298 /* live_label_v@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 88F23F231EA9D18700E4D298 /* live_label_v@3x.png */; };
88F5EE4C1D48CA2800CC7CAF /* ESP_ByteUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECC11D48CA2800CC7CAF /* ESP_ByteUtil.m */; };
88F5EE4D1D48CA2800CC7CAF /* ESP_CRC8.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECC31D48CA2800CC7CAF /* ESP_CRC8.m */; };
88F5EE4E1D48CA2800CC7CAF /* ESP_NetUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECC51D48CA2800CC7CAF /* ESP_NetUtil.m */; };
88F5EE4F1D48CA2800CC7CAF /* IPAddress.c in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECC61D48CA2800CC7CAF /* IPAddress.c */; };
88F5EE501D48CA2800CC7CAF /* ESPTouchResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECCB1D48CA2800CC7CAF /* ESPTouchResult.m */; };
88F5EE511D48CA2800CC7CAF /* ESPTouchTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECCD1D48CA2800CC7CAF /* ESPTouchTask.m */; };
88F5EE521D48CA2800CC7CAF /* ESPTouchTaskParameter.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECCF1D48CA2800CC7CAF /* ESPTouchTaskParameter.m */; };
88F5EE531D48CA2800CC7CAF /* ESPUDPSocketClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECD11D48CA2800CC7CAF /* ESPUDPSocketClient.m */; };
88F5EE541D48CA2800CC7CAF /* ESPUDPSocketServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECD31D48CA2800CC7CAF /* ESPUDPSocketServer.m */; };
88F5EE551D48CA2800CC7CAF /* ESPDataCode.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECD61D48CA2800CC7CAF /* ESPDataCode.m */; };
88F5EE561D48CA2800CC7CAF /* ESPDatumCode.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECD81D48CA2800CC7CAF /* ESPDatumCode.m */; };
88F5EE571D48CA2800CC7CAF /* ESPGuideCode.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECDA1D48CA2800CC7CAF /* ESPGuideCode.m */; };
88F5EE581D48CA2800CC7CAF /* ESPTouchGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5ECDC1D48CA2800CC7CAF /* ESPTouchGenerator.m */; };
88F5EFA91D48D08100CC7CAF /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5EEEC1D48D08000CC7CAF /* AFHTTPRequestOperation.m */; };
88F5EFAA1D48D08100CC7CAF /* AFHTTPRequestOperationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5EEEE1D48D08000CC7CAF /* AFHTTPRequestOperationManager.m */; };
88F5EFAB1D48D08100CC7CAF /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5EEF01D48D08000CC7CAF /* AFHTTPSessionManager.m */; };
@ -2258,6 +2245,38 @@
C024B7B12379668B00509424 /* NSMutableArray+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B79D2379668B00509424 /* NSMutableArray+AvoidCrash.h */; };
C0837A57244FF5510034FEC5 /* EGOCache.m in Sources */ = {isa = PBXBuildFile; fileRef = C0837A55244FF5500034FEC5 /* EGOCache.m */; };
C0837A58244FF5510034FEC5 /* EGOCache.h in Headers */ = {isa = PBXBuildFile; fileRef = C0837A56244FF5500034FEC5 /* EGOCache.h */; };
C0873EE12491060000D47D34 /* ESPUDPSocketClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EBE249105FF00D47D34 /* ESPUDPSocketClient.h */; };
C0873EE22491060000D47D34 /* ESPUDPSocketServer.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873EBF249105FF00D47D34 /* ESPUDPSocketServer.m */; };
C0873EE32491060000D47D34 /* ESPUDPSocketClient.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873EC0249105FF00D47D34 /* ESPUDPSocketClient.m */; };
C0873EE42491060000D47D34 /* ESPUDPSocketServer.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EC1249105FF00D47D34 /* ESPUDPSocketServer.h */; };
C0873EE52491060000D47D34 /* ESPGuideCode.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873EC3249105FF00D47D34 /* ESPGuideCode.m */; };
C0873EE62491060000D47D34 /* ESPTouchGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873EC4249105FF00D47D34 /* ESPTouchGenerator.m */; };
C0873EE72491060000D47D34 /* ESPDataCode.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EC5249105FF00D47D34 /* ESPDataCode.h */; };
C0873EE82491060000D47D34 /* ESPDatumCode.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EC6249105FF00D47D34 /* ESPDatumCode.h */; };
C0873EE92491060000D47D34 /* ESPGuideCode.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EC7249105FF00D47D34 /* ESPGuideCode.h */; };
C0873EEA2491060000D47D34 /* ESPDataCode.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873EC8249105FF00D47D34 /* ESPDataCode.m */; };
C0873EEB2491060000D47D34 /* ESPTouchGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EC9249105FF00D47D34 /* ESPTouchGenerator.h */; };
C0873EEC2491060000D47D34 /* ESPDatumCode.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873ECA249105FF00D47D34 /* ESPDatumCode.m */; };
C0873EED2491060000D47D34 /* ESPTools.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873ECC249105FF00D47D34 /* ESPTools.m */; };
C0873EEE2491060000D47D34 /* ESP_NetUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873ECD249105FF00D47D34 /* ESP_NetUtil.m */; };
C0873EEF2491060000D47D34 /* ESP_ByteUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873ECE249105FF00D47D34 /* ESP_ByteUtil.m */; };
C0873EF02491060000D47D34 /* ESP_WifiUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873ECF249105FF00D47D34 /* ESP_WifiUtil.m */; };
C0873EF12491060000D47D34 /* ESP_CRC8.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873ED0249105FF00D47D34 /* ESP_CRC8.m */; };
C0873EF22491060000D47D34 /* ESPVersionMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873ED1249105FF00D47D34 /* ESPVersionMacro.h */; };
C0873EF32491060000D47D34 /* ESPAES.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873ED2249105FF00D47D34 /* ESPAES.h */; };
C0873EF42491060000D47D34 /* ESP_NetUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873ED3249105FF00D47D34 /* ESP_NetUtil.h */; };
C0873EF52491060000D47D34 /* ESP_ByteUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873ED4249105FF00D47D34 /* ESP_ByteUtil.h */; };
C0873EF62491060000D47D34 /* ESPTools.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873ED5249105FF00D47D34 /* ESPTools.h */; };
C0873EF72491060000D47D34 /* ESP_CRC8.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873ED6249105FF00D47D34 /* ESP_CRC8.h */; };
C0873EF82491060000D47D34 /* ESP_WifiUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873ED7249105FF00D47D34 /* ESP_WifiUtil.h */; };
C0873EF92491060000D47D34 /* ESPAES.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873ED8249105FF00D47D34 /* ESPAES.m */; };
C0873EFA2491060000D47D34 /* ESPTouchResult.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873EDA2491060000D47D34 /* ESPTouchResult.m */; };
C0873EFB2491060000D47D34 /* ESPTouchTaskParameter.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EDB2491060000D47D34 /* ESPTouchTaskParameter.h */; };
C0873EFC2491060000D47D34 /* ESPTouchTask.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EDC2491060000D47D34 /* ESPTouchTask.h */; };
C0873EFD2491060000D47D34 /* ESPTouchResult.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EDD2491060000D47D34 /* ESPTouchResult.h */; };
C0873EFE2491060000D47D34 /* ESPTouchDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EDE2491060000D47D34 /* ESPTouchDelegate.h */; };
C0873EFF2491060000D47D34 /* ESPTouchTaskParameter.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873EDF2491060000D47D34 /* ESPTouchTaskParameter.m */; };
C0873F002491060000D47D34 /* ESPTouchTask.m in Sources */ = {isa = PBXBuildFile; fileRef = C0873EE02491060000D47D34 /* ESPTouchTask.m */; };
C0B2F541244C6FE3001079AA /* PetStoresViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B2F53E244C6FE3001079AA /* PetStoresViewController.h */; };
C0B2F542244C6FE3001079AA /* PetStoresViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0B2F53F244C6FE3001079AA /* PetStoresViewController.m */; };
C0B2F543244C6FE3001079AA /* PetStoresViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0B2F540244C6FE3001079AA /* PetStoresViewController.xib */; };
@ -5561,33 +5580,6 @@
88F23F211EA9D18700E4D298 /* live_label_v.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = live_label_v.png; sourceTree = "<group>"; };
88F23F221EA9D18700E4D298 /* live_label_v@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "live_label_v@2x.png"; sourceTree = "<group>"; };
88F23F231EA9D18700E4D298 /* live_label_v@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "live_label_v@3x.png"; sourceTree = "<group>"; };
88F5ECC01D48CA2800CC7CAF /* ESP_ByteUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESP_ByteUtil.h; sourceTree = "<group>"; };
88F5ECC11D48CA2800CC7CAF /* ESP_ByteUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESP_ByteUtil.m; sourceTree = "<group>"; };
88F5ECC21D48CA2800CC7CAF /* ESP_CRC8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESP_CRC8.h; sourceTree = "<group>"; };
88F5ECC31D48CA2800CC7CAF /* ESP_CRC8.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESP_CRC8.m; sourceTree = "<group>"; };
88F5ECC41D48CA2800CC7CAF /* ESP_NetUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESP_NetUtil.h; sourceTree = "<group>"; };
88F5ECC51D48CA2800CC7CAF /* ESP_NetUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESP_NetUtil.m; sourceTree = "<group>"; };
88F5ECC61D48CA2800CC7CAF /* IPAddress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = IPAddress.c; sourceTree = "<group>"; };
88F5ECC71D48CA2800CC7CAF /* IPAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPAddress.h; sourceTree = "<group>"; };
88F5ECC91D48CA2800CC7CAF /* ESPTouchDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchDelegate.h; sourceTree = "<group>"; };
88F5ECCA1D48CA2800CC7CAF /* ESPTouchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchResult.h; sourceTree = "<group>"; };
88F5ECCB1D48CA2800CC7CAF /* ESPTouchResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTouchResult.m; sourceTree = "<group>"; };
88F5ECCC1D48CA2800CC7CAF /* ESPTouchTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchTask.h; sourceTree = "<group>"; };
88F5ECCD1D48CA2800CC7CAF /* ESPTouchTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTouchTask.m; sourceTree = "<group>"; };
88F5ECCE1D48CA2800CC7CAF /* ESPTouchTaskParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchTaskParameter.h; sourceTree = "<group>"; };
88F5ECCF1D48CA2800CC7CAF /* ESPTouchTaskParameter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTouchTaskParameter.m; sourceTree = "<group>"; };
88F5ECD01D48CA2800CC7CAF /* ESPUDPSocketClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPUDPSocketClient.h; sourceTree = "<group>"; };
88F5ECD11D48CA2800CC7CAF /* ESPUDPSocketClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPUDPSocketClient.m; sourceTree = "<group>"; };
88F5ECD21D48CA2800CC7CAF /* ESPUDPSocketServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPUDPSocketServer.h; sourceTree = "<group>"; };
88F5ECD31D48CA2800CC7CAF /* ESPUDPSocketServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPUDPSocketServer.m; sourceTree = "<group>"; };
88F5ECD51D48CA2800CC7CAF /* ESPDataCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPDataCode.h; sourceTree = "<group>"; };
88F5ECD61D48CA2800CC7CAF /* ESPDataCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPDataCode.m; sourceTree = "<group>"; };
88F5ECD71D48CA2800CC7CAF /* ESPDatumCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPDatumCode.h; sourceTree = "<group>"; };
88F5ECD81D48CA2800CC7CAF /* ESPDatumCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPDatumCode.m; sourceTree = "<group>"; };
88F5ECD91D48CA2800CC7CAF /* ESPGuideCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPGuideCode.h; sourceTree = "<group>"; };
88F5ECDA1D48CA2800CC7CAF /* ESPGuideCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPGuideCode.m; sourceTree = "<group>"; };
88F5ECDB1D48CA2800CC7CAF /* ESPTouchGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchGenerator.h; sourceTree = "<group>"; };
88F5ECDC1D48CA2800CC7CAF /* ESPTouchGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTouchGenerator.m; sourceTree = "<group>"; };
88F5EEEB1D48D08000CC7CAF /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = "<group>"; };
88F5EEEC1D48D08000CC7CAF /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = "<group>"; };
88F5EEED1D48D08000CC7CAF /* AFHTTPRequestOperationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperationManager.h; sourceTree = "<group>"; };
@ -5710,6 +5702,38 @@
C024B79D2379668B00509424 /* NSMutableArray+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+AvoidCrash.h"; sourceTree = "<group>"; };
C0837A55244FF5500034FEC5 /* EGOCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EGOCache.m; sourceTree = "<group>"; };
C0837A56244FF5500034FEC5 /* EGOCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EGOCache.h; sourceTree = "<group>"; };
C0873EBE249105FF00D47D34 /* ESPUDPSocketClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPUDPSocketClient.h; sourceTree = "<group>"; };
C0873EBF249105FF00D47D34 /* ESPUDPSocketServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPUDPSocketServer.m; sourceTree = "<group>"; };
C0873EC0249105FF00D47D34 /* ESPUDPSocketClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPUDPSocketClient.m; sourceTree = "<group>"; };
C0873EC1249105FF00D47D34 /* ESPUDPSocketServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPUDPSocketServer.h; sourceTree = "<group>"; };
C0873EC3249105FF00D47D34 /* ESPGuideCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPGuideCode.m; sourceTree = "<group>"; };
C0873EC4249105FF00D47D34 /* ESPTouchGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTouchGenerator.m; sourceTree = "<group>"; };
C0873EC5249105FF00D47D34 /* ESPDataCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPDataCode.h; sourceTree = "<group>"; };
C0873EC6249105FF00D47D34 /* ESPDatumCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPDatumCode.h; sourceTree = "<group>"; };
C0873EC7249105FF00D47D34 /* ESPGuideCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPGuideCode.h; sourceTree = "<group>"; };
C0873EC8249105FF00D47D34 /* ESPDataCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPDataCode.m; sourceTree = "<group>"; };
C0873EC9249105FF00D47D34 /* ESPTouchGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchGenerator.h; sourceTree = "<group>"; };
C0873ECA249105FF00D47D34 /* ESPDatumCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPDatumCode.m; sourceTree = "<group>"; };
C0873ECC249105FF00D47D34 /* ESPTools.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTools.m; sourceTree = "<group>"; };
C0873ECD249105FF00D47D34 /* ESP_NetUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESP_NetUtil.m; sourceTree = "<group>"; };
C0873ECE249105FF00D47D34 /* ESP_ByteUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESP_ByteUtil.m; sourceTree = "<group>"; };
C0873ECF249105FF00D47D34 /* ESP_WifiUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESP_WifiUtil.m; sourceTree = "<group>"; };
C0873ED0249105FF00D47D34 /* ESP_CRC8.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESP_CRC8.m; sourceTree = "<group>"; };
C0873ED1249105FF00D47D34 /* ESPVersionMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPVersionMacro.h; sourceTree = "<group>"; };
C0873ED2249105FF00D47D34 /* ESPAES.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPAES.h; sourceTree = "<group>"; };
C0873ED3249105FF00D47D34 /* ESP_NetUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESP_NetUtil.h; sourceTree = "<group>"; };
C0873ED4249105FF00D47D34 /* ESP_ByteUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESP_ByteUtil.h; sourceTree = "<group>"; };
C0873ED5249105FF00D47D34 /* ESPTools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTools.h; sourceTree = "<group>"; };
C0873ED6249105FF00D47D34 /* ESP_CRC8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESP_CRC8.h; sourceTree = "<group>"; };
C0873ED7249105FF00D47D34 /* ESP_WifiUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESP_WifiUtil.h; sourceTree = "<group>"; };
C0873ED8249105FF00D47D34 /* ESPAES.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPAES.m; sourceTree = "<group>"; };
C0873EDA2491060000D47D34 /* ESPTouchResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTouchResult.m; sourceTree = "<group>"; };
C0873EDB2491060000D47D34 /* ESPTouchTaskParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchTaskParameter.h; sourceTree = "<group>"; };
C0873EDC2491060000D47D34 /* ESPTouchTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchTask.h; sourceTree = "<group>"; };
C0873EDD2491060000D47D34 /* ESPTouchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchResult.h; sourceTree = "<group>"; };
C0873EDE2491060000D47D34 /* ESPTouchDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPTouchDelegate.h; sourceTree = "<group>"; };
C0873EDF2491060000D47D34 /* ESPTouchTaskParameter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTouchTaskParameter.m; sourceTree = "<group>"; };
C0873EE02491060000D47D34 /* ESPTouchTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESPTouchTask.m; sourceTree = "<group>"; };
C0B2F53E244C6FE3001079AA /* PetStoresViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PetStoresViewController.h; sourceTree = "<group>"; };
C0B2F53F244C6FE3001079AA /* PetStoresViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PetStoresViewController.m; sourceTree = "<group>"; };
C0B2F540244C6FE3001079AA /* PetStoresViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PetStoresViewController.xib; sourceTree = "<group>"; };
@ -11902,83 +11926,17 @@
88F5ECA41D48C9C400CC7CAF /* ThirdPartUnity */ = {
isa = PBXGroup;
children = (
C0873EBC249105FF00D47D34 /* ESPTouch */,
18C54F032350541400DF4E7D /* AlibcTradeSDK-3.1.1.96 */,
CB8B646A230FAD250032EB24 /* Bugly */,
88C6860D1EA60A40004CDFD9 /* TalkingDataV2.2.88 */,
88C685C81EA603A8004CDFD9 /* UMSocial */,
883E7BC81EA5FA1A00ED5D89 /* SMS_SDK */,
88F5ECBD1D48CA2800CC7CAF /* ESPTouch */,
88F5ECE51D48CA2800CC7CAF /* UMCommunity */,
);
name = ThirdPartUnity;
sourceTree = "<group>";
};
88F5ECBD1D48CA2800CC7CAF /* ESPTouch */ = {
isa = PBXGroup;
children = (
88F5ECBE1D48CA2800CC7CAF /* ESPTouAPI */,
);
path = ESPTouch;
sourceTree = "<group>";
};
88F5ECBE1D48CA2800CC7CAF /* ESPTouAPI */ = {
isa = PBXGroup;
children = (
88F5ECBF1D48CA2800CC7CAF /* Esptouchdata */,
88F5ECC81D48CA2800CC7CAF /* Esptouchtask */,
88F5ECD41D48CA2800CC7CAF /* protocol */,
);
path = ESPTouAPI;
sourceTree = "<group>";
};
88F5ECBF1D48CA2800CC7CAF /* Esptouchdata */ = {
isa = PBXGroup;
children = (
88F5ECC01D48CA2800CC7CAF /* ESP_ByteUtil.h */,
88F5ECC11D48CA2800CC7CAF /* ESP_ByteUtil.m */,
88F5ECC21D48CA2800CC7CAF /* ESP_CRC8.h */,
88F5ECC31D48CA2800CC7CAF /* ESP_CRC8.m */,
88F5ECC41D48CA2800CC7CAF /* ESP_NetUtil.h */,
88F5ECC51D48CA2800CC7CAF /* ESP_NetUtil.m */,
88F5ECC61D48CA2800CC7CAF /* IPAddress.c */,
88F5ECC71D48CA2800CC7CAF /* IPAddress.h */,
);
path = Esptouchdata;
sourceTree = "<group>";
};
88F5ECC81D48CA2800CC7CAF /* Esptouchtask */ = {
isa = PBXGroup;
children = (
88F5ECC91D48CA2800CC7CAF /* ESPTouchDelegate.h */,
88F5ECCA1D48CA2800CC7CAF /* ESPTouchResult.h */,
88F5ECCB1D48CA2800CC7CAF /* ESPTouchResult.m */,
88F5ECCC1D48CA2800CC7CAF /* ESPTouchTask.h */,
88F5ECCD1D48CA2800CC7CAF /* ESPTouchTask.m */,
88F5ECCE1D48CA2800CC7CAF /* ESPTouchTaskParameter.h */,
88F5ECCF1D48CA2800CC7CAF /* ESPTouchTaskParameter.m */,
88F5ECD01D48CA2800CC7CAF /* ESPUDPSocketClient.h */,
88F5ECD11D48CA2800CC7CAF /* ESPUDPSocketClient.m */,
88F5ECD21D48CA2800CC7CAF /* ESPUDPSocketServer.h */,
88F5ECD31D48CA2800CC7CAF /* ESPUDPSocketServer.m */,
);
path = Esptouchtask;
sourceTree = "<group>";
};
88F5ECD41D48CA2800CC7CAF /* protocol */ = {
isa = PBXGroup;
children = (
88F5ECD51D48CA2800CC7CAF /* ESPDataCode.h */,
88F5ECD61D48CA2800CC7CAF /* ESPDataCode.m */,
88F5ECD71D48CA2800CC7CAF /* ESPDatumCode.h */,
88F5ECD81D48CA2800CC7CAF /* ESPDatumCode.m */,
88F5ECD91D48CA2800CC7CAF /* ESPGuideCode.h */,
88F5ECDA1D48CA2800CC7CAF /* ESPGuideCode.m */,
88F5ECDB1D48CA2800CC7CAF /* ESPTouchGenerator.h */,
88F5ECDC1D48CA2800CC7CAF /* ESPTouchGenerator.m */,
);
path = protocol;
sourceTree = "<group>";
};
88F5ECE51D48CA2800CC7CAF /* UMCommunity */ = {
isa = PBXGroup;
children = (
@ -12220,6 +12178,77 @@
path = EGOCache;
sourceTree = "<group>";
};
C0873EBC249105FF00D47D34 /* ESPTouch */ = {
isa = PBXGroup;
children = (
C0873EBD249105FF00D47D34 /* udp */,
C0873EC2249105FF00D47D34 /* protocol */,
C0873ECB249105FF00D47D34 /* ESPUtils */,
C0873ED92491060000D47D34 /* task */,
);
path = ESPTouch;
sourceTree = "<group>";
};
C0873EBD249105FF00D47D34 /* udp */ = {
isa = PBXGroup;
children = (
C0873EBE249105FF00D47D34 /* ESPUDPSocketClient.h */,
C0873EBF249105FF00D47D34 /* ESPUDPSocketServer.m */,
C0873EC0249105FF00D47D34 /* ESPUDPSocketClient.m */,
C0873EC1249105FF00D47D34 /* ESPUDPSocketServer.h */,
);
path = udp;
sourceTree = "<group>";
};
C0873EC2249105FF00D47D34 /* protocol */ = {
isa = PBXGroup;
children = (
C0873EC3249105FF00D47D34 /* ESPGuideCode.m */,
C0873EC4249105FF00D47D34 /* ESPTouchGenerator.m */,
C0873EC5249105FF00D47D34 /* ESPDataCode.h */,
C0873EC6249105FF00D47D34 /* ESPDatumCode.h */,
C0873EC7249105FF00D47D34 /* ESPGuideCode.h */,
C0873EC8249105FF00D47D34 /* ESPDataCode.m */,
C0873EC9249105FF00D47D34 /* ESPTouchGenerator.h */,
C0873ECA249105FF00D47D34 /* ESPDatumCode.m */,
);
path = protocol;
sourceTree = "<group>";
};
C0873ECB249105FF00D47D34 /* ESPUtils */ = {
isa = PBXGroup;
children = (
C0873ECC249105FF00D47D34 /* ESPTools.m */,
C0873ECD249105FF00D47D34 /* ESP_NetUtil.m */,
C0873ECE249105FF00D47D34 /* ESP_ByteUtil.m */,
C0873ECF249105FF00D47D34 /* ESP_WifiUtil.m */,
C0873ED0249105FF00D47D34 /* ESP_CRC8.m */,
C0873ED1249105FF00D47D34 /* ESPVersionMacro.h */,
C0873ED2249105FF00D47D34 /* ESPAES.h */,
C0873ED3249105FF00D47D34 /* ESP_NetUtil.h */,
C0873ED4249105FF00D47D34 /* ESP_ByteUtil.h */,
C0873ED5249105FF00D47D34 /* ESPTools.h */,
C0873ED6249105FF00D47D34 /* ESP_CRC8.h */,
C0873ED7249105FF00D47D34 /* ESP_WifiUtil.h */,
C0873ED8249105FF00D47D34 /* ESPAES.m */,
);
path = ESPUtils;
sourceTree = "<group>";
};
C0873ED92491060000D47D34 /* task */ = {
isa = PBXGroup;
children = (
C0873EDA2491060000D47D34 /* ESPTouchResult.m */,
C0873EDB2491060000D47D34 /* ESPTouchTaskParameter.h */,
C0873EDC2491060000D47D34 /* ESPTouchTask.h */,
C0873EDD2491060000D47D34 /* ESPTouchResult.h */,
C0873EDE2491060000D47D34 /* ESPTouchDelegate.h */,
C0873EDF2491060000D47D34 /* ESPTouchTaskParameter.m */,
C0873EE02491060000D47D34 /* ESPTouchTask.m */,
);
path = task;
sourceTree = "<group>";
};
C0B2F53D244C6FAF001079AA /* pets */ = {
isa = PBXGroup;
children = (
@ -12815,6 +12844,7 @@
CB484E0422B8C8C80075F050 /* bprint.h in Headers */,
FAFC08232279CB5900B5A07B /* SetTimerCell.h in Headers */,
CB7D6AA122953BEB0014E5C7 /* YYKVStorage.h in Headers */,
C0873EF42491060000D47D34 /* ESP_NetUtil.h in Headers */,
CB484DE522B8C8C80075F050 /* rational.h in Headers */,
CB484DE922B8C8C80075F050 /* avutil.h in Headers */,
3D1C508C221A9EDF0096AE43 /* Utils.h in Headers */,
@ -12836,6 +12866,7 @@
3D1C50BB221A9EE00096AE43 /* RegisterResult.h in Headers */,
CBA6167F228F9AB100ED380D /* MASViewConstraint.h in Headers */,
C024B7A22379668B00509424 /* NSAttributedString+AvoidCrash.h in Headers */,
C0873EF62491060000D47D34 /* ESPTools.h in Headers */,
CB8B6468230F7F980032EB24 /* IfishMainInfoCell.h in Headers */,
C0EA8A2A23AF74F4003DC53B /* SDWebImageOperation.h in Headers */,
CB484E1122B8C8C90075F050 /* version.h in Headers */,
@ -12887,6 +12918,7 @@
3D1C50B7221A9EDF0096AE43 /* YTargetAndAction.h in Headers */,
3D1C510A221A9EE00096AE43 /* PlayBaseViewController.h in Headers */,
CB484DE222B8C8C80075F050 /* samplefmt.h in Headers */,
C0873EF72491060000D47D34 /* ESP_CRC8.h in Headers */,
3D1C50AA221A9EDF0096AE43 /* CyclePickerView.h in Headers */,
CB484DE322B8C8C80075F050 /* pixdesc.h in Headers */,
CB48204D2334D0A200A50C92 /* ConAquarChooseWiFiVC.h in Headers */,
@ -12953,6 +12985,7 @@
3D1C50D1221A9EE00096AE43 /* SVPullToRefresh.h in Headers */,
CB7D6AB022954DE20014E5C7 /* CommonUtils.h in Headers */,
3D1C513C221A9EE10096AE43 /* FishControlFourthCell.h in Headers */,
C0873EF82491060000D47D34 /* ESP_WifiUtil.h in Headers */,
3D1C5086221A9EDF0096AE43 /* KTThumbView.h in Headers */,
3D1C50E5221A9EE00096AE43 /* ShakeManager.h in Headers */,
3D1C5088221A9EDF0096AE43 /* KTThumbsView.h in Headers */,
@ -12962,6 +12995,7 @@
C024B79F2379668B00509424 /* AvoidCrash.h in Headers */,
C024B7AE2379668B00509424 /* NSObject+AvoidCrash.h in Headers */,
C0B2F541244C6FE3001079AA /* PetStoresViewController.h in Headers */,
C0873EFE2491060000D47D34 /* ESPTouchDelegate.h in Headers */,
3D1C50C7221A9EE00096AE43 /* LocalDevice.h in Headers */,
3D1C50A0221A9EDF0096AE43 /* TouchButton.h in Headers */,
CBB0243723517947002900D5 /* MJExtension.h in Headers */,
@ -12978,6 +13012,7 @@
3D1C509D221A9EDF0096AE43 /* GetContactMessageResult.h in Headers */,
CBB0243923517947002900D5 /* MJPropertyKey.h in Headers */,
CBA61681228F9AB100ED380D /* NSLayoutConstraint+MASDebugAdditions.h in Headers */,
C0873EE72491060000D47D34 /* ESPDataCode.h in Headers */,
3D1C5109221A9EE00096AE43 /* P2PPlaybackController.h in Headers */,
C024B7B02379668B00509424 /* NSMutableAttributedString+AvoidCrash.h in Headers */,
C0E7D6D323A1D16D00256A10 /* UIAlertView+WX.h in Headers */,
@ -12991,6 +13026,7 @@
C0EA8A1C23AF74F4003DC53B /* UIButton+WebCache.h in Headers */,
C024B7AC2379668B00509424 /* NSArray+AvoidCrash.h in Headers */,
CB48207D2334E99700A50C92 /* IQUIView+IQKeyboardToolbar.h in Headers */,
C0873EF52491060000D47D34 /* ESP_ByteUtil.h in Headers */,
C024B7AF2379668B00509424 /* NSMutableString+AvoidCrash.h in Headers */,
C0EA8A2023AF74F4003DC53B /* UIView+WebCacheOperation.h in Headers */,
CB48208A2334E99700A50C92 /* IQKeyboardReturnKeyHandler.h in Headers */,
@ -12998,8 +13034,11 @@
3D1C5095221A9EDF0096AE43 /* Alarm.h in Headers */,
CB4820872334E99700A50C92 /* IQKeyboardManagerConstantsInternal.h in Headers */,
C0EA8A2D23AF74F4003DC53B /* SDWebImagePrefetcher.h in Headers */,
C0873EEB2491060000D47D34 /* ESPTouchGenerator.h in Headers */,
3D1C5145221A9EE10096AE43 /* BootomViewSoketBackMasgConreol.h in Headers */,
C0873EF22491060000D47D34 /* ESPVersionMacro.h in Headers */,
3D1C5146221A9EE10096AE43 /* FishTankBootmDataHelper.h in Headers */,
C0873EE92491060000D47D34 /* ESPGuideCode.h in Headers */,
CB484DF522B8C8C80075F050 /* hmac.h in Headers */,
CB484E0922B8C8C80075F050 /* intreadwrite.h in Headers */,
CB484E0122B8C8C80075F050 /* imgutils.h in Headers */,
@ -13010,6 +13049,7 @@
3D1C5101221A9EE00096AE43 /* IfishP2PMonitorController.h in Headers */,
3D1C50F5221A9EE00096AE43 /* CameraManager.h in Headers */,
C0EA8A2423AF74F4003DC53B /* UIImageView+HighlightedWebCache.h in Headers */,
C0873EE82491060000D47D34 /* ESPDatumCode.h in Headers */,
CB484DF422B8C8C80075F050 /* common.h in Headers */,
3D1C50A3221A9EDF0096AE43 /* WaitingPageView.h in Headers */,
CB484DEB22B8C8C80075F050 /* xtea.h in Headers */,
@ -13025,7 +13065,9 @@
3D1C50F0221A9EE00096AE43 /* RecommendInfo.h in Headers */,
3D1C509C221A9EDF0096AE43 /* ModifyLoginPasswordResult.h in Headers */,
C0EA8A2E23AF74F4003DC53B /* SDWebImageCompat.h in Headers */,
C0873EFB2491060000D47D34 /* ESPTouchTaskParameter.h in Headers */,
CBA61680228F9AB100ED380D /* MASConstraint.h in Headers */,
C0873EE42491060000D47D34 /* ESPUDPSocketServer.h in Headers */,
CB484E0622B8C8C80075F050 /* timestamp.h in Headers */,
3D1C512E221A9EE10096AE43 /* CameraBottomHView.h in Headers */,
C0EA8A2223AF74F4003DC53B /* UIImage+WebP.h in Headers */,
@ -13067,6 +13109,7 @@
3D1C511B221A9EE00096AE43 /* ShootImgDataSource.h in Headers */,
3D1C5132221A9EE10096AE43 /* CameraRecordViewController.h in Headers */,
CB48208B2334E99700A50C92 /* IQKeyboardManager.h in Headers */,
C0873EE12491060000D47D34 /* ESPUDPSocketClient.h in Headers */,
CB484DF122B8C8C80075F050 /* adler32.h in Headers */,
3D1C50A9221A9EDF0096AE43 /* MXSCycleScrollView.h in Headers */,
CB484E0322B8C8C80075F050 /* parseutils.h in Headers */,
@ -13079,7 +13122,9 @@
CB484DEE22B8C8C80075F050 /* md5.h in Headers */,
FAA732D4227BE2B80062C252 /* ReadTimerModel.h in Headers */,
C0EA8A1923AF74F4003DC53B /* SDImageCache.h in Headers */,
C0873EFC2491060000D47D34 /* ESPTouchTask.h in Headers */,
CBA61676228F9AB100ED380D /* MASConstraint+Private.h in Headers */,
C0873EF32491060000D47D34 /* ESPAES.h in Headers */,
CB484DF022B8C8C80075F050 /* attributes.h in Headers */,
3D1C508B221A9EDF0096AE43 /* KTPhotoScrollViewController.h in Headers */,
3D1C50DB221A9EE00096AE43 /* YAudioStreamPlayer.h in Headers */,
@ -13091,6 +13136,7 @@
3D1C5108221A9EE00096AE43 /* P2PPlayingbackVC.h in Headers */,
3D1C50AD221A9EDF0096AE43 /* FXBlurView.h in Headers */,
CB0F4E8A22951A130091C76D /* SVRadialGradientLayer.h in Headers */,
C0873EFD2491060000D47D34 /* ESPTouchResult.h in Headers */,
404D7CEB2238CF77005655F5 /* UIViewController+Swizzling.h in Headers */,
CB0F4E8E22951A130091C76D /* SVProgressAnimatedView.h in Headers */,
FA0892FD2275A1B30084A609 /* Xuanduo2SettingController.h in Headers */,
@ -14587,13 +14633,11 @@
8816719E1EA5DE2B00BEBF23 /* UMComCommentListDataController.m in Sources */,
88591EE61D655B9E00A1316E /* ChinaPlckerView.m in Sources */,
883E763B1D4897570030E075 /* huifushebeiruwnagModel.m in Sources */,
88F5EE551D48CA2800CC7CAF /* ESPDataCode.m in Sources */,
886F4E011D76BFF8001EDA34 /* KanHuBaoGaoModel.m in Sources */,
883E79C21D48B0280030E075 /* InfoCell.m in Sources */,
CBA6169A22924F1E00ED380D /* MessageAlertView.m in Sources */,
C0EA8A1F23AF74F4003DC53B /* SDWebImagePrefetcher.m in Sources */,
C0B2F55E244D5577001079AA /* StoreNameView.m in Sources */,
88F5EE531D48CA2800CC7CAF /* ESPUDPSocketClient.m in Sources */,
883E78561D48A5E50030E075 /* IfishBlackListCenterViewController.m in Sources */,
CB484E1A22B8C8C90075F050 /* RtspInterface.mm in Sources */,
883A3D181EC44EF300DA84FF /* IfishUsersActivityListController.m in Sources */,
@ -14723,6 +14767,7 @@
881672031EA5DE2B00BEBF23 /* UMComRefreshView.m in Sources */,
3D34479A212CF71C00CF3941 /* IfishHotBarVc.m in Sources */,
881672211EA5DE2B00BEBF23 /* UMComBriefEditView.m in Sources */,
C0873EEF2491060000D47D34 /* ESP_ByteUtil.m in Sources */,
881A1D4F1DD41AB000BA1AF4 /* MineKanEditSec1ThredCell.m in Sources */,
885C43BC1E89F79D00685A2E /* WMPageController.m in Sources */,
CBB0243C23517947002900D5 /* NSObject+MJClass.m in Sources */,
@ -14741,6 +14786,7 @@
881671AE1EA5DE2B00BEBF23 /* UMComUserUpdateDataController.m in Sources */,
885C43B71E89F79D00685A2E /* IfishLiveRecommendListViewController.m in Sources */,
8816721C1EA5DE2B00BEBF23 /* UMComSimplicityFindTableViewCell.m in Sources */,
C0873EEC2491060000D47D34 /* ESPDatumCode.m in Sources */,
88597ABD1E56BAF1003D0E5C /* WBSPopShareView.m in Sources */,
8816720E1EA5DE2B00BEBF23 /* UMComProgressHUD.m in Sources */,
886185C11EF2228000459AD1 /* ThreeControlNameViewController.m in Sources */,
@ -14751,6 +14797,7 @@
886185C71EF228E100459AD1 /* FourControlName.m in Sources */,
CBB0243523517947002900D5 /* NSString+MJExtension.m in Sources */,
881672251EA5DE2B00BEBF23 /* UMComSelectTopicViewController.m in Sources */,
C0873EEE2491060000D47D34 /* ESP_NetUtil.m in Sources */,
3D1C5140221A9EE10096AE43 /* BootomViewSoketBackMasgConreol.m in Sources */,
883E78601D48A5E50030E075 /* LeftViewController.m in Sources */,
3D1C511A221A9EE00096AE43 /* ShotScreenImgViewController.m in Sources */,
@ -14768,6 +14815,7 @@
8815D11E1DF7A0E300BEA2DA /* NSTimer+Convenience.m in Sources */,
3D1C50A4221A9EDF0096AE43 /* ProgressImageView.m in Sources */,
CB7D6AA022953BEB0014E5C7 /* YYDiskCache.m in Sources */,
C0873EE62491060000D47D34 /* ESPTouchGenerator.m in Sources */,
883E793E1D48ACFF0030E075 /* AFHttpTool.m in Sources */,
3DD7AB5121E2F2FB0064856A /* mask.c in Sources */,
883E787C1D48A5E50030E075 /* IfishMeViewController.m in Sources */,
@ -14809,11 +14857,9 @@
C0EA8A1623AF74F4003DC53B /* SDWebImageDecoder.m in Sources */,
885A376E1E6EBB67007AD930 /* QianDaoGiftView.m in Sources */,
CBA61657228F9A6C00ED380D /* YYClassInfo.m in Sources */,
88F5EE4E1D48CA2800CC7CAF /* ESP_NetUtil.m in Sources */,
FA0892F2226CA3920084A609 /* NSString+Add.m in Sources */,
883E763E1D4897570030E075 /* ServerBackDeviceLogInModel.m in Sources */,
C0EA8A1223AF74F4003DC53B /* MKAnnotationView+WebCache.m in Sources */,
88F5EE511D48CA2800CC7CAF /* ESPTouchTask.m in Sources */,
CBA616A822928B1700ED380D /* UIButton+button.m in Sources */,
3D1C5098221A9EDF0096AE43 /* UDManager.m in Sources */,
3D1C50EA221A9EE00096AE43 /* des2.c in Sources */,
@ -14865,7 +14911,6 @@
3D1C174F2171BB0700A159A8 /* PNPieChart.m in Sources */,
88F5EFCB1D48D08100CC7CAF /* UIScrollView+JHExtension.m in Sources */,
88C1B1CB1DC99B0500C2C99A /* TabMineDeivceListViewCell.m in Sources */,
88F5EE541D48CA2800CC7CAF /* ESPUDPSocketServer.m in Sources */,
8853531C1D672695009B828B /* ShopCertifyStausModel.m in Sources */,
883E79C41D48B0280030E075 /* SecondSetTimeCell.m in Sources */,
3D1C5081221A9EDF0096AE43 /* KTThumbView.m in Sources */,
@ -14913,7 +14958,6 @@
3D5C437321339F8F00E15B66 /* IfishChatView.m in Sources */,
881671FB1EA5DE2B00BEBF23 /* UMAssetsCollectionCell.m in Sources */,
88678C771E8C9E7F0043DA55 /* ifishLiveListAdViewCell.m in Sources */,
88F5EE571D48CA2800CC7CAF /* ESPGuideCode.m in Sources */,
883E76371D4897570030E075 /* deviceLoginModel.m in Sources */,
3D1C50C1221A9EE00096AE43 /* Utils.m in Sources */,
88F5EFCC1D48D08100CC7CAF /* UIScrollView+JHRefresh.m in Sources */,
@ -14947,6 +14991,7 @@
CBB0244223517947002900D5 /* MJPropertyType.m in Sources */,
8871FAA41EBC0CE30038E99A /* ShopCerProgressHeaderView.m in Sources */,
88F5EFD81D48D08100CC7CAF /* MMVectorImage.m in Sources */,
C0873EF02491060000D47D34 /* ESP_WifiUtil.m in Sources */,
CBB0243623517947002900D5 /* NSObject+MJProperty.m in Sources */,
883E79B81D48B0280030E075 /* remindCyclePic.m in Sources */,
88696FCF1E9C8872005D4AFB /* MemeberEditeViewCustomCell.m in Sources */,
@ -14965,7 +15010,7 @@
883E78731D48A5E50030E075 /* SetNameTextViewController.m in Sources */,
88F5EFD51D48D08100CC7CAF /* MMProgressHUDViewController.m in Sources */,
3D1C507E221A9EDF0096AE43 /* KTPhotoBrowserGlobal.m in Sources */,
88F5EE561D48CA2800CC7CAF /* ESPDatumCode.m in Sources */,
C0873F002491060000D47D34 /* ESPTouchTask.m in Sources */,
883E78931D48A5E50030E075 /* IfishDiscoverViewController.m in Sources */,
88696FD41E9C8B4A005D4AFB /* MemberEditeViewLocationCell.m in Sources */,
886F4DF61D753877001EDA34 /* Report3ViewCell.m in Sources */,
@ -14974,7 +15019,6 @@
885979D31E529F64003D0E5C /* GoNetShopViewCell.m in Sources */,
881671A81EA5DE2B00BEBF23 /* UMComTopicGroupDataController.m in Sources */,
883E762C1D4897570030E075 /* setRemindWaterModel.m in Sources */,
88F5EE501D48CA2800CC7CAF /* ESPTouchResult.m in Sources */,
88742C3D1D63FA270074F1F8 /* CertifyListFourthCell.m in Sources */,
8871FAAF1EBC2CE60038E99A /* ShopCerPatr1DetailLocationCell.m in Sources */,
88597A2B1E5597C8003D0E5C /* KanHuGuanLi1ViewCell.m in Sources */,
@ -15000,7 +15044,6 @@
88674A691E4AEABF00C647BB /* UINavigationBar+Background.m in Sources */,
88883B191EF0DA8100CAC0AE /* SongNuo86NameViewController.m in Sources */,
885C43B61E89F79D00685A2E /* IfishLivePopularListViewController.m in Sources */,
88F5EE581D48CA2800CC7CAF /* ESPTouchGenerator.m in Sources */,
883E79A91D48B0280030E075 /* CCMBorderView.m in Sources */,
885FBDE01E4C21FD00E0D7D1 /* WoShiShangJiaViewController.m in Sources */,
8871FAAA1EBC2CAF0038E99A /* shopCerpart1LoactionCell.m in Sources */,
@ -15018,6 +15061,7 @@
3DD7AB9A21E474940064856A /* AsyncSocket.m in Sources */,
886B80641D62F57000E1B9B3 /* SOngNuoGuiDeng.m in Sources */,
881F0F591D73DFFF0091507E /* BaoGaoViewThirdCell.m in Sources */,
C0873EFA2491060000D47D34 /* ESPTouchResult.m in Sources */,
88653C9B1E76691E00FF973E /* IfishInformationViewController.m in Sources */,
88F5EFB81D48D08100CC7CAF /* UIRefreshControl+AFNetworking.m in Sources */,
88D3373C1DC7440C006C0ADB /* IfishConnectingView.m in Sources */,
@ -15084,7 +15128,6 @@
881671E11EA5DE2B00BEBF23 /* UMComUserTableViewController.m in Sources */,
885FBDE91E4C3E1000E0D7D1 /* ShopAlreadyCertifyViewCell.m in Sources */,
881671D01EA5DE2B00BEBF23 /* UMComSelectTopicView.m in Sources */,
88F5EE4D1D48CA2800CC7CAF /* ESP_CRC8.m in Sources */,
8869B3B61E696E770010F099 /* IfishUserObsever.m in Sources */,
881671EA1EA5DE2B00BEBF23 /* UMComButton.m in Sources */,
881671EF1EA5DE2B00BEBF23 /* UMComGridViewerController.m in Sources */,
@ -15122,6 +15165,7 @@
881671C11EA5DE2B00BEBF23 /* UMComNavigationController.m in Sources */,
88380DB61EB1DA7B00FC7C0D /* ShopGoodsManageViewController.m in Sources */,
CB484D0022B8B0D30075F050 /* Reachability.m in Sources */,
C0873EE22491060000D47D34 /* ESPUDPSocketServer.m in Sources */,
887C36281EE63F6000964ACD /* XWCountryCodeController.m in Sources */,
883E786E1D48A5E50030E075 /* infoCollectionViewCell.m in Sources */,
881671C61EA5DE2B00BEBF23 /* UMComDiscoverViewController.m in Sources */,
@ -15143,7 +15187,6 @@
881671AF1EA5DE2B00BEBF23 /* UMComUserAlbumDataController.m in Sources */,
881671B01EA5DE2B00BEBF23 /* UMComLoginManager.m in Sources */,
C024B7A12379668B00509424 /* NSDictionary+AvoidCrash.m in Sources */,
88F5EE4C1D48CA2800CC7CAF /* ESP_ByteUtil.m in Sources */,
883E79C61D48B0280030E075 /* SetCell.m in Sources */,
881671E71EA5DE2B00BEBF23 /* UMComAddedImageCellView.m in Sources */,
881672181EA5DE2B00BEBF23 /* UMComSimpleGridViewerController.m in Sources */,
@ -15185,7 +15228,6 @@
881672201EA5DE2B00BEBF23 /* UINavigationBar+ChangeBackgroundColor.m in Sources */,
881672171EA5DE2B00BEBF23 /* UMComSimpleGridView.m in Sources */,
88F5EFCF1D48D08100CC7CAF /* MMHud.m in Sources */,
88F5EE521D48CA2800CC7CAF /* ESPTouchTaskParameter.m in Sources */,
8871FB0C1EBC7EC90038E99A /* IfishBindDeviceSelectViewController.m in Sources */,
8876A58E1BB83447007A4B54 /* ViewController.m in Sources */,
8891330B1ECE999A00F52EBC /* IfishVideoModel.m in Sources */,
@ -15205,6 +15247,7 @@
CBB0243023517947002900D5 /* MJFoundation.m in Sources */,
883E76451D4897570030E075 /* ZeroControlBackmsgModel.m in Sources */,
889133041ECE999A00F52EBC /* ArtPlayerView.m in Sources */,
C0873EE32491060000D47D34 /* ESPUDPSocketClient.m in Sources */,
881A1D371DD3025400BA1AF4 /* MineKankanEditViewController.m in Sources */,
883E79BE1D48B0280030E075 /* ChangeWaterCell.m in Sources */,
88696FDE1E9C8D51005D4AFB /* MemberDetailMarkDetailViewCell.m in Sources */,
@ -15247,6 +15290,7 @@
881671FC1EA5DE2B00BEBF23 /* UMAssetsCollectionCheckMarkView.m in Sources */,
881477E61E71091300BFB79C /* IfishTaskModel.m in Sources */,
88C1B2BE1DD1749F00C2C99A /* IfishKanKanListViewController.m in Sources */,
C0873EFF2491060000D47D34 /* ESPTouchTaskParameter.m in Sources */,
8868FE511E66BDB4002F7F33 /* DengJiShuoMingViewCell.m in Sources */,
3D1C511D221A9EE00096AE43 /* IfishCameraRecordfirstCell.m in Sources */,
885C43B91E89F79D00685A2E /* WMMenuView.m in Sources */,
@ -15263,6 +15307,7 @@
CB7D6AB122954DE20014E5C7 /* CommonUtils.m in Sources */,
883E78EA1D48A5E50030E075 /* BookViewController.m in Sources */,
3D1C17552171BB0700A159A8 /* PNScatterChart.m in Sources */,
C0873EEA2491060000D47D34 /* ESPDataCode.m in Sources */,
883E79AB1D48B0280030E075 /* UIViewController+MaryPopin.m in Sources */,
CB48204A2334B46100A50C92 /* ConAquarNowWiFiPwdVC.m in Sources */,
881671B81EA5DE2B00BEBF23 /* UMComMessageManager.m in Sources */,
@ -15324,6 +15369,7 @@
88591EEC1D65B8B500A1316E /* ShopCertifyFailViewController.m in Sources */,
883E793C1D48ACFF0030E075 /* IfishDBHelper.m in Sources */,
886B807D1D63116E00E1B9B3 /* CertificationViewFourthCell.m in Sources */,
C0873EED2491060000D47D34 /* ESPTools.m in Sources */,
8867F5C51E656D0300AF021C /* IfishDengjiProgress.m in Sources */,
3D1C17502171BB0700A159A8 /* PNRadarChart.m in Sources */,
8870694A1D4EE89200BCF675 /* DXPopover.m in Sources */,
@ -15357,6 +15403,7 @@
883E78381D48A5E50030E075 /* MorShopViewController.m in Sources */,
881671A21EA5DE2B00BEBF23 /* UMComNoticeListDataController..m in Sources */,
883E78431D48A5E50030E075 /* KeLiAiBackMassage.m in Sources */,
C0873EF92491060000D47D34 /* ESPAES.m in Sources */,
3D3447A0212D113D00CF3941 /* IFishHotBarCell.m in Sources */,
8871FB101EBC80850038E99A /* FishSelectDeviceListViewCell.m in Sources */,
881672421EA5DE2B00BEBF23 /* UMComSimplicityUserCenterViewController.m in Sources */,
@ -15393,6 +15440,7 @@
882A75FD1EBAF2DB00AD1D15 /* IfishShopCerNewViewController.m in Sources */,
8816721E1EA5DE2B00BEBF23 /* UMComSimplicityUserInfoBar.m in Sources */,
883E76251D4897570030E075 /* ChatroomModel.m in Sources */,
C0873EF12491060000D47D34 /* ESP_CRC8.m in Sources */,
3D1C5082221A9EDF0096AE43 /* KTPhotoScrollViewController.m in Sources */,
881671FA1EA5DE2B00BEBF23 /* UMComPageControlView.m in Sources */,
3D1C174A2171BB0700A159A8 /* PNBarChart.m in Sources */,
@ -15453,6 +15501,7 @@
3D1C5143221A9EE10096AE43 /* ifishdeviceListCell.m in Sources */,
881671DF1EA5DE2B00BEBF23 /* UMComUserTableViewCell.m in Sources */,
881671EE1EA5DE2B00BEBF23 /* UMComGridView.m in Sources */,
C0873EE52491060000D47D34 /* ESPGuideCode.m in Sources */,
881672281EA5DE2B00BEBF23 /* UMComFeedImageCollectionViewCell.m in Sources */,
88742C381D63FA060074F1F8 /* CertifyListThridCell.m in Sources */,
889C25E91E1C83F6004F745D /* RuSunBackMessageUtils.m in Sources */,
@ -15498,7 +15547,6 @@
883E78641D48A5E50030E075 /* CellModel.m in Sources */,
888EEB5E1DC346D3003C5C5B /* FBShimmeringLayer.m in Sources */,
883E78F81D48A5E50030E075 /* ForgetViewController.m in Sources */,
88F5EE4F1D48CA2800CC7CAF /* IPAddress.c in Sources */,
885979F31E5422B8003D0E5C /* IfishShopEdite1Cell.m in Sources */,
3D1C5133221A9EE10096AE43 /* YooseeCenterViewCell.m in Sources */,
88597A011E5427FB003D0E5C /* IfishSHopEdite3ViewCell.m in Sources */,

BIN
Ifish/.DS_Store vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,37 +0,0 @@
//
// ESPNetUtil.h
// EspTouchDemo
//
// Created by 白 桦 on 5/15/15.
// Copyright (c) 2015 白 桦. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ESP_NetUtil : NSObject
/**
* get the local ip address by IOS System
*
*/
+ (NSData *) getLocalInetAddress;
/**
* parse InetAddress
*/
+ (NSData *) parseInetAddrByData: (NSData *) inetAddrData andOffset: (int) offset andCount: (int) count;
/**
* descrpion inetAddrData for print pretty
*/
+ (NSString *) descriptionInetAddrByData: (NSData *) inetAddrData;
/**
* parse bssid
*
* @param bssid the bssid
* @return byte converted from bssid
*/
+ (NSData *) parseBssid2bytes: (NSString *) bssid;
@end

View File

@ -1,92 +0,0 @@
//
// ESPNetUtil.m
// EspTouchDemo
//
// Created by on 5/15/15.
// Copyright (c) 2015 . All rights reserved.
//
#import "ESP_NetUtil.h"
#include "IPAddress.h"
#include "ESP_ByteUtil.h"
// only support ipV4 at the moment
#define IP_LEN 4
@implementation ESP_NetUtil
+ (NSData *) getLocalInetAddress
{
InitAddresses();
GetIPAddresses();
GetHWAddresses();
NSData *localInetAddrData = nil;
Byte localIpBytes[IP_LEN];
for (int i=0; i<MAXADDRS; ++i)
{
static unsigned long localHost = 0x100007F; // 127.0.0.1
unsigned long theAddr;
theAddr = ip_addrs[i];
if (theAddr == 0) break;
if (theAddr == localHost) continue;
// NSLog(@"theAddr=%lu",theAddr);
// hard coding
localIpBytes[0] = (theAddr & 0xff) >> 0;
localIpBytes[1] = (theAddr & 0xff00) >> 8;
localIpBytes[2] = (theAddr & 0xff0000) >> 16;
localIpBytes[3] = (theAddr & 0xff000000) >> 24;
// NSLog(@"ESP_NetUtil:: %d.%d.%d.%d",localIpBytes[0],localIpBytes[1],localIpBytes[2],localIpBytes[3]);
// if (theAddr != 0) break;
// NSLog(@"ESP_NetUtil:: Name: %s MAC: %s IP: %s\n", if_names[i], hw_addrs[i], ip_names[i]);
}
localInetAddrData = [[NSData alloc]initWithBytes:localIpBytes length:IP_LEN];
FreeAddresses();
Byte byte1 = 0;
Byte byte2 = 0;
Byte byte3 = 0;
Byte byte4 = 0;
[localInetAddrData getBytes:&byte1 range:NSMakeRange(0, 1)];
[localInetAddrData getBytes:&byte2 range:NSMakeRange(1, 1)];
[localInetAddrData getBytes:&byte3 range:NSMakeRange(2, 1)];
[localInetAddrData getBytes:&byte4 range:NSMakeRange(3, 1)];
NSLog(@"ESP_NetUtil:: %d.%d.%d.%d", byte1,byte2,byte3,byte4);
return localInetAddrData;
}
+ (NSData *) parseInetAddrByData: (NSData *) inetAddrData andOffset: (int) offset andCount: (int) count
{
return [inetAddrData subdataWithRange:NSMakeRange(offset, count)];
}
+ (NSString *) descriptionInetAddrByData: (NSData *) inetAddrData
{
Byte inetAddrBytes[IP_LEN];
[inetAddrData getBytes:inetAddrBytes length:IP_LEN];
// hard coding
return [NSString stringWithFormat:@"%d.%d.%d.%d",inetAddrBytes[0],inetAddrBytes[1],inetAddrBytes[2],inetAddrBytes[3]];
}
+ (NSData *) parseBssid2bytes: (NSString *) bssid
{
NSArray *bssidArray = [bssid componentsSeparatedByString:@":"];
NSInteger size = [bssidArray count];
Byte bssidBytes[size];
for (NSInteger i = 0; i < size; i++) {
NSString *bssidStr = [bssidArray objectAtIndex:i];
bssidBytes[i] = strtoul([bssidStr UTF8String], 0, 16);
}
return [[NSData alloc]initWithBytes:bssidBytes length:size];
}
@end

View File

@ -1,216 +0,0 @@
//
// IPAddress.c
// LocalIpDemo
//
// Created by 白 桦 on 5/11/15.
// Copyright (c) 2015 白 桦. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/sockio.h>
#include <net/if.h>
#include <errno.h>
#include <net/if_dl.h>
#include <net/ethernet.h>
#include "IPAddress.h"
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
#define BUFFERSIZE 4000
char *if_names[MAXADDRS];
char *ip_names[MAXADDRS];
char *hw_addrs[MAXADDRS];
unsigned long ip_addrs[MAXADDRS];
static int nextAddr = 0;
void InitAddresses()
{
int i;
for (i=0; i<MAXADDRS; ++i)
{
if_names[i] = ip_names[i] = hw_addrs[i] = NULL;
ip_addrs[i] = 0;
}
}
void FreeAddresses()
{
int i;
for (i=0; i<MAXADDRS; ++i)
{
if (if_names[i] != 0) free(if_names[i]);
if (ip_names[i] != 0) free(ip_names[i]);
if (hw_addrs[i] != 0) free(hw_addrs[i]);
ip_addrs[i] = 0;
nextAddr = 0;
}
InitAddresses();
}
void GetIPAddresses()
{
int i, len, flags;
char buffer[BUFFERSIZE], *ptr, lastname[IFNAMSIZ], *cptr;
struct ifconf ifc;
struct ifreq *ifr, ifrcopy;
struct sockaddr_in *sin;
char temp[80];
int sockfd;
for (i=0; i<MAXADDRS; ++i)
{
if_names[i] = ip_names[i] = NULL;
ip_addrs[i] = 0;
}
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0)
{
perror("socket failed");
return;
}
ifc.ifc_len = BUFFERSIZE;
ifc.ifc_buf = buffer;
if (ioctl(sockfd, SIOCGIFCONF, &ifc) < 0)
{
perror("ioctl error");
return;
}
lastname[0] = 0;
for (ptr = buffer; ptr < buffer + ifc.ifc_len; )
{
ifr = (struct ifreq *)ptr;
len = max(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);
ptr += sizeof(ifr->ifr_name) + len; // for next one in buffer
if (ifr->ifr_addr.sa_family != AF_INET)
{
continue; // ignore if not desired address family
}
if ((cptr = (char *)strchr(ifr->ifr_name, ':')) != NULL)
{
*cptr = 0; // replace colon will null
}
if (strncmp(lastname, ifr->ifr_name, IFNAMSIZ) == 0)
{
continue; /* already processed this interface */
}
memcpy(lastname, ifr->ifr_name, IFNAMSIZ);
ifrcopy = *ifr;
ioctl(sockfd, SIOCGIFFLAGS, &ifrcopy);
flags = ifrcopy.ifr_flags;
if ((flags & IFF_UP) == 0)
{
continue; // ignore if interface not up
}
if_names[nextAddr] = (char *)malloc(strlen(ifr->ifr_name)+1);
if (if_names[nextAddr] == NULL)
{
return;
}
strcpy(if_names[nextAddr], ifr->ifr_name);
sin = (struct sockaddr_in *)&ifr->ifr_addr;
strcpy(temp, inet_ntoa(sin->sin_addr));
ip_names[nextAddr] = (char *)malloc(strlen(temp)+1);
if (ip_names[nextAddr] == NULL)
{
return;
}
strcpy(ip_names[nextAddr], temp);
ip_addrs[nextAddr] = sin->sin_addr.s_addr;
++nextAddr;
}
close(sockfd);
}
void GetHWAddresses()
{
struct ifconf ifc;
struct ifreq *ifr;
int i, sockfd;
char buffer[BUFFERSIZE], *cp, *cplim;
char temp[80];
for (i=0; i<MAXADDRS; ++i)
{
hw_addrs[i] = NULL;
}
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0)
{
perror("socket failed");
return;
}
ifc.ifc_len = BUFFERSIZE;
ifc.ifc_buf = buffer;
if (ioctl(sockfd, SIOCGIFCONF, (char *)&ifc) < 0)
{
perror("ioctl error");
close(sockfd);
return;
}
ifr = ifc.ifc_req;
cplim = buffer + ifc.ifc_len;
for (cp=buffer; cp < cplim; )
{
ifr = (struct ifreq *)cp;
if (ifr->ifr_addr.sa_family == AF_LINK)
{
struct sockaddr_dl *sdl = (struct sockaddr_dl *)&ifr->ifr_addr;
int a,b,c,d,e,f;
int i;
strcpy(temp, (char *)ether_ntoa((const struct ether_addr *)LLADDR(sdl)));
sscanf(temp, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f);
sprintf(temp, "%02X:%02X:%02X:%02X:%02X:%02X",a,b,c,d,e,f);
for (i=0; i<MAXADDRS; ++i)
{
if ((if_names[i] != NULL) && (strcmp(ifr->ifr_name, if_names[i]) == 0))
{
if (hw_addrs[i] == NULL)
{
hw_addrs[i] = (char *)malloc(strlen(temp)+1);
strcpy(hw_addrs[i], temp);
break;
}
}
}
}
cp += sizeof(ifr->ifr_name) + max(sizeof(ifr->ifr_addr), ifr->ifr_addr.sa_len);
}
close(sockfd);
}

View File

@ -1,26 +0,0 @@
//
// IPAddress.h
// LocalIpDemo
//
// Created by 白 桦 on 5/11/15.
// Copyright (c) 2015 白 桦. All rights reserved.
//
#ifndef LocalIpDemo_IPAddress_h
#define LocalIpDemo_IPAddress_h
#define MAXADDRS 32
extern char *if_names[MAXADDRS];
extern char *ip_names[MAXADDRS];
extern char *hw_addrs[MAXADDRS];
extern unsigned long ip_addrs[MAXADDRS];
// Function prototypes
void InitAddresses();
void FreeAddresses();
void GetIPAddresses();
void GetHWAddresses();
#endif

View File

@ -1,197 +0,0 @@
//
// ESPUDPSocketServer.m
// EspTouchDemo
//
// Created by on 4/13/15.
// Copyright (c) 2015 . All rights reserved.
//
#import "ESPUDPSocketServer.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include "ESPTouchTask.h"
@interface ESPUDPSocketServer ()
@property(nonatomic,assign) int _sck_fd;
@property(nonatomic,assign) int _port;
// it is used to check whether the socket is closed already to prevent close more than once.
// especially, when you close the socket second time, it is created just now, it will crash.
//
// // suppose fd1 = 4, fd1 belong to obj1
// e.g. int fd1 = socket(AF_INET,SOCK_DRAM,0);
// close(fd1);
//
// // suppose fd2 = 4 as well, fd2 belong to obj2
// int fd2 = socket(AF_INET,SOCK_DRAM,0);
//
// // obj1's dealloc() is called by system, so
// close(fd1);
//
// // Amazing!!! at the moment, fd2 is close by others
//
@property(nonatomic,assign) volatile bool _isClosed;
// it is used to lock the close method
@property(nonatomic,strong) volatile NSLock *_lock;
@end
@implementation ESPUDPSocketServer
- (id) initWithPort: (int) port AndSocketTimeout: (int) socketTimeout
{
self = [super init];
if (self)
{
// create local
self._lock = [[NSLock alloc]init];
// create socket
self._isClosed = NO;
self._sck_fd = socket(AF_INET,SOCK_DGRAM,0);
if (DEBUG_ON)
{
NSLog(@"##########################server init(): _sck_fd=%d", self._sck_fd);
}
if (self._sck_fd < 0)
{
if (DEBUG_ON)
{
perror("server: _skd_fd init() fail\n");
}
return nil;
}
// init socket params
struct sockaddr_in server_addr;
socklen_t addr_len;
memset(&server_addr, 0, sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
server_addr.sin_addr.s_addr = INADDR_ANY;
addr_len = sizeof(server_addr);
// set broadcast
const int opt = 1;
if (setsockopt(self._sck_fd,SOL_SOCKET,SO_BROADCAST,(char *)&opt, sizeof(opt)) < 0)
{
if (DEBUG_ON)
{
perror("server init(): setsockopt SO_BROADCAST fail\n");
}
[self close];
return nil;
}
// set timeout
[self setSocketTimeout:socketTimeout];
// bind
if (bind(self._sck_fd, (struct sockaddr*)&server_addr, addr_len) < 0)
{
if (DEBUG_ON)
{
perror("server init(): bind fail\n");
}
[self close];
return nil;
}
}
return self;
}
// make sure the socket will be closed sometime
- (void)dealloc
{
if (DEBUG_ON)
{
NSLog(@"###################server dealloc()");
}
[self close];
}
- (void) close
{
[self._lock lock];
if (!self._isClosed)
{
if (DEBUG_ON)
{
NSLog(@"###################server close() fd=%d",self._sck_fd);
}
close(self._sck_fd);
self._isClosed = true;
}
[self._lock unlock];
}
- (void) interrupt
{
[self close];
}
- (void) setSocketTimeout: (int) timeout
{
struct timeval tv;
tv.tv_sec = timeout/1000;
tv.tv_usec = timeout%1000*1000;
if (setsockopt(self._sck_fd,SOL_SOCKET,SO_RCVTIMEO,(char *)&tv, sizeof(tv)) < 0)
{
if (DEBUG_ON)
{
perror("server: setsockopt SO_RCVTIMEO fail\n");
}
}
}
- (Byte) receiveOneByte
{
ssize_t recNumber = recv(self._sck_fd, _buffer, BUFFER_SIZE, 0);
if (recNumber > 0)
{
return _buffer[0];
}
else if(recNumber == 0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte socket is closed by the other\n");
}
}
else
{
if (DEBUG_ON)
{
perror("server: receiveOneByte fail\n");
}
}
return UINT8_MAX;
}
- (NSData *) receiveSpecLenBytes: (int)len
{
ssize_t recNumber = recv(self._sck_fd, _buffer, BUFFER_SIZE, 0);
if (recNumber==len)
{
NSData *data = [[NSData alloc]initWithBytes:_buffer length:recNumber];
return data;
}
else if(recNumber==0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte socket is closed by the other\n");
}
}
else if(recNumber<0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte fail\n");
}
}
else
{
// receive rubbish message, just ignore it
}
return nil;
}
@end

View File

@ -0,0 +1,19 @@
//
// ESPAES.h
// EspTouchDemo
//
// Created by AE on 2018/4/5.
//
#import <Foundation/Foundation.h>
@interface ESPAES : NSObject {
@private NSString *key;
}
- (instancetype)initWithKey:(NSString *)secretKey;
- (NSData *)AES128EncryptData:(NSData *)data;
- (NSData *)AES128DecryptData:(NSData *)data;
@end

View File

@ -0,0 +1,66 @@
//
// ESPAES.m
// EspTouchDemo
//
// Created by AE on 2018/4/5.
//
#import "ESPAES.h"
#import <CommonCrypto/CommonCryptor.h>
@implementation ESPAES
- (instancetype)initWithKey:(NSString *)secretKey
{
self = [super init];
if (self) {
key = secretKey;
}
return self;
}
- (NSData *)AES128EncryptData:(NSData *)data {
char keyPtr[kCCKeySizeAES128+1];
bzero(keyPtr, sizeof(keyPtr));
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
NSUInteger dataLength = [data length];
size_t bufferSize = dataLength + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
size_t numBytesEncrypted = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128,
kCCOptionPKCS7Padding | kCCOptionECBMode,
keyPtr, kCCBlockSizeAES128,
NULL,
[data bytes], dataLength,
buffer, bufferSize,
&numBytesEncrypted);
if (cryptStatus == kCCSuccess) {
return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
}
free(buffer);
return nil;
}
- (NSData *)AES128DecryptData:(NSData *)data {
char keyPtr[kCCKeySizeAES128+1];
bzero(keyPtr, sizeof(keyPtr));
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
NSUInteger dataLength = [data length];
size_t bufferSize = dataLength + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
size_t numBytesDecrypted = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128,
kCCOptionPKCS7Padding | kCCOptionECBMode,
keyPtr, kCCBlockSizeAES128,
NULL,
[data bytes], dataLength,
buffer, bufferSize,
&numBytesDecrypted);
if (cryptStatus == kCCSuccess) {
return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted];
}
free(buffer);
return nil;
}
@end

View File

@ -0,0 +1,22 @@
//
// EspNetUtils.h
// Esp32Mesh
//
// Created by AE on 2018/4/19.
// Copyright © 2018年 AE. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ESPTools : NSObject
+ (nullable NSString *)getCurrentWiFiSsid;
+ (nullable NSString *)getCurrentBSSID;
+ (NSString *)getIPAddress:(BOOL)preferIPv4;
+ (NSDictionary *)getIPAddresses;
NS_ASSUME_NONNULL_END
@end

View File

@ -0,0 +1,132 @@
//
// EspNetUtils.m
// Esp32Mesh
//
// Created by AE on 2018/4/19.
// Copyright © 2018 AE. All rights reserved.
//
#import "ESPTools.h"
#import <ifaddrs.h>
#import <arpa/inet.h>
#import <net/if.h>
#import <SystemConfiguration/CaptiveNetwork.h>
#define IOS_CELLULAR @"pdp_ip0"
#define IOS_WIFI @"en0"
#define IOS_VPN @"utun0"
#define IP_ADDR_IPv4 @"ipv4"
#define IP_ADDR_IPv6 @"ipv6"
@implementation ESPTools
+ (nullable NSString *)getCurrentWiFiSsid {
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
id info = nil;
for (NSString *ifnam in ifs) {
info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
if (info && [info count]) {
break;
}
}
// Key: BSSID, SSID, SSIDDATA
return [(NSDictionary*)info objectForKey:@"SSID"];
}
+ (nullable NSString *)getCurrentBSSID {
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
id info = nil;
for (NSString *ifnam in ifs) {
info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
if (info && [info count]) {
break;
}
}
// Key: BSSID, SSID, SSIDDATA
return [(NSDictionary*)info objectForKey:@"BSSID"];
}
+ (NSString *)getIPAddress:(BOOL)preferIPv4 {
NSArray *searchArray = preferIPv4 ?
@[ IOS_VPN @"/" IP_ADDR_IPv4, IOS_VPN @"/" IP_ADDR_IPv6, IOS_WIFI @"/" IP_ADDR_IPv4, IOS_WIFI @"/" IP_ADDR_IPv6, IOS_CELLULAR @"/" IP_ADDR_IPv4, IOS_CELLULAR @"/" IP_ADDR_IPv6 ] :
@[ IOS_VPN @"/" IP_ADDR_IPv6, IOS_VPN @"/" IP_ADDR_IPv4, IOS_WIFI @"/" IP_ADDR_IPv6, IOS_WIFI @"/" IP_ADDR_IPv4, IOS_CELLULAR @"/" IP_ADDR_IPv6, IOS_CELLULAR @"/" IP_ADDR_IPv4 ] ;
NSDictionary *addresses = [self getIPAddresses];
NSLog(@"addresses: %@", addresses);
__block NSString *address;
[searchArray enumerateObjectsUsingBlock:^(NSString *key, NSUInteger idx, BOOL *stop) {
address = addresses[key];
//IP
if([self isValidatIP:address]) *stop = YES;
} ];
return address ? address : @"0.0.0.0";
}
+ (BOOL)isValidatIP:(NSString *)ipAddress {
if (ipAddress.length == 0) {
return NO;
}
NSString *urlRegEx = @"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
NSError *error;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:urlRegEx options:0 error:&error];
if (regex != nil) {
NSTextCheckingResult *firstMatch=[regex firstMatchInString:ipAddress options:0 range:NSMakeRange(0, [ipAddress length])];
if (firstMatch) {
NSRange resultRange = [firstMatch rangeAtIndex:0];
NSString *result=[ipAddress substringWithRange:resultRange];
//
NSLog(@"ESPTools 输出结果:%@",result);
return YES;
}
}
return NO;
}
+ (NSDictionary *)getIPAddresses {
NSMutableDictionary *addresses = [NSMutableDictionary dictionaryWithCapacity:8];
// retrieve the current interfaces - returns 0 on success
struct ifaddrs *interfaces;
if(!getifaddrs(&interfaces)) {
// Loop through linked list of interfaces
struct ifaddrs *interface;
for(interface=interfaces; interface; interface=interface->ifa_next) {
if(!(interface->ifa_flags & IFF_UP) /* || (interface->ifa_flags & IFF_LOOPBACK) */ ) {
continue; // deeply nested code harder to read
}
const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr;
char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
if(addr && (addr->sin_family==AF_INET || addr->sin_family==AF_INET6)) {
NSString *name = [NSString stringWithUTF8String:interface->ifa_name];
NSString *type;
if(addr->sin_family == AF_INET) {
if(inet_ntop(AF_INET, &addr->sin_addr, addrBuf, INET_ADDRSTRLEN)) {
type = IP_ADDR_IPv4;
}
} else {
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*)interface->ifa_addr;
if(inet_ntop(AF_INET6, &addr6->sin6_addr, addrBuf, INET6_ADDRSTRLEN)) {
type = IP_ADDR_IPv6;
}
}
if(type) {
NSString *key = [NSString stringWithFormat:@"%@/%@", name, type];
addresses[key] = [NSString stringWithUTF8String:addrBuf];
}
}
}
// Free memory
freeifaddrs(interfaces);
}
return [addresses count] ? addresses : nil;
}
@end

View File

@ -0,0 +1,20 @@
//
// ESPVersionMacro.h
// suite
//
// Created by fby on 5/16/16.
// Copyright © 2016 fby. All rights reserved.
//
#ifndef ESPVersionMacro_h
#define ESPVersionMacro_h
#import <UIKit/UIKit.h>
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
#endif /* ESPVersionMacro_h */

View File

@ -2,8 +2,8 @@
// ESP_ByteUtil.h
// EspTouchDemo
//
// Created by 白 桦 on 4/7/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 4/7/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@ -48,7 +48,6 @@
* @return the high and low bytes be split, byte[0] is high and byte[1] is
* low
*/
+ (NSData *) splitUint8To2Bytes: (UInt8) uint8;
/**
@ -60,7 +59,6 @@
* the low byte
* @return the whole byte
*/
+ (Byte) combine2bytesToOneWithHigh: (Byte) high andLow: (Byte) low;
/**

View File

@ -2,8 +2,8 @@
// ESP_ByteUtil.m
// EspTouchDemo
//
// Created by on 4/7/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 4/7/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESP_ByteUtil.h"
@ -57,6 +57,7 @@
high = 0;
low = [self intFromHexString:[hexString substringWithRange:NSMakeRange(0, 1)]];
}
Byte bytes[] = { high, low };
NSData *data = [[NSData alloc] initWithBytes:bytes length:2];
return data;
@ -108,7 +109,6 @@
+ (NSString *) parseBssid:(Byte[]) bssidBytes Offset: (int) offset Count: (int) count
{
Byte bytes[count];
for (int i = 0; i < count; i++ )
{
bytes[i] = bssidBytes[i + offset];

View File

@ -2,8 +2,8 @@
// ESP_CRC8.h
// EspTouchDemo
//
// Created by 白 桦 on 3/23/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 3/23/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@ -53,7 +53,7 @@
/**
* Updates the checksum value with the given byte.
*
* @param val
* @param value
* the byte to update the checksum with.
*/
- (void)updateWithValue:(int)value;

View File

@ -2,8 +2,8 @@
// ESP_CRC8.m
// EspTouchDemo
//
// Created by on 3/23/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 3/23/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESP_CRC8.h"

View File

@ -0,0 +1,82 @@
//
// ESPNetUtil.h
// EspTouchDemo
//
// Created by fby on 5/15/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ESP_NetUtil : NSObject
/**
* get local ip v4 or nil
*
* @return local ip v4 or nil
*/
+ (NSString *) getLocalIPv4;
/**
* get local ip v6 or nil
*
* @return local ip v6 or nil
*/
+ (NSString *) getLocalIPv6;
/**
* whether the ipAddr is v4
*
* @return whether the ipAddr is v4
*/
+ (BOOL) isIPv4Addr:(NSString *)ipAddr;
/**
* whether the ipAddr v4 is private
*
* @return whether the ipAddr v4 is private
*/
+ (BOOL) isIPv4PrivateAddr:(NSString *)ipAddr;
/**
* get the local ip address by local inetAddress ip4
*
* @param localInetAddr4 local inetAddress ip4
*/
+ (NSData *) getLocalInetAddress4ByAddr:(NSString *) localInetAddr4;
/**
* get the invented local ip address by local port
*
*/
+ (NSData *) getLocalInetAddress6ByPort:(int) localPort;
/**
* parse InetAddress
*/
+ (NSData *) parseInetAddrByData: (NSData *) inetAddrData andOffset: (int) offset andCount: (int) count;
/**
* descrpion inetAddrData for print pretty IPv4
*/
+ (NSString *) descriptionInetAddr4ByData: (NSData *) inetAddrData;
/**
* descrpion inetAddrData for print pretty IPv6
*/
+ (NSString *) descriptionInetAddr6ByData: (NSData *) inetAddrData;
/**
* parse bssid
*
* @param bssid the bssid
* @return byte converted from bssid
*/
+ (NSData *) parseBssid2bytes: (NSString *) bssid;
/**
* send a dummy GET to "https://8.8.8.8" just to get Network Permission after ios10.0(including)
*/
+ (void) tryOpenNetworkPermission;
@end

View File

@ -0,0 +1,153 @@
//
// ESPNetUtil.m
// EspTouchDemo
//
// Created by fby on 5/15/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESP_NetUtil.h"
#import "ESP_WifiUtil.h"
#import "ESP_ByteUtil.h"
#import "ESPVersionMacro.h"
#define IP4_LEN 4
#define IP6_LEN 16
@implementation ESP_NetUtil
/**
* get local ip v4 or nil
*
* @return local ip v4 or nil
*/
+ (NSString *) getLocalIPv4
{
return [ESP_WifiUtil getIPAddress4];
}
/**
* get local ip v6 or nil
*
* @return local ip v6 or nil
*/
+ (NSString *) getLocalIPv6
{
return [ESP_WifiUtil getIpAddress6];
}
+ (BOOL) isIPv4Addr:(NSString *)ipAddr
{
NSArray *ip4array = [ipAddr componentsSeparatedByString:@"."];
return [ip4array count]==4;
}
+ (BOOL) isIPv4PrivateAddr:(NSString *)ipAddr4
{
NSArray *ip4array = [ipAddr4 componentsSeparatedByString:@"."];
Byte byte0 = [[ip4array objectAtIndex:0]intValue];
Byte byte1 = [[ip4array objectAtIndex:1]intValue];
// Byte byte2 = [[ip4array objectAtIndex:2]intValue];
// Byte byte3 = [[ip4array objectAtIndex:3]intValue];
if (byte0==10) {
// 10.0.0.0~10.255.255.255
return YES;
} else if (byte0==172&&16<=byte1&&byte1<=31) {
// 172.16.0.0~172.31.255.255
return YES;
} else if (byte0==192&&byte1==168) {
// 192.168.0.0~192.168.255.255
return YES;
}
return NO;
}
+ (NSData *) getLocalInetAddress4ByAddr:(NSString *) localInetAddr4
{
NSArray *ip4array = [localInetAddr4 componentsSeparatedByString:@"."];
Byte byte0 = [[ip4array objectAtIndex:0]intValue];
Byte byte1 = [[ip4array objectAtIndex:1]intValue];
Byte byte2 = [[ip4array objectAtIndex:2]intValue];
Byte byte3 = [[ip4array objectAtIndex:3]intValue];
Byte bytes[] = {byte0,byte1,byte2,byte3};
NSData *ip4data = [NSData dataWithBytes:bytes length:IP4_LEN];
return ip4data;
}
+ (NSData *) getLocalInetAddress6ByPort:(int) localPort
{
Byte lowPort = localPort & 0xff;
Byte highPort = (localPort>>8) & 0xff;
Byte bytes[] = {highPort,lowPort,0xff,0xff};
NSData *ip6data = [NSData dataWithBytes:bytes length:IP4_LEN];
return ip6data;
}
+ (NSData *) parseInetAddrByData: (NSData *) inetAddrData andOffset: (int) offset andCount: (int) count
{
return [inetAddrData subdataWithRange:NSMakeRange(offset, count)];
}
+ (NSString *) descriptionInetAddr4ByData: (NSData *) inetAddrData
{
// check whether inetAddrData is belong to IPv4
if ([inetAddrData length]!=IP4_LEN) {
return nil;
}
Byte inetAddrBytes[IP4_LEN];
[inetAddrData getBytes:inetAddrBytes length:IP4_LEN];
// hard coding
return [NSString stringWithFormat:@"%d.%d.%d.%d",inetAddrBytes[0],inetAddrBytes[1],inetAddrBytes[2],inetAddrBytes[3]];
}
+ (NSString *) descriptionInetAddr6ByData: (NSData *) inetAddrData
{
// check whether inetAddrData is belong to IPv4
if ([inetAddrData length]!=IP6_LEN) {
return nil;
}
Byte inetAddrBytes[IP6_LEN];
[inetAddrData getBytes:inetAddrBytes length:IP6_LEN];
// hard coding
return [NSString stringWithFormat:@"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",inetAddrBytes[0],inetAddrBytes[1],inetAddrBytes[2],inetAddrBytes[3],inetAddrBytes[4],inetAddrBytes[5],inetAddrBytes[6],inetAddrBytes[7],inetAddrBytes[8],inetAddrBytes[9],inetAddrBytes[10],inetAddrBytes[11],inetAddrBytes[12],inetAddrBytes[13],inetAddrBytes[14],inetAddrBytes[15]];
}
+ (NSData *) parseBssid2bytes: (NSString *) bssid
{
NSArray *bssidArray = [bssid componentsSeparatedByString:@":"];
NSInteger size = [bssidArray count];
Byte bssidBytes[size];
for (NSInteger i = 0; i < size; i++) {
NSString *bssidStr = [bssidArray objectAtIndex:i];
bssidBytes[i] = strtoul([bssidStr UTF8String], 0, 16);
}
return [[NSData alloc]initWithBytes:bssidBytes length:size];
}
+ (NSURLSessionConfiguration *) DEFAULT_SESSION_CONFIGURATION
{
static dispatch_once_t predicate;
static NSURLSessionConfiguration *DEFAULT_SESSION_CONFIGURATION;
dispatch_once(&predicate, ^{
DEFAULT_SESSION_CONFIGURATION = [NSURLSessionConfiguration defaultSessionConfiguration];
});
return DEFAULT_SESSION_CONFIGURATION;
}
+ (void) tryOpenNetworkPermission
{
// only ios 10.0 later required to try open network permission
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) {
NSURL *url = [NSURL URLWithString:@"https://8.8.8.8"];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:1000];
NSURLSession *urlSession = [NSURLSession sessionWithConfiguration:[self DEFAULT_SESSION_CONFIGURATION] delegate:nil delegateQueue:[NSOperationQueue currentQueue]];
[[urlSession dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error){
}] resume];
}
}
@end

View File

@ -0,0 +1,33 @@
//
// ESP_WifiUtil.h
// EspTouchDemo
//
// Created by fby on 6/15/16.
// Copyright © 2016 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ESP_WifiUtil : NSObject
// refer to http://stackoverflow.com/questions/7072989/iphone-ipad-osx-how-to-get-my-ip-address-programmatically
+ (NSString *)getIPAddress:(BOOL)preferIPv4;
// refer to http://stackoverflow.com/questions/7072989/iphone-ipad-osx-how-to-get-my-ip-address-programmatically
+ (NSDictionary *)getIPAddresses;
/**
* get local ip address by IPv4
*
* @return local ip address by IPv4(or nil when en0/ipv4 unaccessible)
*/
+ (NSString *)getIPAddress4;
/**
* get local ip address by IPv6
*
* @return local ip address by IPv6(or nil when en0/ipv6 unaccessible)
*/
+ (NSString *)getIpAddress6;
@end

View File

@ -0,0 +1,95 @@
//
// ESP_WifiUtil.m
// EspTouchDemo
//
// Created by fby on 6/15/16.
// Copyright © 2016 fby. All rights reserved.
//
#import "ESP_WifiUtil.h"
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <net/if.h>
#define IOS_CELLULAR @"pdp_ip0"
#define IOS_WIFI @"en0"
#define IOS_VPN @"utun0"
#define IP_ADDR_IPv4 @"ipv4"
#define IP_ADDR_IPv6 @"ipv6"
@implementation ESP_WifiUtil
+ (NSString *)getIPAddress:(BOOL)preferIPv4
{
NSArray *searchArray = preferIPv4 ?
@[ IOS_VPN @"/" IP_ADDR_IPv4, IOS_VPN @"/" IP_ADDR_IPv6, IOS_WIFI @"/" IP_ADDR_IPv4, IOS_WIFI @"/" IP_ADDR_IPv6, IOS_CELLULAR @"/" IP_ADDR_IPv4, IOS_CELLULAR @"/" IP_ADDR_IPv6 ] :
@[ IOS_VPN @"/" IP_ADDR_IPv6, IOS_VPN @"/" IP_ADDR_IPv4, IOS_WIFI @"/" IP_ADDR_IPv6, IOS_WIFI @"/" IP_ADDR_IPv4, IOS_CELLULAR @"/" IP_ADDR_IPv6, IOS_CELLULAR @"/" IP_ADDR_IPv4 ] ;
NSDictionary *addresses = [self getIPAddresses];
// NSLog(@"addresses: %@", addresses);
__block NSString *address;
[searchArray enumerateObjectsUsingBlock:^(NSString *key, NSUInteger idx, BOOL *stop)
{
address = addresses[key];
if(address) *stop = YES;
} ];
return address ? address : @"0.0.0.0";
}
+ (NSDictionary *)getIPAddresses
{
NSMutableDictionary *addresses = [NSMutableDictionary dictionaryWithCapacity:8];
// retrieve the current interfaces - returns 0 on success
struct ifaddrs *interfaces;
if(!getifaddrs(&interfaces)) {
// Loop through linked list of interfaces
struct ifaddrs *interface;
for(interface=interfaces; interface; interface=interface->ifa_next) {
if(!(interface->ifa_flags & IFF_UP) /* || (interface->ifa_flags & IFF_LOOPBACK) */ ) {
continue; // deeply nested code harder to read
}
const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr;
char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
if(addr && (addr->sin_family==AF_INET || addr->sin_family==AF_INET6)) {
NSString *name = [NSString stringWithUTF8String:interface->ifa_name];
NSString *type;
if(addr->sin_family == AF_INET) {
if(inet_ntop(AF_INET, &addr->sin_addr, addrBuf, INET_ADDRSTRLEN)) {
type = IP_ADDR_IPv4;
}
} else {
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*)interface->ifa_addr;
if(inet_ntop(AF_INET6, &addr6->sin6_addr, addrBuf, INET6_ADDRSTRLEN)) {
type = IP_ADDR_IPv6;
}
}
if(type) {
NSString *key = [NSString stringWithFormat:@"%@/%@", name, type];
addresses[key] = [NSString stringWithUTF8String:addrBuf];
}
}
}
// Free memory
freeifaddrs(interfaces);
}
return [addresses count] ? addresses : nil;
}
+ (NSString *)getIPAddress4
{
NSString *key = [NSString stringWithFormat:@"%@/%@",IOS_WIFI,IP_ADDR_IPv4];
NSString *ipv4 = [[self getIPAddresses]objectForKey:key];
return ipv4;
}
+ (NSString *)getIpAddress6
{
NSString *key = [NSString stringWithFormat:@"%@/%@",IOS_WIFI,IP_ADDR_IPv6];
NSString *ipv6 = [[self getIPAddresses]objectForKey:key];
return ipv6;
}
@end

View File

@ -2,8 +2,8 @@
// ESPDataCode.h
// EspTouchDemo
//
// Created by 白 桦 on 4/9/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 4/9/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@ -2,8 +2,8 @@
// ESPDataCode.m
// EspTouchDemo
//
// Created by on 4/9/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 4/9/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESPDataCode.h"

View File

@ -2,8 +2,8 @@
// ESPDatumCode.h
// EspTouchDemo
//
// Created by 白 桦 on 4/9/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 4/9/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@ -29,7 +29,7 @@
* whether the Ap's ssid is hidden
*
*/
- (id) initWithSsid: (NSString *) apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString*) apPwd andInetAddrData: (NSData *) ipAddrData andIsSsidHidden: (BOOL) isSsidHidden;
- (id) initWithSsid: (NSData *) apSsid andApBssid: (NSData *) apBssid andApPwd: (NSData*) apPwd andInetAddrData: (NSData *) ipAddrData andIsSsidHidden: (BOOL) isSsidHidden;
- (NSData *) getBytes;

View File

@ -2,8 +2,8 @@
// ESPDatumCode.m
// EspTouchDemo
//
// Created by on 4/9/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 4/9/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESPDatumCode.h"
@ -18,34 +18,34 @@
@implementation ESPDatumCode
- (id) initWithSsid: (NSString *) apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString*) apPwd andInetAddrData: (NSData *) ipAddrData andIsSsidHidden: (BOOL) isSsidHidden
- (id) initWithSsid: (NSData *) apSsid andApBssid: (NSData *) apBssid andApPwd: (NSData*) apPwd andInetAddrData: (NSData *) ipAddrData andIsSsidHidden: (BOOL) isSsidHidden
{
self = [super init];
if (self)
{
// Data = total len(1 byte) + apPwd len(1 byte) + SSID CRC(1 byte) +
// BSSID CRC(1 byte) + TOTAL XOR(1 byte) + ipAddress(4 byte) + apPwd + apSsid apPwdLen <=
// 105 at the moment
// BSSID CRC(1 byte) + TOTAL XOR(1 byte) + ipAddress(4 byte) + apPwd + apSsid apPwdLen <=
// 105 at the moment
// total xor
UInt8 totalXor = 0;
NSData *apPwdBytesData = [ESP_ByteUtil getBytesByNSString:apPwd];
NSData *apSsidBytesData = [ESP_ByteUtil getBytesByNSString:apSsid];
NSData *apPwdBytesData = apPwd;
NSData *apSsidBytesData = apSsid;
Byte apPwdBytes[[apPwdBytesData length]];
Byte apSsidBytes[[apSsidBytesData length]];
[apPwdBytesData getBytes:apPwdBytes];
[apSsidBytesData getBytes:apSsidBytes];
[apPwdBytesData getBytes:apPwdBytes length:[apPwdBytesData length]];
[apSsidBytesData getBytes:apSsidBytes length:[apSsidBytesData length]];
Byte apPwdLen = [apPwdBytesData length];
ESP_CRC8 *crc = [[ESP_CRC8 alloc]init];
[crc updateWithBuf:apSsidBytes Nbytes:(int)sizeof(apSsidBytes)];
Byte apSsidCrc = [crc getValue];
[crc reset];
NSData *apBssidData = [ESP_NetUtil parseBssid2bytes:apBssid];
NSData *apBssidData = apBssid;
int apBssidDataLen = (int)[apBssidData length];
Byte apBssidBytes[apBssidDataLen];
[apBssidData getBytes:apBssidBytes];
[apBssidData getBytes:apBssidBytes length:[apBssidData length]];
[crc updateWithBuf:apBssidBytes Nbytes:apBssidDataLen];
UInt8 apBssidCrc = [crc getValue];
@ -54,14 +54,14 @@
// only support ipv4 at the moment
UInt8 ipLen = [ipAddrData length];
Byte ipAddrUint8s[ipLen];
[ipAddrData getBytes:ipAddrUint8s];
[ipAddrData getBytes:ipAddrUint8s length:[ipAddrData length]];
UInt8 _totalLen = EXTRA_HEAD_LEN + ipLen + apPwdLen + apSsidLen;
UInt8 totalLen = isSsidHidden ? (EXTRA_HEAD_LEN + ipLen + apPwdLen + apSsidLen):(EXTRA_HEAD_LEN + ipLen + apPwdLen);
// build data codes
_dataCodes = [[NSMutableArray alloc]initWithCapacity:totalLen];
_dataCodes = [[NSMutableArray alloc]initWithCapacity:totalLen + apBssidDataLen];
ESPDataCode *dataCode = [[ESPDataCode alloc]initWithU8:_totalLen andIndex:0];
[_dataCodes addObject:dataCode];
totalXor ^= _totalLen;
@ -106,6 +106,20 @@
// add total xor last
dataCode = [[ESPDataCode alloc]initWithU8:totalXor andIndex:4];
[_dataCodes insertObject:dataCode atIndex:4];
// add bssid
NSUInteger bssidInsertIndex = EXTRA_HEAD_LEN;
for (int i = 0; i < apBssidDataLen; i++) {
int index = totalLen + i;
Byte b = apBssidBytes[i];
ESPDataCode *dc = [[ESPDataCode alloc] initWithU8:b andIndex:index];
if (bssidInsertIndex >= _dataCodes.count) {
[_dataCodes addObject:dc];
} else {
[_dataCodes insertObject:dc atIndex:bssidInsertIndex];
}
bssidInsertIndex += 4;
}
}
return self;
}

View File

@ -2,8 +2,8 @@
// ESPGuideCode.h
// EspTouchDemo
//
// Created by 白 桦 on 4/9/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 4/9/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@ -2,8 +2,8 @@
// ESPGuideCode.m
// EspTouchDemo
//
// Created by on 4/9/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 4/9/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESPGuideCode.h"

View File

@ -2,8 +2,8 @@
// ESPTouchGenerator.h
// EspTouchDemo
//
// Created by 白 桦 on 4/9/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 4/9/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@ -29,13 +29,12 @@
* @param isSsidHidden
* whether the Ap's ssid is hidden
*/
- (id) initWithSsid: (NSString *) apSsid andApBssid: (NSString *) apBssid andApPassword: (NSString *) apPwd andInetAddrData: (NSData *) ipAddrData andIsSsidHidden: (BOOL) isSsidHidden;
- (id) initWithSsid: (NSData *)apSsid andApBssid: (NSData *)apBssid andApPassword: (NSData *)apPwd andInetAddrData: (NSData *)ipAddrData andIsSsidHidden: (BOOL)isSsidHidden;
/**
* Get guide code by the format of byte[][]
* @return guide code by the format of byte[][]
*/
- (NSArray *) getGCBytes2;
/**

View File

@ -2,8 +2,8 @@
// ESPTouchGenerator.m
// EspTouchDemo
//
// Created by on 4/9/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 4/9/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESPTouchGenerator.h"
@ -14,20 +14,18 @@
@implementation ESPTouchGenerator
- (id) initWithSsid: (NSString *) apSsid andApBssid: (NSString *) apBssid andApPassword: (NSString *) apPwd andInetAddrData: (NSData *) ipAddrData andIsSsidHidden: (BOOL) isSsidHidden
- (id) initWithSsid: (NSData *)apSsid andApBssid: (NSData *)apBssid andApPassword: (NSData *)apPwd andInetAddrData: (NSData *)ipAddrData andIsSsidHidden:(BOOL) isSsidHidden
{
self = [super init];
if (self)
{
// generate guide code
ESPGuideCode *gc = [[ESPGuideCode alloc]init];
NSData *gcData1 = [gc getU16s];
NSUInteger gcData1Len = [gcData1 length];
UInt16 gcU16_1[gcData1Len/2];
[gcData1 getBytes:gcU16_1 length:gcData1Len];
_gcBytes2 = [[NSMutableArray alloc]initWithCapacity:gcData1Len];
for (int i = 0; i < gcData1Len/2; i++)
{
NSData* data = [ESP_ByteUtil genSpecBytesWithU16:gcU16_1[i]];
@ -35,26 +33,19 @@
}
// generate data code
ESPDatumCode *dc = [[ESPDatumCode alloc]initWithSsid:apSsid andApBssid:apBssid andApPwd:apPwd andInetAddrData:ipAddrData andIsSsidHidden:isSsidHidden];
NSData *dcData1 = [dc getU16s];
NSUInteger dcDataLen = [dcData1 length];
UInt16 dcU16_1[dcDataLen/2];
[dcData1 getBytes:dcU16_1 length:dcDataLen];
_dcBytes2 = [[NSMutableArray alloc]initWithCapacity:dcDataLen];
for (int i = 0; i < dcDataLen/2; i++)
{
NSData* data = [ESP_ByteUtil genSpecBytesWithU16:dcU16_1[i]];
[_dcBytes2 addObject:data];
}
}
return self;
}
- (NSArray *) getGCBytes2

View File

@ -2,8 +2,8 @@
// ESPTouchDelegate.h
// EspTouchDemo
//
// Created by 白 桦 on 8/14/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 8/14/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@ -2,8 +2,8 @@
// ESPTouchResult.h
// EspTouchDemo
//
// Created by 白 桦 on 4/14/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 4/14/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@ -31,4 +31,6 @@
*/
- (id) initWithIsSuc: (BOOL) isSuc andBssid: (NSString *) bssid andInetAddrData: (NSData *) ipAddrData;
- (NSString *) getAddressString;
@end

View File

@ -2,8 +2,8 @@
// ESPTouchResult.m
// EspTouchDemo
//
// Created by on 4/14/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 4/14/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESPTouchResult.h"
@ -24,9 +24,17 @@
return self;
}
- (NSString *)getAddressString {
NSString *ipAddrDataStr = [ESP_NetUtil descriptionInetAddr4ByData:self.ipAddrData];
if (ipAddrDataStr==nil) {
ipAddrDataStr = [ESP_NetUtil descriptionInetAddr6ByData:self.ipAddrData];
}
return ipAddrDataStr;
}
- (NSString *)description
{
NSString *ipAddrDataStr = [ESP_NetUtil descriptionInetAddrByData:self.ipAddrData];
NSString *ipAddrDataStr = [self getAddressString];
return [[NSString alloc]initWithFormat:@"[isSuc: %@,isCancelled: %@,bssid: %@,inetAddress: %@]",self.isSuc? @"YES":@"NO",
self.isCancelled? @"YES":@"NO"
,self.bssid

View File

@ -2,13 +2,16 @@
// ESPTouchTask.h
// EspTouchDemo
//
// Created by 白 桦 on 4/14/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// 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
@ -16,19 +19,7 @@
@property (atomic,assign) BOOL isCancelled;
/**
* Constructor of EsptouchTask
*
* @param apSsid
* the Ap's ssid
* @param apBssid
* the Ap's bssid
* @param apPassword
* the Ap's password
* @param isSsidHidden
* whether the Ap's ssid is hidden
*/
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andIsSsidHiden: (BOOL) isSsidHidden;
- (id)initWithApSsid:(NSString *)apSsid andApBssid:(NSString *)apBssid andApPwd:(NSString *)apPwd andAES:(ESPAES *)aes;
/**
* Constructor of EsptouchTask
@ -37,21 +28,49 @@
* the Ap's ssid
* @param apBssid
* the Ap's bssid
* @param apPassword
* @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
* @param context
* the Context of the Application
* @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;
- (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;
/**
@ -88,4 +107,9 @@
*/
- (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

View File

@ -2,8 +2,8 @@
// ESPTouchTask.m
// EspTouchDemo
//
// Created by on 4/14/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 4/14/15.
// Copyright (c) 2015 fby. All rights reserved.
//
// The usage of NSCondition refer to: https://gist.github.com/prachigauriar/8118909
@ -16,16 +16,15 @@
#import "ESP_NetUtil.h"
#import "ESPTouchTaskParameter.h"
#import "AppDelegate.h"
#define ONE_DATA_LEN 3
@interface ESPTouchTask ()
@property (nonatomic,strong) NSString *_apSsid;
@property (nonatomic,strong) NSData *_apSsid;
@property (nonatomic,strong) NSString *_apBssid;
@property (nonatomic,strong) NSData *_apBssid;
@property (nonatomic,strong) NSString *_apPwd;
@property (nonatomic,strong) NSData *_apPwd;
@property (atomic,assign) BOOL _isSuc;
@ -55,15 +54,20 @@
@property (nonatomic,strong) id<ESPTouchDelegate> _esptouchDelegate;
@property (nonatomic,strong) NSData *_localInetAddrData;
@end
@implementation ESPTouchTask
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andIsSsidHiden: (BOOL) isSsidHidden
- (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:@""]);
@ -72,26 +76,60 @@
apPwd = @"";
}
self = [super init];
if (self)
{
if (DEBUG_ON)
{
NSLog(@"ESPTouchTask init");
}
self._apSsid = apSsid;
self._apPwd = apPwd;
self._apBssid = apBssid;
if (aes == nil) {
self._apSsid = [ESP_ByteUtil getBytesByNSString:apSsid];
self._apPwd = [ESP_ByteUtil getBytesByNSString:apPwd];
} else {
self._apSsid = [aes AES128EncryptData:[ESP_ByteUtil getBytesByNSString:apSsid]];
self._apPwd = [aes AES128EncryptData:[ESP_ByteUtil getBytesByNSString:apPwd]];
}
self._apBssid = [ESP_NetUtil parseBssid2bytes:apBssid];
self._parameter = [[ESPTaskParameter alloc]init];
// check whether IPv4 and IPv6 is supported
NSString *localInetAddr4 = [ESP_NetUtil getLocalIPv4];
if (![ESP_NetUtil isIPv4PrivateAddr:localInetAddr4]) {
localInetAddr4 = nil;
}
NSString *localInetAddr6 = [ESP_NetUtil getLocalIPv6];
[self._parameter setIsIPv4Supported:localInetAddr4!=nil];
[self._parameter setIsIPv6Supported:localInetAddr6!=nil];
// create udp client and udp server
self._client = [[ESPUDPSocketClient alloc]init];
self._server = [[ESPUDPSocketServer alloc]initWithPort: [self._parameter getPortListening]
AndSocketTimeout: [self._parameter getWaitUdpTotalMillisecond]];
// update listening port for IPv6
[self._parameter setListeningPort6:self._server.port];
if (DEBUG_ON) {
NSLog(@"ESPTouchTask app server port is %d",self._server.port);
}
if (localInetAddr4!=nil) {
self._localInetAddrData = [ESP_NetUtil getLocalInetAddress4ByAddr:localInetAddr4];
} else {
int localPort = [self._parameter getPortListening];
self._localInetAddrData = [ESP_NetUtil getLocalInetAddress6ByPort:localPort];
}
if (DEBUG_ON)
{
// for ESPTouchGenerator only receive 4 bytes for local address no matter IPv4 or IPv6
NSLog(@"ESPTouchTask executeForResult() localInetAddr: %@", [ESP_NetUtil descriptionInetAddr4ByData:self._localInetAddrData]);
}
self._isSuc = NO;
self._isInterrupt = NO;
self._isWakeUp = NO;
self._isExecutedAlready = NO;
self._condition = [[NSCondition alloc]init];
self._isSsidHidden = isSsidHidden;
self._isSsidHidden = YES;
self._esptouchResultArray = [[NSMutableArray alloc]init];
self._bssidTaskSucCountDict = [[NSMutableDictionary alloc]init];
self._esptouchResultArrayCondition = [[NSCondition alloc]init];
@ -99,9 +137,18 @@
return self;
}
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andIsSsidHiden: (BOOL) isSsidHidden andTimeoutMillisecond: (int) timeoutMillisecond
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd {
return [self initWithApSsid:apSsid andApBssid:apBssid andApPwd:apPwd andAES:nil];
}
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andIsSsidHiden: (BOOL) isSsidHidden
{
ESPTouchTask *_self = [self initWithApSsid:apSsid andApBssid:apBssid andApPwd:apPwd andIsSsidHiden:isSsidHidden];
return [self initWithApSsid:apSsid andApBssid:apBssid andApPwd:apPwd];
}
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andTimeoutMillisecond: (int) timeoutMillisecond
{
ESPTouchTask *_self = [self initWithApSsid:apSsid andApBssid:apBssid andApPwd:apPwd];
if (_self)
{
[_self._parameter setWaitUdpTotalMillisecond:timeoutMillisecond];
@ -109,6 +156,11 @@
return _self;
}
- (id) initWithApSsid: (NSString *)apSsid andApBssid: (NSString *) apBssid andApPwd: (NSString *)apPwd andIsSsidHiden: (BOOL) isSsidHidden andTimeoutMillisecond: (int) timeoutMillisecond
{
return [self initWithApSsid:apSsid andApBssid:apBssid andApPwd:apPwd andTimeoutMillisecond:timeoutMillisecond];
}
- (void) __putEsptouchResultIsSuc: (BOOL) isSuc AndBssid: (NSString *)bssid AndInetAddr:(NSData *)inetAddr
{
[self._esptouchResultArrayCondition lock];
@ -174,10 +226,8 @@
esptouchResult.isCancelled = self.isCancelled;
[self._esptouchResultArray addObject:esptouchResult];
}
[self._esptouchResultArrayCondition unlock];
return self._esptouchResultArray;
}
@ -216,8 +266,8 @@
NSLog(@"ESPTouchTask __listenAsyn() start an asyn listen task, current thread is: %@", [NSThread currentThread]);
}
NSTimeInterval startTimestamp = [[NSDate date] timeIntervalSince1970];
NSString *apSsidAndPwd = [NSString stringWithFormat:@"%@%@",self._apSsid,self._apPwd];
Byte expectOneByte = [ESP_ByteUtil getBytesByNSString:apSsidAndPwd].length + 9;
// NSString *apSsidAndPwd = [NSString stringWithFormat:@"%@%@",self._apSsid,self._apPwd];
Byte expectOneByte = [self._apSsid length] + [self._apPwd length] + 9;
if (DEBUG_ON)
{
NSLog(@"ESPTouchTask __listenAsyn() expectOneByte: %d",expectOneByte);
@ -226,7 +276,11 @@
NSData *receiveData = nil;
while ([self._esptouchResultArray count] < [self._parameter getExpectTaskResultCount] && !self._isInterrupt)
{
receiveData = [self._server receiveSpecLenBytes:expectDataLen];
if ([self._parameter isIPv4Supported]) {
receiveData = [self._server receiveSpecLenBytes4:expectDataLen];
} else {
receiveData = [self._server receiveSpecLenBytes6:expectDataLen];
}
if (receiveData != nil)
{
[receiveData getBytes:&receiveOneByte length:1];
@ -396,14 +450,9 @@
[self __checkTaskValid];
NSData *localInetAddrData = [ESP_NetUtil getLocalInetAddress];
if (DEBUG_ON)
{
NSLog(@"ESPTouchTask executeForResult() localInetAddr: %@", [ESP_NetUtil descriptionInetAddrByData:localInetAddrData]);
}
// generator the esptouch byte[][] to be transformed, which will cost
// some time(maybe a bit much)
ESPTouchGenerator *generator = [[ESPTouchGenerator alloc]initWithSsid:self._apSsid andApBssid:self._apBssid andApPassword:self._apPwd andInetAddrData:localInetAddrData andIsSsidHidden:self._isSsidHidden];
ESPTouchGenerator *generator = [[ESPTouchGenerator alloc]initWithSsid:self._apSsid andApBssid:self._apBssid andApPassword:self._apPwd andInetAddrData:self._localInetAddrData andIsSsidHidden:self._isSsidHidden];
// listen the esptouch result asyn
[self __listenAsyn:[self._parameter getEsptouchResultTotalLen]];
BOOL isSuc = NO;
@ -464,4 +513,8 @@
self._esptouchDelegate = esptouchDelegate;
}
- (void)setPackageBroadcast:(BOOL)broadcast {
[self._parameter setBroadcast:broadcast];
}
@end

View File

@ -2,8 +2,8 @@
// ESPTaskParameter.h
// EspTouchDemo
//
// Created by 白 桦 on 5/20/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 5/20/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@ -136,4 +136,38 @@
*/
- (void) setExpectTaskResultCount: (int) expectTaskResultCount;
/**
* get whether the router support IPv4
* @return whether the router support IPv4
*/
- (BOOL) isIPv4Supported;
/**
* set whether the router support IPv4
* @param isIPv4Supported whether the router support IPv4
*/
- (void) setIsIPv4Supported:(BOOL) isIPv4Supported;
/**
* get whether the router support IPv6
* @return whether the router support IPv6
*/
- (BOOL) isIPv6Supported;
/**
* set whether the router support IPv6
* @param isIPv6Supported whether the router support IPv6
*/
- (void) setIsIPv6Supported:(BOOL) isIPv6Supported;
/**
* set listening port for IPv6
*/
- (void) setListeningPort6:(int) listeningPort6;
/**
* Set broadcast or multicast
*/
- (void) setBroadcast:(BOOL) broadcast;
@end

View File

@ -2,8 +2,8 @@
// ESPTaskParameter.m
// EspTouchDemo
//
// Created by on 5/20/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 5/20/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESPTouchTaskParameter.h"
@ -17,14 +17,21 @@
@property (nonatomic,assign) int totalRepeatTime;
@property (nonatomic,assign) int esptouchResultOneLen;
@property (nonatomic,assign) int esptouchResultMacLen;
@property (nonatomic,assign) int esptouchResultIpLen;
@property (nonatomic,assign) int esptouchResultTotalLen;
@property (nonatomic,assign) int portListening;
@property (nonatomic,assign) int targetPort;
@property (nonatomic,assign) int esptouchResultIpLen4;
@property (nonatomic,assign) int esptouchResultIpLen6;
@property (nonatomic,assign) int esptouchResultTotalLen4;
@property (nonatomic,assign) int esptouchResultTotalLen6;
@property (nonatomic,assign) int portListening4;
@property (nonatomic,assign) int portListening6;
@property (nonatomic,assign) int targetPort4;
@property (nonatomic,assign) int targetPort6;
@property (nonatomic,assign) int waitUdpReceivingMillisecond;
@property (nonatomic,assign) int waitUdpSendingMillisecond;
@property (nonatomic,assign) int thresholdSucBroadcastCount;
@property (nonatomic,assign) int expectTaskResultCount;
@property (nonatomic,assign) BOOL isIPv4Supported0;
@property (nonatomic,assign) BOOL isIPv6Supported0;
@property (nonatomic,assign) BOOL broadcast;
@end
@implementation ESPTaskParameter
@ -35,22 +42,28 @@ static int _datagramCount = 0;
{
self = [super init];
if (self) {
self.intervalGuideCodeMillisecond = 10;
self.intervalDataCodeMillisecond = 10;
self.intervalGuideCodeMillisecond = 8;
self.intervalDataCodeMillisecond = 8;
self.timeoutGuideCodeMillisecond = 2000;
self.timeoutDataCodeMillisecond = 4000;
self.timeoutTotalCodeMillisecond = 2000 + 4000;
self.totalRepeatTime = 1;
self.esptouchResultOneLen = 1;
self.esptouchResultMacLen = 6;
self.esptouchResultIpLen = 4;
self.esptouchResultTotalLen = 1 + 6 + 4;
self.portListening = 18266;
self.targetPort = 7001;
self.esptouchResultIpLen4 = 4;
self.esptouchResultIpLen6 = 16;
self.esptouchResultTotalLen4 = 1 + 6 + 4;
self.esptouchResultTotalLen6 = 1 + 6 + 16;
self.portListening4 = 18266;
self.portListening6 = 0;
self.targetPort4 = 7001;
self.targetPort6 = 7001;
self.waitUdpReceivingMillisecond = 15000;
self.waitUdpSendingMillisecond = 45000;
self.thresholdSucBroadcastCount = 1;
self.expectTaskResultCount = 1;
self.isIPv4Supported0 = YES;
self.isIPv6Supported0 = YES;
}
return self;
}
@ -105,30 +118,52 @@ static int _datagramCount = 0;
- (int) getEsptouchResultIpLen
{
return self.esptouchResultIpLen;
return _isIPv4Supported0 ? _esptouchResultIpLen4 : _esptouchResultIpLen6;
}
- (int) getEsptouchResultTotalLen
{
return self.esptouchResultTotalLen;
if (_isIPv4Supported0) {
return _esptouchResultTotalLen4;
} else {
return _esptouchResultTotalLen6;
}
}
- (int) getPortListening
{
return self.portListening;
if (_isIPv4Supported0) {
return _portListening4;
} else {
return _portListening6;
}
}
// target hostname is : 234.1.1.1, 234.2.2.2, 234.3.3.3 to 234.100.100.100
// target hostname is : 234.1.1.1, 234.2.2.2, 234.3.3.3 to 234.100.100.100 for IPv4
// target hostname is : ff02::1 for IPv6
- (NSString *) getTargetHostname
{
int count = [self __getNextDatagramCount];
return [NSString stringWithFormat: @"234.%d.%d.%d", count, count, count];
if (_isIPv4Supported0) {
if (self.broadcast) {
return @"255.255.255.255";
} else {
int count = [self __getNextDatagramCount];
return [NSString stringWithFormat: @"234.%d.%d.%d", count, count, count];
}
} else {
return @"ff02::1%en0";
}
}
- (int) getTargetPort
{
return self.targetPort;
if (_isIPv4Supported0) {
return _targetPort4;
} else {
return _targetPort6;
}
}
- (int) getWaitUdpReceivingMillisecond
@ -171,4 +206,34 @@ static int _datagramCount = 0;
{
_expectTaskResultCount = expectTaskResultCount;
}
- (BOOL) isIPv4Supported
{
return _isIPv4Supported0;
}
- (void) setIsIPv4Supported:(BOOL) isIPv4Supported
{
_isIPv4Supported0 = isIPv4Supported;
}
- (BOOL) isIPv6Supported
{
return _isIPv6Supported0;
}
- (void) setIsIPv6Supported:(BOOL) isIPv6Supported
{
_isIPv6Supported0 = isIPv6Supported;
}
- (void) setListeningPort6:(int) listeningPort6
{
_portListening6 = listeningPort6;
}
- (void)setBroadcast:(BOOL)broadcast {
_broadcast = broadcast;
}
@end

View File

@ -2,8 +2,8 @@
// ESPUDPSocketClient.h
// EspTouchDemo
//
// Created by 白 桦 on 4/13/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 4/13/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@ -17,11 +17,11 @@
/**
* send the data by UDP
*
* @param bytes
* @param bytesArray2
* the array of datas to be sent
* @param targetHost
* @param targetHostName
* the host name of target, e.g. 192.168.1.101
* @param targetPort
* @param port
* the port of target
* @param interval
* the milliseconds to between each UDP sent
@ -32,15 +32,15 @@
/**
* send the data by UDP
*
* @param data
* @param bytesArray2
* the data to be sent
* @param offset
* the offset which data to be sent
* @param count
* the count of the data
* @param targetHost
* @param targetHostName
* the host name of target, e.g. 192.168.1.101
* @param targetPort
* @param port
* the port of target
* @param interval
* the milliseconds to between each UDP sent

View File

@ -2,19 +2,24 @@
// ESPUDPSocketClient.m
// EspTouchDemo
//
// Created by on 4/13/15.
// Copyright (c) 2015 . All rights reserved.
// Created by fby on 4/13/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESPUDPSocketClient.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#import <netdb.h>
#include "ESPTouchTask.h"
#import "ESP_NetUtil.h"
#define SOCKET_NULL -1
@interface ESPUDPSocketClient ()
@property(nonatomic, assign) int _sck_fd;
@property(nonatomic, assign) int _sck_fd4;
@property(nonatomic, assign) int _sck_fd6;
@property(nonatomic, assign) BOOL _isStop;
// it is used to check whether the socket is closed already to prevent close more than once.
// especially, when you close the socket second time, it is created just now, it will crash.
@ -45,16 +50,31 @@
if (self)
{
self._isStop = NO;
self._sck_fd = socket(AF_INET,SOCK_DGRAM,0);
self._sck_fd4 = SOCKET_NULL;
self._sck_fd6 = SOCKET_NULL;
self._sck_fd4 = socket(AF_INET,SOCK_DGRAM,0);
if (DEBUG_ON)
{
NSLog(@"##########################client init() _sck_fd=%d",self._sck_fd);
NSLog(@"##########################client init() _sck_fd4=%d",self._sck_fd4);
}
if (self._sck_fd < 0)
if (self._sck_fd4 < 0)
{
if (DEBUG_ON)
{
perror("client: init() _skd_fd init fail\n");
perror("client: init() _skd_fd4 init fail\n");
}
return nil;
}
self._sck_fd6 = socket(AF_INET6,SOCK_DGRAM,0);
if (DEBUG_ON)
{
NSLog(@"##########################client init() _sck_fd6=%d",self._sck_fd6);
}
if (self._sck_fd6 < 0)
{
if (DEBUG_ON)
{
perror("client: init() _skd_fd6 init fail\n");
}
return nil;
}
@ -77,11 +97,22 @@
[self._lock lock];
if (!self._isClosed)
{
if (DEBUG_ON)
{
NSLog(@"###################client close() fd=%d",self._sck_fd);
if (self._sck_fd4!=SOCKET_NULL) {
if (DEBUG_ON)
{
NSLog(@"###################client close() fd4=%d",self._sck_fd4);
}
close(self._sck_fd4);
self._sck_fd4 = SOCKET_NULL;
}
if (self._sck_fd6!=SOCKET_NULL) {
if (DEBUG_ON)
{
NSLog(@"###################client close() fd6=%d",self._sck_fd6);
}
close(self._sck_fd6);
self._sck_fd6 = SOCKET_NULL;
}
close(self._sck_fd);
self._isClosed = YES;
}
[self._lock unlock];
@ -98,19 +129,9 @@
return [self sendDataWithBytesArray2:bytesArray2 Offset:0 Count:[bytesArray2 count] ToTargetHostName:targetHostName WithPort:port andInterval:interval];
}
- (void) sendDataWithBytesArray2: (NSArray *) bytesArray2 Offset: (NSUInteger) offset Count: (NSUInteger) count ToTargetHostName: (NSString *)targetHostName WithPort: (int) port
- (void) sendDataWithBytesArray2Ipv4: (NSArray *) bytesArray2 Offset: (NSUInteger) offset Count: (NSUInteger) count ToTargetHostName: (NSString *)targetHostName WithPort: (int) port
andInterval: (long) interval
{
// check data is valid
if (nil == bytesArray2 || 0 == [bytesArray2 count])
{
if (DEBUG_ON)
{
perror("client: data is null or data's length equals 0, so sendData fail\n");
}
[self close];
return;
}
// init socket parameters
bool isBroadcast = [targetHostName isEqualToString:@"255.255.255.255"];
socklen_t addr_len;
@ -123,7 +144,7 @@
if (isBroadcast) {
const int opt = 1;
// set whether the socket is broadcast or not
if (setsockopt(self._sck_fd,SOL_SOCKET,SO_BROADCAST,(char *)&opt, sizeof(opt)) < 0)
if (setsockopt(self._sck_fd4,SOL_SOCKET,SO_BROADCAST,(char *)&opt, sizeof(opt)) < 0)
{
if (DEBUG_ON)
{
@ -145,7 +166,7 @@
Byte bytes[dataLen];
[data getBytes:bytes length:dataLen];
// send data
if (sendto(self._sck_fd, bytes, dataLen, 0, (struct sockaddr*)&target_addr, addr_len) < 0)
if (sendto(self._sck_fd4, bytes, dataLen, 0, (struct sockaddr*)&target_addr, addr_len) < 0)
{
if (DEBUG_ON)
{
@ -163,4 +184,81 @@
}
}
- (void) sendDataWithBytesArray2Ipv6: (NSArray *) bytesArray2 Offset: (NSUInteger) offset Count: (NSUInteger) count ToTargetHostName: (NSString *)targetHostName WithPort: (int) port
andInterval: (long) interval
{
// init socket parameters
socklen_t addr_len;
struct sockaddr_in6 target_addr6;
memset(&target_addr6, 0, sizeof(target_addr6));
target_addr6.sin6_family = AF_INET6;
target_addr6.sin6_port = htons(port);
addr_len = sizeof(target_addr6);
NSString *portStr = [NSString stringWithFormat:@"%hu",(uint16_t)port];
struct addrinfo *res0,hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET6;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
int gai_error = getaddrinfo([targetHostName UTF8String], [portStr UTF8String], &hints, &res0);
if (gai_error) {
perror("client: gai_error, stop");
return;
}
NSData *dstData = [NSData dataWithBytes:res0->ai_addr length:res0->ai_addrlen];
const void *dst = [dstData bytes];
socklen_t dstSize = addr_len;
// send data gotten from the array
for (NSUInteger i = offset; !self._isStop && i < offset + count; i++) {
// get data
NSData* data = [bytesArray2 objectAtIndex:i];
NSUInteger dataLen = [data length];
if (0 == dataLen)
{
continue;
}
Byte bytes[dataLen];
[data getBytes:bytes length:dataLen];
// send data
if (sendto(self._sck_fd6, bytes, dataLen, 0, dst, dstSize) < 0)
{
if (DEBUG_ON)
{
perror("client: sendto fail, but just ignore it\n");
}
// for the Ap will make some troubles when the phone send too many UDP packets,
// but we don't expect the UDP packet received by others, so just ignore it
}
// sleep interval
usleep((useconds_t)(interval*1000));
}
// check whether the client is stop
if (self._isStop) {
[self close];
}
}
- (void) sendDataWithBytesArray2: (NSArray *) bytesArray2 Offset: (NSUInteger) offset Count: (NSUInteger) count ToTargetHostName: (NSString *)targetHostName WithPort: (int) port
andInterval: (long) interval
{
// check data is valid
if (nil == bytesArray2 || 0 == [bytesArray2 count])
{
if (DEBUG_ON)
{
perror("client: data is null or data's length equals 0, so sendData fail\n");
}
[self close];
return;
}
if ([ESP_NetUtil isIPv4Addr:targetHostName]) {
[self sendDataWithBytesArray2Ipv4:bytesArray2 Offset:offset Count:count ToTargetHostName:targetHostName WithPort:port andInterval:interval];
} else {
[self sendDataWithBytesArray2Ipv6:bytesArray2 Offset:offset Count:count ToTargetHostName:targetHostName WithPort:port andInterval:interval];
}
}
@end

View File

@ -2,8 +2,8 @@
// ESPUDPSocketServer.h
// EspTouchDemo
//
// Created by 白 桦 on 4/13/15.
// Copyright (c) 2015 白 桦. All rights reserved.
// Created by fby on 4/13/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import <Foundation/Foundation.h>
@ -16,6 +16,8 @@
Byte _buffer[BUFFER_SIZE];
}
@property (nonatomic, assign) int port;
- (void) close;
- (void) interrupt;
@ -25,7 +27,6 @@
*
* @param timeout
* the timeout in milliseconds or 0 for no timeout.
* @return true whether the timeout is set suc
*/
- (void) setSocketTimeout: (int) timeout;
@ -34,9 +35,13 @@
*
* @return one byte receive from the port or UINT8_MAX(it impossible receive it from the socket)
*/
- (Byte) receiveOneByte;
- (Byte) receiveOneByte4;
- (NSData *) receiveSpecLenBytes: (int)len;
- (NSData *) receiveSpecLenBytes4: (int)len;
- (Byte) receiveOneByte6;
- (NSData *) receiveSpecLenBytes6:(int)len;
- (id) initWithPort: (int) port AndSocketTimeout: (int) socketTimeout;

View File

@ -0,0 +1,379 @@
//
// ESPUDPSocketServer.m
// EspTouchDemo
//
// Created by fby on 4/13/15.
// Copyright (c) 2015 fby. All rights reserved.
//
#import "ESPUDPSocketServer.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include "ESPTouchTask.h"
#define SOCKET_NULL -1
@interface ESPUDPSocketServer ()
@property(nonatomic,assign) int _sck_fd4;
@property(nonatomic,assign) int _sck_fd6;
// it is used to check whether the socket is closed already to prevent close more than once.
// especially, when you close the socket second time, it is created just now, it will crash.
//
// // suppose fd1 = 4, fd1 belong to obj1
// e.g. int fd1 = socket(AF_INET,SOCK_DRAM,0);
// close(fd1);
//
// // suppose fd2 = 4 as well, fd2 belong to obj2
// int fd2 = socket(AF_INET,SOCK_DRAM,0);
//
// // obj1's dealloc() is called by system, so
// close(fd1);
//
// // Amazing!!! at the moment, fd2 is close by others
//
@property(nonatomic,assign) volatile bool _isClosed;
// it is used to lock the close method
@property(nonatomic,strong) volatile NSLock *_lock;
@end
@implementation ESPUDPSocketServer
- (BOOL) initWithPort4: (int) port AndSocketTimeout: (int) socketTimeout
{
self._sck_fd4 = socket(AF_INET,SOCK_DGRAM,0);
if (DEBUG_ON)
{
NSLog(@"##########################server init(): _sck_fd4=%d", self._sck_fd4);
}
if (self._sck_fd4 < 0)
{
if (DEBUG_ON)
{
perror("server: _skd_fd4 init() fail\n");
}
return NO;
}
// init socket4 params
struct sockaddr_in server_addr;
socklen_t addr_len;
memset(&server_addr, 0, sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
server_addr.sin_addr.s_addr = INADDR_ANY;
addr_len = sizeof(server_addr);
// set broadcast
const int opt = 1;
if (setsockopt(self._sck_fd4,SOL_SOCKET,SO_BROADCAST,(char *)&opt, sizeof(opt)) < 0)
{
if (DEBUG_ON)
{
perror("server init() sck4: setsockopt SO_BROADCAST fail\n");
}
[self close];
return NO;
}
// set socket timeout
if (![self setSocketTimeout:socketTimeout SocketFd:self._sck_fd4]) {
if (DEBUG_ON) {
perror("server: sck4: setsockopt SO_RCVTIMEO fail\n");
}
[self close];
return NO;
}
// set SO_REUSEADDR for ipv4
if (setsockopt(self._sck_fd4, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt))< 0) {
if (DEBUG_ON)
{
perror("server init() sck4: setsockopt SO_REUSEADDR fail\n");
}
[self close];
return NO;
}
// bind for ipv4
if (bind(self._sck_fd4, (struct sockaddr*)&server_addr, addr_len) < 0)
{
if (DEBUG_ON)
{
perror("server init() sck4: bind fail\n");
}
[self close];
return NO;
}
return YES;
}
- (BOOL) initWithPort6: (int) port AndSocketTimeout: (int) socketTimeout
{
self._sck_fd6 = socket(AF_INET6,SOCK_DGRAM,0);
if (DEBUG_ON)
{
NSLog(@"##########################server init(): _sck_fd6=%d", self._sck_fd6);
}
if (self._sck_fd6 < 0)
{
if (DEBUG_ON)
{
perror("server: _skd_fd6 init() fail\n");
}
return NO;
}
// init socket6 params
struct sockaddr_in6 server_addr6;
socklen_t addr6_len = sizeof(server_addr6);
memset(&server_addr6, 0, addr6_len);
server_addr6.sin6_family = AF_INET6;
server_addr6.sin6_port = htons(port);
server_addr6.sin6_addr = in6addr_any;
// set socket timeout
if (![self setSocketTimeout:socketTimeout SocketFd:self._sck_fd6]) {
if (DEBUG_ON) {
perror("server: sck4: setsockopt SO_RCVTIMEO fail\n");
}
[self close];
return NO;
}
// set SO_REUSEADDR for ipv6
const int opt = 1;
if (setsockopt(self._sck_fd6, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt))< 0) {
if (DEBUG_ON)
{
perror("server init() sck6: setsockopt SO_REUSEADDR fail\n");
}
[self close];
return NO;
}
// bind for ipv6
if (bind(self._sck_fd6, (struct sockaddr*)&server_addr6, addr6_len) < 0)
{
if (DEBUG_ON)
{
perror("server init() sck6: bind fail\n");
}
[self close];
return NO;
}
return YES;
}
- (id) initWithPort:(int)port AndSocketTimeout:(int)socketTimeout
{
self = [super init];
if (self) {
// create lock
self._lock = [[NSLock alloc]init];
// init
self._isClosed = NO;
self._sck_fd4 = SOCKET_NULL;
self._sck_fd6 = SOCKET_NULL;
// init sck4
if (![self initWithPort4:port AndSocketTimeout:socketTimeout]) {
if (DEBUG_ON) {
NSLog(@"fail to init socket for ipv4");
}
return nil;
}
if (port==0) {
struct sockaddr_in local_addr;
socklen_t len = sizeof(local_addr);
if (getsockname(self._sck_fd4, (struct sockaddr *)&local_addr, &len)==0) {
port = ntohs(local_addr.sin_port);
}
else {
if (DEBUG_ON) {
NSLog(@"fail to get socket port for ipv4");
}
[self close];
return nil;
}
}
_port = port;
// init sck6
if (![self initWithPort6:port AndSocketTimeout:socketTimeout]) {
if (DEBUG_ON) {
NSLog(@"fail to init socket for ipv6");
}
return nil;
}
}
return self;
}
// make sure the socket will be closed sometime
- (void)dealloc
{
if (DEBUG_ON)
{
NSLog(@"###################server dealloc()");
}
[self close];
}
- (void) close
{
[self._lock lock];
if (!self._isClosed)
{
if (self._sck_fd4!=SOCKET_NULL) {
if (DEBUG_ON)
{
NSLog(@"###################server close() fd4=%d",self._sck_fd4);
}
close(self._sck_fd4);
self._sck_fd4 = SOCKET_NULL;
}
if (self._sck_fd6!=SOCKET_NULL) {
if (DEBUG_ON)
{
NSLog(@"###################server close() fd6=%d",self._sck_fd6);
}
close(self._sck_fd6);
self._sck_fd6 = SOCKET_NULL;
}
self._isClosed = true;
}
[self._lock unlock];
}
- (void) interrupt
{
[self close];
}
- (BOOL) setSocketTimeout: (int) timeout SocketFd:(int) socketFd
{
struct timeval tv;
tv.tv_sec = timeout/1000;
tv.tv_usec = timeout%1000*1000;
if (setsockopt(socketFd,SOL_SOCKET,SO_RCVTIMEO,(char *)&tv, sizeof(tv)) < 0)
{
if (DEBUG_ON)
{
perror("server: setsockopt SO_RCVTIMEO fail\n");
}
return NO;
} else {
return YES;
}
}
- (void) setSocketTimeout:(int)timeout
{
[self setSocketTimeout:timeout SocketFd:self._sck_fd4];
[self setSocketTimeout:timeout SocketFd:self._sck_fd6];
}
- (Byte) receiveOneByte4
{
ssize_t recNumber = recv(self._sck_fd4, _buffer, BUFFER_SIZE, 0);
if (recNumber > 0)
{
return _buffer[0];
}
else if(recNumber == 0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte4 socket is closed by the other\n");
}
}
else
{
if (DEBUG_ON)
{
perror("server: receiveOneByte4 fail\n");
}
}
return UINT8_MAX;
}
- (Byte) receiveOneByte6
{
ssize_t recNumber = recv(self._sck_fd6, _buffer, BUFFER_SIZE, 0);
if (recNumber > 0)
{
return _buffer[0];
}
else if(recNumber == 0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte6 socket is closed by the other\n");
}
}
else
{
if (DEBUG_ON)
{
perror("server: receiveOneByte6 fail\n");
}
}
return UINT8_MAX;
}
- (NSData *) receiveSpecLenBytes4: (int)len
{
ssize_t recNumber = recv(self._sck_fd4, _buffer, BUFFER_SIZE, 0);
if (recNumber==len)
{
NSData *data = [[NSData alloc]initWithBytes:_buffer length:recNumber];
return data;
}
else if(recNumber==0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte4 socket is closed by the other\n");
}
}
else if(recNumber<0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte4 fail\n");
}
}
else
{
// receive rubbish message, just ignore it
}
return nil;
}
- (NSData *) receiveSpecLenBytes6:(int)len
{
ssize_t recNumber = recv(self._sck_fd6, _buffer, BUFFER_SIZE, 0);
if (recNumber==len)
{
NSData *data = [[NSData alloc]initWithBytes:_buffer length:recNumber];
return data;
}
else if(recNumber==0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte6 socket is closed by the other\n");
}
}
else if(recNumber<0)
{
if (DEBUG_ON)
{
perror("server: receiveOneByte6 fail\n");
}
}
else
{
// receive rubbish message, just ignore it
}
return nil;
}
@end