| // !$*UTF8*$! | |||||
| { | |||||
| archiveVersion = 1; | |||||
| classes = { | |||||
| }; | |||||
| objectVersion = 50; | |||||
| objects = { | |||||
| /* Begin PBXBuildFile section */ | |||||
| E622E260243F1CA5003C319D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E25F243F1CA5003C319D /* AppDelegate.m */; }; | |||||
| E622E263243F1CA5003C319D /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E262243F1CA5003C319D /* SceneDelegate.m */; }; | |||||
| E622E26B243F1CA6003C319D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E622E26A243F1CA6003C319D /* Assets.xcassets */; }; | |||||
| E622E26E243F1CA6003C319D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E622E26C243F1CA6003C319D /* LaunchScreen.storyboard */; }; | |||||
| E622E271243F1CA6003C319D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E270243F1CA6003C319D /* main.m */; }; | |||||
| E622E27B243F1CA6003C319D /* AILinkBleSDKDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E27A243F1CA6003C319D /* AILinkBleSDKDemoUITests.m */; }; | |||||
| E622E287243F1D41003C319D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E622E286243F1D40003C319D /* Main.storyboard */; }; | |||||
| E622E2DE243F1D4A003C319D /* HeightGuageScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E289243F1D49003C319D /* HeightGuageScanViewController.m */; }; | |||||
| E622E2DF243F1D4A003C319D /* HeightGuageConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E28C243F1D49003C319D /* HeightGuageConnectViewController.m */; }; | |||||
| E622E2E0243F1D4A003C319D /* SubBleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E28E243F1D4A003C319D /* SubBleManager.m */; }; | |||||
| E622E2E1243F1D4A003C319D /* InheritConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E290243F1D4A003C319D /* InheritConnectViewController.m */; }; | |||||
| E622E2E2243F1D4A003C319D /* InheritScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E291243F1D4A003C319D /* InheritScanViewController.m */; }; | |||||
| E622E2E3243F1D4A003C319D /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = E622E295243F1D4A003C319D /* LICENSE */; }; | |||||
| E622E2E4243F1D4A003C319D /* NSLayoutConstraint+MASDebugAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E298243F1D4A003C319D /* NSLayoutConstraint+MASDebugAdditions.m */; }; | |||||
| E622E2E5243F1D4A003C319D /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2A1243F1D4A003C319D /* ViewController+MASAdditions.m */; }; | |||||
| E622E2E6243F1D4A003C319D /* MASCompositeConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2A5243F1D4A003C319D /* MASCompositeConstraint.m */; }; | |||||
| E622E2E7243F1D4A003C319D /* MASConstraintMaker.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2A6243F1D4A003C319D /* MASConstraintMaker.m */; }; | |||||
| E622E2E8243F1D4A003C319D /* MASLayoutConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2A7243F1D4A003C319D /* MASLayoutConstraint.m */; }; | |||||
| E622E2E9243F1D4A003C319D /* NSArray+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2A8243F1D4A003C319D /* NSArray+MASAdditions.m */; }; | |||||
| E622E2EA243F1D4A003C319D /* View+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2A9243F1D4A003C319D /* View+MASAdditions.m */; }; | |||||
| E622E2EB243F1D4A003C319D /* MASConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2AC243F1D4A003C319D /* MASConstraint.m */; }; | |||||
| E622E2EC243F1D4A003C319D /* MASViewConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2AE243F1D4A003C319D /* MASViewConstraint.m */; }; | |||||
| E622E2ED243F1D4A003C319D /* MASViewAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2AF243F1D4A003C319D /* MASViewAttribute.m */; }; | |||||
| E622E2EE243F1D4A003C319D /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = E622E2B0243F1D4A003C319D /* README.md */; }; | |||||
| E622E2EF243F1D4A003C319D /* BloodConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2B3243F1D4A003C319D /* BloodConnectViewController.m */; }; | |||||
| E622E2F0243F1D4A003C319D /* BloodScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2B4243F1D4A003C319D /* BloodScanViewController.m */; }; | |||||
| E622E2F2243F1D4A003C319D /* AilinkSuperConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2B8243F1D4A003C319D /* AilinkSuperConnectViewController.m */; }; | |||||
| E622E2F3243F1D4A003C319D /* AiLinkSuperViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2BB243F1D4A003C319D /* AiLinkSuperViewController.m */; }; | |||||
| E622E2F4243F1D4A003C319D /* ForeheadConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2BD243F1D4A003C319D /* ForeheadConnectViewController.m */; }; | |||||
| E622E2F5243F1D4A003C319D /* ForeheadScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2C0243F1D4A003C319D /* ForeheadScanViewController.m */; }; | |||||
| E622E2F6243F1D4A003C319D /* WheelMonitorConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2C3243F1D4A003C319D /* WheelMonitorConnectViewController.m */; }; | |||||
| E622E2F7243F1D4A003C319D /* WheelMonitorScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2C5243F1D4A003C319D /* WheelMonitorScanViewController.m */; }; | |||||
| E622E2F8243F1D4A003C319D /* RemoteControlConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2CA243F1D4A003C319D /* RemoteControlConnectViewController.m */; }; | |||||
| E622E2F9243F1D4A003C319D /* RemoteControlScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2CB243F1D4A003C319D /* RemoteControlScanViewController.m */; }; | |||||
| E622E2FA243F1D4A003C319D /* BabyScaleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2CD243F1D4A003C319D /* BabyScaleViewController.m */; }; | |||||
| E622E2FB243F1D4A003C319D /* BabyScaleConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2D0243F1D4A003C319D /* BabyScaleConnectViewController.m */; }; | |||||
| E622E2FC243F1D4A003C319D /* BodyFatScaleScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2D2243F1D4A003C319D /* BodyFatScaleScanViewController.m */; }; | |||||
| E622E2FD243F1D4A003C319D /* WiFiSetupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2D3243F1D4A003C319D /* WiFiSetupViewController.m */; }; | |||||
| E622E2FE243F1D4A003C319D /* BodyFatScaleConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2D4243F1D4A003C319D /* BodyFatScaleConnectViewController.m */; }; | |||||
| E622E2FF243F1D4A003C319D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2D8243F1D4A003C319D /* ViewController.m */; }; | |||||
| E622E300243F1D4A003C319D /* ThermometerScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2DA243F1D4A003C319D /* ThermometerScanViewController.m */; }; | |||||
| E622E301243F1D4A003C319D /* ThermometerConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E622E2DD243F1D4A003C319D /* ThermometerConnectViewController.m */; }; | |||||
| E64A7EEA24404B1400D22B84 /* AILinkBleSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E64A7EE924404B1400D22B84 /* AILinkBleSDK.framework */; }; | |||||
| /* End PBXBuildFile section */ | |||||
| /* Begin PBXContainerItemProxy section */ | |||||
| E622E277243F1CA6003C319D /* PBXContainerItemProxy */ = { | |||||
| isa = PBXContainerItemProxy; | |||||
| containerPortal = E622E253243F1CA5003C319D /* Project object */; | |||||
| proxyType = 1; | |||||
| remoteGlobalIDString = E622E25A243F1CA5003C319D; | |||||
| remoteInfo = AILinkBleSDKDemo; | |||||
| }; | |||||
| /* End PBXContainerItemProxy section */ | |||||
| /* Begin PBXFileReference section */ | |||||
| E622E25B243F1CA5003C319D /* AILinkBleSDKDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AILinkBleSDKDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; | |||||
| E622E25E243F1CA5003C319D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; | |||||
| E622E25F243F1CA5003C319D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; | |||||
| E622E261243F1CA5003C319D /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; }; | |||||
| E622E262243F1CA5003C319D /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; }; | |||||
| E622E26A243F1CA6003C319D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; | |||||
| E622E26D243F1CA6003C319D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; | |||||
| E622E26F243F1CA6003C319D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | |||||
| E622E270243F1CA6003C319D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; | |||||
| E622E276243F1CA6003C319D /* AILinkBleSDKDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AILinkBleSDKDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; | |||||
| E622E27A243F1CA6003C319D /* AILinkBleSDKDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AILinkBleSDKDemoUITests.m; sourceTree = "<group>"; }; | |||||
| E622E27C243F1CA6003C319D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | |||||
| E622E286243F1D40003C319D /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; }; | |||||
| E622E289243F1D49003C319D /* HeightGuageScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HeightGuageScanViewController.m; sourceTree = "<group>"; }; | |||||
| E622E28A243F1D49003C319D /* HeightGuageConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeightGuageConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E28B243F1D49003C319D /* HeightGuageScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeightGuageScanViewController.h; sourceTree = "<group>"; }; | |||||
| E622E28C243F1D49003C319D /* HeightGuageConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HeightGuageConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E28E243F1D4A003C319D /* SubBleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SubBleManager.m; sourceTree = "<group>"; }; | |||||
| E622E28F243F1D4A003C319D /* InheritScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InheritScanViewController.h; sourceTree = "<group>"; }; | |||||
| E622E290243F1D4A003C319D /* InheritConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InheritConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E291243F1D4A003C319D /* InheritScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InheritScanViewController.m; sourceTree = "<group>"; }; | |||||
| E622E292243F1D4A003C319D /* SubBleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubBleManager.h; sourceTree = "<group>"; }; | |||||
| E622E293243F1D4A003C319D /* InheritConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InheritConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E295243F1D4A003C319D /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; }; | |||||
| E622E297243F1D4A003C319D /* MASCompositeConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASCompositeConstraint.h; sourceTree = "<group>"; }; | |||||
| E622E298243F1D4A003C319D /* NSLayoutConstraint+MASDebugAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+MASDebugAdditions.m"; sourceTree = "<group>"; }; | |||||
| E622E299243F1D4A003C319D /* MASConstraint+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASConstraint+Private.h"; sourceTree = "<group>"; }; | |||||
| E622E29A243F1D4A003C319D /* MASLayoutConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASLayoutConstraint.h; sourceTree = "<group>"; }; | |||||
| E622E29B243F1D4A003C319D /* NSArray+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASShorthandAdditions.h"; sourceTree = "<group>"; }; | |||||
| E622E29C243F1D4A003C319D /* MASConstraintMaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraintMaker.h; sourceTree = "<group>"; }; | |||||
| E622E29D243F1D4A003C319D /* View+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASAdditions.h"; sourceTree = "<group>"; }; | |||||
| E622E29E243F1D4A003C319D /* NSArray+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASAdditions.h"; sourceTree = "<group>"; }; | |||||
| E622E29F243F1D4A003C319D /* MASUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASUtilities.h; sourceTree = "<group>"; }; | |||||
| E622E2A0243F1D4A003C319D /* MASViewAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewAttribute.h; sourceTree = "<group>"; }; | |||||
| E622E2A1243F1D4A003C319D /* ViewController+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ViewController+MASAdditions.m"; sourceTree = "<group>"; }; | |||||
| E622E2A2243F1D4A003C319D /* MASViewConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewConstraint.h; sourceTree = "<group>"; }; | |||||
| E622E2A3243F1D4A003C319D /* MASConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraint.h; sourceTree = "<group>"; }; | |||||
| E622E2A4243F1D4A003C319D /* NSLayoutConstraint+MASDebugAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSLayoutConstraint+MASDebugAdditions.h"; sourceTree = "<group>"; }; | |||||
| E622E2A5243F1D4A003C319D /* MASCompositeConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASCompositeConstraint.m; sourceTree = "<group>"; }; | |||||
| E622E2A6243F1D4A003C319D /* MASConstraintMaker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraintMaker.m; sourceTree = "<group>"; }; | |||||
| E622E2A7243F1D4A003C319D /* MASLayoutConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASLayoutConstraint.m; sourceTree = "<group>"; }; | |||||
| E622E2A8243F1D4A003C319D /* NSArray+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+MASAdditions.m"; sourceTree = "<group>"; }; | |||||
| E622E2A9243F1D4A003C319D /* View+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "View+MASAdditions.m"; sourceTree = "<group>"; }; | |||||
| E622E2AA243F1D4A003C319D /* View+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASShorthandAdditions.h"; sourceTree = "<group>"; }; | |||||
| E622E2AB243F1D4A003C319D /* Masonry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Masonry.h; sourceTree = "<group>"; }; | |||||
| E622E2AC243F1D4A003C319D /* MASConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraint.m; sourceTree = "<group>"; }; | |||||
| E622E2AD243F1D4A003C319D /* ViewController+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ViewController+MASAdditions.h"; sourceTree = "<group>"; }; | |||||
| E622E2AE243F1D4A003C319D /* MASViewConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewConstraint.m; sourceTree = "<group>"; }; | |||||
| E622E2AF243F1D4A003C319D /* MASViewAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewAttribute.m; sourceTree = "<group>"; }; | |||||
| E622E2B0243F1D4A003C319D /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; }; | |||||
| E622E2B2243F1D4A003C319D /* BloodScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BloodScanViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2B3243F1D4A003C319D /* BloodConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BloodConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2B4243F1D4A003C319D /* BloodScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BloodScanViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2B5243F1D4A003C319D /* BloodConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BloodConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2B8243F1D4A003C319D /* AilinkSuperConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AilinkSuperConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2B9243F1D4A003C319D /* AiLinkSuperViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AiLinkSuperViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2BA243F1D4A003C319D /* AilinkSuperConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AilinkSuperConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2BB243F1D4A003C319D /* AiLinkSuperViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AiLinkSuperViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2BD243F1D4A003C319D /* ForeheadConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ForeheadConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2BE243F1D4A003C319D /* ForeheadScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForeheadScanViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2BF243F1D4A003C319D /* ForeheadConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForeheadConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2C0243F1D4A003C319D /* ForeheadScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ForeheadScanViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2C1243F1D4A003C319D /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2C3243F1D4A003C319D /* WheelMonitorConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WheelMonitorConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2C4243F1D4A003C319D /* WheelMonitorScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelMonitorScanViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2C5243F1D4A003C319D /* WheelMonitorScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WheelMonitorScanViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2C6243F1D4A003C319D /* WheelMonitorConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelMonitorConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2C8243F1D4A003C319D /* RemoteControlScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteControlScanViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2C9243F1D4A003C319D /* RemoteControlConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteControlConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2CA243F1D4A003C319D /* RemoteControlConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RemoteControlConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2CB243F1D4A003C319D /* RemoteControlScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RemoteControlScanViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2CD243F1D4A003C319D /* BabyScaleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BabyScaleViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2CE243F1D4A003C319D /* BabyScaleConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BabyScaleConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2CF243F1D4A003C319D /* BabyScaleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BabyScaleViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2D0243F1D4A003C319D /* BabyScaleConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BabyScaleConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2D2243F1D4A003C319D /* BodyFatScaleScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BodyFatScaleScanViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2D3243F1D4A003C319D /* WiFiSetupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WiFiSetupViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2D4243F1D4A003C319D /* BodyFatScaleConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BodyFatScaleConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2D5243F1D4A003C319D /* WiFiSetupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WiFiSetupViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2D6243F1D4A003C319D /* BodyFatScaleScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BodyFatScaleScanViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2D7243F1D4A003C319D /* BodyFatScaleConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BodyFatScaleConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2D8243F1D4A003C319D /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2DA243F1D4A003C319D /* ThermometerScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThermometerScanViewController.m; sourceTree = "<group>"; }; | |||||
| E622E2DB243F1D4A003C319D /* ThermometerConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThermometerConnectViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2DC243F1D4A003C319D /* ThermometerScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThermometerScanViewController.h; sourceTree = "<group>"; }; | |||||
| E622E2DD243F1D4A003C319D /* ThermometerConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThermometerConnectViewController.m; sourceTree = "<group>"; }; | |||||
| E64A7EE924404B1400D22B84 /* AILinkBleSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = AILinkBleSDK.framework; sourceTree = "<group>"; }; | |||||
| /* End PBXFileReference section */ | |||||
| /* Begin PBXFrameworksBuildPhase section */ | |||||
| E622E258243F1CA5003C319D /* Frameworks */ = { | |||||
| isa = PBXFrameworksBuildPhase; | |||||
| buildActionMask = 2147483647; | |||||
| files = ( | |||||
| E64A7EEA24404B1400D22B84 /* AILinkBleSDK.framework in Frameworks */, | |||||
| ); | |||||
| runOnlyForDeploymentPostprocessing = 0; | |||||
| }; | |||||
| E622E273243F1CA6003C319D /* Frameworks */ = { | |||||
| isa = PBXFrameworksBuildPhase; | |||||
| buildActionMask = 2147483647; | |||||
| files = ( | |||||
| ); | |||||
| runOnlyForDeploymentPostprocessing = 0; | |||||
| }; | |||||
| /* End PBXFrameworksBuildPhase section */ | |||||
| /* Begin PBXGroup section */ | |||||
| E622E252243F1CA5003C319D = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E25D243F1CA5003C319D /* AILinkBleSDKDemo */, | |||||
| E622E279243F1CA6003C319D /* AILinkBleSDKDemoUITests */, | |||||
| E622E25C243F1CA5003C319D /* Products */, | |||||
| ); | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E25C243F1CA5003C319D /* Products */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E25B243F1CA5003C319D /* AILinkBleSDKDemo.app */, | |||||
| E622E276243F1CA6003C319D /* AILinkBleSDKDemoUITests.xctest */, | |||||
| ); | |||||
| name = Products; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E25D243F1CA5003C319D /* AILinkBleSDKDemo */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E64A7EE924404B1400D22B84 /* AILinkBleSDK.framework */, | |||||
| E622E2B7243F1D4A003C319D /* AiLinkSuper */, | |||||
| E622E2CC243F1D4A003C319D /* BabyScale */, | |||||
| E622E2B1243F1D4A003C319D /* BloodPressure */, | |||||
| E622E2D1243F1D4A003C319D /* BodyFatScale */, | |||||
| E622E2BC243F1D4A003C319D /* Forehead */, | |||||
| E622E288243F1D49003C319D /* HeightGuage */, | |||||
| E622E28D243F1D4A003C319D /* Inherit */, | |||||
| E622E294243F1D4A003C319D /* Masonry */, | |||||
| E622E2C7243F1D4A003C319D /* RemoteControl */, | |||||
| E622E2D9243F1D4A003C319D /* Thermometer */, | |||||
| E622E2C2243F1D4A003C319D /* WheelMonitor */, | |||||
| E622E25E243F1CA5003C319D /* AppDelegate.h */, | |||||
| E622E25F243F1CA5003C319D /* AppDelegate.m */, | |||||
| E622E261243F1CA5003C319D /* SceneDelegate.h */, | |||||
| E622E262243F1CA5003C319D /* SceneDelegate.m */, | |||||
| E622E2C1243F1D4A003C319D /* ViewController.h */, | |||||
| E622E2D8243F1D4A003C319D /* ViewController.m */, | |||||
| E622E286243F1D40003C319D /* Main.storyboard */, | |||||
| E622E26A243F1CA6003C319D /* Assets.xcassets */, | |||||
| E622E26C243F1CA6003C319D /* LaunchScreen.storyboard */, | |||||
| E622E26F243F1CA6003C319D /* Info.plist */, | |||||
| E622E270243F1CA6003C319D /* main.m */, | |||||
| ); | |||||
| path = AILinkBleSDKDemo; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E279243F1CA6003C319D /* AILinkBleSDKDemoUITests */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E27A243F1CA6003C319D /* AILinkBleSDKDemoUITests.m */, | |||||
| E622E27C243F1CA6003C319D /* Info.plist */, | |||||
| ); | |||||
| path = AILinkBleSDKDemoUITests; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E288243F1D49003C319D /* HeightGuage */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E289243F1D49003C319D /* HeightGuageScanViewController.m */, | |||||
| E622E28A243F1D49003C319D /* HeightGuageConnectViewController.h */, | |||||
| E622E28B243F1D49003C319D /* HeightGuageScanViewController.h */, | |||||
| E622E28C243F1D49003C319D /* HeightGuageConnectViewController.m */, | |||||
| ); | |||||
| path = HeightGuage; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E28D243F1D4A003C319D /* Inherit */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E28E243F1D4A003C319D /* SubBleManager.m */, | |||||
| E622E28F243F1D4A003C319D /* InheritScanViewController.h */, | |||||
| E622E290243F1D4A003C319D /* InheritConnectViewController.m */, | |||||
| E622E291243F1D4A003C319D /* InheritScanViewController.m */, | |||||
| E622E292243F1D4A003C319D /* SubBleManager.h */, | |||||
| E622E293243F1D4A003C319D /* InheritConnectViewController.h */, | |||||
| ); | |||||
| path = Inherit; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E294243F1D4A003C319D /* Masonry */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E295243F1D4A003C319D /* LICENSE */, | |||||
| E622E296243F1D4A003C319D /* Masonry */, | |||||
| E622E2B0243F1D4A003C319D /* README.md */, | |||||
| ); | |||||
| path = Masonry; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E296243F1D4A003C319D /* Masonry */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E297243F1D4A003C319D /* MASCompositeConstraint.h */, | |||||
| E622E298243F1D4A003C319D /* NSLayoutConstraint+MASDebugAdditions.m */, | |||||
| E622E299243F1D4A003C319D /* MASConstraint+Private.h */, | |||||
| E622E29A243F1D4A003C319D /* MASLayoutConstraint.h */, | |||||
| E622E29B243F1D4A003C319D /* NSArray+MASShorthandAdditions.h */, | |||||
| E622E29C243F1D4A003C319D /* MASConstraintMaker.h */, | |||||
| E622E29D243F1D4A003C319D /* View+MASAdditions.h */, | |||||
| E622E29E243F1D4A003C319D /* NSArray+MASAdditions.h */, | |||||
| E622E29F243F1D4A003C319D /* MASUtilities.h */, | |||||
| E622E2A0243F1D4A003C319D /* MASViewAttribute.h */, | |||||
| E622E2A1243F1D4A003C319D /* ViewController+MASAdditions.m */, | |||||
| E622E2A2243F1D4A003C319D /* MASViewConstraint.h */, | |||||
| E622E2A3243F1D4A003C319D /* MASConstraint.h */, | |||||
| E622E2A4243F1D4A003C319D /* NSLayoutConstraint+MASDebugAdditions.h */, | |||||
| E622E2A5243F1D4A003C319D /* MASCompositeConstraint.m */, | |||||
| E622E2A6243F1D4A003C319D /* MASConstraintMaker.m */, | |||||
| E622E2A7243F1D4A003C319D /* MASLayoutConstraint.m */, | |||||
| E622E2A8243F1D4A003C319D /* NSArray+MASAdditions.m */, | |||||
| E622E2A9243F1D4A003C319D /* View+MASAdditions.m */, | |||||
| E622E2AA243F1D4A003C319D /* View+MASShorthandAdditions.h */, | |||||
| E622E2AB243F1D4A003C319D /* Masonry.h */, | |||||
| E622E2AC243F1D4A003C319D /* MASConstraint.m */, | |||||
| E622E2AD243F1D4A003C319D /* ViewController+MASAdditions.h */, | |||||
| E622E2AE243F1D4A003C319D /* MASViewConstraint.m */, | |||||
| E622E2AF243F1D4A003C319D /* MASViewAttribute.m */, | |||||
| ); | |||||
| path = Masonry; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E2B1243F1D4A003C319D /* BloodPressure */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E2B2243F1D4A003C319D /* BloodScanViewController.h */, | |||||
| E622E2B3243F1D4A003C319D /* BloodConnectViewController.m */, | |||||
| E622E2B4243F1D4A003C319D /* BloodScanViewController.m */, | |||||
| E622E2B5243F1D4A003C319D /* BloodConnectViewController.h */, | |||||
| ); | |||||
| path = BloodPressure; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E2B7243F1D4A003C319D /* AiLinkSuper */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E2B8243F1D4A003C319D /* AilinkSuperConnectViewController.m */, | |||||
| E622E2B9243F1D4A003C319D /* AiLinkSuperViewController.h */, | |||||
| E622E2BA243F1D4A003C319D /* AilinkSuperConnectViewController.h */, | |||||
| E622E2BB243F1D4A003C319D /* AiLinkSuperViewController.m */, | |||||
| ); | |||||
| path = AiLinkSuper; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E2BC243F1D4A003C319D /* Forehead */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E2BD243F1D4A003C319D /* ForeheadConnectViewController.m */, | |||||
| E622E2BE243F1D4A003C319D /* ForeheadScanViewController.h */, | |||||
| E622E2BF243F1D4A003C319D /* ForeheadConnectViewController.h */, | |||||
| E622E2C0243F1D4A003C319D /* ForeheadScanViewController.m */, | |||||
| ); | |||||
| path = Forehead; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E2C2243F1D4A003C319D /* WheelMonitor */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E2C3243F1D4A003C319D /* WheelMonitorConnectViewController.m */, | |||||
| E622E2C4243F1D4A003C319D /* WheelMonitorScanViewController.h */, | |||||
| E622E2C5243F1D4A003C319D /* WheelMonitorScanViewController.m */, | |||||
| E622E2C6243F1D4A003C319D /* WheelMonitorConnectViewController.h */, | |||||
| ); | |||||
| path = WheelMonitor; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E2C7243F1D4A003C319D /* RemoteControl */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E2C8243F1D4A003C319D /* RemoteControlScanViewController.h */, | |||||
| E622E2C9243F1D4A003C319D /* RemoteControlConnectViewController.h */, | |||||
| E622E2CA243F1D4A003C319D /* RemoteControlConnectViewController.m */, | |||||
| E622E2CB243F1D4A003C319D /* RemoteControlScanViewController.m */, | |||||
| ); | |||||
| path = RemoteControl; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E2CC243F1D4A003C319D /* BabyScale */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E2CD243F1D4A003C319D /* BabyScaleViewController.m */, | |||||
| E622E2CE243F1D4A003C319D /* BabyScaleConnectViewController.h */, | |||||
| E622E2CF243F1D4A003C319D /* BabyScaleViewController.h */, | |||||
| E622E2D0243F1D4A003C319D /* BabyScaleConnectViewController.m */, | |||||
| ); | |||||
| path = BabyScale; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E2D1243F1D4A003C319D /* BodyFatScale */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E2D2243F1D4A003C319D /* BodyFatScaleScanViewController.m */, | |||||
| E622E2D3243F1D4A003C319D /* WiFiSetupViewController.m */, | |||||
| E622E2D4243F1D4A003C319D /* BodyFatScaleConnectViewController.m */, | |||||
| E622E2D5243F1D4A003C319D /* WiFiSetupViewController.h */, | |||||
| E622E2D6243F1D4A003C319D /* BodyFatScaleScanViewController.h */, | |||||
| E622E2D7243F1D4A003C319D /* BodyFatScaleConnectViewController.h */, | |||||
| ); | |||||
| path = BodyFatScale; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| E622E2D9243F1D4A003C319D /* Thermometer */ = { | |||||
| isa = PBXGroup; | |||||
| children = ( | |||||
| E622E2DA243F1D4A003C319D /* ThermometerScanViewController.m */, | |||||
| E622E2DB243F1D4A003C319D /* ThermometerConnectViewController.h */, | |||||
| E622E2DC243F1D4A003C319D /* ThermometerScanViewController.h */, | |||||
| E622E2DD243F1D4A003C319D /* ThermometerConnectViewController.m */, | |||||
| ); | |||||
| path = Thermometer; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| /* End PBXGroup section */ | |||||
| /* Begin PBXNativeTarget section */ | |||||
| E622E25A243F1CA5003C319D /* AILinkBleSDKDemo */ = { | |||||
| isa = PBXNativeTarget; | |||||
| buildConfigurationList = E622E27F243F1CA6003C319D /* Build configuration list for PBXNativeTarget "AILinkBleSDKDemo" */; | |||||
| buildPhases = ( | |||||
| E622E257243F1CA5003C319D /* Sources */, | |||||
| E622E258243F1CA5003C319D /* Frameworks */, | |||||
| E622E259243F1CA5003C319D /* Resources */, | |||||
| ); | |||||
| buildRules = ( | |||||
| ); | |||||
| dependencies = ( | |||||
| ); | |||||
| name = AILinkBleSDKDemo; | |||||
| productName = AILinkBleSDKDemo; | |||||
| productReference = E622E25B243F1CA5003C319D /* AILinkBleSDKDemo.app */; | |||||
| productType = "com.apple.product-type.application"; | |||||
| }; | |||||
| E622E275243F1CA6003C319D /* AILinkBleSDKDemoUITests */ = { | |||||
| isa = PBXNativeTarget; | |||||
| buildConfigurationList = E622E282243F1CA6003C319D /* Build configuration list for PBXNativeTarget "AILinkBleSDKDemoUITests" */; | |||||
| buildPhases = ( | |||||
| E622E272243F1CA6003C319D /* Sources */, | |||||
| E622E273243F1CA6003C319D /* Frameworks */, | |||||
| E622E274243F1CA6003C319D /* Resources */, | |||||
| ); | |||||
| buildRules = ( | |||||
| ); | |||||
| dependencies = ( | |||||
| E622E278243F1CA6003C319D /* PBXTargetDependency */, | |||||
| ); | |||||
| name = AILinkBleSDKDemoUITests; | |||||
| productName = AILinkBleSDKDemoUITests; | |||||
| productReference = E622E276243F1CA6003C319D /* AILinkBleSDKDemoUITests.xctest */; | |||||
| productType = "com.apple.product-type.bundle.ui-testing"; | |||||
| }; | |||||
| /* End PBXNativeTarget section */ | |||||
| /* Begin PBXProject section */ | |||||
| E622E253243F1CA5003C319D /* Project object */ = { | |||||
| isa = PBXProject; | |||||
| attributes = { | |||||
| LastUpgradeCheck = 1130; | |||||
| ORGANIZATIONNAME = IOT; | |||||
| TargetAttributes = { | |||||
| E622E25A243F1CA5003C319D = { | |||||
| CreatedOnToolsVersion = 11.3.1; | |||||
| }; | |||||
| E622E275243F1CA6003C319D = { | |||||
| CreatedOnToolsVersion = 11.3.1; | |||||
| TestTargetID = E622E25A243F1CA5003C319D; | |||||
| }; | |||||
| }; | |||||
| }; | |||||
| buildConfigurationList = E622E256243F1CA5003C319D /* Build configuration list for PBXProject "AILinkBleSDKDemo" */; | |||||
| compatibilityVersion = "Xcode 9.3"; | |||||
| developmentRegion = en; | |||||
| hasScannedForEncodings = 0; | |||||
| knownRegions = ( | |||||
| en, | |||||
| Base, | |||||
| ); | |||||
| mainGroup = E622E252243F1CA5003C319D; | |||||
| productRefGroup = E622E25C243F1CA5003C319D /* Products */; | |||||
| projectDirPath = ""; | |||||
| projectRoot = ""; | |||||
| targets = ( | |||||
| E622E25A243F1CA5003C319D /* AILinkBleSDKDemo */, | |||||
| E622E275243F1CA6003C319D /* AILinkBleSDKDemoUITests */, | |||||
| ); | |||||
| }; | |||||
| /* End PBXProject section */ | |||||
| /* Begin PBXResourcesBuildPhase section */ | |||||
| E622E259243F1CA5003C319D /* Resources */ = { | |||||
| isa = PBXResourcesBuildPhase; | |||||
| buildActionMask = 2147483647; | |||||
| files = ( | |||||
| E622E287243F1D41003C319D /* Main.storyboard in Resources */, | |||||
| E622E26E243F1CA6003C319D /* LaunchScreen.storyboard in Resources */, | |||||
| E622E2EE243F1D4A003C319D /* README.md in Resources */, | |||||
| E622E2E3243F1D4A003C319D /* LICENSE in Resources */, | |||||
| E622E26B243F1CA6003C319D /* Assets.xcassets in Resources */, | |||||
| ); | |||||
| runOnlyForDeploymentPostprocessing = 0; | |||||
| }; | |||||
| E622E274243F1CA6003C319D /* Resources */ = { | |||||
| isa = PBXResourcesBuildPhase; | |||||
| buildActionMask = 2147483647; | |||||
| files = ( | |||||
| ); | |||||
| runOnlyForDeploymentPostprocessing = 0; | |||||
| }; | |||||
| /* End PBXResourcesBuildPhase section */ | |||||
| /* Begin PBXSourcesBuildPhase section */ | |||||
| E622E257243F1CA5003C319D /* Sources */ = { | |||||
| isa = PBXSourcesBuildPhase; | |||||
| buildActionMask = 2147483647; | |||||
| files = ( | |||||
| E622E2FF243F1D4A003C319D /* ViewController.m in Sources */, | |||||
| E622E2EF243F1D4A003C319D /* BloodConnectViewController.m in Sources */, | |||||
| E622E2F6243F1D4A003C319D /* WheelMonitorConnectViewController.m in Sources */, | |||||
| E622E2EB243F1D4A003C319D /* MASConstraint.m in Sources */, | |||||
| E622E2E9243F1D4A003C319D /* NSArray+MASAdditions.m in Sources */, | |||||
| E622E2FA243F1D4A003C319D /* BabyScaleViewController.m in Sources */, | |||||
| E622E301243F1D4A003C319D /* ThermometerConnectViewController.m in Sources */, | |||||
| E622E2F8243F1D4A003C319D /* RemoteControlConnectViewController.m in Sources */, | |||||
| E622E2FE243F1D4A003C319D /* BodyFatScaleConnectViewController.m in Sources */, | |||||
| E622E2DF243F1D4A003C319D /* HeightGuageConnectViewController.m in Sources */, | |||||
| E622E2DE243F1D4A003C319D /* HeightGuageScanViewController.m in Sources */, | |||||
| E622E2FC243F1D4A003C319D /* BodyFatScaleScanViewController.m in Sources */, | |||||
| E622E2E4243F1D4A003C319D /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, | |||||
| E622E2ED243F1D4A003C319D /* MASViewAttribute.m in Sources */, | |||||
| E622E2E1243F1D4A003C319D /* InheritConnectViewController.m in Sources */, | |||||
| E622E2F4243F1D4A003C319D /* ForeheadConnectViewController.m in Sources */, | |||||
| E622E2EC243F1D4A003C319D /* MASViewConstraint.m in Sources */, | |||||
| E622E2E0243F1D4A003C319D /* SubBleManager.m in Sources */, | |||||
| E622E2E7243F1D4A003C319D /* MASConstraintMaker.m in Sources */, | |||||
| E622E2E8243F1D4A003C319D /* MASLayoutConstraint.m in Sources */, | |||||
| E622E300243F1D4A003C319D /* ThermometerScanViewController.m in Sources */, | |||||
| E622E2F9243F1D4A003C319D /* RemoteControlScanViewController.m in Sources */, | |||||
| E622E2F3243F1D4A003C319D /* AiLinkSuperViewController.m in Sources */, | |||||
| E622E2FD243F1D4A003C319D /* WiFiSetupViewController.m in Sources */, | |||||
| E622E2FB243F1D4A003C319D /* BabyScaleConnectViewController.m in Sources */, | |||||
| E622E2EA243F1D4A003C319D /* View+MASAdditions.m in Sources */, | |||||
| E622E2F2243F1D4A003C319D /* AilinkSuperConnectViewController.m in Sources */, | |||||
| E622E2E6243F1D4A003C319D /* MASCompositeConstraint.m in Sources */, | |||||
| E622E2F7243F1D4A003C319D /* WheelMonitorScanViewController.m in Sources */, | |||||
| E622E2F5243F1D4A003C319D /* ForeheadScanViewController.m in Sources */, | |||||
| E622E260243F1CA5003C319D /* AppDelegate.m in Sources */, | |||||
| E622E2E5243F1D4A003C319D /* ViewController+MASAdditions.m in Sources */, | |||||
| E622E2F0243F1D4A003C319D /* BloodScanViewController.m in Sources */, | |||||
| E622E2E2243F1D4A003C319D /* InheritScanViewController.m in Sources */, | |||||
| E622E271243F1CA6003C319D /* main.m in Sources */, | |||||
| E622E263243F1CA5003C319D /* SceneDelegate.m in Sources */, | |||||
| ); | |||||
| runOnlyForDeploymentPostprocessing = 0; | |||||
| }; | |||||
| E622E272243F1CA6003C319D /* Sources */ = { | |||||
| isa = PBXSourcesBuildPhase; | |||||
| buildActionMask = 2147483647; | |||||
| files = ( | |||||
| E622E27B243F1CA6003C319D /* AILinkBleSDKDemoUITests.m in Sources */, | |||||
| ); | |||||
| runOnlyForDeploymentPostprocessing = 0; | |||||
| }; | |||||
| /* End PBXSourcesBuildPhase section */ | |||||
| /* Begin PBXTargetDependency section */ | |||||
| E622E278243F1CA6003C319D /* PBXTargetDependency */ = { | |||||
| isa = PBXTargetDependency; | |||||
| target = E622E25A243F1CA5003C319D /* AILinkBleSDKDemo */; | |||||
| targetProxy = E622E277243F1CA6003C319D /* PBXContainerItemProxy */; | |||||
| }; | |||||
| /* End PBXTargetDependency section */ | |||||
| /* Begin PBXVariantGroup section */ | |||||
| E622E26C243F1CA6003C319D /* LaunchScreen.storyboard */ = { | |||||
| isa = PBXVariantGroup; | |||||
| children = ( | |||||
| E622E26D243F1CA6003C319D /* Base */, | |||||
| ); | |||||
| name = LaunchScreen.storyboard; | |||||
| sourceTree = "<group>"; | |||||
| }; | |||||
| /* End PBXVariantGroup section */ | |||||
| /* Begin XCBuildConfiguration section */ | |||||
| E622E27D243F1CA6003C319D /* Debug */ = { | |||||
| isa = XCBuildConfiguration; | |||||
| buildSettings = { | |||||
| ALWAYS_SEARCH_USER_PATHS = NO; | |||||
| CLANG_ANALYZER_NONNULL = YES; | |||||
| CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | |||||
| CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; | |||||
| CLANG_CXX_LIBRARY = "libc++"; | |||||
| CLANG_ENABLE_MODULES = YES; | |||||
| CLANG_ENABLE_OBJC_ARC = YES; | |||||
| CLANG_ENABLE_OBJC_WEAK = YES; | |||||
| CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | |||||
| CLANG_WARN_BOOL_CONVERSION = YES; | |||||
| CLANG_WARN_COMMA = YES; | |||||
| CLANG_WARN_CONSTANT_CONVERSION = YES; | |||||
| CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | |||||
| CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | |||||
| CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | |||||
| CLANG_WARN_EMPTY_BODY = YES; | |||||
| CLANG_WARN_ENUM_CONVERSION = YES; | |||||
| CLANG_WARN_INFINITE_RECURSION = YES; | |||||
| CLANG_WARN_INT_CONVERSION = YES; | |||||
| CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | |||||
| CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | |||||
| CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | |||||
| CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | |||||
| CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | |||||
| CLANG_WARN_STRICT_PROTOTYPES = YES; | |||||
| CLANG_WARN_SUSPICIOUS_MOVE = YES; | |||||
| CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; | |||||
| CLANG_WARN_UNREACHABLE_CODE = YES; | |||||
| CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | |||||
| COPY_PHASE_STRIP = NO; | |||||
| DEBUG_INFORMATION_FORMAT = dwarf; | |||||
| ENABLE_STRICT_OBJC_MSGSEND = YES; | |||||
| ENABLE_TESTABILITY = YES; | |||||
| GCC_C_LANGUAGE_STANDARD = gnu11; | |||||
| GCC_DYNAMIC_NO_PIC = NO; | |||||
| GCC_NO_COMMON_BLOCKS = YES; | |||||
| GCC_OPTIMIZATION_LEVEL = 0; | |||||
| GCC_PREPROCESSOR_DEFINITIONS = ( | |||||
| "DEBUG=1", | |||||
| "$(inherited)", | |||||
| ); | |||||
| GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | |||||
| GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | |||||
| GCC_WARN_UNDECLARED_SELECTOR = YES; | |||||
| GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | |||||
| GCC_WARN_UNUSED_FUNCTION = YES; | |||||
| GCC_WARN_UNUSED_VARIABLE = YES; | |||||
| IPHONEOS_DEPLOYMENT_TARGET = 13.2; | |||||
| MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; | |||||
| MTL_FAST_MATH = YES; | |||||
| ONLY_ACTIVE_ARCH = YES; | |||||
| SDKROOT = iphoneos; | |||||
| }; | |||||
| name = Debug; | |||||
| }; | |||||
| E622E27E243F1CA6003C319D /* Release */ = { | |||||
| isa = XCBuildConfiguration; | |||||
| buildSettings = { | |||||
| ALWAYS_SEARCH_USER_PATHS = NO; | |||||
| CLANG_ANALYZER_NONNULL = YES; | |||||
| CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | |||||
| CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; | |||||
| CLANG_CXX_LIBRARY = "libc++"; | |||||
| CLANG_ENABLE_MODULES = YES; | |||||
| CLANG_ENABLE_OBJC_ARC = YES; | |||||
| CLANG_ENABLE_OBJC_WEAK = YES; | |||||
| CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | |||||
| CLANG_WARN_BOOL_CONVERSION = YES; | |||||
| CLANG_WARN_COMMA = YES; | |||||
| CLANG_WARN_CONSTANT_CONVERSION = YES; | |||||
| CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | |||||
| CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | |||||
| CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | |||||
| CLANG_WARN_EMPTY_BODY = YES; | |||||
| CLANG_WARN_ENUM_CONVERSION = YES; | |||||
| CLANG_WARN_INFINITE_RECURSION = YES; | |||||
| CLANG_WARN_INT_CONVERSION = YES; | |||||
| CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | |||||
| CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | |||||
| CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | |||||
| CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | |||||
| CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | |||||
| CLANG_WARN_STRICT_PROTOTYPES = YES; | |||||
| CLANG_WARN_SUSPICIOUS_MOVE = YES; | |||||
| CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; | |||||
| CLANG_WARN_UNREACHABLE_CODE = YES; | |||||
| CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | |||||
| COPY_PHASE_STRIP = NO; | |||||
| DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | |||||
| ENABLE_NS_ASSERTIONS = NO; | |||||
| ENABLE_STRICT_OBJC_MSGSEND = YES; | |||||
| GCC_C_LANGUAGE_STANDARD = gnu11; | |||||
| GCC_NO_COMMON_BLOCKS = YES; | |||||
| GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | |||||
| GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | |||||
| GCC_WARN_UNDECLARED_SELECTOR = YES; | |||||
| GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | |||||
| GCC_WARN_UNUSED_FUNCTION = YES; | |||||
| GCC_WARN_UNUSED_VARIABLE = YES; | |||||
| IPHONEOS_DEPLOYMENT_TARGET = 13.2; | |||||
| MTL_ENABLE_DEBUG_INFO = NO; | |||||
| MTL_FAST_MATH = YES; | |||||
| SDKROOT = iphoneos; | |||||
| VALIDATE_PRODUCT = YES; | |||||
| }; | |||||
| name = Release; | |||||
| }; | |||||
| E622E280243F1CA6003C319D /* Debug */ = { | |||||
| isa = XCBuildConfiguration; | |||||
| buildSettings = { | |||||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | |||||
| CODE_SIGN_STYLE = Automatic; | |||||
| DEVELOPMENT_TEAM = YEU77XR292; | |||||
| FRAMEWORK_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "$(PROJECT_DIR)/AILinkBleSDKDemo", | |||||
| ); | |||||
| INFOPLIST_FILE = AILinkBleSDKDemo/Info.plist; | |||||
| LD_RUNPATH_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "@executable_path/Frameworks", | |||||
| ); | |||||
| PRODUCT_BUNDLE_IDENTIFIER = com.pingwang.AILinkBleSDKDemo; | |||||
| PRODUCT_NAME = "$(TARGET_NAME)"; | |||||
| TARGETED_DEVICE_FAMILY = "1,2"; | |||||
| }; | |||||
| name = Debug; | |||||
| }; | |||||
| E622E281243F1CA6003C319D /* Release */ = { | |||||
| isa = XCBuildConfiguration; | |||||
| buildSettings = { | |||||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | |||||
| CODE_SIGN_STYLE = Automatic; | |||||
| DEVELOPMENT_TEAM = YEU77XR292; | |||||
| FRAMEWORK_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "$(PROJECT_DIR)/AILinkBleSDKDemo", | |||||
| ); | |||||
| INFOPLIST_FILE = AILinkBleSDKDemo/Info.plist; | |||||
| LD_RUNPATH_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "@executable_path/Frameworks", | |||||
| ); | |||||
| PRODUCT_BUNDLE_IDENTIFIER = com.pingwang.AILinkBleSDKDemo; | |||||
| PRODUCT_NAME = "$(TARGET_NAME)"; | |||||
| TARGETED_DEVICE_FAMILY = "1,2"; | |||||
| }; | |||||
| name = Release; | |||||
| }; | |||||
| E622E283243F1CA6003C319D /* Debug */ = { | |||||
| isa = XCBuildConfiguration; | |||||
| buildSettings = { | |||||
| CODE_SIGN_STYLE = Automatic; | |||||
| DEVELOPMENT_TEAM = YEU77XR292; | |||||
| INFOPLIST_FILE = AILinkBleSDKDemoUITests/Info.plist; | |||||
| LD_RUNPATH_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "@executable_path/Frameworks", | |||||
| "@loader_path/Frameworks", | |||||
| ); | |||||
| PRODUCT_BUNDLE_IDENTIFIER = com.pingwang.AILinkBleSDKDemoUITests; | |||||
| PRODUCT_NAME = "$(TARGET_NAME)"; | |||||
| TARGETED_DEVICE_FAMILY = "1,2"; | |||||
| TEST_TARGET_NAME = AILinkBleSDKDemo; | |||||
| }; | |||||
| name = Debug; | |||||
| }; | |||||
| E622E284243F1CA6003C319D /* Release */ = { | |||||
| isa = XCBuildConfiguration; | |||||
| buildSettings = { | |||||
| CODE_SIGN_STYLE = Automatic; | |||||
| DEVELOPMENT_TEAM = YEU77XR292; | |||||
| INFOPLIST_FILE = AILinkBleSDKDemoUITests/Info.plist; | |||||
| LD_RUNPATH_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "@executable_path/Frameworks", | |||||
| "@loader_path/Frameworks", | |||||
| ); | |||||
| PRODUCT_BUNDLE_IDENTIFIER = com.pingwang.AILinkBleSDKDemoUITests; | |||||
| PRODUCT_NAME = "$(TARGET_NAME)"; | |||||
| TARGETED_DEVICE_FAMILY = "1,2"; | |||||
| TEST_TARGET_NAME = AILinkBleSDKDemo; | |||||
| }; | |||||
| name = Release; | |||||
| }; | |||||
| /* End XCBuildConfiguration section */ | |||||
| /* Begin XCConfigurationList section */ | |||||
| E622E256243F1CA5003C319D /* Build configuration list for PBXProject "AILinkBleSDKDemo" */ = { | |||||
| isa = XCConfigurationList; | |||||
| buildConfigurations = ( | |||||
| E622E27D243F1CA6003C319D /* Debug */, | |||||
| E622E27E243F1CA6003C319D /* Release */, | |||||
| ); | |||||
| defaultConfigurationIsVisible = 0; | |||||
| defaultConfigurationName = Release; | |||||
| }; | |||||
| E622E27F243F1CA6003C319D /* Build configuration list for PBXNativeTarget "AILinkBleSDKDemo" */ = { | |||||
| isa = XCConfigurationList; | |||||
| buildConfigurations = ( | |||||
| E622E280243F1CA6003C319D /* Debug */, | |||||
| E622E281243F1CA6003C319D /* Release */, | |||||
| ); | |||||
| defaultConfigurationIsVisible = 0; | |||||
| defaultConfigurationName = Release; | |||||
| }; | |||||
| E622E282243F1CA6003C319D /* Build configuration list for PBXNativeTarget "AILinkBleSDKDemoUITests" */ = { | |||||
| isa = XCConfigurationList; | |||||
| buildConfigurations = ( | |||||
| E622E283243F1CA6003C319D /* Debug */, | |||||
| E622E284243F1CA6003C319D /* Release */, | |||||
| ); | |||||
| defaultConfigurationIsVisible = 0; | |||||
| defaultConfigurationName = Release; | |||||
| }; | |||||
| /* End XCConfigurationList section */ | |||||
| }; | |||||
| rootObject = E622E253243F1CA5003C319D /* Project object */; | |||||
| } |
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <Workspace | |||||
| version = "1.0"> | |||||
| <FileRef | |||||
| location = "self:AILinkBleSDKDemo.xcodeproj"> | |||||
| </FileRef> | |||||
| </Workspace> |
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
| <plist version="1.0"> | |||||
| <dict> | |||||
| <key>IDEDidComputeMac32BitWarning</key> | |||||
| <true/> | |||||
| </dict> | |||||
| </plist> |
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
| <plist version="1.0"> | |||||
| <dict> | |||||
| <key>SchemeUserState</key> | |||||
| <dict> | |||||
| <key>AILinkBleSDKDemo.xcscheme_^#shared#^_</key> | |||||
| <dict> | |||||
| <key>orderHint</key> | |||||
| <integer>0</integer> | |||||
| </dict> | |||||
| </dict> | |||||
| </dict> | |||||
| </plist> |
| // | |||||
| // ELBabyScaleBleHeader.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/9/16. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #ifndef ELBabyScaleBleHeader_h | |||||
| #define ELBabyScaleBleHeader_h | |||||
| //Baby scale transparent data type(婴儿秤透传数据类型) | |||||
| typedef NS_ENUM(NSUInteger, BabyScaleBleDataType) { | |||||
| /**Weight stability data( 体重稳定数据) */ | |||||
| BabyScaleBleDataType_WeightStableData = 0x01 , | |||||
| /** Weight real-time data(体重实时数据) */ | |||||
| BabyScaleBleDataType_WeightRealtimeData = 0x02 , | |||||
| /** Length data(身长数据) */ | |||||
| BabyScaleBleDataType_Height = 0x03 , | |||||
| /** App delivery unit settings(app下发单位设置 )*/ | |||||
| BabyScaleBleDataType_AppSendUnit = 0x81 , | |||||
| /** MCU reply setting result(MCU回复设置结果) */ | |||||
| BabyScaleBleDataType_BackSendUnit = 0x82 , | |||||
| /** App sends control class instructions(app发送控制类指令 )*/ | |||||
| BabyScaleBleDataType_AppSendCtrl = 0x83 , | |||||
| /** MCU reply control result(MCU回复控制结果) */ | |||||
| BabyScaleBleDataType_BackSendCtrl = 0x84 , | |||||
| /** he device sends an error code.(设备上发错误码) */ | |||||
| BabyScaleBleDataType_DeviceBackErrorCode = 0xFF, | |||||
| }; | |||||
| typedef NS_ENUM(NSInteger ,BabyScaleResultType) { | |||||
| /** Successful setup(设置成功) */ | |||||
| BabyScaleResultType_Succeed = 0 , | |||||
| /** Setup failed(设置失败) */ | |||||
| BabyScaleResultType_Failure , | |||||
| /** Does not support settings(不支持设置) */ | |||||
| BabyScaleResultType_Unsupported , | |||||
| }; | |||||
| typedef NS_ENUM(NSInteger ,BabyScaleDeviceErrorCode) { | |||||
| /** overweight(超重) */ | |||||
| BabyScaleDeviceErrorCode_Overweight = 0 , | |||||
| /** Unstable weight during weighing 0(称重为0 期间,重量不稳定) */ | |||||
| BabyScaleDeviceErrorCode_Unstable , | |||||
| /** Weighing to 0 failed(称重为 0 失败 )*/ | |||||
| BabyScaleDeviceErrorCode_Failure , | |||||
| }; | |||||
| typedef NS_ENUM(NSUInteger, HoldDataType) { | |||||
| HoldDataTypeKeep = 0x00, | |||||
| HoldDataTypeCancel = 0x01, | |||||
| HoldDataTypeUnkonwn | |||||
| }; | |||||
| #endif /* ELBabyScaleBleHeader_h */ |
| // | |||||
| // ELBabyScaleBleHeightModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/4/23. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELSDKHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBabyScaleBleHeightModel : NSObject | |||||
| @property (nonatomic, assign) NSUInteger height; //height(身高) | |||||
| @property (nonatomic, assign) ELDeviceHeightUnit unit; | |||||
| @property (nonatomic, copy) NSString *unitStr; | |||||
| @property (nonatomic, assign) NSInteger heightPoint;//Decimal offset position(小数点偏移位置) | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBabyScaleBleManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/4/19. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELBluetoothManager.h" | |||||
| #import "ELBabyScaleDeviceModel.h" | |||||
| #import "ELBabyScaleBleWeightModel.h" | |||||
| #import "ELBabyScaleBleHeightModel.h" | |||||
| #import "ELBabyScaleBleHeader.h" | |||||
| @protocol BabyScaleBleDelegate <NSObject> | |||||
| @optional | |||||
| //Callback Bluetooth status(回调蓝牙状态) | |||||
| - (void)babyScaleManagerUpdateState:(ELBluetoothState)state; | |||||
| //Callback to all baby scale equipment(回调所有婴儿秤设备) | |||||
| - (void)babyScaleManagerScanDevices:(NSArray<ELBabyScaleDeviceModel *> *_Nullable)babyScaleDevices; | |||||
| //Callback weight data(回调体重数据) | |||||
| - (void)babyScaleManagerReceiveWeightModel:(ELBabyScaleBleWeightModel *_Nonnull)model; | |||||
| //Callback height data(回调身高数据) | |||||
| - (void)babyScaleManagerHeightModel:(ELBabyScaleBleHeightModel *_Nonnull)model; | |||||
| /** Return the result of the unit setting(返回单位设置的结果) */ | |||||
| - (void)babyScaleBackSetUnitResults:(BabyScaleResultType )result; | |||||
| /** Callback peeling (zeroing) and locking results(回调去皮(归零)和锁定结果) | |||||
| * type : 0 peeled, 1 locked(0去皮,1锁定) | |||||
| */ | |||||
| - (void)babyScaleBackCtrlType:(NSInteger )type Results:(BabyScaleResultType )result; | |||||
| /** The device sends an error code.(设备上发错误码) */ | |||||
| - (void)babyScaleBackDeviceErrorCode:(BabyScaleDeviceErrorCode )code; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBabyScaleBleManager : ELBluetoothManager | |||||
| //Baby scale Bluetooth manager agent(婴儿秤蓝牙管理者代理) | |||||
| @property (nonatomic, weak) id<BabyScaleBleDelegate> babyScaleDelegate; | |||||
| +(ELBabyScaleBleManager *)shareManager; | |||||
| //MARK:Hold YES is locked, NO is peeled (return to zero)(hold YES为锁定,NO去皮(归零)) | |||||
| -(void)changeHold:(BOOL)hold; | |||||
| //MARK:Height and weight unit switching(身高和体重单位切换) | |||||
| -(void)changeHeightUnit:(ELDeviceHeightUnit)heightUnit AndWeightUnit:(ELDeviceWeightUnit)weightUnit; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBabyScaleBleWeightModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/4/23. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELSDKHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBabyScaleBleWeightModel : NSObject | |||||
| @property (nonatomic, assign) ELDeviceWeightUnit unit;//unit(单位) | |||||
| @property (nonatomic, assign) int weight;//weight(重量) | |||||
| @property (nonatomic, assign) BOOL dataType;//Stable mark: 0 real-time weight, 1 stable weight(稳定标志:0 实时重量,1 稳定重量) | |||||
| @property (nonatomic, copy) NSString *unitStr; | |||||
| @property (nonatomic, assign) NSInteger weightPoint;//Decimal offset position(小数点偏移位置) | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBleBabyScalePeripheralModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/4/19. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELPeripheralModel.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBabyScaleDeviceModel : ELPeripheralModel | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBlePublicTool.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/5/10. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBlePublicTool : NSObject | |||||
| //MARK:Keep decimal places, support for retaining 7 significant digits(保留小数位,支持保留7位有效数字) | |||||
| +(NSString *)retainPointValue:(double)value withPoint:(NSUInteger)point; | |||||
| /** | |||||
| Turn time into time (将时间转成时间截) | |||||
| @param timeString time | |||||
| @param formatter format | |||||
| @return Time cut(时间截) | |||||
| */ | |||||
| + (NSInteger)getTimeStampWithTimeString:(NSString *)timeString AndFormatter:(NSString *)formatter; | |||||
| /** | |||||
| Determine if the WiFi password is legal(判断WiFi密码是否合法) | |||||
| @param password wifi password (8 ~ 56 characters)(wifi密码(8~56个字符)) | |||||
| @return yes: legal, NO: illegal(yes:合法,NO:不合法) | |||||
| */ | |||||
| +(BOOL)legalBleWifiPassword:(NSString *)password; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBleWifiDetailModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/12/30. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| typedef NS_ENUM(NSUInteger, ELBleWifiSecureType) { | |||||
| ELBleWifiSecureTypeOpen = 0, | |||||
| ELBleWifiSecureTypeWEP = 1, | |||||
| ELBleWifiSecureTypeWPA_PSK = 2, | |||||
| ELBleWifiSecureTypeWPA2_PSK = 3, | |||||
| ELBleWifiSecureTypeWPA_WPA_2_PSK = 4, | |||||
| ELBleWifiSecureTypeWPA2_ENTERPRISE = 5, | |||||
| }; | |||||
| typedef NS_ENUM(NSUInteger, ELBleWifiUseState) { | |||||
| ELBleWifiUseStateUnknown = 0, //Strange wifi(陌生wifi) | |||||
| ELBleWifiUseStateSaved = 1, //Wifi with saved password(保存过的密码的wifi) | |||||
| ELBleWifiUseStateConnected = 2, //Currently connected wifi(目前连接着的wifi) | |||||
| }; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBleWifiDetailModel : NSObject<NSCopying> | |||||
| //wifi number(wifi编号) | |||||
| @property (nonatomic, assign) int wifiNumber; | |||||
| //wifi name(wifi 名字) | |||||
| @property (nonatomic, copy) NSString *wifiName; | |||||
| //wifi MAC address (little endian)(wifi MAC地址(小端序)) | |||||
| @property (nonatomic, copy) NSData *macData; | |||||
| //Signal strength(信号强度) | |||||
| @property (nonatomic, assign) int wifiRssi; | |||||
| //Security type(安全类型) | |||||
| @property (nonatomic, assign) ELBleWifiSecureType secureType; | |||||
| //wifi status(wifi状态) | |||||
| @property (nonatomic, assign) ELBleWifiUseState wifiState; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBloodBleDataModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/5/11. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELBloodBleSDKHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBloodBleDataModel : NSObject | |||||
| @property (nonatomic, copy) NSString *dia;//Diastolic blood pressure(舒张压) | |||||
| @property (nonatomic, copy) NSString *sys; //Systolic blood pressure(收缩压) | |||||
| @property (nonatomic, assign) int heartRate; //Heart rate(心率) | |||||
| @property (nonatomic, assign) ELDeviceBloodPressureUnit unit;//单位 | |||||
| @property (nonatomic, assign) int point; //小数点 | |||||
| @property (nonatomic, assign) NSInteger createTime;//时间 | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBloodBleManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/5/11. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELBluetoothManager.h" | |||||
| #import "ELBloodBleSDKHeader.h" | |||||
| #import "ELBloodBleDataModel.h" | |||||
| typedef NS_ENUM(NSUInteger, ELBloodBleDataType) { | |||||
| ELBloodBleDataTypeStableData = 0x01, //Stable data(稳定数据) | |||||
| ELBloodBleDataTypeRealTimeData = 0x02, //Real-time data(实时数据) | |||||
| ELBloodBleDataTypeSetUnit = 0x81, //App release unit settings(app 下发单位设置) | |||||
| ELBloodBleDataTypeSetUnitResult = 0x82, //Unit setting result(单位设置结果) | |||||
| ELBloodBleDataTypeInteraction = 0x83, //Interactive command(交互指令) | |||||
| ELBloodBleDataTypeSetSwitchVoice = 0x85, //Send voice alarm settings(下发语音报警设置) | |||||
| ELBloodBleDataTypeSwitchVoiceResult = 0x86, //Send voice alarm setting result(下发语音报警设置结果) | |||||
| ELBloodBleDataTypeFailCode = 0xFF, //Report error code(上报错误码) | |||||
| }; | |||||
| @protocol ELBloodBleManagerDelegate <NSObject> | |||||
| @optional | |||||
| /** | |||||
| Callback Bluetooth status(回调蓝牙状态) | |||||
| @param state Bluetooth status(蓝牙状态) | |||||
| */ | |||||
| -(void)bloodBleManagerUpdateBleState:(ELBluetoothState)state; | |||||
| /** | |||||
| Callback scanned device(回调扫描到的设备) | |||||
| @param devices 设备 | |||||
| */ | |||||
| -(void)bloodBleManagerScanDevices:(NSArray<ELPeripheralModel *> *_Nullable)devices; | |||||
| /** | |||||
| Call back real-time, stable data(回调实时、稳定数据) | |||||
| @param model 数据 | |||||
| @param type 类型 | |||||
| */ | |||||
| -(void)bloodBleManagerReceiceTestData:(ELBloodBleDataModel *_Nonnull)model type:(ELBloodBleDataModelType)type; | |||||
| /** | |||||
| Set unit callback(设置单位回调) | |||||
| @param type 结果 | |||||
| */ | |||||
| -(void)bloodBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type; | |||||
| /** | |||||
| Set the interaction type(设置交互类型) | |||||
| @param type 结果 | |||||
| */ | |||||
| -(void)bloodBleManagerReceiveInteractionType:(ELBloodInteractionType)type; | |||||
| /** | |||||
| Error code sent on the device(设备上发错误码) | |||||
| @param code error code(错误码) | |||||
| */ | |||||
| -(void)bloodBleManagerReceiveFailCode:(ELBloodFailCode)code; | |||||
| /** | |||||
| Send voice alarm setting result(下发语音报警设置结果) | |||||
| @param type 操作类型 | |||||
| @param result 结果 | |||||
| */ | |||||
| -(void)bloodBleManagerReceiveSetSwitchVoiceOperationType:(ELBloodBleSwitchVoiceType)type result:(ELSetBluetoothResponseType)result; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBloodBleManager : ELBluetoothManager | |||||
| @property (nonatomic, weak) id<ELBloodBleManagerDelegate> bloodDelegate; | |||||
| +(instancetype)shareManager; | |||||
| //Set unit(设置单位) | |||||
| -(void)changeUnit:(ELDeviceBloodPressureUnit)unit; | |||||
| /** | |||||
| Interact with Bluetooth(与蓝牙交互) | |||||
| @param type 类型 | |||||
| ELBloodInteractionTypeStartTest = 0, //Start measurement(开始测量) | |||||
| ELBloodInteractionTypeStopTest = 1, //Stop testing(停止测试) | |||||
| ELBloodInteractionTypeBoot = 2, //Boot(开机) | |||||
| ELBloodInteractionTypeShutdown = 3, //Shut down(关机) | |||||
| */ | |||||
| -(void)sendInteractiveInstructions:(ELBloodInteractionType)type; | |||||
| /** | |||||
| Send voice alarm settings(下发语音报警设置) | |||||
| @param type operation type | |||||
| */ | |||||
| -(void)sendSwitchVoice:(ELBloodBleSwitchVoiceType)type; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBloodBleSDKHeader.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/5/11. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #ifndef ELBloodBleSDKHeader_h | |||||
| #define ELBloodBleSDKHeader_h | |||||
| #import "ELSDKHeader.h" | |||||
| #define BloodUnitDic @{\ | |||||
| @(ELBloodUnitType_mmhg):BloodUnit_mmhg,\ | |||||
| @(ELBloodUnitType_kPa):BloodUnit_kPa\ | |||||
| } | |||||
| #define BloodUnit_mmhg AiLinkBloodUnit_mmHgStr | |||||
| #define BloodUnit_kPa AiLinkBloodUnit_kPaStr | |||||
| #define kPa_To_mmHg(kPa) kPa*7.5006168270417 | |||||
| #define mmHg_To_kPa(mmHg) mmHg/7.5006168270417 | |||||
| //type of data(数据类型) | |||||
| typedef NS_ENUM(NSUInteger, ELBloodBleDataModelType) { | |||||
| ELBloodBleDataModelTypeStable, //Stable data(稳定数据) | |||||
| ELBloodBleDataModelTypeRealTime, //Real-time data(实时数据) | |||||
| }; | |||||
| //error code(错误码) | |||||
| typedef NS_ENUM(NSUInteger, ELBloodFailCode) { | |||||
| ELBloodFailCodeUnfoundDia = 0, //High voltage not found(未找到高压) | |||||
| ELBloodFailCodeCantInflating = 1, //Unable to pressurize normally, please check whether the cuff is inserted, or re-insert the cuff trachea(无法正常加压,请检查是否插入袖带,或者重新插拔袖带气管) | |||||
| ELBloodFailCodePowerLow = 2, //Low battery(电量低) | |||||
| ELBloodFailCodeSignalError = 3, //Abnormal sensor signal(传感器信号异常) | |||||
| ELBloodFailCodeMeasureError = 4, //Abnormal measurement results(测量结果异常) | |||||
| ELBloodFailCodeWristbandError = 5, //Wrist strap is too tight or the airway is blocked(腕带过紧或气路堵塞) | |||||
| ELBloodFailCodeHaveInterence = 6, //Serious pressure interference during measurement(测量中压力干扰严重) | |||||
| ELBloodFailCodeOverStressed = 7, //Overpressure 290(压力超 290) | |||||
| ELBloodFailCodeDataError = 8, //Abnormal calibration data or abnormal storage IC(标定数据异常或存储 IC 异常) | |||||
| }; | |||||
| //Interactive command(交互指令) | |||||
| typedef NS_ENUM(NSUInteger, ELBloodInteractionType) { | |||||
| ELBloodInteractionTypeStartTest = 0, //Start measurement(开始测量) | |||||
| ELBloodInteractionTypeStopTest = 1, //Stop testing(停止测试) | |||||
| ELBloodInteractionTypeBoot = 2, //Boot(开机) | |||||
| ELBloodInteractionTypeShutdown = 3, //Shut down(关机) | |||||
| }; | |||||
| typedef NS_ENUM(NSUInteger, ELBloodBleSwitchVoiceType) { | |||||
| ELBloodBleSwitchVoiceTypeOn = 0x00, //turn on(打开) | |||||
| ELBloodBleSwitchVoiceTypeOff = 0x01, //shut down(关闭) | |||||
| }; | |||||
| #endif /* ELBloodBleSDKHeader_h */ |
| // | |||||
| // ELBluetoothManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/4/22. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELPeripheralModel.h" | |||||
| #import "ELSDKHeader.h" | |||||
| #import "ELBlePublicTool.h" | |||||
| #import "ELBleWifiDetailModel.h" | |||||
| //MARK:Bluetooth Wifi protocol(蓝牙Wifi协议) | |||||
| @protocol ElBleWifiDelegate <NSObject> | |||||
| @optional | |||||
| /** | |||||
| Callback Wifi details(回调Wifi详情) | |||||
| @param model 模型 | |||||
| */ | |||||
| -(void)bleWifiReceiveWifiDetailModel:(ELBleWifiDetailModel *_Nonnull)model; | |||||
| /** | |||||
| Scan nearby wifi results(扫描附近wifi结果) | |||||
| @param count Number of nearby wifi(附近wifi数量) | |||||
| */ | |||||
| -(void)bleWifiReceiveScanedWifiCount:(int)count; | |||||
| /** | |||||
| Callback Wifi MAC address(回调Wifi MAC地址) | |||||
| @param macData mac | |||||
| */ | |||||
| -(void)bleWifiReceiveWifiMacData:(NSData *_Nullable)macData; | |||||
| /** | |||||
| Callback WIFI password(回调WIFI密码) | |||||
| @param pwd password(密码) | |||||
| */ | |||||
| -(void)bleWifiReceiveWifiPwd:(NSString *_Nonnull)pwd; | |||||
| /** | |||||
| Get DTIM interval (unit: ms)(获取DTIM间隔(单位:ms)) | |||||
| @param interval Interval (unit: ms)(间隔(单位:ms)) | |||||
| */ | |||||
| -(void)bleWifiReceiveWifiDTIMInterval:(NSInteger)interval; | |||||
| /** | |||||
| Returns the visited URL(返回访问的url) | |||||
| @param url url | |||||
| */ | |||||
| -(void)bleWifiReceiveWifiAccessURL:(NSString *_Nonnull)url; | |||||
| /** | |||||
| Call back wifi port number(回调wifi的端口号) | |||||
| @param port 端口号 | |||||
| */ | |||||
| -(void)bleWifiReceiveWifiPort:(int)port; | |||||
| /** | |||||
| Set or query the callback of the instruction execution result(设置指令蓝牙WIFI响应回调方法) | |||||
| 只支持蓝牙Wifi部分枚举 | |||||
| @param type Type of setting (设置的类型) | |||||
| @param result Set result(设置的结果) | |||||
| */ | |||||
| -(void)bleWifiReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result; | |||||
| /** | |||||
| 获取会话码 | |||||
| @param code 会话码(为0时表示不存在) | |||||
| */ | |||||
| -(void)bleWifiReceiveWifiSNCode:(int)code; | |||||
| @end | |||||
| //MARK:蓝牙通用协议 | |||||
| @protocol ELBluetoothManagerDelegate <NSObject> | |||||
| @optional | |||||
| //Callback Bluetooth status(回调蓝牙状态) | |||||
| -(void)bluetoothManagerUpdateBleState:(ELBluetoothState)state; | |||||
| //Callback to scanned device(回调扫描到的设备) | |||||
| -(void)bluetoothManagerScanedPeripherals:(NSArray<ELPeripheralModel *> *_Nonnull)peripherals; | |||||
| //Special devices that can be bound in the callback, such as door locks(回调中扫描到的可以绑定的特殊设备,如门锁) | |||||
| -(void)bluetoothManagerScanedCanBindSpecialPeripherals:(NSArray<ELPeripheralModel *> *_Nonnull)peripherals; | |||||
| //Callback decrypted transparent data (A7 decrypted payload data)(回调解密后的数据(A7解密后payload数据)) | |||||
| -(void)bluetoothManagerReceiveData:(NSData *_Nonnull)data deviceType:(ELSupportDeviceType)type; | |||||
| /** | |||||
| 回调透传数据 | |||||
| @param data 透传数据(此数据不能以A6或A7开头) | |||||
| */ | |||||
| -(void)bluetoothManagerReceivePassData:(NSData *_Nullable)data; | |||||
| #pragma mark ============ A6 Set or query the callback of the instruction execution result(设置或查询指令执行结果的回调) ============== | |||||
| /** | |||||
| Set or query the callback of the instruction execution result(设置指令蓝牙响应回调方法(握手指令除外)) | |||||
| @param type Type of setting (设置的类型) | |||||
| @param result Set result(设置的结果) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result; | |||||
| /** | |||||
| Query module status callback(查询模块状态的回调) | |||||
| @param stateStrct 结构体 | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveMCUConnectedState:(struct ELMCUStateStruct)stateStrct; | |||||
| /** | |||||
| Query the callback of the communication mode(查询通信模式的回调) | |||||
| @param type communication mode(通信模式) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveCommunicationMode:(ELCommunicationModeType)type; | |||||
| /** | |||||
| Query the callback of automatic sleep time(查询自动睡眠时间的回调) | |||||
| @param sleetStrct Automatic sleep time(自动睡眠时间) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveAutoSleepTime:(struct ELAutoSleepTimeStruct)sleetStrct; | |||||
| /** | |||||
| Query master-slave mode callback(查询主从模式回调) | |||||
| @param mode 模式 | |||||
| 0:Slave mode(从机模式) | |||||
| 1:Host mode(主机模式) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveMCUMode:(int)mode; | |||||
| /** | |||||
| Query the callback of UUID information(查询UUID信息的回调) | |||||
| @param uuid ELUUIDStruct | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveUUID:(struct ELUUIDStruct)uuid; | |||||
| /** | |||||
| Query the callback of the MAC address size endian(查询MAC地址大小端序的回调) | |||||
| @param type 类型 | |||||
| 0:Little endian(小端序) | |||||
| 1:Big endian (大端序) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveMacAddressType:(int)type; | |||||
| /** | |||||
| Query the callback of the Bluetooth serial port baud rate(查询蓝牙串口波特率的回调) | |||||
| @param rate Serial port baud rate(串口波特率) | |||||
| 0:9600 | |||||
| 1:19200 | |||||
| 2:38400 | |||||
| 3:57600 | |||||
| 4:115200 | |||||
| 5:921600 | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveSerialPostBaudRate:(int)rate; | |||||
| /** | |||||
| Query the callback of Bluetooth transmit power(查询蓝牙发射功率的回调) | |||||
| @param dbm Transmit power(发射功率) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveTransmittingPower:(int)dbm; | |||||
| /** | |||||
| Query the callback of the Bluetooth connection interval(查询蓝牙连接间隔的回调) | |||||
| @param intervalStrct connection interval | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveConnectInterval:(struct ELConnectIntervalStruct)intervalStrct; | |||||
| /** | |||||
| Query the callback of the Bluetooth name(查询蓝牙名称的回调) | |||||
| @param name Bluetooth name(蓝牙名称) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiceName:(NSString *_Nullable)name; | |||||
| /** | |||||
| Query the callback of the Bluetooth broadcast interval(查询蓝牙广播间隔的回调) | |||||
| @param interval broadcast interval(广播间隔) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveBroadcastInterval:(int)interval; | |||||
| /** | |||||
| Query the callback of the Bluetooth MAC address(查询蓝牙MAC地址的回调) | |||||
| @param macAddress MAC | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveMACAddress:(NSString *_Nonnull)macAddress; | |||||
| /** | |||||
| Query the callback of the software and hardware version number of the BM module(查询BM模块软硬件版本号的回调) | |||||
| @param bmVersion BM module software and hardware version number(BM模块软硬件版本号) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveBMVersion:(NSString *_Nonnull)bmVersion; | |||||
| /** | |||||
| Query the callback of the MCU software and hardware version number(查询MCU软硬件版本号的回调) | |||||
| @param mcuVersion Callback of MCU software and hardware version number(MCU软硬件版本号的回调) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveMCUVersion:(NSString *_Nonnull)mcuVersion; | |||||
| /** | |||||
| Query the callback of Bluetooth time(查询蓝牙时间的回调) | |||||
| @param date yyyy-MM-dd HH:mm:ss | |||||
| @param effective Time is invalid(时间有无效) | |||||
| 0:effective(系统时间无效) | |||||
| 1:invalid(系统时间有效) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveBluetoothDate:(NSString * _Nonnull)date effective:(BOOL)effective; | |||||
| /** | |||||
| Query CID, VID, PID callback(查询CID,VID,PID的回调) | |||||
| @param did CID,VID,PID | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did; | |||||
| /** | |||||
| Query the callback of the battery status(查询电池状态的回调) | |||||
| @param battery Structure of battery charge status and charge percentage(电池充电状态和电量百分比的结构体) | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveBattery:(struct ELBatteryStruct)battery; | |||||
| /** | |||||
| * Query the callback of the device support unit(查询设备支持单位的回调) | |||||
| */ | |||||
| - (void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *_Nullable)weightArray | |||||
| Height:(NSArray<NSNumber *> *_Nullable)heightArray | |||||
| Temperature:(NSArray<NSNumber *> *_Nullable)temperatureArray | |||||
| BloodPressure:(NSArray<NSNumber *> *_Nullable)bloodPressureArray | |||||
| Pressure:(NSArray<NSNumber *> *_Nullable)pressureArray; | |||||
| /** | |||||
| Set the result of the decoding key(设置解码密钥的结果) | |||||
| @param result 结果 | |||||
| */ | |||||
| -(void)bluetoothManagerReceiveSetKeyResult:(BOOL)result; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELBluetoothManager : NSObject | |||||
| @property (nonatomic, assign, readonly) BOOL isOn; | |||||
| //Bluetooth status(蓝牙状态) | |||||
| @property (nonatomic, assign, readonly) ELBluetoothState state; | |||||
| //version number(版本号) | |||||
| @property (nonatomic, copy, readonly) NSString *bmVersion; | |||||
| /** | |||||
| Save the model corresponding to the currently connected device | |||||
| 保存当前连接的设备对应的模型 | |||||
| */ | |||||
| @property (nonatomic, strong, readonly) ELPeripheralModel *peripheralModel; | |||||
| //Bluetooth proxy(蓝牙代理) | |||||
| @property (nonatomic, weak) id<ELBluetoothManagerDelegate> delegate; | |||||
| //Bluetooth wifi proxy(蓝牙wifi代理) | |||||
| @property (nonatomic, weak) id<ElBleWifiDelegate> bleWifiDelegate; | |||||
| //设置appkey和secret | |||||
| +(void)setAppKey:(NSString *)key appSecret:(NSString *)secret; | |||||
| // | |||||
| +(__kindof ELBluetoothManager * _Nonnull)shareManager; | |||||
| /** | |||||
| Get the SDK version number | |||||
| 获取SDK版本号 | |||||
| */ | |||||
| -(NSString *)sdkVersion; | |||||
| //Start scanning(开始扫描) | |||||
| -(void)startScan; | |||||
| //Stop scanning(停止扫描) | |||||
| -(void)stopScan; | |||||
| //Connecting device(连接设备) | |||||
| -(void)connectPeripheral:(ELPeripheralModel *)peripheralModel; | |||||
| //Disconnect device(断开设备) | |||||
| -(void)disconnectPeripheral; | |||||
| #pragma mark ============ 发送指令的3种方法 ============== | |||||
| /** | |||||
| Shortcut method to send A6 data to BLE(发送A6数据给BLE的快捷方法) | |||||
| @param data The stitched payload part(拼接好的payload部分) | |||||
| */ | |||||
| -(void)sendCmdToMCUWithA6PayloadData:(NSData *)data; | |||||
| /** | |||||
| Shortcut method of sending A7 data to MCU(发送A7数据给MCU的快捷方法) | |||||
| @param data The stitched payload part(拼接好的payload部分) | |||||
| @param type Equipment type(设备类型) | |||||
| */ | |||||
| -(void)sendCmdToMCUWithA7PayloadData:(NSData *)data deviceType:(ELSupportDeviceType)type; | |||||
| /** | |||||
| General method of sending data (support data transparent transmission)(发送数据通用方法(支持数据透传)) | |||||
| @param data 数据 | |||||
| */ | |||||
| -(void)sendData:(NSData *)data; | |||||
| #pragma mark ============ Please rewrite the following methods in the subclass(请在子类重写以下方法) BEGIN============== | |||||
| -(void)bluetoothUpdateState:(ELBluetoothState)state; | |||||
| -(void)bluetoothScanPeripherals:(NSArray *)peripherals; | |||||
| /** | |||||
| Callback decrypted A7 transparent data (payload part), type device type( 回调解密后的A7透传数据(payload部分),type设备类型) | |||||
| */ | |||||
| -(void)bluetoothReceiveData:(NSData *)playload deviceType:(ELSupportDeviceType)type; | |||||
| /** | |||||
| The special A6 data will only be received by the supported devices, and the complete A6 data (A6 is not encrypted) is passed to the subclass resolution. | |||||
| 特殊的A6数据,只有支持的设备才会收到,将完整A6数据(A6不加密)传给子类解析 | |||||
| ELSupportDeviceType support: | |||||
| ELSupportDeviceTypeBodyFatScale | |||||
| ELSupportDeviceTypeSmartLock | |||||
| */ | |||||
| -(void)bluetoothBackA6Data:(NSData *)data withClassId:(ELSupportDeviceType)type; | |||||
| /** | |||||
| Callback to scan special devices that can be bound, such as door locks(回调扫描到的可以绑定的特殊设备,如门锁) | |||||
| */ | |||||
| -(void)bluetoothScanCanBindSpecialPeripherals:(NSArray *)peripherals; | |||||
| /** | |||||
| Callback device basic information(回调设备基本信息) | |||||
| @param data Device basic information payload data (length is 16 bytes)(设备基本信息payload数据(长度为16个byte)) | |||||
| */ | |||||
| -(void)bluetoothReceiveBasicInfoPayloadData:(NSData *)data; | |||||
| #pragma mark ============ Please rewrite the following methods in the subclass(子类重写方法) END============== | |||||
| #pragma mark ============ A6 Set or query instructions(设置或查询指令) ============== | |||||
| /** | |||||
| Get Bluetooth information(获取蓝牙信息) | |||||
| @param type ELInetGetCmdType (ELInetGetCmdTypeGetHandshake除外) | |||||
| */ | |||||
| -(void)getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdType)type; | |||||
| /** | |||||
| Set the Bluetooth name(设置蓝牙名称) | |||||
| @param name Name, less than 14 bytes(名称,小于14个byte) | |||||
| */ | |||||
| -(void)setBluetoothName:(NSString * _Nonnull)name; | |||||
| /** | |||||
| Set the broadcast interval(设置广播间隔时间) | |||||
| @param interval 20~2000 | |||||
| */ | |||||
| -(void)setBroadcastInterval:(int)interval; | |||||
| /** | |||||
| Set the connection interval 10(设置连接间隔) | |||||
| @param interval The interval range is 20~2000ms.(interval范围是20~2000ms) | |||||
| @param timeout The timeout range is 1000~6000ms(timeout范围是1000~6000ms) | |||||
| @param latency The latency range is 0~4(latency范围是0〜4) | |||||
| */ | |||||
| -(void)setConnectedInterval:(int)interval timeout:(int)timeout Latency:(int)latency; | |||||
| /** | |||||
| Set the transmit power(设置发射功率) | |||||
| @param power The range of power is 0~10(power的范围是0~10) | |||||
| */ | |||||
| -(void)setTransmittingPower:(int)power; | |||||
| /** | |||||
| Set the serial port baud rate(设置串口波特率) | |||||
| @param rate The range of rate is 0~5(rate的范围是0~5) | |||||
| 0:9600 | |||||
| 1:19200 | |||||
| 2:38400 | |||||
| 3:57600 | |||||
| 4:115200 | |||||
| 5:921600 | |||||
| */ | |||||
| -(void)setSerialPortbaudRate:(int)rate; | |||||
| /** | |||||
| Set the MCU software and hardware version number(设置MCU软硬件版本号) | |||||
| @param hardware 硬件 | |||||
| @param software 软件 | |||||
| 如果是:S1.1,S11.1,S111.1, ..... | |||||
| 请传:11,111,1111, .... | |||||
| @param type Manufacturer's own definition(厂家自己定义) | |||||
| @param year 年 | |||||
| @param month 月 | |||||
| @param day 日 | |||||
| */ | |||||
| -(void)setMCUVersion:(unsigned int)hardware software:(unsigned int)software mcuType:(unsigned int)type year:(unsigned int)year month:(unsigned int)month day:(unsigned int)day; | |||||
| /** | |||||
| Set the big endian or little endian of the Mac address in the broadcast manufacturer's custom data.(设置广播厂家自定义数据中Mac地址的大端序或小端序) | |||||
| @param type type | |||||
| 0:Little endian (default)(小端序 (默认)) | |||||
| 1:Big endian(大端序) | |||||
| */ | |||||
| -(void)setSetMACAddressType:(int)type; | |||||
| /** | |||||
| Set up the module's service and feature services(设置模块的服务和特征服务) | |||||
| @param serverUUIDData server | |||||
| @param charateristicUUIDData charateristic | |||||
| @param type UUID length: | |||||
| 0 : 16 bytes(default) | |||||
| 1:2 bytes | |||||
| */ | |||||
| -(void)setBluetoothServerUUID:(NSData *)serverUUIDData charateristicUUID:(NSData *)charateristicUUIDData UUIDType:(int)type; | |||||
| /** | |||||
| Set the master-slave mode of the module(设置模块的主从模式) | |||||
| @param type Value: | |||||
| 0:Slave mode (default)(从机模式(默认)) | |||||
| 1:Host mode(主机模式) | |||||
| */ | |||||
| -(void)setMCUModel:(int)type; | |||||
| /** | |||||
| Set the module's automatic sleep time without connection(设置模块无连接的自动休眠时间) | |||||
| @param open Automatic sleep flag(自动睡眠标志位): | |||||
| 0:Do not turn on automatic sleep(不开启自动休眠) | |||||
| 1:Turn on auto sleep, the module is not connected(开启自动休眠,模块没有连接) | |||||
| @param time Automatic sleep time (ms)(自动睡眠时间(ms)) | |||||
| @param radio Whether to enable low frequency broadcast after sleep: (unit: ms)(睡眠后是否开启低频广播:(单位:ms)) | |||||
| 0:Not open(不开启) | |||||
| 1:Open(开启) | |||||
| @param interval 低频广播间隔时间,20~2000ms | |||||
| */ | |||||
| -(void)setAutoSleepTimeIsOpen:(BOOL)open autoSleepTime:(unsigned int)time isRadio:(BOOL)radio radioInterval:(int)interval; | |||||
| /** | |||||
| Set to sleep(设置进入睡眠) | |||||
| @param radio Whether to enable low frequency broadcast after sleep: (in ms)(睡眠后是否开启低频广播:(单位 ms)) | |||||
| 0:Not open(不开启) | |||||
| 1:Open(开启) | |||||
| @param interval 低频广播间隔时间,20~2000ms | |||||
| */ | |||||
| -(void)setGotoSleepIsRadio:(BOOL)radio interval:(int)interval; | |||||
| /** | |||||
| Set module wake up(设置模块唤醒) | |||||
| */ | |||||
| -(void)setMCUWakeUp; | |||||
| /** | |||||
| Set the current time of the system(设置系统当前时间) | |||||
| @param enable | |||||
| NO: In addition to the ability to turn off the time function, you can save part of the current (default)(除能,关闭时间功能,可省部分电流(默认)) | |||||
| YES:Enable, turn on the timer function timer(使能,开启计时功能定时器) | |||||
| */ | |||||
| -(void)setMCUNowDateWithEnable:(BOOL)enable; | |||||
| /** | |||||
| Setting CID, VID, PID(设置CID、VID、PID) | |||||
| @param setC Whether to set the CID(是否设置CID) | |||||
| @param setV Whether to set the VID(是否设置VID) | |||||
| @param setP Whether to set the PID(是否设置PID) | |||||
| @param cid Product Type ID: Less than 65536(产品类型ID:小于65536) | |||||
| @param vid Manufacturer ID: less than 65536(厂家ID:小于65536) | |||||
| @param pid Product ID: Less than 65536(产品ID:小于65536) | |||||
| */ | |||||
| -(void)setC_V_P_IDWithIsSetCID:(BOOL)setC isSetVID:(BOOL)setV isSetPID:(BOOL)setP CID:(unsigned int)cid VID:(unsigned int)vid PID:(unsigned int)pid; | |||||
| /** | |||||
| Set module communication mode | |||||
| 设置模块通信模式 | |||||
| @param mode communication mode(通信模式) | |||||
| */ | |||||
| -(void)setCommunicationMode:(ELCommunicationModeType)mode; | |||||
| /** | |||||
| Set module restart | |||||
| 设置模块重启 | |||||
| */ | |||||
| -(void)setMCURestart; | |||||
| /** | |||||
| Set factory reset | |||||
| 设置恢复出厂设置 | |||||
| */ | |||||
| -(void)setFactoryDataReset; | |||||
| /** | |||||
| Set the Bluetooth connection status(设置蓝牙连接状态) | |||||
| @param disconnect Active disconnect flag(主动断开连接标志位) | |||||
| 1:Disconnect immediately(立刻断开连接) | |||||
| 0:Not disconnected(不断开连接) | |||||
| */ | |||||
| -(void)setDisconnected:(BOOL)disconnect; | |||||
| /** | |||||
| Send decoding key(发送解码密钥) | |||||
| @param data The length of the decoding key is 19, the first 16 are keys, and the last 3 are random texts. You need to save this value on the app and MCU to generate a one-time password. (解码密钥的长度为19,前16个为密钥,后3个为随机文,需要在app端和MCU端保存这个值,用于生成一次性密码) | |||||
| */ | |||||
| - (void)setKeyWithData:(NSData *)data; | |||||
| #pragma mark ============ Bluetooth WIFI calling method(蓝牙WIFI调用方法) ============== | |||||
| /** | |||||
| WIFI initiate connection and disconnect(WIFI 发起连接、断开连接) | |||||
| @param connect YES: initiate connection NO: disconnect(YES:发起连接 NO:断开连接) | |||||
| */ | |||||
| -(void)bleWifiSetupWifiConnect:(BOOL)connect; | |||||
| /** | |||||
| Set WIFI access URL(设置WIFI访问URL) | |||||
| @param url url(Not more than 56chars(不超过56chars)) | |||||
| */ | |||||
| -(void)bleWifiSetWifiURL:(NSString *)url; | |||||
| /** | |||||
| Set Wifi access port number(设置Wifi访问端口号) | |||||
| @param port 端口号 | |||||
| */ | |||||
| -(void)bleWifiSetPort:(int)port; | |||||
| /** | |||||
| Set DTIM interval(设置DTIM间隔) | |||||
| @param interval 间隔 | |||||
| */ | |||||
| -(void)bleWifiSetDTIMInterval:(int)interval; | |||||
| /** | |||||
| Set WIFI password(设置WIFI密码) | |||||
| @param pwd WIFI password (8 ~ 56 chars)(WIFI密码(8~56 个chars)) | |||||
| */ | |||||
| -(void)bleWifiSetWifiPwd:(NSString *)pwd; | |||||
| /** | |||||
| Set up connected WIFI(设置连接的WIFI) | |||||
| @param macData wifi MAC (little endian)(wifi的MAC(小端序)) | |||||
| */ | |||||
| -(void)bleWifiSetConnectWifiMac:(NSData *)macData; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END | |||||
| // | |||||
| // ELBodyFatScaleBleHeader.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/7/18. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #ifndef ELBodyFatScaleBleHeader_h | |||||
| #define ELBodyFatScaleBleHeader_h | |||||
| #import "ELSDKHeader.h" | |||||
| //A6 Byte[2]=2B Byte[3]为A6二级指令(1~7) BLE <-> APP | |||||
| typedef NS_ENUM(NSInteger , ELBodyFatScaleBleDataA6SubType) { | |||||
| /** 0x2B01 app下发离线用户列表 */ | |||||
| ELBodyFatScaleBleDataA6SubType_AppSendUpdateOfflineUserList = 0x01 , | |||||
| /** 0x2B02 app结束发送离线用户列表 */ | |||||
| ELBodyFatScaleBleDataA6SubType_AppFinishUpdateOfflineUserList = 0x02 , | |||||
| /** 0x2B03 app更新离线用户列表中单人信息 */ | |||||
| ELBodyFatScaleBleDataA6SubType_AppSendUpdateSingleOfflineUser = 0x03 , | |||||
| /** 2B01~2B03操作的结果回调》2B0400/02:更新列表成功/失败 2B0401/03:更新单个成功/失败 */ | |||||
| ELBodyFatScaleBleDataA6SubType_BleBackUpdateOfflineUserResult = 0x04 , | |||||
| /** 0x2B05 app请求历史记录及Ble回复都是用2B05》2B0500:无历史记录 2B0501:开始发送历史记录 2B0502:结束发送历史记录 */ | |||||
| ELBodyFatScaleBleDataA6SubType_AppSendAndBleBackHistory = 0x05 , | |||||
| /** ble发给app有体脂数据的历史记录 */ | |||||
| ELBodyFatScaleBleDataA6SubType_BleBackHistoryWithMCUAlgorithm = 0x06 , | |||||
| /** ble发给app无体脂数据的历史记录,app需要根据vip/pid确定使用哪种算法来计算8项体脂数据 */ | |||||
| ELBodyFatScaleBleDataA6SubType_BleBackHistoryWithAppAlgorithm = 0x07 | |||||
| }; | |||||
| //A7 Byte[4]为指令类型(1~8) MCU <-> APP | |||||
| typedef NS_ENUM(NSInteger , ELBodyFatScaleBleDataType) { | |||||
| /** MCU发送实时体重 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackRealtimeWeight = 0x01 , | |||||
| /** MCU发送稳定体重 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackStableWeight = 0x02 , | |||||
| /** MCU发送温度 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackTemperature = 0x03 , | |||||
| /** MCU:阻抗测量中 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackAdcMeasuring = 0x04 , | |||||
| /** MCU:阻抗测量成功 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackAdcMeasureSuccess = 0x05 , | |||||
| /** MCU:阻抗测量失败 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackAdcMeasureFailed = 0x06 , | |||||
| /** MCU:阻抗测量成功并使用App算法(VID/PID决定算法) */ | |||||
| ELBodyFatScaleBleDataType_MCUBackAdcMeasureSuccessWithAppAlgorithm = 0x07 , | |||||
| /** 开始称重前app下发当前称重用户的信息给MCU,以便进行体脂计算 */ | |||||
| ELBodyFatScaleBleDataType_SyncCurrentUserInfo = 0x08 , //2B0802 APP下发当前用户 2B0803/04 MCU回复下发当前用户成功/失败 | |||||
| /** MCU发送体脂数据给App */ | |||||
| ELBodyFatScaleBleDataType_MCUBackBodyFatData = 0x09 , | |||||
| /** MCU发送体脂数据给App,发送完毕(一次完整测量结束) */ | |||||
| ELBodyFatScaleBleDataType_MCUBackBodyFatDataOver = 0x0A , | |||||
| /** MCU->APP:心率测量中 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackHeartRateMeasuring = 0x0B , | |||||
| /** MCU->APP:心率测量成功 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackHeartRateMeasureSuccess = 0x0C , | |||||
| /** MCU->APP:心率测量失败 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackHeartRateMeasureFailed = 0x0D , | |||||
| /** App发送指令切换单位 */ | |||||
| ELBodyFatScaleBleDataType_AppSendUnit = 0x81 , | |||||
| /** MCU发送体脂数据给App,发送完毕(一次完整测量结束) */ | |||||
| ELBodyFatScaleBleDataType_MCUBackSendUnitResult = 0x82 , | |||||
| /** 设备上发错误码 */ | |||||
| ELBodyFatScaleBleDataType_MCUBackErrorCode = 0xFF , | |||||
| }; | |||||
| //MCU请求App用户信息状态 | |||||
| typedef NS_ENUM(NSUInteger, BodyFatScaleMCURequestUserInfoStatus) { | |||||
| BodyFatScaleMCURequestUserInfoStatus_Get = 0x01, //MCU requests App user information(MCU请求App用户信息) | |||||
| BodyFatScaleMCURequestUserInfoStatus_Success = 0x03, //请求成功 | |||||
| BodyFatScaleMCURequestUserInfoStatus_Fail = 0x04, //失败 | |||||
| }; | |||||
| //Impedance measurement status(阻抗测量状态) | |||||
| typedef NS_ENUM(NSUInteger, BodyFatScaleMeasureStatus) { | |||||
| BodyFatScaleMeasureStatus_Unstable = 0, | |||||
| BodyFatScaleMeasureStatus_Stable, | |||||
| BodyFatScaleMeasureStatus_Complete, | |||||
| BodyFatScaleMeasureStatus_Failed, | |||||
| }; | |||||
| //Impedance measurement status (intentionally consistent with A7 command enumeration)(阻抗测量状态(故意和A7指令枚举保持一致)) | |||||
| typedef NS_ENUM(NSUInteger, BodyFatScaleAdcMeasureStatus) { | |||||
| BodyFatScaleAdcMeasureStatus_Testing = 0x04,//测阻抗中 | |||||
| BodyFatScaleAdcMeasureStatus_Success = 0x05,//测阻抗成功 | |||||
| BodyFatScaleAdcMeasureStatus_Fail = 0x06,//测阻抗失败 | |||||
| BodyFatScaleAdcMeasureStatus_SuccessCustom = 0x07,//The impedance measurement is successful, and the APP algorithm is used. The APP will identify the corresponding algorithm according to VID and PID(测阻抗成功,并使用 APP 算法,APP 会根据 VID,PID 来识 别对应算法) | |||||
| }; | |||||
| //Heart rate measurement status (intentionally consistent with A7 command enumeration)(心率测量状态(故意和A7指令枚举保持一致)) | |||||
| typedef NS_ENUM(NSUInteger, BodyFatScaleHeartRateMeasureStatus) { | |||||
| BodyFatScaleHeartRateMeasureStatus_Testing = 0x0B,//测心率中 | |||||
| BodyFatScaleHeartRateMeasureStatus_Success = 0x0C,//测心率成功 | |||||
| BodyFatScaleHeartRateMeasureStatus_Fail = 0x0D,//测心率失败 | |||||
| }; | |||||
| //Send success or failure callback for offline user list(发送离线用户列表的成功或失败回调) | |||||
| typedef NS_ENUM(NSUInteger, BodyFatScaleUpdateRecordStatus) { | |||||
| BodyFatScaleUpdateRecordStatus_AllSuccess = 0x00,//Successfully updated list(更新列表成功) | |||||
| BodyFatScaleUpdateRecordStatus_OneSuccess = 0x01,//Successfully update individual users(更新个人用户成功) | |||||
| BodyFatScaleUpdateRecordStatus_AllFail = 0x02,//Update list failed(更新列表失败) | |||||
| BodyFatScaleUpdateRecordStatus_OneFail = 0x03,//Failed to update individual user(更新个人用户失败) | |||||
| }; | |||||
| //Request offline history callback(请求离线历史记录回调) | |||||
| typedef NS_ENUM(NSUInteger, BodyFatScaleSendHistoryDataStatus) { | |||||
| BodyFatScaleSendHistoryDataStatus_No = 0x00,//无历史记录 | |||||
| BodyFatScaleSendHistoryDataStatus_Begin = 0x01,//开始发送历史记录 | |||||
| BodyFatScaleSendHistoryDataStatus_End = 0x02,//结束发送历史记录 | |||||
| }; | |||||
| //Character(角色) | |||||
| typedef NS_ENUM(NSUInteger, BodyFatScaleRole) { | |||||
| BodyFatScaleRole_Ordinary = 0x00,//Ordinary(普通人) | |||||
| BodyFatScaleRole_Athlete = 0x01,//Athlete(运动员) | |||||
| BodyFatScaleRole_AthletePro = 0x02,//AthletePro(专业运动员) | |||||
| BodyFatScaleRole_Pregnancy = 0x03,//Pregnancy(孕妇) | |||||
| }; | |||||
| #endif /* ELBodyFatScaleBleHeader_h */ |
| // | |||||
| // ELScaleBleManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by 王庭 on 2019/5/28. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELBluetoothManager.h" | |||||
| #import "ELBodyFatScaleBleHeader.h" | |||||
| @class ELBodyFatScaleBleUserModel,ELBodyFatScaleBleWeightModel,ELBodyFatScaleDeviceModel; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @protocol ELBodyFatScaleBleDelegate <NSObject> | |||||
| @optional | |||||
| /** Callback Bluetooth status(回调蓝牙状态) */ | |||||
| - (void)bodyFatScaleManagerUpdateState:(ELBluetoothState )state; | |||||
| /**Callback all body fat scales detected( 回调扫描到的所有体脂秤 )*/ | |||||
| - (void)bodyFatScaleManagerScanDevices:(NSArray<ELBodyFatScaleDeviceModel *> *)scaleDevices; | |||||
| //MARK:回调A7指令数据 | |||||
| /** | |||||
| Callback to set unit result(回调设置单位结果) | |||||
| @param result 结果 | |||||
| */ | |||||
| - (void)bodyFatScaleManagerCallBackSetUnitResult:(ELSetBluetoothResponseType)result; | |||||
| /** | |||||
| MCU requests user information( MCU 请求用户信息) | |||||
| @param status 请求状态 | |||||
| */ | |||||
| - (void)bodyFatScaleManagerMCURequestAppUserInfoType:(BodyFatScaleMCURequestUserInfoStatus)status; | |||||
| /** | |||||
| Return weight and body fat model(返回重量及体脂model) | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackWeight:(ELBodyFatScaleBleWeightModel *)weightModel state:(BodyFatScaleMeasureStatus)status; | |||||
| /** | |||||
| Return temperature (unit: ° C)(返回温度(单位:°C)) | |||||
| @param temp 温度(单位:°C) | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackTemp:(NSString *)temp; | |||||
| /** | |||||
| Back to impedance measurement(返回阻抗测量) | |||||
| @param status 阻抗测量状态 | |||||
| @param adc 阻抗 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackAdcMeasureStatus:(BodyFatScaleAdcMeasureStatus)status adcValue:(NSInteger)adc; | |||||
| /** | |||||
| Callback heart rate measurement(回调心率测量) | |||||
| @param status 心率测量状态 | |||||
| @param heartRate 心率 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackHeartRateMeasureStatus:(BodyFatScaleHeartRateMeasureStatus)status heartRateValue:(NSInteger)heartRate; | |||||
| /** | |||||
| Return error code(返回错误码) | |||||
| @param code 错误码 | |||||
| 1:超重 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackErrorCode:(NSInteger)code; | |||||
| //MARK:回调A6指令数据 | |||||
| /** | |||||
| Send success or failure callback for offline user list(发送离线用户列表的成功或失败回调) | |||||
| @param status 状态 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackUpdateRecordStatus:(BodyFatScaleUpdateRecordStatus)status; | |||||
| /** | |||||
| Request callback for offline history(请求离线历史记录的回调) | |||||
| @param status 状态 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackSendHistoryDataStatus:(BodyFatScaleSendHistoryDataStatus)status; | |||||
| /** | |||||
| APP algorithm-offline history data(APP 算法-离线历史记录数据) | |||||
| @param user 用户信息 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackBleUserHistoryDataCustomADCModel:(ELBodyFatScaleBleUserModel *)user bodyDataModel:(ELBodyFatScaleBleWeightModel *)bodyModel; | |||||
| /** | |||||
| MCU algorithm-offline history data(MCU 算法-离线历史记录数据) | |||||
| @param user 用户信息 | |||||
| @param bodyModel 体脂数据 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackBleUserHistoryDataModel:(ELBodyFatScaleBleUserModel *)user bodyDataModel:(ELBodyFatScaleBleWeightModel *)bodyModel; | |||||
| @end | |||||
| @interface ELBodyFatScaleBleManager : ELBluetoothManager | |||||
| @property (nonatomic,weak) id<ELBodyFatScaleBleDelegate> bodyFatScaleDelegate; | |||||
| + (ELBodyFatScaleBleManager *)shareManager; | |||||
| #pragma mark ============ 下发A7指令 ============== | |||||
| - (void)changeBodyFatScaleUnit:(ELDeviceWeightUnit)unit; | |||||
| - (void)sendCurrentUserToBle:(ELBodyFatScaleBleUserModel *)usr; | |||||
| #pragma mark ============ 下发A6指令 ============== | |||||
| -(void)sendOfflineUserListToBle:(NSArray <ELBodyFatScaleBleUserModel *> *)userListArr; | |||||
| -(void)updateSingleUserInOfflineUserList:(ELBodyFatScaleBleUserModel *)usr; | |||||
| -(void)sendCmd_RequestHistory; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBodyFatScaleBleUserModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/7/18. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELBodyFatScaleBleHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| /** | |||||
| APP下发当前用户或者用户列表前需要将appUser转换为如下bleUser | |||||
| */ | |||||
| @interface ELBodyFatScaleBleUserModel : NSObject | |||||
| @property (nonatomic, assign) NSUInteger createTime; | |||||
| @property (nonatomic, assign) NSUInteger usrID; | |||||
| @property (nonatomic, assign) BodyFatScaleRole role; //角色 | |||||
| @property (nonatomic, assign) ELBluetoothUserSex sex; //性别 | |||||
| @property (nonatomic, assign) NSUInteger age; //Age 28 (only counts for the whole year)(年龄28(只算整年)) | |||||
| @property (nonatomic, assign) NSUInteger height; //Height 170 (Unit fixed to death: cm, accuracy 1)(身高170(单位定死:cm,精度1)) | |||||
| @property (nonatomic, assign) NSUInteger weight; //Weight 562 (Unit fixed death: kg, accuracy 0.1) 120lb-》 54.4lkg-》 545(体重562(单位定死:kg,精度0.1) 120lb-》54.4lkg-》545) | |||||
| @property (nonatomic, assign) NSUInteger adc;//Impedance 1230 (accuracy is 1Ω)(阻抗1230(精度为 1Ω)) | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELBodyFatScaleBodyDataModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/7/18. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| /** | |||||
| Raw data received from ble: all integers(从ble接收的原始数据:都是整数) | |||||
| */ | |||||
| @interface ELBodyFatScaleBleWeightModel : NSObject | |||||
| @property (nonatomic, assign) NSUInteger weight; | |||||
| @property (nonatomic, assign) NSUInteger weightUnit; | |||||
| @property (nonatomic, assign) NSUInteger weightPoint; | |||||
| ///Body fat rate, need / 10(体脂率,需要/10) | |||||
| @property (nonatomic, assign) NSUInteger bfr; | |||||
| ///Subcutaneous fat rate, need / 10(皮下脂肪率,需要/10) | |||||
| @property (nonatomic, assign) NSUInteger sfr; | |||||
| ///Visceral fat rate with an accuracy of 1(内脏脂肪率,精度为1) | |||||
| @property (nonatomic, assign) NSUInteger uvi; | |||||
| ///Muscle rate, need / 10(肌肉率,需要/10) | |||||
| @property (nonatomic, assign) NSUInteger rom; | |||||
| ///Basal metabolic rate with an accuracy of 1(基础代谢率,精度为1) | |||||
| @property (nonatomic, assign) NSUInteger bmr; | |||||
| ///Bone quality, need / 10(骨骼质量,需要/10) | |||||
| @property (nonatomic, assign) NSUInteger bm; | |||||
| ///Water content, need / 10(水含量,需要/10) | |||||
| @property (nonatomic, assign) NSUInteger vwc; | |||||
| ///Body age with an accuracy of 1(身体年龄,精度为1) | |||||
| @property (nonatomic, assign) NSUInteger bodyAge; | |||||
| ///Protein rate, need / 10(蛋白率,需要/10) | |||||
| @property (nonatomic, assign) NSUInteger pp; | |||||
| ///Creation time with an accuracy of 1(创建时间,精度为1) | |||||
| @property (nonatomic, assign) NSUInteger createTime; | |||||
| ///Impedance, accuracy is 1(阻抗,精度为1) | |||||
| @property (nonatomic, assign) NSUInteger adc; | |||||
| ///Heart rate with an accuracy of 1(心率,精度为1) | |||||
| @property (nonatomic, assign) NSUInteger heartRate; | |||||
| ///Algorithm ID(算法ID) | |||||
| @property (nonatomic, assign) NSUInteger algNum; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELScaleDeviceModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by 王庭 on 2019/5/28. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELPeripheralModel.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| /** | |||||
| 蓝牙扫描出来的模型 | |||||
| */ | |||||
| @interface ELBodyFatScaleDeviceModel : ELPeripheralModel | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELForeHeadBleManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/4/18. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELBluetoothManager.h" | |||||
| #import "ELForeheadBleDataModel.h" | |||||
| #import "ELForeheadHeader.h" | |||||
| typedef NS_ENUM(NSUInteger, ForeheadBleDataType) { | |||||
| ForeheadBleDataType_ForeheadStabilityData = 0x01, //Forehead temperature stability data sign(额头温度稳定数据标志) | |||||
| ForeheadBleDataType_ForeheadDynamicData = 0x02, //Forehead temperature real-time data sign(额头温度实时数据标志) | |||||
| ForeheadBleDataType_EarStabilityData = 0x03, //Ear temperature stability data sign(耳朵温度稳定数据标志) | |||||
| ForeheadBleDataType_EarDynamicData = 0x04, //Ear temperature real-time data sign(耳朵温度实时数据标志) | |||||
| ForeheadBleDataType_EnvironmentStabilityData = 0x05, //Ambient temperature stable data sign(环境温度稳定数据标志) | |||||
| ForeheadBleDataType_EnvironmentDynamicData = 0x06, //Ambient temperature real-time data sign(环境温度实时数据标志) | |||||
| ForeheadBleDataType_SubstatanceStabilityData = 0x07, //Object temperature stable data sign(物体温度稳定数据标志) | |||||
| ForeheadBleDataType_SubstatanceDynamicData = 0x08, //Object temperature real-time data sign(物体温度实时数据标志) | |||||
| ForeheadBleDataTypeAppSendUnit = 0x81, //App release unit settings(app下发单位设置) | |||||
| ForeheadBleDataTypeSetUnitResult = 0x82, //Unit setting result(单位设置结果) | |||||
| ForeheadBleDataTypeFailCode = 0xFF, //Report an error message(上报错误信息) | |||||
| }; | |||||
| @protocol ELForeheadBleManagerDelegate <NSObject> | |||||
| @optional | |||||
| /** | |||||
| Callback Bluetooth status(回调蓝牙状态) | |||||
| @param state 蓝牙状态 | |||||
| */ | |||||
| -(void)foreheadBleManagerUpdateBleState:(ELBluetoothState)state; | |||||
| /** | |||||
| Callback scanned device(回调扫描到的设备) | |||||
| @param devices 额温枪设备 | |||||
| */ | |||||
| -(void)foreheadBleManagerScanDevices:(NSArray<ELPeripheralModel *> *_Nullable)devices; | |||||
| /** | |||||
| Callback temperature(回调温度) | |||||
| @param model ELForeheadBleDataModel | |||||
| */ | |||||
| -(void)foreheadBleManagerReceiveTemperature:(ELForeheadBleDataModel *_Nonnull)model dataType:(ForeheadBleDataType)dataType; | |||||
| /** | |||||
| Set unit callback( 设置单位回调) | |||||
| @param type 结果 | |||||
| */ | |||||
| -(void)foreheadBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type; | |||||
| /** | |||||
| Error code sent on the device(设备上发错误码) | |||||
| @param code 错误码 | |||||
| */ | |||||
| -(void)foreheadBleManagerReceiveFailCode:(ForeheadFailCode)code; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELForeHeadBleManager : ELBluetoothManager | |||||
| @property (nonatomic, weak) id<ELForeheadBleManagerDelegate> foreheadDelegate; | |||||
| +(instancetype)shareManager; | |||||
| /** | |||||
| Edit unit(修改单位) | |||||
| @param unit 单位 | |||||
| */ | |||||
| -(void)changeUnit:(ELDeviceTemperatureUnit)unit; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELForeheadBleDataModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/5/10. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELForeheadHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELForeheadBleDataModel : NSObject | |||||
| @property (nonatomic, assign) NSString * temperature;//温度 | |||||
| @property (nonatomic, assign) ELDeviceTemperatureUnit unit;//单位 | |||||
| @property (nonatomic, assign) NSInteger point;//小数点 | |||||
| @property (nonatomic, assign) NSInteger createTime;//时间 | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELForeheadHeader.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/5/10. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #ifndef ELForeheadHeader_h | |||||
| #define ELForeheadHeader_h | |||||
| #import "ELSDKHeader.h" | |||||
| //单位 | |||||
| #define ForeheadUnit_CStr AiLinkBleTempUnit_CStr | |||||
| #define ForeheadUnit_FStr AiLinkBleTempUnit_FStr | |||||
| #define ForeheadUnitDic @{@(ForeheadUnitType_C):ForeheadUnit_CStr,@(ForeheadUnitType_F):ForeheadUnit_FStr} | |||||
| // | |||||
| #define C_TO_F(C) (C*1.8+32) //F = C*1.8 + 32 | |||||
| #define CFMultiple 1.8 | |||||
| #define F_TO_C(F) ((F-32)/1.8) //F = C*1.8 + 32 | |||||
| //异常 | |||||
| typedef NS_ENUM(NSUInteger, ForeheadFailCode) { | |||||
| ForeheadFailCodeTemperatureTooHigh = 0, //Temperature is too high(温度过高) | |||||
| ForeheadFailCodeTemperatureTooLow = 1, //The temperature is too low(温度过低) | |||||
| }; | |||||
| #endif /* ELForeheadHeader_h */ |
| // | |||||
| // ELHeightGaugeBleDataModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/5/10. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import <UIKit/UIKit.h> | |||||
| #import "ELHeightGaugeHeader.h" | |||||
| #import "ELSDKHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELHeightGaugeBleDataModel : NSObject | |||||
| @property (nonatomic, assign) NSUInteger height; //ble raw data | |||||
| @property (nonatomic, assign) NSUInteger heightPoint; //decimal | |||||
| @property (nonatomic, assign) ELDeviceHeightUnit heightUnit;//单位 | |||||
| @property (nonatomic, assign) NSInteger createTime;//时间 | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELForeHeadBleManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/4/18. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELBluetoothManager.h" | |||||
| #import "ELHeightGaugeBleDataModel.h" | |||||
| #import "ELHeightGaugeHeader.h" | |||||
| typedef NS_ENUM(NSUInteger, HeightGaugeBleDataType) { | |||||
| HeightGaugeBleDataTypeStabilityData = 0x01, //stable temperature | |||||
| HeightGaugeBleDataTypeAppSendUnit = 0x81, //set unit | |||||
| HeightGaugeBleDataTypeSetUnitResult = 0x82, //result of set unit | |||||
| HeightGaugeBleDataTypeFailCode = 0xFF, //error code | |||||
| }; | |||||
| @protocol ELHeightGaugeBleManagerDelegate <NSObject> | |||||
| @optional | |||||
| /** | |||||
| call back ble status | |||||
| */ | |||||
| -(void)heightGaugeBleManagerUpdateBleState:(ELBluetoothState)state; | |||||
| /** | |||||
| call back ble scan devices model | |||||
| */ | |||||
| -(void)heightGaugeBleManagerScanDevices:(NSArray<ELPeripheralModel *> *_Nullable)devices; | |||||
| /** | |||||
| call back ELHeightGaugeBleDataModel | |||||
| */ | |||||
| -(void)heightGaugeBleManagerReceiceTestData:(ELHeightGaugeBleDataModel *_Nonnull)model; | |||||
| /** | |||||
| call back the result of set unit | |||||
| */ | |||||
| -(void)heightGaugeBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type; | |||||
| /** | |||||
| call back fail code | |||||
| */ | |||||
| -(void)heightGaugeBleManagerReceiveFailCode:(ELHeightGaugeFailCode)code; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELHeightGaugeBleManager : ELBluetoothManager | |||||
| @property (nonatomic, weak) id<ELHeightGaugeBleManagerDelegate> heightGaugeDelegate; | |||||
| +(instancetype)shareManager; | |||||
| -(void)changeUnit:(ELDeviceHeightUnit)unit; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELHeightGaugeHeader.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/5/10. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #ifndef ELHeightGaugeHeader_h | |||||
| #define ELHeightGaugeHeader_h | |||||
| //单位 | |||||
| //typedef NS_ENUM(NSUInteger, ELHeightGaugeUnitType) { | |||||
| // ELHeightGaugeUnitType_cm = 0, | |||||
| // ELHeightGaugeUnitType_inch = 1, | |||||
| // ELHeightGaugeUnitType_ft_in = 2, //feet-inch | |||||
| //}; | |||||
| //abnormal(异常) | |||||
| typedef NS_ENUM(NSUInteger, ELHeightGaugeFailCode) { | |||||
| ELHeightGaugeFailCodeMeasureFailed = 0, //Measurement failed(测量失败) | |||||
| }; | |||||
| #endif /* ELHeightGaugeHeader_h */ |
| // | |||||
| // ELPeripheralModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/4/22. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import <CoreBluetooth/CoreBluetooth.h> | |||||
| #import "ELSDKHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| /** | |||||
| Bluetooth peripheral out model(蓝牙扫描出来的外设模型) | |||||
| */ | |||||
| @interface ELPeripheralModel : NSObject | |||||
| /** | |||||
| CID | |||||
| */ | |||||
| @property (nonatomic, assign) ELSupportDeviceType deviceType; | |||||
| /** | |||||
| VID | |||||
| */ | |||||
| @property (nonatomic, assign) NSInteger vendorID; | |||||
| /** | |||||
| PID | |||||
| */ | |||||
| @property (nonatomic, assign) NSInteger productID; | |||||
| @property (nonatomic, copy) NSString *deviceName; | |||||
| @property (nonatomic, copy) NSString *macAddress; | |||||
| @property (nonatomic, assign) NSInteger rssi; | |||||
| @property (nonatomic, strong) CBPeripheral *peripheral; | |||||
| /** | |||||
| 6 bytes: small endian(6个byte:小端序) | |||||
| */ | |||||
| @property (nonatomic, copy) NSData *macData; | |||||
| /** | |||||
| 2 bytes | |||||
| */ | |||||
| @property (nonatomic, copy) NSData *deviceTypeData; | |||||
| /** Device with unit: support unit string | |||||
| Unitless equipment | |||||
| Smart Door Lock: Supported unlock type | |||||
| 有单位的设备:支持单位字符串 | |||||
| 无单位的设备 | |||||
| 智能门锁:支持的开锁类型 | |||||
| */ | |||||
| @property (nonatomic, copy) NSString *supportUnit; | |||||
| /** Device version numbe(设备版本号) */ | |||||
| @property (nonatomic, copy) NSString *version; | |||||
| /** | |||||
| Screening equipment(筛选设备) | |||||
| @param peripherals All devices scanned by the parent class(父类扫描到的所有设备) | |||||
| @param type Equipment type(设备类型) | |||||
| @return Array of corresponding devices(对应设备的数组) | |||||
| */ | |||||
| +(NSArray<ELPeripheralModel *> *)getDevicesWithPeripherals:(NSArray<__kindof ELPeripheralModel *> *)peripherals supportDeviceType:(ELSupportDeviceType)type; | |||||
| //MARK:Screen multiple devices(筛选多个设备) | |||||
| +(NSArray<ELPeripheralModel *> *)getDevicesWithPeripherals:(NSArray<__kindof ELPeripheralModel *> *)peripherals supportDeviceTypes:(NSArray<NSNumber *> *)types; | |||||
| //Descending order(降序) | |||||
| -(NSComparisonResult)compareRSSI:(ELPeripheralModel *)model; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELRemoteControlBleHeader.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/8/22. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #ifndef ELRemoteControlBleHeader_h | |||||
| #define ELRemoteControlBleHeader_h | |||||
| /** 遥控器按钮类型 */ | |||||
| typedef NS_ENUM(NSInteger ,RemoteControlType) { | |||||
| /** K */ | |||||
| RemoteControlType_K_0_05 = 0 , | |||||
| /** 字母0.1 到 1.2 */ | |||||
| RemoteControlType_Letter_0_1 ,//1 | |||||
| RemoteControlType_Letter_0_2 , | |||||
| RemoteControlType_Letter_0_5 , | |||||
| RemoteControlType_Letter_0_8 , | |||||
| RemoteControlType_Letter_1_2 , | |||||
| /** 时钟图形 */ | |||||
| RemoteControlType_Clock , | |||||
| /** 对称的方块 */ | |||||
| RemoteControlType_SymmetryBox , | |||||
| RemoteControlType_E_0_1 , | |||||
| RemoteControlType_E_0_3 , | |||||
| RemoteControlType_E_0_6 , | |||||
| RemoteControlType_E_1_0 , | |||||
| /** 数字0.1到1.0 */ | |||||
| RemoteControlType_Number_0_1 , | |||||
| RemoteControlType_Number_0_3 , | |||||
| RemoteControlType_Number_0_6 , | |||||
| RemoteControlType_Number_1_0 , | |||||
| /** 动植物0.1到0.7 */ | |||||
| RemoteControlType_Pattern_0_1 ,//16 | |||||
| RemoteControlType_Pattern_0_2 , | |||||
| RemoteControlType_Pattern_0_4 , | |||||
| RemoteControlType_Pattern_0_7 , | |||||
| /** 黑色的散点 */ | |||||
| RemoteControlType_BlackDots , | |||||
| /** 多个圆弧 */ | |||||
| RemoteControlType_CircularArc , | |||||
| /** 3956 */ | |||||
| RemoteControlType_3956 , | |||||
| /** 上下为空的方块 */ | |||||
| RemoteControlType_UpDownEmpty , | |||||
| /** 左右为空的方块 */ | |||||
| RemoteControlType_LeftRightEmpty , | |||||
| /** 黑色的点 */ | |||||
| RemoteControlType_BlockDot , | |||||
| /** 空心的准星 */ | |||||
| RemoteControlType_HollowSightBead , | |||||
| /** 准星 */ | |||||
| RemoteControlType_SightBead , | |||||
| RemoteControlType_UpProgram , | |||||
| RemoteControlType_DownProgram , | |||||
| RemoteControlType_8_3 ,//30 | |||||
| RemoteControlType_8_4 , | |||||
| /** 显示水平 */ | |||||
| RemoteControlType_HorizontalLine , | |||||
| /** 显示垂直 */ | |||||
| RemoteControlType_VerticalLine , | |||||
| /** 显示单个 */ | |||||
| RemoteControlType_Point , | |||||
| RemoteControlType_Reset , | |||||
| RemoteControlType_Light , | |||||
| RemoteControlType_Right , | |||||
| RemoteControlType_Mute ,//38 | |||||
| /** 上下左右 */ | |||||
| RemoteControlType_TouchTop , | |||||
| RemoteControlType_TouchLeft , | |||||
| RemoteControlType_TouchRight , | |||||
| RemoteControlType_TouchBottom , | |||||
| }; | |||||
| #endif /* ELRemoteControlBleHeader_h */ |
| // | |||||
| // ELRemoteControlBleManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by 王庭 on 2019/7/2. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELRemoteControlBleHeader.h" | |||||
| #import "ELBluetoothManager.h" | |||||
| #import "ELRemoteControlDeviceModel.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @protocol ELRemoteControlBleDelegate <NSObject> | |||||
| @optional | |||||
| /** 回调蓝牙状态 */ | |||||
| - (void)remoteControlManagerUpdateState:(ELBluetoothState )state; | |||||
| /** 回调所有遥控器设备 */ | |||||
| - (void)remoteControlManagerScanDevices:(NSArray<ELRemoteControlDeviceModel *> *)deviceList; | |||||
| @end | |||||
| @interface ELRemoteControlBleManager : ELBluetoothManager | |||||
| @property (nonatomic,weak) id <ELRemoteControlBleDelegate> remoteControlDelegate; | |||||
| + (ELRemoteControlBleManager *)shareManager; | |||||
| /** APP下发控制命令 */ | |||||
| - (void)sendRemoreControlData:(RemoteControlType )type; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELRemoteControlDeviceModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by 王庭 on 2019/7/2. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELPeripheralModel.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELRemoteControlDeviceModel : ELPeripheralModel | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELSDKHeader.h | |||||
| // AILinkSDKDemo | |||||
| // | |||||
| // Created by iot_user on 2019/5/10. | |||||
| // Copyright © 2019 IOT. All rights reserved. | |||||
| // | |||||
| #ifndef ELSDKHeader_h | |||||
| #define ELSDKHeader_h | |||||
| //Bluetooth command type(蓝牙指令类型) | |||||
| typedef NS_ENUM(NSUInteger, ELInetBleDataType) { | |||||
| ELInetBleDataPackHead_A6 = 0xA6, | |||||
| ELInetBleDataPackTail_6A = 0x6A, | |||||
| ELInetBleDataPackHead_A7 = 0xA7, | |||||
| ELInetBleDataPackTail_7A = 0x7A, | |||||
| }; | |||||
| //The type of instruction acquired by Inet(Inet获取的指令类型) | |||||
| typedef NS_ENUM(NSUInteger, ELInetGetCmdType) { | |||||
| ELInetGetCmdTypeGetName = 0x02, //-Get the Bluetooth name(获取蓝牙名称) | |||||
| ELInetGetCmdTypeGetBroadcastInterval = 0x06, //-Get broadcast interval (unit: ms)(获取广播间隔时间(单位:ms)) | |||||
| ELInetGetCmdTypeGetConnectedInterval = 0x08, //-Get Bluetooth connection interval(获取蓝牙连接间隔) | |||||
| ELInetGetCmdTypeGetTransmittingPower = 0x0A, //-Get Bluetooth transmit power(获取蓝牙发射功率) | |||||
| ELInetGetCmdTypeGetSerialPortbaudRate = 0x0C, //-Get the serial port baud rate(获取串口波特率) | |||||
| ELInetGetCmdTypeGetMACAddress = 0x0D, //-Read MAC address value(读取MAC地址值) | |||||
| ELInetGetCmdTypeGetBMVersion = 0x0E, //-Read the BM module software and hardware version number(读取BM模块软硬件版本号) | |||||
| ELInetGetCmdTypeGetMCUVersion = 0x10, //-Obtain the MCU software and hardware version number(获取MCU软硬件版本号) | |||||
| ELInetGetCmdTypeGetMACAddressType = 0x12, //-Get the big endian or little endian of the Mac address in the broadcast manufacturer's custom data(获取广播厂家自定义数据中Mac地址的大端序或小端序) | |||||
| ELInetGetCmdTypeGetUUID = 0x14, //-Get service and feature UUID(获取服务和特征UUID) | |||||
| ELInetGetCmdTypeGetMCUMode = 0x16, //-Get master-slave mode(获取主从模式) | |||||
| ELInetGetCmdTypeGetAutoSleepTime = 0x18, //-Get automatic sleep time value(获取自动睡眠时间值) | |||||
| ELInetGetCmdTypeGetMCUDate = 0x1C, //-Get the current time of the system(获取系统当前时间) | |||||
| ELInetGetCmdTypeGetC_V_P_ID = 0x1E, //-Read CID, VID, PID(读取CID、VID、PID) | |||||
| ELInetGetCmdTypeGetCommunicationMode = 0x20, //-Get module communication mode(获取模块通信模式) | |||||
| ELInetGetCmdTypeGetConnectState = 0x26, //-Get Bluetooth and WiFi connection status(获取蓝牙和WiFi连接状态) | |||||
| ELInetGetCmdTypeGetBatteryState = 0x28, //-Get MCU battery status(获取MCU电池状态) | |||||
| ELInetGetCmdTypeGetHandshake = 0x24, //-Encrypted handshake data returned by Bluetooth(蓝牙返回的加密的握手数据) | |||||
| ELInetGetCmdTypeGetBodyFatScaleA6Data = 0x2B, //-Body fat scale 0x2B stands for A6 protocol (see the second level instructions for details)(体脂秤0x2B代表A6协议(具体见二级指令)) | |||||
| ELInetGetCmdTypeReadDeviceSupportUnit = 0x2C, //-APP reads the MCU end unit instruction(APP读取MCU端单位指令) | |||||
| ELInetGetCmdTypeGetSendKeyState = 0x31, //-APP reads the result of sending the decoding key(APP读取下发解码秘钥的结果) | |||||
| ELInetGetCmdTypeGetSmartLockA6Data = 0x34, //-Door lock 0x34 represents the A6 protocol (see the second level command for details)(门锁0x34代表A6协议(具体见二级指令)) | |||||
| ELInetGetCmdTypeGetBasicInfoData = 0x36, //Obtain basic device information data(获取设备基本信息数据) | |||||
| #pragma mark ============ 蓝牙Wifi ============== | |||||
| ELInetGetCmdTypeBleWifiGetNearbyWifi = 0x80, //Get nearby Wifi(获取附近Wifi) | |||||
| ELInetGetCmdTypeBleWifiReceiveWifiName = 0x81, //Reply to wifi name(回复wifi名字) | |||||
| ELInetGetCmdTypeBleWifiReceiveWifiMac = 0x82, //Reply to wifi mac(回复wifi mac) | |||||
| ELInetGetCmdTypeBleWifiReceiveScanResult = 0x83, //Reply to scan Wifi result(回复扫描Wifi结果) | |||||
| ELInetGetCmdTypeBleWifiGetWifiMac = 0x85, //Get Wifi Mac address(获取Wifi的Mac地址) | |||||
| ELInetGetCmdTypeBleWifiGetWifiPwd = 0x87, //Get Wifi password(获取Wifi密码) | |||||
| ELInetGetCmdTypeBleWifiGetDTIMInterval = 0x8A, //Get DTIM interval(获取DTIM间隔) | |||||
| ELInetGetCmdTypeBleWifiGetURL = 0x8C, //Get visited sites(获取访问的网站) | |||||
| ELInetGetCmdTypeBleWifiGetPort = 0x8E, //Get access port number(获取访问的端口号) | |||||
| ELInetGetCmdTypeBleWifiGetSNNumber = 0x93, //Get SN number (session code)(获取SN号(会话码)) | |||||
| }; | |||||
| //Instruction type set by Inet(Inet设置的指令类型) | |||||
| typedef NS_ENUM(NSUInteger, ELInetSetCmdType) { | |||||
| ELInetSetCmdTypeSetName = 0x01, //Set the broadcast name(设置广播名称) | |||||
| ELInetSetCmdTypeSetBroadcastInterval = 0x05, //Set the broadcast interval(设置广播间隔时间) | |||||
| ELInetSetCmdTypeSetConnectedInterval = 0x07, //Set the connection interval(设置连接间隔) | |||||
| ELInetSetCmdTypeSetTransmittingPower = 0x09, //Set the transmit power(设置发射功率) | |||||
| ELInetSetCmdTypeSetSerialPortbaudRate = 0x0B, //Set the serial port baud rate(设置串口波特率) | |||||
| ELInetSetCmdTypeSetMCUVersion = 0x0F, //Set the MCU software and hardware version number(设置MCU软硬件版本号) | |||||
| ELInetSetCmdTypeSetMACAddressType = 0x11, //Set the big endian or little endian of the Mac address in the broadcast manufacturer's custom data.(设置广播厂家自定义数据中Mac地址的大端序或小端序) | |||||
| ELInetSetCmdTypeSetUUID = 0x13, //Set the module's service and feature UUID(设置模块的服务和特征UUID) | |||||
| ELInetSetCmdTypeSetMCUMode = 0x15, //Set the master-slave mode of the module(设置模块的主从模式) | |||||
| ELInetSetCmdTypeSetAutoSleepTime = 0x17, //Set the module's automatic sleep time without connection(设置模块无连接的自动休眠时间) | |||||
| ELInetSetCmdTypeSetGotoSleep = 0x19, //Set to sleep(设置进入睡眠) | |||||
| ELInetSetCmdTypeSetMCUWakeUp = 0x1A, //Set module wake up(设置模块唤醒) | |||||
| ELInetSetCmdTypeSetMCUNowDate = 0x1B, //Set the current time of the system(设置系统当前时间) | |||||
| ELInetSetCmdTypeSetC_V_P_ID = 0x1D, //Set CID, VID, PID(设置CID、VID、PID) | |||||
| ELInetSetCmdTypeSetCommunicationMode = 0x1F, //Set module serial port mode, I2C mode, SPI mode(设置模块串口模式、I2C模式、SPI模式) | |||||
| ELInetSetCmdTypeSetMCURestart = 0x21, //Set module restart(设置模块重启) | |||||
| ELInetSetCmdTypeSetFactoryDataReset = 0x22, //Set factory reset(设置恢复出厂设置) | |||||
| ELInetSetCmdTypeSetConnectState = 0x25, //Set the Bluetooth connection status(设置蓝牙连接状态) | |||||
| ELInetSetCmdTypeSetHandshake = 0x23, //Encrypted handshake data returned by Bluetooth(蓝牙返回的加密的握手数据) | |||||
| ELInetSetCmdTypeSetKey = 0x31, //APP sends the decoding key(APP下发解码秘钥) | |||||
| ELInetSetCmdTypeSetSmartLockA6Data = 0x34, //Door lock 0x34 represents the A6 protocol (see the second level command for details)(门锁0x34代表A6协议(具体见二级指令)) | |||||
| #pragma mark ============ 蓝牙Wifi ============== | |||||
| ELInetSetCmdTypeBleWifiSetWifiMac = 0x84, //设置WIFI Mac地址 | |||||
| ELInetSetCmdTypeBleWifiSetWifiPwd = 0x86, //设置WIFI 密码 | |||||
| ELInetSetCmdTypeBleWifiSetConnectWifi = 0x88, //设置设备连接WIFI | |||||
| ELInetSetCmdTypeBleWifiSetDTIMInterval = 0x89, //设置DTIM间隔 | |||||
| ELInetSetCmdTypeBleWifiSetWifiURL = 0x8B, //设置访问的URL | |||||
| ELInetSetCmdTypeBleWifiSetWifiPort = 0x8D, //设置端口号 | |||||
| }; | |||||
| //Response to Bluetooth after device(给蓝牙进行设备后的响应) | |||||
| typedef NS_ENUM(NSUInteger, ELSetBluetoothResponseType) { | |||||
| ELSetBluetoothResponseTypeSuccess =0 , //success(成功) | |||||
| ELSetBluetoothResponseTypeFailure =1 , //failure(失败) | |||||
| ELSetBluetoothResponseTypeNoSupport =2 , //not support(不支持) | |||||
| }; | |||||
| //Device types supported by Elink: Please communicate with the hardware to set(Elink支持的设备类型:请与硬件沟通后设置) | |||||
| typedef NS_ENUM(NSUInteger, ELSupportDeviceType) { | |||||
| ELSupportDeviceTypeUnkonwn = 0x0000 , //unknown(未知) | |||||
| ELSupportDeviceTypeBlood = 0x0001 , //sphygmomanometer(血压计) | |||||
| ELSupportDeviceTypeForehead = 0x0002 , //Temperature gun(额温枪) | |||||
| ELSupportDeviceTypeThermometer = 0x0003 , //thermometer(体温计) | |||||
| ELSupportDeviceTypeBabyScale = 0x0004 , //Baby scale(婴儿秤) | |||||
| ELSupportDeviceTypeHeightGauge = 0x0005 , //Height meter(身高仪) | |||||
| ELSupportDeviceTypeSmartLock = 0x000B , //Smart door lock(智能门锁) | |||||
| ELSupportDeviceTypeRemoteControl = 0x000C , //Internal projection vision tester(内投影视力检查仪) | |||||
| ELSupportDeviceTypeWheelMonitor = 0x000D , //TPMS(胎压转接板) | |||||
| ELSupportDeviceTypeBodyFatScale = 0x000E , //Body fat scale(体脂秤) | |||||
| ELSupportDeviceTypeSmatLockRemote = 0x0010 , //Smart door lock remote control(智能门锁遥控器) | |||||
| ELSupportDeviceTypeBLE_WIFIScale = 0x0011 , //Ble and wifi Scale(蓝牙Wifi体脂秤) | |||||
| }; | |||||
| //Communication mode(通信模式) | |||||
| typedef NS_ENUM(NSInteger, ELCommunicationModeType) { | |||||
| ELCommunicationModeTypeSerialPort = 0, //Serial port mode(串口模式) | |||||
| ELCommunicationModeTypeI2C = 1, //I2C mode(I2C模式) | |||||
| ELCommunicationModeTypeSPI = 2, //SPI mode( SPI模式) | |||||
| }; | |||||
| //Battery charge status (电池充电状态) | |||||
| typedef NS_ENUM(NSUInteger, ELBatteryChargingState) { | |||||
| ELBatteryChargingStateDefault = 0x00, //No charging (default)(没有充电(默认)) | |||||
| ELBatteryChargingStateWorking = 0x01, //charging(充电中) | |||||
| ELBatteryChargingStateComplete = 0x02, //full charge(充满电) | |||||
| ELBatteryChargingStateException = 0x03, //Abnormal charging(充电异常) | |||||
| ELBatteryChargingStatePowerLow = 0x04, //Low battery(电量过低) | |||||
| }; | |||||
| //CID,VID,PID | |||||
| struct ELDIDStruct { | |||||
| ELSupportDeviceType deviceType; //CID | |||||
| int vendorID; //VID | |||||
| int productID; //PID | |||||
| }; | |||||
| //Battery charging state and power structur(电池充电状态和电量的结构体) | |||||
| struct ELBatteryStruct { | |||||
| ELBatteryChargingState state; //charging(充电状态) | |||||
| int power; //Electricity(电量)(0—100%) | |||||
| }; | |||||
| //Connection interval structure(连接间隔时间的结构体) | |||||
| struct ELConnectIntervalStruct { | |||||
| int interval; //Connection interval, unit: ms; range: 20-2000(连接间隔,单位:ms;范围:20-2000) | |||||
| int latency; //Slave delay, value: 0-4(从设备延时,取值:0-4) | |||||
| int timeout; //Connection timeout, unit: ms; Range: 1000~6000(连接超时,单位:ms; 范围: 1000~6000) | |||||
| }; | |||||
| struct ELUUIDStruct { | |||||
| char *serviceUUID; //Service UUID(服务UUID) | |||||
| char *writeUUID; //For APP to send data to MCU (write)(用于 APP 下发数据到 MCU(write)) | |||||
| char *notifyUUID; //Used for MCU data transfer to APP (notify)(用于 MCU 数据传输到 APP (notify)) | |||||
| }; | |||||
| struct ELAutoSleepTimeStruct { | |||||
| int sleepTime; //Automatic sleep time, unit: s(自动睡眠时间,单位:s) | |||||
| int open; //Whether to enable low frequency broadcast after sleep: 0: not open, 1: open(睡眠后是否开启低频广播: 0:不开启 ,1:开启) | |||||
| int interval; //Low frequency broadcast interval, unit: ms; range 20~2000(低频广播间隔,单位 :ms ;范围 20~2000) | |||||
| }; | |||||
| //WiFi连接状态 | |||||
| typedef NS_ENUM(NSUInteger, BleWiFiConnectState) { | |||||
| BleWiFiConnectStateNoWiFi = 0,//0:没有连接,0: No connection | |||||
| BleWiFiConnectStateConnectFail = 1 ,//1:尝试连接热点,但是失败1: Attempt to connect to the hotspot, but failed | |||||
| BleWiFiConnectStateNoNetwork = 2 ,//2:连接热点,热点无网络,2: Connected to the hotspot, the hotspot has no network | |||||
| BleWiFiConnectStateSuccess = 3 ,//3:连接热点,热点有网络,3: Connected to the hotspot, the hotspot has a network | |||||
| BleWiFiConnectStateNoConnect = 4 ,//4:有热点信息,未连接,4: There is hotspot information, not connected | |||||
| }; | |||||
| struct ELMCUStateStruct { | |||||
| int connectState; //Connection status: 0: no connection 1: connected(蓝牙连接状态: 0:无连接 1:已连接 2:配对完成) | |||||
| BleWiFiConnectState wifiState; // | |||||
| int workState; //Working status: 0: Wake 1: Go to sleep 2: Module is ready(工作状态: 0:唤醒 1:进入休眠 2:模块准备就绪) | |||||
| }; | |||||
| #pragma mark - AiLink unit | |||||
| /** Type key of unit string(单位字符串的type key) */ | |||||
| #define ELDeviceUnitTypeKey @"type" | |||||
| /** supportUnit key */ | |||||
| #define ELDeviceUnitSupportUnitKey @"supportUnit" | |||||
| /** Ailink unit */ | |||||
| typedef NS_ENUM(NSInteger, ELDeviceUnitType) { | |||||
| /** Weight(重量) */ | |||||
| ELDeviceUnitType_Weight = 1 , | |||||
| /** length(长度) */ | |||||
| ELDeviceUnitType_Height , | |||||
| /** temperature(温度) */ | |||||
| ELDeviceUnitType_Temperature , | |||||
| /** Pressure(血压) */ | |||||
| ELDeviceUnitType_BloodPressure , | |||||
| /** Tire pressure(轮胎胎压压力) */ | |||||
| ELDeviceUnitType_Pressure , | |||||
| }; | |||||
| #define AiLinkBleWeightUnit_KG_Str @"kg" | |||||
| #define AiLinkBleWeightUnit_Jin_Str @"斤" | |||||
| #define AiLinkBleWeightUnit_LB_OZ_Str @"lb:oz" | |||||
| #define AiLinkBleWeightUnit_OZ_Str @"oz" | |||||
| #define AiLinkBleWeightUnit_ST_LB_Str @"st:lb" | |||||
| #define AiLinkBleWeightUnit_G_Str @"g" | |||||
| #define AiLinkBleWeightUnit_LB_Str @"lb" | |||||
| #define AiLinkBleWeightUnitStrDic(key) [@{AiLinkBleWeightUnit_KG_Str:@(ELDeviceWeightUnit_KG),AiLinkBleWeightUnit_Jin_Str:@(ELDeviceWeightUnit_JIN),AiLinkBleWeightUnit_LB_OZ_Str:@(ELDeviceWeightUnit_LB_OZ),AiLinkBleWeightUnit_OZ_Str:@(ELDeviceWeightUnit_OZ),AiLinkBleWeightUnit_ST_LB_Str:@(ELDeviceWeightUnit_ST_LB),AiLinkBleWeightUnit_G_Str:@(ELDeviceWeightUnit_G),AiLinkBleWeightUnit_LB_Str:@(ELDeviceWeightUnit_LB)}[key] integerValue] | |||||
| #define AiLinkBleWeightUnitDic @{@(ELDeviceWeightUnit_KG):AiLinkBleWeightUnit_KG_Str,@(ELDeviceWeightUnit_JIN):AiLinkBleWeightUnit_Jin_Str,@(ELDeviceWeightUnit_LB_OZ):AiLinkBleWeightUnit_LB_OZ_Str,@(ELDeviceWeightUnit_OZ):AiLinkBleWeightUnit_OZ_Str,@(ELDeviceWeightUnit_ST_LB):AiLinkBleWeightUnit_ST_LB_Str,@(ELDeviceWeightUnit_G):AiLinkBleWeightUnit_G_Str,@(ELDeviceWeightUnit_LB):AiLinkBleWeightUnit_LB_Str} | |||||
| /** AiLink Weight unit(体重单位)*/ | |||||
| typedef NS_ENUM(NSInteger, ELDeviceWeightUnit) { | |||||
| /** kg */ | |||||
| ELDeviceWeightUnit_KG = 0x00 , | |||||
| /** 斤 */ | |||||
| ELDeviceWeightUnit_JIN = 0x01 , | |||||
| /** lb:oz */ | |||||
| ELDeviceWeightUnit_LB_OZ = 0x02 , | |||||
| /** oz */ | |||||
| ELDeviceWeightUnit_OZ = 0x03 , | |||||
| /** st:lb */ | |||||
| ELDeviceWeightUnit_ST_LB = 0x04 , | |||||
| /** g */ | |||||
| ELDeviceWeightUnit_G = 0x05 , | |||||
| /** lb */ | |||||
| ELDeviceWeightUnit_LB = 0x06 , | |||||
| /** Unsupported unit */ | |||||
| ELDeviceWeightUnit_Fail = 0xFF , | |||||
| }; | |||||
| #define AiLinkBleHeightUnit_CMStr @"cm" | |||||
| #define AiLinkBleHeightUnit_InchStr @"inch" | |||||
| #define AiLinkBleHeightUnit_FeetStr @"feet" | |||||
| #define AiLinkBleHeightUnitDic @{@(ELDeviceHeightUnit_CM):AiLinkBleHeightUnit_CMStr,@(ELDeviceHeightUnit_Inch):AiLinkBleHeightUnit_InchStr,@(ELDeviceHeightUnit_FT_IN):AiLinkBleHeightUnit_FeetStr} | |||||
| /** AiLink Length unit(长度单位) */ | |||||
| typedef NS_ENUM(NSInteger, ELDeviceHeightUnit) { | |||||
| /** cm */ | |||||
| ELDeviceHeightUnit_CM = 0x00 , | |||||
| /** inch */ | |||||
| ELDeviceHeightUnit_Inch = 0x01 , | |||||
| /** feet:inch */ | |||||
| ELDeviceHeightUnit_FT_IN = 0x02 , | |||||
| /** Unsupported unit */ | |||||
| ELDeviceHeightUnit_Fail = 0xFF , | |||||
| }; | |||||
| #define AiLinkBleTempUnit_CStr @"℃" | |||||
| #define AiLinkBleTempUnit_FStr @"℉" | |||||
| #define AiLinkBleTempUnitDic @{@(ELDeviceTemperatureUnit_C):AiLinkBleTempUnit_CStr,@(ELDeviceTemperatureUnit_F):AiLinkBleTempUnit_FStr} | |||||
| /** AiLink Temperature unit(温度单位)*/ | |||||
| typedef NS_ENUM(NSInteger, ELDeviceTemperatureUnit) { | |||||
| /** ℃ */ | |||||
| ELDeviceTemperatureUnit_C = 0x00 , | |||||
| /** ℉ */ | |||||
| ELDeviceTemperatureUnit_F = 0x01 , | |||||
| /** Unsupported unit */ | |||||
| ELDeviceTemperatureUnit_Fail = 0xFF , | |||||
| }; | |||||
| #define AiLinkBloodUnit_mmHgStr @"mmHg" | |||||
| #define AiLinkBloodUnit_kPaStr @"kPa" | |||||
| #define AiLinkBloodUnitDic @{\ | |||||
| @(ELDeviceBloodPressureUnit_mmhg):AiLinkBloodUnit_mmHgStr,\ | |||||
| @(ELDeviceBloodPressureUnit_kPa):AiLinkBloodUnit_kPaStr\ | |||||
| } | |||||
| /** AiLink Blood pressure unit(血压单位) */ | |||||
| typedef NS_ENUM(NSInteger, ELDeviceBloodPressureUnit) { | |||||
| /** mmhg */ | |||||
| ELDeviceBloodPressureUnit_mmhg = 0x00 , | |||||
| /** kPa */ | |||||
| ELDeviceBloodPressureUnit_kPa , | |||||
| /** Unsupported unit */ | |||||
| ELDeviceBloodPressureUnit_Fail , | |||||
| }; | |||||
| #define AiLinkBlePressureUnit_BarStr @"Bar" | |||||
| #define AiLinkBlePressureUnit_PsiStr @"Psi" | |||||
| #define AiLinkBlePressureUnit_KpaStr @"Kpa" | |||||
| #define AiLinkBlePressureUnitDic @{@(ELDevicePressureUnit_Bar):AiLinkBlePressureUnit_BarStr,@(ELDevicePressureUnit_Psi):AiLinkBlePressureUnit_PsiStr,@(ELDevicePressureUnit_kPa):AiLinkBlePressureUnit_KpaStr} | |||||
| /** AiLink Tire tire pressure unit(轮胎胎压单位) */ | |||||
| typedef NS_ENUM(NSInteger, ELDevicePressureUnit) { | |||||
| /** kPa */ | |||||
| ELDevicePressureUnit_kPa = 0x00 , | |||||
| /** Psi */ | |||||
| ELDevicePressureUnit_Psi = 0x01 , | |||||
| /** Bar */ | |||||
| ELDevicePressureUnit_Bar = 0x02 , | |||||
| /** Unsupported unit */ | |||||
| ELDevicePressureUnit_Fail , | |||||
| }; | |||||
| #pragma mark ============ 枚举 ============== | |||||
| typedef NS_ENUM(NSUInteger, ELBluetoothState) { | |||||
| ELBluetoothStateUnavailable, //Bluetooth is not available(蓝牙不可用) | |||||
| ELBluetoothStateAvailable, //Bluetooth available(蓝牙可用) | |||||
| ELBluetoothStateStopScan, //Stop scanning(停止扫描) | |||||
| ELBluetoothStateScaning, //Scanning(正在扫描) | |||||
| ELBluetoothStateWillConnect, //Will connect(将要连接) | |||||
| ELBluetoothStateDidConnect, //Already connected(已经连接) | |||||
| ELBluetoothStateConnectFail, //Connection error(连接出错) | |||||
| ELBluetoothStateDidDiscoverCharacteristics, //Peripheral feature callback(外设特征回调) | |||||
| ELBluetoothStateDidDisconnect, //Disconnect(断开连接) | |||||
| ELBluetoothStateDidValidationPass, //approved(通过验证) | |||||
| ELBluetoothStateFailedValidation, //Failed verification(未通过验证) | |||||
| }; | |||||
| //sex(性别) | |||||
| typedef NS_ENUM(NSUInteger, ELBluetoothUserSex) { | |||||
| ELBluetoothUserSex_Woman = 0x00,//female(女) | |||||
| ELBluetoothUserSex_Man = 0x01,//male(男) | |||||
| }; | |||||
| #endif /* ELSDKHeader_h */ |
| // | |||||
| // ELThermometerBleManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by 王庭 on 2019/5/28. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELBluetoothManager.h" | |||||
| #import "ELThermometerDeviceModel.h" | |||||
| #import "ELThermometerBleModel.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| typedef NS_ENUM(NSInteger , ThermometerBleDataType) { | |||||
| /**Stable temperature( 稳定温度 )*/ | |||||
| ThermometerBleDataType_StableData = 0x01 , | |||||
| /** Real-time temperature(实时温度) */ | |||||
| ThermometerBleDataType_RealtimeData = 0x02 , | |||||
| /** App release unit settings(app下发单位设置) */ | |||||
| ThermometerBleDataType_AppSendUnit = 0x81 , | |||||
| /** The MCU replies to the setting result(MCU回复设置结果) */ | |||||
| ThermometerBleDataType_BackSendUnit = 0x82 , | |||||
| /** Error code sent on the device(设备上发错误码) */ | |||||
| ThermometerBleDataType_DeviceBackErrorCode = 0xFF , | |||||
| }; | |||||
| typedef NS_ENUM(NSInteger , ThermometerBleResultType) { | |||||
| /** success(设置成功 )*/ | |||||
| ThermometerBleResultType_Succeed = 0x01 , | |||||
| /** failure(设置失败) */ | |||||
| ThermometerBleResultType_Failure , | |||||
| /** unsupport(不支持设置) */ | |||||
| ThermometerBleResultType_Unsupported , | |||||
| }; | |||||
| typedef NS_ENUM(NSInteger , ThermometerBleErrorCode) { | |||||
| /** Hyperthermia(体温过高) */ | |||||
| ThermometerBleErrorCode_Hyperthemia = 0x00 , | |||||
| /** Hypothermia(体温过低 )*/ | |||||
| ThermometerBleErrorCode_Hypothermia , | |||||
| /** error(测量出错) */ | |||||
| ThermometerBleErrorCode_Failure , | |||||
| }; | |||||
| @protocol ELThermometerBleDelegate <NSObject> | |||||
| @optional | |||||
| /** Callback Bluetooth status(回调蓝牙状态) */ | |||||
| - (void)thermometerManagerUpdateState:(ELBluetoothState )state; | |||||
| /** Call back all thermometer devices(回调所有体温计设备) */ | |||||
| - (void)thermometerManagerScanDevices:(NSArray<ELThermometerDeviceModel *> *)thermometerDevices; | |||||
| /** Callback temperature data(回调温度数据) */ | |||||
| - (void)thermometerManagerReceiveModel:(ELThermometerBleModel *)model; | |||||
| /** Return unit setting result(返回单位设置结果) */ | |||||
| - (void)thermometerManagerSetUnitResults:(ThermometerBleResultType )result; | |||||
| /** Error code sent on the device(设备上发错误码)*/ | |||||
| - (void)thermometerManagerBackDeviceErrorCode:(ThermometerBleErrorCode )code; | |||||
| @end | |||||
| @interface ELThermometerBleManager : ELBluetoothManager | |||||
| @property (nonatomic,weak) id<ELThermometerBleDelegate> thermometerDelegate; | |||||
| + (ELThermometerBleManager *)shareManager; | |||||
| /** App release unit settings(app下发单位设置 )*/ | |||||
| - (void)changeThermometerUnit:(ELDeviceTemperatureUnit )unit; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELThermometerBleModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by 王庭 on 2019/5/28. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELSDKHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELThermometerBleModel : NSObject | |||||
| @property (nonatomic,assign) ELDeviceTemperatureUnit unit;//单位 | |||||
| @property (nonatomic,assign) NSUInteger temperature;//温度 | |||||
| @property (nonatomic,assign) BOOL dataType;//Stability flag: 0 real-time data, 1 stable data(稳定标志:0 实时数据,1 稳定数据) | |||||
| @property (nonatomic,copy) NSString *unitStr; | |||||
| @property (nonatomic,assign) NSInteger tempPoint; //小数点偏移位置 | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELThermometerDeviceModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by 王庭 on 2019/5/28. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELPeripheralModel.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELThermometerDeviceModel : ELPeripheralModel | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELUnitChangeTool.h | |||||
| // Elink | |||||
| // | |||||
| // Created by steven wu on 2019/9/21. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELSDKHeader.h" | |||||
| #define StLbSymbol @":" | |||||
| #define FeetSymbol @"′" | |||||
| #define InchSymbol @"″" | |||||
| #define KG_LB_CONST 2.2046226f | |||||
| #define ST_LB_CONST 14.0f | |||||
| #define INCH_CM_CONST 2.54f | |||||
| #define FEET_INCH_CONST 12.0f | |||||
| @interface ELUnitConvertTool : NSObject | |||||
| /** | |||||
| Convert the integer returned by Bluetooth to the character string required for interface display, the display unit is the current user unit | |||||
| @param weightInt AILink protocol integer returned by Bluetooth | |||||
| @param unit kg / lb / st: lb / jin | |||||
| @param point 1,2 | |||||
| @return The weight displayed on the interface, such as 5: 6.5 st: lb | |||||
| 将蓝牙返回的整数,转换为界面显示所需要的字符串,显示单位为当前用户单位 | |||||
| // weightInt AILink协议蓝牙返回的整数 | |||||
| // unit kg/lb/st:lb/jin | |||||
| // point 1,2 | |||||
| // 界面显示的体重,如 5:6.5 st:lb | |||||
| */ | |||||
| + (NSString *)getWeightShowStrWithTargetUnit:(ELDeviceWeightUnit)targetUnit bleWeightInt:(NSUInteger)weightInt bleWeightUnit:(ELDeviceWeightUnit)unit bleWeightPoint:(NSUInteger)point; | |||||
| + (NSString *)getHeightShowStrWithTargetUnit:(ELDeviceHeightUnit)targetUnit origHeightShow:(NSString *)origHeightShow origHeightUnit:(ELDeviceHeightUnit)origHeightUnit origHeightPoint:(NSUInteger)origHeightPoint; | |||||
| /** | |||||
| Display data returned from the server or converted from the original Bluetooth data: such as 5: 6.5, 56.2, etc., converted to kg for drawing or conversion | |||||
| @param weightShow The data read directly from the database, or the AILink protocol Bluetooth returns to the interface 68.56 (kg) 120.6 (lb) | |||||
| @param unit kg / lb / st: lb / jin | |||||
| @param point 1,2 | |||||
| @return is converted to the value of kg (the number of kg used for drawing or conversion, rounded to 2 decimal places) | |||||
| 将服务器返回或者蓝牙原始数据转换来的显示数据:如5:6.5、56.2等数据转换为kg,用来画图或者换算 | |||||
| // weightShow 从数据库中直接读出来的,或者AILink协议蓝牙返给界面的数据 68.56(kg) 120.6(lb) | |||||
| // unit kg/lb/st:lb/jin | |||||
| // point 1,2 | |||||
| // 转换为kg的值(用于绘图或换算的kg数,一律四舍五入保留2位小数) | |||||
| */ | |||||
| + (NSString *)getKgWithWeightShowStr:(NSString *)weightShow weightUnit:(ELDeviceWeightUnit)unit weightPoint:(NSUInteger)point; | |||||
| + (NSString *)getCmWithHeightShowStr:(NSString *)heightShow heightUnit:(ELDeviceHeightUnit)unit heightPoint:(NSUInteger)point; | |||||
| @end | |||||
| // | |||||
| // ELWheelMonitorBleHeader.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/7/4. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #ifndef ELWheelMonitorBleHeader_h | |||||
| #define ELWheelMonitorBleHeader_h | |||||
| #import "ELSDKHeader.h" | |||||
| typedef NS_ENUM(NSUInteger, WheelMonitorBleDataType) { | |||||
| WheelMonitorBleDataTypeMCUSend = 0x01, //MCU upload tire pressure status(MCU 上传胎压状态) | |||||
| WheelMonitorBleDataTypeMCUReceive = 0x02, //MCU returns to tire pressure(MCU 返回胎压状态) | |||||
| WheelMonitorBleDataTypeSetUnit = 0x81, //App release unit settings(app 下发单位设置) | |||||
| WheelMonitorBleDataTypeSetUnitResult = 0x82, //MCU reply unit setting result(MCU 回复单位设置结果) | |||||
| WheelMonitorBleDataTypeSetPressureLimit = 0x84, //MCU reverts to setting the tire pressure threshold(MCU 回复设置胎压阀值) | |||||
| WheelMonitorBleDataTypeSetTempLimit = 0x86, //MCU reply setting temperature threshold and alarm value(MCU 回复设置温度阀值、报警值) | |||||
| WheelMonitorBleDataTypeSetVoice = 0x88 , //MCU reply to set alarm prompt(MCU 回复设置报警提示) | |||||
| }; | |||||
| typedef NS_ENUM(NSUInteger, WheelMonitorWheelType) { | |||||
| WheelMonitorWheelTypeLeftFront = 1, //左前轮 | |||||
| WheelMonitorWheelTypeRightFront = 2, //右前轮 | |||||
| WheelMonitorWheelTypeLeftBack = 3, //左后轮 | |||||
| WheelMonitorWheelTypeRightBack = 4, //右后轮 | |||||
| }; | |||||
| typedef NS_ENUM(NSInteger, WheelMonitorDeviceState) { | |||||
| WheelMonitorDeviceStateNormal = 0x00, //Normal(正常) | |||||
| WheelMonitorDeviceStateAirLeakage = 0x01, //Air Leakage (漏气) | |||||
| WheelMonitorDeviceStateInflatable = 0x02, //Inflatable(充气) | |||||
| WheelMonitorDeviceStateStart = 0x03, //Start(启动) | |||||
| WheelMonitorDeviceStatePowerOn = 0x04, //Power On(上电) | |||||
| WheelMonitorDeviceStateWakeUp = 0x05, //Wake Up(唤醒) | |||||
| WheelMonitorDeviceStateLost = 0x06, //Lost(丢失) | |||||
| }; | |||||
| typedef NS_ENUM(NSUInteger, WheelMonitorGetWheelData) { | |||||
| WheelMonitorGetWheelData_All = 0x00, //全部数据 | |||||
| WheelMonitorGetWheelData_LeftFront = 0x01, //左前轮数据 | |||||
| WheelMonitorGetWheelData_RightFront = 0x02, //右前轮数据 | |||||
| WheelMonitorGetWheelData_LeftBack = 0x03, //左后轮 | |||||
| WheelMonitorGetWheelData_RightBack = 0x04, //右后轮 | |||||
| }; | |||||
| //Get whether the front and rear wheel parameters are set uniformly(获取前后轮参数是否统一设置) | |||||
| typedef NS_ENUM(NSUInteger, WheelMonitorSettingType) { | |||||
| WheelMonitorSettingType_Together = 1, //Set together(一起设置) | |||||
| WheelMonitorSettingType_Separate = 2, //Set separately(分开设定) | |||||
| }; | |||||
| #endif /* ELWheelMonitorBleHeader_h */ |
| // | |||||
| // ELWheelMonitorBleManager.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/7/3. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import "ELBluetoothManager.h" | |||||
| #import "ELWheelMonitorBleHeader.h" | |||||
| #import "ELWheelMonitorBleModel.h" | |||||
| @protocol WheelMonitorBleManagerDelegate <NSObject> | |||||
| @optional | |||||
| /** | |||||
| Callback Bluetooth status(回调蓝牙状态) | |||||
| @param state 蓝牙状态 | |||||
| */ | |||||
| -(void)wheelMonitorBleManagerUpdateBleState:(ELBluetoothState)state; | |||||
| /** | |||||
| Callback scanned device(回调扫描到的设备) | |||||
| @param devices 设备 | |||||
| */ | |||||
| -(void)wheelMonitorBleManagerScanDevices:(NSArray<ELPeripheralModel *> *_Nullable)devices; | |||||
| /** | |||||
| Set unit callback(设置单位回调) | |||||
| @param type 结果 | |||||
| @param settingType 支持类型: | |||||
| WheelMonitorBleDataTypeSetUnitResult | |||||
| WheelMonitorBleDataTypeSetPressureLimit | |||||
| WheelMonitorBleDataTypeSetTempLimit | |||||
| WheelMonitorBleDataTypeSetVoice | |||||
| */ | |||||
| -(void)wheelMonitorBleManagerReceiveSetResult:(ELSetBluetoothResponseType)type settingType:(WheelMonitorBleDataType)settingType; | |||||
| /** | |||||
| Callback tire pressure data(回调胎压数据) | |||||
| @param model 胎压数据模型 | |||||
| */ | |||||
| -(void)wheelMonitorBleManagerWheelMonitorData:(ELWheelMonitorBleModel *_Nonnull)model; | |||||
| /** | |||||
| Get front and rear wheel parameter setting type(获取前后轮参数设置类型) | |||||
| @param type 类型 | |||||
| */ | |||||
| -(void)wheelMonitorBleManagerReceiveSettingType:(WheelMonitorSettingType)type; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELWheelMonitorBleManager : ELBluetoothManager | |||||
| @property (nonatomic, weak) id<WheelMonitorBleManagerDelegate> wheelMonitordelegate; | |||||
| +(instancetype)shareManager; | |||||
| /** | |||||
| Set unit(设置单位) | |||||
| @param pressureUnit 压力单位 | |||||
| @param tempUnit 温度单位 | |||||
| */ | |||||
| -(void)changePressureUnit:(ELDevicePressureUnit)pressureUnit tempUnit:(ELDeviceTemperatureUnit)tempUnit; | |||||
| /** | |||||
| Read tire pressure information(读取胎压信息) | |||||
| @param type 轮胎 | |||||
| */ | |||||
| -(void)getWheelData:(WheelMonitorGetWheelData)type; | |||||
| /** | |||||
| Set tire pressure threshold(设置胎压阀值) | |||||
| @param frontMax 前轮上限阀值 | |||||
| @param frontMin 前轮下限阀值 | |||||
| @param backMax 后轮上限阀值 | |||||
| @param backMin 后轮下限阀值 | |||||
| @param unit 单位 | |||||
| @param point 阀值数值小数点 | |||||
| */ | |||||
| -(void)sendSettingWheelPressureLimitWithFrontMax:(int)frontMax frontMin:(int)frontMin backMax:(int)backMax backMin:(int)backMin pressureUnit:(ELDevicePressureUnit)unit valuePoint:(int)point; | |||||
| /** | |||||
| Set temperature threshold and alarm value(设置温度阀值、报警值) | |||||
| @param tempMax 温度上限阀值 | |||||
| @param tempMin 温度下限阀值(目前用不到,值为 0000) | |||||
| @param unit 温度值单位 | |||||
| @param point 阀值数值小数点 | |||||
| @param open 语音报警:YES:打开,NO:关闭 | |||||
| */ | |||||
| -(void)sendSettingWheelTempLimitWithTempMax:(int16_t)tempMax tempMin:(int16_t)tempMin tempUnit:(ELDeviceTemperatureUnit)unit valuePoint:(int)point openVoice:(BOOL)open; | |||||
| /** | |||||
| Set alarm prompt(设置报警提示) | |||||
| @param open Voice alarm: YES: on, NO: off(语音报警:YES:打开,NO:关闭) | |||||
| */ | |||||
| -(void)sendSettingWheelOpenVoice:(BOOL)open; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ELWheelMonitorBleModel.h | |||||
| // Elink | |||||
| // | |||||
| // Created by iot_user on 2019/7/3. | |||||
| // Copyright © 2019 iot_iMac. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #import "ELWheelMonitorBleHeader.h" | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ELWheelMonitorBleModel : NSObject | |||||
| @property (nonatomic, assign) WheelMonitorWheelType wheelType;//Tire number, 1: front left wheel 2: front right wheel 3: rear left wheel 4: rear right wheel(轮胎编号,1:左前轮 2:右前轮 3:左后轮 4:右后轮) | |||||
| @property (nonatomic, copy) NSString *v;//Actual voltage (unit: V)(实际电压(单位:V)) | |||||
| @property (nonatomic, copy) NSString *p;//pressure(压力) | |||||
| @property (nonatomic, assign) ELDevicePressureUnit pressureUnit; | |||||
| @property (nonatomic, copy) NSString *t;//temperature(温度) | |||||
| @property (nonatomic, assign) ELDeviceTemperatureUnit tempUnit;// | |||||
| @property (nonatomic, assign) WheelMonitorDeviceState state;//状态 | |||||
| @property (nonatomic, assign) NSInteger createTime; | |||||
| /** | |||||
| Analyze tire pressure data(解析胎压数据) | |||||
| @param playload playload | |||||
| @return 数据模型 | |||||
| */ | |||||
| +(ELWheelMonitorBleModel *)analysisWheelMonitorData:(NSData *)playload; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
| <plist version="1.0"> | |||||
| <dict> | |||||
| <key>files</key> | |||||
| <dict> | |||||
| <key>Headers/ELBabyScaleBleHeader.h</key> | |||||
| <data> | |||||
| g7G6A8WA/vvsdi0F844f28aSSXo= | |||||
| </data> | |||||
| <key>Headers/ELBabyScaleBleHeightModel.h</key> | |||||
| <data> | |||||
| eoRBRUYRuUN6TPaU0r6KkdNgJyE= | |||||
| </data> | |||||
| <key>Headers/ELBabyScaleBleManager.h</key> | |||||
| <data> | |||||
| J6c1MDjvS95sK0HOdRSWo8VYj+o= | |||||
| </data> | |||||
| <key>Headers/ELBabyScaleBleWeightModel.h</key> | |||||
| <data> | |||||
| +XHoAFklse3pcB92l6nle0vbk+o= | |||||
| </data> | |||||
| <key>Headers/ELBabyScaleDeviceModel.h</key> | |||||
| <data> | |||||
| OvZQw4fYrptuR1uSrpNxOlSyms0= | |||||
| </data> | |||||
| <key>Headers/ELBlePublicTool.h</key> | |||||
| <data> | |||||
| JUlukzH3vjpTzoXduB2VQIAyTJI= | |||||
| </data> | |||||
| <key>Headers/ELBleWifiDetailModel.h</key> | |||||
| <data> | |||||
| tamPhBn4G67QTURIBneQDHggOaY= | |||||
| </data> | |||||
| <key>Headers/ELBloodBleDataModel.h</key> | |||||
| <data> | |||||
| DpRqeBN9ZsF9qYH3I3sP2RuP2WQ= | |||||
| </data> | |||||
| <key>Headers/ELBloodBleManager.h</key> | |||||
| <data> | |||||
| DqRpRvzW1aR+Uhl0Bir4WcjwG9Y= | |||||
| </data> | |||||
| <key>Headers/ELBloodBleSDKHeader.h</key> | |||||
| <data> | |||||
| N2ScrY3zUXS4vLeY/b3xtcPA5J8= | |||||
| </data> | |||||
| <key>Headers/ELBluetoothManager.h</key> | |||||
| <data> | |||||
| q3LVBfQJJqGw0AR8h6q3nC+Nlgw= | |||||
| </data> | |||||
| <key>Headers/ELBodyFatScaleBleHeader.h</key> | |||||
| <data> | |||||
| 0b9mGDuee7WiIQE4CW0ADfbEL1s= | |||||
| </data> | |||||
| <key>Headers/ELBodyFatScaleBleManager.h</key> | |||||
| <data> | |||||
| k+OxOANxEznDe5jW76CiJ9hdU7k= | |||||
| </data> | |||||
| <key>Headers/ELBodyFatScaleBleUserModel.h</key> | |||||
| <data> | |||||
| MBQ6uNFIQp9eH5QYseXEn9u8XSs= | |||||
| </data> | |||||
| <key>Headers/ELBodyFatScaleBleWeightModel.h</key> | |||||
| <data> | |||||
| ACYbuCI3GXFXuNHirYhKf1nx9Jk= | |||||
| </data> | |||||
| <key>Headers/ELBodyFatScaleDeviceModel.h</key> | |||||
| <data> | |||||
| wzOhRUInZ0tuoj3LHMmJV1XejoY= | |||||
| </data> | |||||
| <key>Headers/ELForeHeadBleManager.h</key> | |||||
| <data> | |||||
| PGM6FQ7DALcjdFVRIe5TI/8HAjM= | |||||
| </data> | |||||
| <key>Headers/ELForeheadBleDataModel.h</key> | |||||
| <data> | |||||
| 5pOOuuEZPUiCO8mC+8RieX0ZktE= | |||||
| </data> | |||||
| <key>Headers/ELForeheadHeader.h</key> | |||||
| <data> | |||||
| 3LS8MObWrVCjLnaKWwoUKBaqc34= | |||||
| </data> | |||||
| <key>Headers/ELHeightGaugeBleDataModel.h</key> | |||||
| <data> | |||||
| B+jv5YT79HhyGg7UL0jGn0SAvdg= | |||||
| </data> | |||||
| <key>Headers/ELHeightGaugeBleManager.h</key> | |||||
| <data> | |||||
| fI+CN9ThacjPbLrkT67I1KEp7do= | |||||
| </data> | |||||
| <key>Headers/ELHeightGaugeHeader.h</key> | |||||
| <data> | |||||
| ame1lW5x3LyjrTa2tD/aBjA8Cfw= | |||||
| </data> | |||||
| <key>Headers/ELPeripheralModel.h</key> | |||||
| <data> | |||||
| ibVmqneQ5mPsyjCTT8qkT1PXy9w= | |||||
| </data> | |||||
| <key>Headers/ELRemoteControlBleHeader.h</key> | |||||
| <data> | |||||
| aiNkkJtSvIT1yQxcICSDLRbP4j0= | |||||
| </data> | |||||
| <key>Headers/ELRemoteControlBleManager.h</key> | |||||
| <data> | |||||
| zuhb0JmsWk+ScnpB7P4E34IU1r8= | |||||
| </data> | |||||
| <key>Headers/ELRemoteControlDeviceModel.h</key> | |||||
| <data> | |||||
| ckFgMSGZyOJnzl2Kxs0FPR96pn4= | |||||
| </data> | |||||
| <key>Headers/ELSDKHeader.h</key> | |||||
| <data> | |||||
| iRAPDeauG3rYOdp0JoDPzK6Ozhc= | |||||
| </data> | |||||
| <key>Headers/ELThermometerBleManager.h</key> | |||||
| <data> | |||||
| /o/ZHXV/7Avopz38NRDtUATN7Ak= | |||||
| </data> | |||||
| <key>Headers/ELThermometerBleModel.h</key> | |||||
| <data> | |||||
| gfcdH3dOdDIjBaU0lbhAsuqSDQU= | |||||
| </data> | |||||
| <key>Headers/ELThermometerDeviceModel.h</key> | |||||
| <data> | |||||
| Oa8GTYS1hEhJk+BQL1IiR2T3eSw= | |||||
| </data> | |||||
| <key>Headers/ELUnitConvertTool.h</key> | |||||
| <data> | |||||
| KUvTJzAj6UgO0TVIag6jroPEZ9g= | |||||
| </data> | |||||
| <key>Headers/ELWheelMonitorBleHeader.h</key> | |||||
| <data> | |||||
| IKCvB9SN0bht+QzbqywX+LIO45A= | |||||
| </data> | |||||
| <key>Headers/ELWheelMonitorBleManager.h</key> | |||||
| <data> | |||||
| E86BRjWkC4g+n/X86i53afpC5pI= | |||||
| </data> | |||||
| <key>Headers/ELWheelMonitorBleModel.h</key> | |||||
| <data> | |||||
| 33QcqrJFFbKEYqLTPl0GvIq3/4c= | |||||
| </data> | |||||
| <key>Info.plist</key> | |||||
| <data> | |||||
| 7GRWEyAnXxjLbVEdHfMEXqK3VO0= | |||||
| </data> | |||||
| </dict> | |||||
| <key>files2</key> | |||||
| <dict> | |||||
| <key>Headers/ELBabyScaleBleHeader.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| g7G6A8WA/vvsdi0F844f28aSSXo= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| JzZihsx0frCLjAQHwuezNCUYdFlgQNvs37cFhVnZ9Cc= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBabyScaleBleHeightModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| eoRBRUYRuUN6TPaU0r6KkdNgJyE= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| h1sk9fTlb1WTfx/adOgj+Kcg1QnSAqrw9CZ29x9+RsM= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBabyScaleBleManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| J6c1MDjvS95sK0HOdRSWo8VYj+o= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| pIQTGSmxrY0vKeLBz0vZVwVYeaNsnSU7i44UhErmGl8= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBabyScaleBleWeightModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| +XHoAFklse3pcB92l6nle0vbk+o= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| ucVO/T2eZbfDm4CKfRNz7UmOXc+sZ/iPVapGZr1dzbo= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBabyScaleDeviceModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| OvZQw4fYrptuR1uSrpNxOlSyms0= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| w2jBr/fZ98z7Umjq/fr4QA1RAJ0FD5EB/QzCdF/BQjo= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBlePublicTool.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| JUlukzH3vjpTzoXduB2VQIAyTJI= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| NsQTTlAs1Jf6T3Yh6zBZU/sBAwDX974Cc23kkrvwHxo= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBleWifiDetailModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| tamPhBn4G67QTURIBneQDHggOaY= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| xfyapBE5STjDisWWQRyG7EFZXeM/zEUkTcuKbCZztug= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBloodBleDataModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| DpRqeBN9ZsF9qYH3I3sP2RuP2WQ= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| MQxwbR+wSqYSadxV6Wy7ODXlaFYZDwSs8J15eSLT3BI= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBloodBleManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| DqRpRvzW1aR+Uhl0Bir4WcjwG9Y= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| gEVr8x9+ssQPT/NdA0zVhw1jHhbYbAy2sSxZ9Rus02I= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBloodBleSDKHeader.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| N2ScrY3zUXS4vLeY/b3xtcPA5J8= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| DJIEwcPb2L+C8PWkXoK8ChDmrREy1z4j+KIPlU/Pxv8= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBluetoothManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| q3LVBfQJJqGw0AR8h6q3nC+Nlgw= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| 5VoTwBUB4Lq2im9bqd73754D6HCo53vW6XoX6EioHXw= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBodyFatScaleBleHeader.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| 0b9mGDuee7WiIQE4CW0ADfbEL1s= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| 2py6JfIiYKS46qwDo7/27T0rqmu7YbHa+fqUBdvhth0= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBodyFatScaleBleManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| k+OxOANxEznDe5jW76CiJ9hdU7k= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| v1HPAh30uLZy9KqJxyWSvifOrjCBTDPNRYKsM/kDPw4= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBodyFatScaleBleUserModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| MBQ6uNFIQp9eH5QYseXEn9u8XSs= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| EhqjKgLFWoipLPU+hDqAOmsB8L3eapoVCS+dq4P+f8g= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBodyFatScaleBleWeightModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| ACYbuCI3GXFXuNHirYhKf1nx9Jk= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| MJq+xb+X8LJ7f1ynJoK0wMQHkQ845EDay2JyAHuMN/E= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELBodyFatScaleDeviceModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| wzOhRUInZ0tuoj3LHMmJV1XejoY= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| ZP6cxgBFbWaQx/NIDxVVSWHwIu4JcVyIgQFhDh/6WO0= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELForeHeadBleManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| PGM6FQ7DALcjdFVRIe5TI/8HAjM= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| fPQqdIxqDufGCTCTrgQ+ZUZAPxIvk7sTuvSgH+3A2CQ= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELForeheadBleDataModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| 5pOOuuEZPUiCO8mC+8RieX0ZktE= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| OT0VXqsUYZUY7X+MRujUaoJEDRFRUoaeIOwn2ZeVlpU= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELForeheadHeader.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| 3LS8MObWrVCjLnaKWwoUKBaqc34= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| S4+2M5mPrWRGaOZPU2ZBnh0I3EC8Xsw160okYl9SdKU= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELHeightGaugeBleDataModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| B+jv5YT79HhyGg7UL0jGn0SAvdg= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| LTE74gs3V3TrNvclF3YfurebOuZ/6SGGdbunw0bZKxk= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELHeightGaugeBleManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| fI+CN9ThacjPbLrkT67I1KEp7do= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| DC+5AXDTzQwo3qk4gZsG2XUZGcnJEbh5+uGEqYMEFk8= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELHeightGaugeHeader.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| ame1lW5x3LyjrTa2tD/aBjA8Cfw= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| cGlFpjbfDm88HxwGHZsIk5PD17XWUnkyEUNeaM8BALk= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELPeripheralModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| ibVmqneQ5mPsyjCTT8qkT1PXy9w= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| 1kPE7LNXG51xcfDIuG0pi0iM5tWGqj3rUPDJhLoyaBg= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELRemoteControlBleHeader.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| aiNkkJtSvIT1yQxcICSDLRbP4j0= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| kHJsJM71CmIbvMKh6ltED65HzWa0OFUsgV/xHpnKWLE= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELRemoteControlBleManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| zuhb0JmsWk+ScnpB7P4E34IU1r8= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| Eh9arZbJEreN/PCu301E65iPDLM3c0/Bi1maaCc41b0= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELRemoteControlDeviceModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| ckFgMSGZyOJnzl2Kxs0FPR96pn4= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| L/ievm90HlYaSADq8DO3GkT7wk9nFYrQKcHf0Xq+X9g= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELSDKHeader.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| iRAPDeauG3rYOdp0JoDPzK6Ozhc= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| uUXMgU5uOmIE0Ng8ZTZiiam+Cy5TOvMxThDSAhOmRoY= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELThermometerBleManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| /o/ZHXV/7Avopz38NRDtUATN7Ak= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| hwwcRlEBfaVTWb8fTirt6y+tSfC0ZBEe/6sqDTu0Nx4= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELThermometerBleModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| gfcdH3dOdDIjBaU0lbhAsuqSDQU= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| ay1fe+kwQGlcxg6zWWv0Z9h+hZdIiWcqkXaWmfHUfKQ= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELThermometerDeviceModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| Oa8GTYS1hEhJk+BQL1IiR2T3eSw= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| gSjca3FLXifg5U5v47xNQpOf4dgQ0ib6CwitQPp1Hbs= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELUnitConvertTool.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| KUvTJzAj6UgO0TVIag6jroPEZ9g= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| m9kGIMT+Hyb5vxlcF8hsbi4cmg8IWW0u1d690GOSIqA= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELWheelMonitorBleHeader.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| IKCvB9SN0bht+QzbqywX+LIO45A= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| qQ9uS8FPSSjcilXKMf/6E1rO+WYq8/TkezeJGdGarWk= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELWheelMonitorBleManager.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| E86BRjWkC4g+n/X86i53afpC5pI= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| XeP8EN2/J69v1/z0O1P8dd2R+DM/sP4lz2ALZhKwB0Y= | |||||
| </data> | |||||
| </dict> | |||||
| <key>Headers/ELWheelMonitorBleModel.h</key> | |||||
| <dict> | |||||
| <key>hash</key> | |||||
| <data> | |||||
| 33QcqrJFFbKEYqLTPl0GvIq3/4c= | |||||
| </data> | |||||
| <key>hash2</key> | |||||
| <data> | |||||
| 3x0+7c3+zhAdZCb2nagaiXYx5O2P124ki7PJrSqjxUI= | |||||
| </data> | |||||
| </dict> | |||||
| </dict> | |||||
| <key>rules</key> | |||||
| <dict> | |||||
| <key>^.*</key> | |||||
| <true/> | |||||
| <key>^.*\.lproj/</key> | |||||
| <dict> | |||||
| <key>optional</key> | |||||
| <true/> | |||||
| <key>weight</key> | |||||
| <real>1000</real> | |||||
| </dict> | |||||
| <key>^.*\.lproj/locversion.plist$</key> | |||||
| <dict> | |||||
| <key>omit</key> | |||||
| <true/> | |||||
| <key>weight</key> | |||||
| <real>1100</real> | |||||
| </dict> | |||||
| <key>^Base\.lproj/</key> | |||||
| <dict> | |||||
| <key>weight</key> | |||||
| <real>1010</real> | |||||
| </dict> | |||||
| <key>^version.plist$</key> | |||||
| <true/> | |||||
| </dict> | |||||
| <key>rules2</key> | |||||
| <dict> | |||||
| <key>.*\.dSYM($|/)</key> | |||||
| <dict> | |||||
| <key>weight</key> | |||||
| <real>11</real> | |||||
| </dict> | |||||
| <key>^(.*/)?\.DS_Store$</key> | |||||
| <dict> | |||||
| <key>omit</key> | |||||
| <true/> | |||||
| <key>weight</key> | |||||
| <real>2000</real> | |||||
| </dict> | |||||
| <key>^.*</key> | |||||
| <true/> | |||||
| <key>^.*\.lproj/</key> | |||||
| <dict> | |||||
| <key>optional</key> | |||||
| <true/> | |||||
| <key>weight</key> | |||||
| <real>1000</real> | |||||
| </dict> | |||||
| <key>^.*\.lproj/locversion.plist$</key> | |||||
| <dict> | |||||
| <key>omit</key> | |||||
| <true/> | |||||
| <key>weight</key> | |||||
| <real>1100</real> | |||||
| </dict> | |||||
| <key>^Base\.lproj/</key> | |||||
| <dict> | |||||
| <key>weight</key> | |||||
| <real>1010</real> | |||||
| </dict> | |||||
| <key>^Info\.plist$</key> | |||||
| <dict> | |||||
| <key>omit</key> | |||||
| <true/> | |||||
| <key>weight</key> | |||||
| <real>20</real> | |||||
| </dict> | |||||
| <key>^PkgInfo$</key> | |||||
| <dict> | |||||
| <key>omit</key> | |||||
| <true/> | |||||
| <key>weight</key> | |||||
| <real>20</real> | |||||
| </dict> | |||||
| <key>^embedded\.provisionprofile$</key> | |||||
| <dict> | |||||
| <key>weight</key> | |||||
| <real>20</real> | |||||
| </dict> | |||||
| <key>^version\.plist$</key> | |||||
| <dict> | |||||
| <key>weight</key> | |||||
| <real>20</real> | |||||
| </dict> | |||||
| </dict> | |||||
| </dict> | |||||
| </plist> |
| // | |||||
| // AiLinkSuperViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface AiLinkSuperViewController : UIViewController | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // AiLinkSuperViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "AiLinkSuperViewController.h" | |||||
| #import <AILinkBleSDK/ELBluetoothManager.h> | |||||
| #import "Masonry.h" | |||||
| #import "AilinkSuperConnectViewController.h" | |||||
| @interface AiLinkSuperViewController ()<UITableViewDelegate,UITableViewDataSource,ELBluetoothManagerDelegate> | |||||
| @property (nonatomic, strong) UITableView *tableView; | |||||
| @property (nonatomic, strong) NSArray<ELPeripheralModel *> *devices; | |||||
| @end | |||||
| @implementation AiLinkSuperViewController | |||||
| //-(NSMutableArray *)devices{ | |||||
| // if (_devices == nil) { | |||||
| // _devices = [[NSMutableArray alloc] init]; | |||||
| // } | |||||
| // return _devices; | |||||
| //} | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| // self.title = @"Devices"; | |||||
| [self.view addSubview:self.tableView]; | |||||
| [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.top.left.right.bottom.mas_equalTo(0); | |||||
| }]; | |||||
| } | |||||
| -(void)viewWillAppear:(BOOL)animated{ | |||||
| [super viewWillAppear:animated]; | |||||
| [[ELBluetoothManager shareManager] startScan]; | |||||
| [ELBluetoothManager shareManager].delegate = self; | |||||
| } | |||||
| -(void)viewDidDisappear:(BOOL)animated{ | |||||
| [super viewDidDisappear:animated]; | |||||
| [[ELBluetoothManager shareManager] stopScan]; | |||||
| } | |||||
| #pragma mark ============ ELBluetoothManagerDelegate ============== | |||||
| -(void)bluetoothManagerUpdateBleState:(ELBluetoothState)state{ | |||||
| NSLog(@"bluetoothManagerUpdateBleState = %ld",state); | |||||
| } | |||||
| -(void)bluetoothManagerScanedPeripherals:(NSArray<ELPeripheralModel *> *)peripherals{ | |||||
| self.devices = peripherals; | |||||
| [self.tableView reloadData]; | |||||
| } | |||||
| -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | |||||
| return self.devices.count; | |||||
| } | |||||
| -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| return 60; | |||||
| } | |||||
| -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| static NSString *cellId = @"cellid"; | |||||
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; | |||||
| if (!cell) { | |||||
| cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; | |||||
| } | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| cell.textLabel.text = [NSString stringWithFormat:@"Name:%@---Mac:%@\nCID:%ld---VID:%ld---PID:%ld",p.deviceName,p.macAddress,p.deviceType,p.vendorID,p.productID]; | |||||
| cell.textLabel.numberOfLines = 2; | |||||
| cell.textLabel.textColor = [UIColor blackColor]; | |||||
| return cell; | |||||
| } | |||||
| -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| AilinkSuperConnectViewController *vc = [[AilinkSuperConnectViewController alloc] init]; | |||||
| vc.p = p; | |||||
| [self.navigationController pushViewController:vc animated:YES]; | |||||
| } | |||||
| -(UITableView *)tableView{ | |||||
| if (_tableView == nil) { | |||||
| _tableView = [[UITableView alloc] init]; | |||||
| _tableView.delegate = self; | |||||
| _tableView.dataSource = self; | |||||
| } | |||||
| return _tableView; | |||||
| } | |||||
| @end |
| // | |||||
| // AilinkSuperConnectViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| @class ELPeripheralModel; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface AilinkSuperConnectViewController : UIViewController | |||||
| @property (nonatomic, strong) ELPeripheralModel *p; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // AilinkSuperConnectViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "AilinkSuperConnectViewController.h" | |||||
| #import <AILinkBleSDK/ELBluetoothManager.h> | |||||
| #import "Masonry.h" | |||||
| @interface AilinkSuperConnectViewController ()<ELBluetoothManagerDelegate> | |||||
| @property (nonatomic, strong) UITextView *textView; | |||||
| @end | |||||
| @implementation AilinkSuperConnectViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| self.view.backgroundColor = [UIColor whiteColor]; | |||||
| [ELBluetoothManager shareManager].delegate = self; | |||||
| [[ELBluetoothManager shareManager] connectPeripheral:self.p]; | |||||
| [self setupUIView]; | |||||
| } | |||||
| -(void)viewWillDisappear:(BOOL)animated{ | |||||
| [super viewWillDisappear:animated]; | |||||
| [[ELBluetoothManager shareManager] disconnectPeripheral]; | |||||
| } | |||||
| -(void)addLog:(NSString *)log{ | |||||
| self.textView.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView.text]; | |||||
| } | |||||
| -(void)buttonAction:(UIButton *)sender{ | |||||
| if ([ELBluetoothManager shareManager].state != ELBluetoothStateDidValidationPass) { | |||||
| [self addLog:@"Disconnected"]; | |||||
| return; | |||||
| } | |||||
| [self addLog:sender.titleLabel.text]; | |||||
| NSInteger tag = sender.tag; | |||||
| if (tag == 1) { | |||||
| //getBluetoothInfoWithELInetGetCmdType是获取设备信息的方法 | |||||
| [[ELBluetoothManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)]; | |||||
| }else if (tag == 2){ | |||||
| [[ELBluetoothManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetC_V_P_ID)]; | |||||
| }else if (tag == 3){ | |||||
| [[ELBluetoothManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetName)]; | |||||
| }else if (tag == 4){ | |||||
| [[ELBluetoothManager shareManager] setBluetoothName:@"AILink"]; | |||||
| }else if (tag == 5){ | |||||
| //MARK:发送透传数据 | |||||
| Byte b[5] = {0x0A,0x00,0x01,0x02,0xA0}; | |||||
| NSData *data = [[NSData alloc] initWithBytes:b length:5]; | |||||
| [self addLog:data.description]; | |||||
| [[ELBluetoothManager shareManager] sendData:data]; | |||||
| } | |||||
| } | |||||
| -(void)setupUIView{ | |||||
| UIButton *button1 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button1 setTitle:@"Get BM Version" forState:(UIControlStateNormal)]; | |||||
| button1.tag = 1; | |||||
| button1.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button1.titleLabel.numberOfLines = 2; | |||||
| button1.backgroundColor = [UIColor blackColor]; | |||||
| [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button1]; | |||||
| [button1 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button2 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button2 setTitle:@"Get C V P ID" forState:(UIControlStateNormal)]; | |||||
| button2.tag = 2; | |||||
| button2.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button2.titleLabel.numberOfLines = 2; | |||||
| button2.backgroundColor = [UIColor blackColor]; | |||||
| [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button2]; | |||||
| [button2 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button1.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button3 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button3 setTitle:@"Get Name" forState:(UIControlStateNormal)]; | |||||
| button3.tag = 3; | |||||
| button3.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button3.titleLabel.numberOfLines = 2; | |||||
| button3.backgroundColor = [UIColor blackColor]; | |||||
| [button3 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button3]; | |||||
| [button3 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button2.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button4 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button4 setTitle:@"Set Name" forState:(UIControlStateNormal)]; | |||||
| button4.tag = 4; | |||||
| button4.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button4.titleLabel.numberOfLines = 2; | |||||
| button4.backgroundColor = [UIColor blackColor]; | |||||
| [button4 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button4]; | |||||
| [button4 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button5 setTitle:@"Send Data" forState:(UIControlStateNormal)]; | |||||
| button5.tag = 5; | |||||
| button5.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button5.titleLabel.numberOfLines = 2; | |||||
| button5.backgroundColor = [UIColor blackColor]; | |||||
| [button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button5]; | |||||
| [button5 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button4.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| self.textView = [[UITextView alloc] init]; | |||||
| self.textView.backgroundColor = [UIColor blackColor]; | |||||
| self.textView.text = @"Log"; | |||||
| self.textView.textColor = [UIColor redColor]; | |||||
| [self.view addSubview:self.textView]; | |||||
| [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.right.bottom.mas_equalTo(-10); | |||||
| make.height.mas_equalTo(200); | |||||
| }]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{ | |||||
| if (type == ELInetSetCmdTypeSetName) { | |||||
| if (result == ELSetBluetoothResponseTypeSuccess) { | |||||
| [self addLog:@"Set name Success "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeFailure){ | |||||
| [self addLog:@"Set name failure "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeNoSupport){ | |||||
| [self addLog:@"Set name unsupport "]; | |||||
| } | |||||
| } | |||||
| } | |||||
| -(void)bluetoothManagerReceiceName:(NSString *)name{ | |||||
| [self addLog:name]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did{ | |||||
| [self addLog:[NSString stringWithFormat:@"CID = %d,VID = %d,PID = %d",did.deviceType,did.vendorID,did.productID]]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{ | |||||
| [self addLog:bmVersion]; | |||||
| } | |||||
| //MARK:接收透传数据(不符合AILink协议的数据,需要做透传的客户可在此根据自己的协议解析数据,透传数据不可以"A6"或"A7"开头) | |||||
| -(void)bluetoothManagerReceivePassData:(NSData *)data{ | |||||
| NSLog(@"bluetoothManagerReceivePassData = %@",data.description); | |||||
| [self addLog:[NSString stringWithFormat:@"Penetrate:%@",data.description]]; | |||||
| } | |||||
| //MARK:获取设备支持的单位 | |||||
| -(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{ | |||||
| //这里要压力和温度单位 | |||||
| //设置单位时,要设置设备支持的单位 | |||||
| } | |||||
| -(void)bluetoothManagerUpdateBleState:(ELBluetoothState)state{ | |||||
| switch (state) { | |||||
| case ELBluetoothStateUnavailable: | |||||
| { | |||||
| self.title = @"Please open the bluetooth"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateAvailable: | |||||
| { | |||||
| self.title = @"Bluetooth is open"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateScaning: | |||||
| { | |||||
| self.title = @"Scaning"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateConnectFail: | |||||
| { | |||||
| self.title = @"Connect fail"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidDisconnect: | |||||
| { | |||||
| self.title = @"Disconnected"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidValidationPass: | |||||
| { | |||||
| self.title = @"Connected"; | |||||
| [[ELBluetoothManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)]; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateFailedValidation: | |||||
| { | |||||
| self.title = @"Illegal equipment"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateWillConnect: | |||||
| self.title = @"Connecting"; | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| -(void)dealloc{ | |||||
| } | |||||
| @end |
| // | |||||
| // AppDelegate.h | |||||
| // AILinkBleSDKDemo | |||||
| // | |||||
| // Created by iot_user on 2020/4/9. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| @interface AppDelegate : UIResponder <UIApplicationDelegate> | |||||
| @end | |||||
| // | |||||
| // AppDelegate.m | |||||
| // AILinkBleSDKDemo | |||||
| // | |||||
| // Created by iot_user on 2020/4/9. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "AppDelegate.h" | |||||
| #import <AILinkBleSDK/ELBluetoothManager.h> | |||||
| @interface AppDelegate () | |||||
| @end | |||||
| @implementation AppDelegate | |||||
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |||||
| // Override point for customization after application launch. | |||||
| [ELBluetoothManager setAppKey:@"df97ca735924fff0" appSecret:@"00912bb4e6b4a0c1363618b3f8"]; | |||||
| return YES; | |||||
| } | |||||
| #pragma mark - UISceneSession lifecycle | |||||
| - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { | |||||
| // Called when a new scene session is being created. | |||||
| // Use this method to select a configuration to create the new scene with. | |||||
| return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; | |||||
| } | |||||
| - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions { | |||||
| // Called when the user discards a scene session. | |||||
| // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. | |||||
| // Use this method to release any resources that were specific to the discarded scenes, as they will not return. | |||||
| } | |||||
| @end |
| { | |||||
| "images" : [ | |||||
| { | |||||
| "idiom" : "iphone", | |||||
| "size" : "20x20", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "iphone", | |||||
| "size" : "20x20", | |||||
| "scale" : "3x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "iphone", | |||||
| "size" : "29x29", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "iphone", | |||||
| "size" : "29x29", | |||||
| "scale" : "3x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "iphone", | |||||
| "size" : "40x40", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "iphone", | |||||
| "size" : "40x40", | |||||
| "scale" : "3x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "iphone", | |||||
| "size" : "60x60", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "iphone", | |||||
| "size" : "60x60", | |||||
| "scale" : "3x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "20x20", | |||||
| "scale" : "1x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "20x20", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "29x29", | |||||
| "scale" : "1x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "29x29", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "40x40", | |||||
| "scale" : "1x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "40x40", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "76x76", | |||||
| "scale" : "1x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "76x76", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ipad", | |||||
| "size" : "83.5x83.5", | |||||
| "scale" : "2x" | |||||
| }, | |||||
| { | |||||
| "idiom" : "ios-marketing", | |||||
| "size" : "1024x1024", | |||||
| "scale" : "1x" | |||||
| } | |||||
| ], | |||||
| "info" : { | |||||
| "version" : 1, | |||||
| "author" : "xcode" | |||||
| } | |||||
| } |
| { | |||||
| "info" : { | |||||
| "version" : 1, | |||||
| "author" : "xcode" | |||||
| } | |||||
| } |
| // | |||||
| // BabyScaleConnectViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| @class ELPeripheralModel; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface BabyScaleConnectViewController : UIViewController | |||||
| @property (nonatomic, strong) ELPeripheralModel *p; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // BabyScaleConnectViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "BabyScaleConnectViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELBabyScaleBleManager.h> | |||||
| @interface BabyScaleConnectViewController ()<ELBluetoothManagerDelegate,BabyScaleBleDelegate> | |||||
| @property (nonatomic, strong) UITextView *textView; | |||||
| @end | |||||
| @implementation BabyScaleConnectViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| self.view.backgroundColor = [UIColor whiteColor]; | |||||
| [ELBabyScaleBleManager shareManager].babyScaleDelegate = self; | |||||
| [ELBabyScaleBleManager shareManager].delegate =self; | |||||
| [[ELBabyScaleBleManager shareManager] connectPeripheral:self.p]; | |||||
| [self setupUIView]; | |||||
| } | |||||
| -(void)viewWillDisappear:(BOOL)animated{ | |||||
| [super viewWillDisappear:animated]; | |||||
| [[ELBabyScaleBleManager shareManager] disconnectPeripheral]; | |||||
| } | |||||
| -(void)addLog:(NSString *)log{ | |||||
| self.textView.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView.text]; | |||||
| } | |||||
| -(void)buttonAction:(UIButton *)sender{ | |||||
| if ([ELBabyScaleBleManager shareManager].state != ELBluetoothStateDidValidationPass) { | |||||
| [self addLog:@"Disconnected"]; | |||||
| return; | |||||
| } | |||||
| [self addLog:sender.titleLabel.text]; | |||||
| NSInteger tag = sender.tag; | |||||
| if (tag == 1) { | |||||
| //getBluetoothInfoWithELInetGetCmdType是获取设备信息的方法 | |||||
| [[ELBabyScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)]; | |||||
| }else if (tag == 2){ | |||||
| [[ELBabyScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetC_V_P_ID)]; | |||||
| }else if (tag == 3){ | |||||
| [[ELBabyScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetName)]; | |||||
| }else if (tag == 4){ | |||||
| [[ELBabyScaleBleManager shareManager] setBluetoothName:@"AILink"]; | |||||
| }else if (tag == 5){ | |||||
| [[ELBabyScaleBleManager shareManager] changeHold:YES]; | |||||
| }else if (tag == 6){ | |||||
| [[ELBabyScaleBleManager shareManager] changeHold:NO]; | |||||
| }else if (tag == 7){ | |||||
| [[ELBabyScaleBleManager shareManager] changeHeightUnit:(ELDeviceHeightUnit_CM) AndWeightUnit:(ELDeviceWeightUnit_KG)]; | |||||
| } | |||||
| } | |||||
| -(void)setupUIView{ | |||||
| UIButton *button1 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button1 setTitle:@"Get BM Version" forState:(UIControlStateNormal)]; | |||||
| button1.tag = 1; | |||||
| button1.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button1.titleLabel.numberOfLines = 2; | |||||
| button1.backgroundColor = [UIColor blackColor]; | |||||
| [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button1]; | |||||
| [button1 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button2 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button2 setTitle:@"Get C V P ID" forState:(UIControlStateNormal)]; | |||||
| button2.tag = 2; | |||||
| button2.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button2.titleLabel.numberOfLines = 2; | |||||
| button2.backgroundColor = [UIColor blackColor]; | |||||
| [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button2]; | |||||
| [button2 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button1.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button3 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button3 setTitle:@"Get Name" forState:(UIControlStateNormal)]; | |||||
| button3.tag = 3; | |||||
| button3.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button3.titleLabel.numberOfLines = 2; | |||||
| button3.backgroundColor = [UIColor blackColor]; | |||||
| [button3 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button3]; | |||||
| [button3 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button2.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button4 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button4 setTitle:@"Set Name" forState:(UIControlStateNormal)]; | |||||
| button4.tag = 4; | |||||
| button4.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button4.titleLabel.numberOfLines = 2; | |||||
| button4.backgroundColor = [UIColor blackColor]; | |||||
| [button4 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button4]; | |||||
| [button4 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button5 setTitle:@"Hold" forState:(UIControlStateNormal)]; | |||||
| button5.tag = 5; | |||||
| button5.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button5.titleLabel.numberOfLines = 2; | |||||
| button5.backgroundColor = [UIColor blackColor]; | |||||
| [button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button5]; | |||||
| [button5 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button4.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| // | |||||
| UIButton *button6 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button6 setTitle:@"Zero" forState:(UIControlStateNormal)]; | |||||
| button6.tag = 6; | |||||
| button6.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button6.titleLabel.numberOfLines = 2; | |||||
| button6.backgroundColor = [UIColor blackColor]; | |||||
| [button6 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button6]; | |||||
| [button6 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button5.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button7 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button7 setTitle:@"Change Unit" forState:(UIControlStateNormal)]; | |||||
| button7.tag = 7; | |||||
| button7.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button7.titleLabel.numberOfLines = 2; | |||||
| button7.backgroundColor = [UIColor blackColor]; | |||||
| [button7 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button7]; | |||||
| [button7 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button4.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| self.textView = [[UITextView alloc] init]; | |||||
| self.textView.backgroundColor = [UIColor blackColor]; | |||||
| self.textView.text = @"Log"; | |||||
| self.textView.textColor = [UIColor redColor]; | |||||
| [self.view addSubview:self.textView]; | |||||
| [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.right.bottom.mas_equalTo(-10); | |||||
| make.height.mas_equalTo(200); | |||||
| }]; | |||||
| } | |||||
| //错误 | |||||
| -(void)babyScaleBackDeviceErrorCode:(BabyScaleDeviceErrorCode)code{ | |||||
| [self addLog:[NSString stringWithFormat:@"error code = %ld",code]]; | |||||
| } | |||||
| //体重 | |||||
| -(void)babyScaleManagerReceiveWeightModel:(ELBabyScaleBleWeightModel *)model{ | |||||
| [self addLog:[NSString stringWithFormat:@"weight = %ld unit=%@ point = %ld",model.weight,model.unitStr,model.weightPoint]]; | |||||
| } | |||||
| //身长数据 | |||||
| -(void)babyScaleManagerHeightModel:(ELBabyScaleBleHeightModel *)model{ | |||||
| [self addLog:[NSString stringWithFormat:@"height = %ld unit=%@ point = %ld",model.height,model.unitStr,model.heightPoint]]; | |||||
| } | |||||
| -(void)babyScaleBackCtrlType:(NSInteger)type Results:(BabyScaleResultType)result{ | |||||
| // 0去皮,1锁定) | |||||
| if (type == 0) { | |||||
| if (result == BabyScaleResultType_Succeed) { | |||||
| [self addLog:@"Zero Unit success"]; | |||||
| }else if (result == BabyScaleResultType_Failure){ | |||||
| [self addLog:@"Zero Unit failure"]; | |||||
| }else if (result == BabyScaleResultType_Unsupported){ | |||||
| [self addLog:@"Zero Unit unsupported"]; | |||||
| } | |||||
| }else{ | |||||
| if (result == BabyScaleResultType_Succeed) { | |||||
| [self addLog:@"Hold Unit success"]; | |||||
| }else if (result == BabyScaleResultType_Failure){ | |||||
| [self addLog:@"Hold Unit failure"]; | |||||
| }else if (result == BabyScaleResultType_Unsupported){ | |||||
| [self addLog:@"Hold Unit unsupported"]; | |||||
| } | |||||
| } | |||||
| } | |||||
| -(void)babyScaleBackSetUnitResults:(BabyScaleResultType)result{ | |||||
| if (result == BabyScaleResultType_Succeed) { | |||||
| [self addLog:@"Change Unit success"]; | |||||
| }else if (result == BabyScaleResultType_Failure){ | |||||
| [self addLog:@"Change Unit failure"]; | |||||
| }else if (result == BabyScaleResultType_Unsupported){ | |||||
| [self addLog:@"Change Unit unsupported"]; | |||||
| } | |||||
| } | |||||
| -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{ | |||||
| if (type == ELInetSetCmdTypeSetName) { | |||||
| if (result == ELSetBluetoothResponseTypeSuccess) { | |||||
| [self addLog:@"Set name Success "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeFailure){ | |||||
| [self addLog:@"Set name failure "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeNoSupport){ | |||||
| [self addLog:@"Set name unsupport "]; | |||||
| } | |||||
| } | |||||
| } | |||||
| -(void)bluetoothManagerReceiceName:(NSString *)name{ | |||||
| [self addLog:name]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did{ | |||||
| [self addLog:[NSString stringWithFormat:@"CID = %d,VID = %d,PID = %d",did.deviceType,did.vendorID,did.productID]]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{ | |||||
| [self addLog:bmVersion]; | |||||
| } | |||||
| //MARK:获取设备支持的单位 | |||||
| -(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{ | |||||
| //这里体重和身高单位 | |||||
| //设置单位时,要设置设备支持的单位 | |||||
| } | |||||
| -(void)babyScaleManagerUpdateState:(ELBluetoothState)state{ | |||||
| switch (state) { | |||||
| case ELBluetoothStateUnavailable: | |||||
| { | |||||
| self.title = @"Please open the bluetooth"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateAvailable: | |||||
| { | |||||
| self.title = @"Bluetooth is open"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateScaning: | |||||
| { | |||||
| self.title = @"Scaning"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateConnectFail: | |||||
| { | |||||
| self.title = @"Connect fail"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidDisconnect: | |||||
| { | |||||
| self.title = @"Disconnected"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidValidationPass: | |||||
| { | |||||
| self.title = @"Connected"; | |||||
| [[ELBabyScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)]; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateFailedValidation: | |||||
| { | |||||
| self.title = @"Illegal equipment"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateWillConnect: | |||||
| self.title = @"Connecting"; | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| -(void)dealloc{ | |||||
| } | |||||
| @end |
| // | |||||
| // BabyScaleViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface BabyScaleViewController : UIViewController | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // BabyScaleViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "BabyScaleViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELBabyScaleBleManager.h> | |||||
| #import "BabyScaleConnectViewController.h" | |||||
| @interface BabyScaleViewController ()<UITableViewDelegate,UITableViewDataSource,BabyScaleBleDelegate> | |||||
| @property (nonatomic, strong) UITableView *tableView; | |||||
| @property (nonatomic, strong) NSArray<ELPeripheralModel *> *devices; | |||||
| @end | |||||
| @implementation BabyScaleViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| // self.title = @"Devices"; | |||||
| [self.view addSubview:self.tableView]; | |||||
| [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.top.left.right.bottom.mas_equalTo(0); | |||||
| }]; | |||||
| } | |||||
| -(void)viewWillAppear:(BOOL)animated{ | |||||
| [super viewWillAppear:animated]; | |||||
| [[ELBabyScaleBleManager shareManager] startScan]; | |||||
| [ELBabyScaleBleManager shareManager].babyScaleDelegate = self; | |||||
| } | |||||
| -(void)viewDidDisappear:(BOOL)animated{ | |||||
| [super viewDidDisappear:animated]; | |||||
| [[ELBabyScaleBleManager shareManager] stopScan]; | |||||
| } | |||||
| #pragma mark ============ ELBluetoothManagerDelegate ============== | |||||
| -(void)babyScaleManagerUpdateState:(ELBluetoothState)state{ | |||||
| NSLog(@"bluetoothManagerUpdateBleState = %ld",state); | |||||
| } | |||||
| -(void)babyScaleManagerScanDevices:(NSArray<ELBabyScaleDeviceModel *> *)babyScaleDevices{ | |||||
| self.devices = babyScaleDevices; | |||||
| [self.tableView reloadData]; | |||||
| } | |||||
| -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | |||||
| return self.devices.count; | |||||
| } | |||||
| -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| return 60; | |||||
| } | |||||
| -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| static NSString *cellId = @"cellid"; | |||||
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; | |||||
| if (!cell) { | |||||
| cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; | |||||
| } | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| cell.textLabel.text = [NSString stringWithFormat:@"Name:%@---Mac:%@\nCID:%ld---VID:%ld---PID:%ld",p.deviceName,p.macAddress,p.deviceType,p.vendorID,p.productID]; | |||||
| cell.textLabel.numberOfLines = 2; | |||||
| cell.textLabel.textColor = [UIColor blackColor]; | |||||
| return cell; | |||||
| } | |||||
| -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| BabyScaleConnectViewController *vc = [[BabyScaleConnectViewController alloc] init]; | |||||
| vc.p = p; | |||||
| [self.navigationController pushViewController:vc animated:YES]; | |||||
| } | |||||
| -(UITableView *)tableView{ | |||||
| if (_tableView == nil) { | |||||
| _tableView = [[UITableView alloc] init]; | |||||
| _tableView.delegate = self; | |||||
| _tableView.dataSource = self; | |||||
| } | |||||
| return _tableView; | |||||
| } | |||||
| @end |
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||||
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | |||||
| <dependencies> | |||||
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> | |||||
| <capability name="Safe area layout guides" minToolsVersion="9.0"/> | |||||
| <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | |||||
| </dependencies> | |||||
| <scenes> | |||||
| <!--View Controller--> | |||||
| <scene sceneID="EHf-IW-A2E"> | |||||
| <objects> | |||||
| <viewController id="01J-lp-oVM" sceneMemberID="viewController"> | |||||
| <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | |||||
| <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | |||||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | |||||
| <color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | |||||
| <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | |||||
| </view> | |||||
| </viewController> | |||||
| <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | |||||
| </objects> | |||||
| <point key="canvasLocation" x="53" y="375"/> | |||||
| </scene> | |||||
| </scenes> | |||||
| </document> |
| // | |||||
| // BloodConnectViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| @class ELPeripheralModel; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface BloodConnectViewController : UIViewController | |||||
| @property (nonatomic, strong) ELPeripheralModel *p; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // BloodConnectViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "BloodConnectViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELBloodBleManager.h> | |||||
| @interface BloodConnectViewController ()<ELBluetoothManagerDelegate,ELBloodBleManagerDelegate> | |||||
| @property (nonatomic, strong) UITextView *textView; | |||||
| @end | |||||
| @implementation BloodConnectViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| self.view.backgroundColor = [UIColor whiteColor]; | |||||
| [ELBloodBleManager shareManager].bloodDelegate = self; | |||||
| [ELBloodBleManager shareManager].delegate =self; | |||||
| [[ELBloodBleManager shareManager] connectPeripheral:self.p]; | |||||
| [self setupUIView]; | |||||
| } | |||||
| -(void)viewWillDisappear:(BOOL)animated{ | |||||
| [super viewWillDisappear:animated]; | |||||
| [[ELBloodBleManager shareManager] disconnectPeripheral]; | |||||
| } | |||||
| -(void)addLog:(NSString *)log{ | |||||
| self.textView.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView.text]; | |||||
| } | |||||
| -(void)buttonAction:(UIButton *)sender{ | |||||
| if ([ELBloodBleManager shareManager].state != ELBluetoothStateDidValidationPass) { | |||||
| [self addLog:@"Disconnected"]; | |||||
| return; | |||||
| } | |||||
| [self addLog:sender.titleLabel.text]; | |||||
| NSInteger tag = sender.tag; | |||||
| if (tag == 1) { | |||||
| //getBluetoothInfoWithELInetGetCmdType是获取设备信息的方法 | |||||
| [[ELBloodBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)]; | |||||
| }else if (tag == 2){ | |||||
| [[ELBloodBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetC_V_P_ID)]; | |||||
| }else if (tag == 3){ | |||||
| [[ELBloodBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetName)]; | |||||
| }else if (tag == 4){ | |||||
| [[ELBloodBleManager shareManager] setBluetoothName:@"AILink"]; | |||||
| }else if (tag == 5){ | |||||
| [[ELBloodBleManager shareManager] sendInteractiveInstructions:(ELBloodInteractionTypeStartTest)]; | |||||
| }else if (tag == 6){ | |||||
| [[ELBloodBleManager shareManager] sendInteractiveInstructions:(ELBloodInteractionTypeStopTest)]; | |||||
| }else if (tag == 7){ | |||||
| [[ELBloodBleManager shareManager] changeUnit:(ELDeviceBloodPressureUnit_mmhg)]; | |||||
| }else if (tag == 8){ | |||||
| [[ELBloodBleManager shareManager] sendSwitchVoice:(ELBloodBleSwitchVoiceTypeOff)]; | |||||
| }else if (tag == 9){ | |||||
| [[ELBloodBleManager shareManager] sendSwitchVoice:(ELBloodBleSwitchVoiceTypeOn)]; | |||||
| } | |||||
| } | |||||
| -(void)setupUIView{ | |||||
| UIButton *button1 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button1 setTitle:@"Get BM Version" forState:(UIControlStateNormal)]; | |||||
| button1.tag = 1; | |||||
| button1.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button1.titleLabel.numberOfLines = 2; | |||||
| button1.backgroundColor = [UIColor blackColor]; | |||||
| [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button1]; | |||||
| [button1 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button2 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button2 setTitle:@"Get C V P ID" forState:(UIControlStateNormal)]; | |||||
| button2.tag = 2; | |||||
| button2.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button2.titleLabel.numberOfLines = 2; | |||||
| button2.backgroundColor = [UIColor blackColor]; | |||||
| [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button2]; | |||||
| [button2 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button1.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button3 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button3 setTitle:@"Get Name" forState:(UIControlStateNormal)]; | |||||
| button3.tag = 3; | |||||
| button3.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button3.titleLabel.numberOfLines = 2; | |||||
| button3.backgroundColor = [UIColor blackColor]; | |||||
| [button3 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button3]; | |||||
| [button3 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button2.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button4 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button4 setTitle:@"Set Name" forState:(UIControlStateNormal)]; | |||||
| button4.tag = 4; | |||||
| button4.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button4.titleLabel.numberOfLines = 2; | |||||
| button4.backgroundColor = [UIColor blackColor]; | |||||
| [button4 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button4]; | |||||
| [button4 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button5 setTitle:@"Start Test" forState:(UIControlStateNormal)]; | |||||
| button5.tag = 5; | |||||
| button5.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button5.titleLabel.numberOfLines = 2; | |||||
| button5.backgroundColor = [UIColor blackColor]; | |||||
| [button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button5]; | |||||
| [button5 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button4.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| // | |||||
| UIButton *button6 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button6 setTitle:@"Stop Test" forState:(UIControlStateNormal)]; | |||||
| button6.tag = 6; | |||||
| button6.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button6.titleLabel.numberOfLines = 2; | |||||
| button6.backgroundColor = [UIColor blackColor]; | |||||
| [button6 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button6]; | |||||
| [button6 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button5.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button7 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button7 setTitle:@"Change Unit" forState:(UIControlStateNormal)]; | |||||
| button7.tag = 7; | |||||
| button7.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button7.titleLabel.numberOfLines = 2; | |||||
| button7.backgroundColor = [UIColor blackColor]; | |||||
| [button7 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button7]; | |||||
| [button7 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button4.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button8 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button8 setTitle:@"Close Voice" forState:(UIControlStateNormal)]; | |||||
| button8.tag = 8; | |||||
| button8.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button8.titleLabel.numberOfLines = 2; | |||||
| button8.backgroundColor = [UIColor blackColor]; | |||||
| [button8 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button8]; | |||||
| [button8 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button4.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button9 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button9 setTitle:@"Open Voice" forState:(UIControlStateNormal)]; | |||||
| button9.tag = 9; | |||||
| button9.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button9.titleLabel.numberOfLines = 2; | |||||
| button9.backgroundColor = [UIColor blackColor]; | |||||
| [button9 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button9]; | |||||
| [button9 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button8.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button4.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| self.textView = [[UITextView alloc] init]; | |||||
| self.textView.backgroundColor = [UIColor blackColor]; | |||||
| self.textView.text = @"Log"; | |||||
| self.textView.textColor = [UIColor redColor]; | |||||
| [self.view addSubview:self.textView]; | |||||
| [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.right.bottom.mas_equalTo(-10); | |||||
| make.height.mas_equalTo(200); | |||||
| }]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{ | |||||
| if (type == ELInetSetCmdTypeSetName) { | |||||
| if (result == ELSetBluetoothResponseTypeSuccess) { | |||||
| [self addLog:@"Set name Success "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeFailure){ | |||||
| [self addLog:@"Set name failure "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeNoSupport){ | |||||
| [self addLog:@"Set name unsupport "]; | |||||
| } | |||||
| } | |||||
| } | |||||
| -(void)bluetoothManagerReceiceName:(NSString *)name{ | |||||
| [self addLog:name]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did{ | |||||
| [self addLog:[NSString stringWithFormat:@"CID = %d,VID = %d,PID = %d",did.deviceType,did.vendorID,did.productID]]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{ | |||||
| [self addLog:bmVersion]; | |||||
| } | |||||
| //MARK:获取设备支持的单位 | |||||
| -(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{ | |||||
| //这里要血压单位 | |||||
| //设置单位时,要设置设备支持的单位 | |||||
| } | |||||
| -(void)bloodBleManagerReceiceTestData:(ELBloodBleDataModel *)model type:(ELBloodBleDataModelType)type{ | |||||
| [self addLog:[NSString stringWithFormat:@"dia = %@--sys=%@ unit = %ld point = %ld",model.dia,model.sys,AiLinkBloodUnitDic[@(model.unit)],model.point]]; | |||||
| } | |||||
| -(void)bloodBleManagerReceiveSetSwitchVoiceOperationType:(ELBloodBleSwitchVoiceType)type result:(ELSetBluetoothResponseType)result{ | |||||
| if (type == ELBloodBleSwitchVoiceTypeOff) { | |||||
| [self addLog:[NSString stringWithFormat:@"close voice result = %ld",result]]; | |||||
| }else{ | |||||
| [self addLog:[NSString stringWithFormat:@"open voice result = %ld",result]]; | |||||
| } | |||||
| } | |||||
| -(void)bloodBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type{ | |||||
| [self addLog:[NSString stringWithFormat:@"change unit result = %ld",type]]; | |||||
| } | |||||
| -(void)bloodBleManagerReceiveFailCode:(ELBloodFailCode)code{ | |||||
| [self addLog:[NSString stringWithFormat:@"error code = %ld",code]]; | |||||
| } | |||||
| -(void)bloodBleManagerUpdateBleState:(ELBluetoothState)state{ | |||||
| switch (state) { | |||||
| case ELBluetoothStateUnavailable: | |||||
| { | |||||
| self.title = @"Please open the bluetooth"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateAvailable: | |||||
| { | |||||
| self.title = @"Bluetooth is open"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateScaning: | |||||
| { | |||||
| self.title = @"Scaning"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateConnectFail: | |||||
| { | |||||
| self.title = @"Connect fail"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidDisconnect: | |||||
| { | |||||
| self.title = @"Disconnected"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidValidationPass: | |||||
| { | |||||
| self.title = @"Connected"; | |||||
| [[ELBloodBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)]; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateFailedValidation: | |||||
| { | |||||
| self.title = @"Illegal equipment"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateWillConnect: | |||||
| self.title = @"Connecting"; | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| -(void)dealloc{ | |||||
| } | |||||
| @end |
| // | |||||
| // BloodScanViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface BloodScanViewController : UIViewController | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // BloodScanViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "BloodScanViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELBloodBleManager.h> | |||||
| #import "BloodConnectViewController.h" | |||||
| @interface BloodScanViewController ()<UITableViewDelegate,UITableViewDataSource,ELBloodBleManagerDelegate> | |||||
| @property (nonatomic, strong) UITableView *tableView; | |||||
| @property (nonatomic, strong) NSArray<ELPeripheralModel *> *devices; | |||||
| @end | |||||
| @implementation BloodScanViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| // self.title = @"Devices"; | |||||
| [self.view addSubview:self.tableView]; | |||||
| [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.top.left.right.bottom.mas_equalTo(0); | |||||
| }]; | |||||
| } | |||||
| -(void)viewWillAppear:(BOOL)animated{ | |||||
| [super viewWillAppear:animated]; | |||||
| [[ELBloodBleManager shareManager] startScan]; | |||||
| [ELBloodBleManager shareManager].bloodDelegate = self; | |||||
| } | |||||
| -(void)viewDidDisappear:(BOOL)animated{ | |||||
| [super viewDidDisappear:animated]; | |||||
| [[ELBloodBleManager shareManager] stopScan]; | |||||
| } | |||||
| #pragma mark ============ ELBluetoothManagerDelegate ============== | |||||
| -(void)bloodBleManagerUpdateBleState:(ELBluetoothState)state{ | |||||
| NSLog(@"bluetoothManagerUpdateBleState = %ld",state); | |||||
| } | |||||
| -(void)bloodBleManagerScanDevices:(NSArray<ELPeripheralModel *> *)devices{ | |||||
| self.devices = devices; | |||||
| [self.tableView reloadData]; | |||||
| } | |||||
| -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | |||||
| return self.devices.count; | |||||
| } | |||||
| -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| return 60; | |||||
| } | |||||
| -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| static NSString *cellId = @"cellid"; | |||||
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; | |||||
| if (!cell) { | |||||
| cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; | |||||
| } | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| cell.textLabel.text = [NSString stringWithFormat:@"Name:%@---Mac:%@\nCID:%ld---VID:%ld---PID:%ld",p.deviceName,p.macAddress,p.deviceType,p.vendorID,p.productID]; | |||||
| cell.textLabel.numberOfLines = 2; | |||||
| cell.textLabel.textColor = [UIColor blackColor]; | |||||
| return cell; | |||||
| } | |||||
| -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| BloodConnectViewController *vc = [[BloodConnectViewController alloc] init]; | |||||
| vc.p = p; | |||||
| [self.navigationController pushViewController:vc animated:YES]; | |||||
| } | |||||
| -(UITableView *)tableView{ | |||||
| if (_tableView == nil) { | |||||
| _tableView = [[UITableView alloc] init]; | |||||
| _tableView.delegate = self; | |||||
| _tableView.dataSource = self; | |||||
| } | |||||
| return _tableView; | |||||
| } | |||||
| @end |
| // | |||||
| // BodyFatScaleConnectViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| @class ELPeripheralModel; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface BodyFatScaleConnectViewController : UIViewController | |||||
| @property (nonatomic, strong) ELPeripheralModel *p; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // BodyFatScaleConnectViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "BodyFatScaleConnectViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELBodyFatScaleBleManager.h> | |||||
| #import <AILinkBleSDK/ELBodyFatScaleBleUserModel.h> | |||||
| #import <AILinkBleSDK/ELBodyFatScaleBleWeightModel.h> | |||||
| #import "WiFiSetupViewController.h" | |||||
| @interface BodyFatScaleConnectViewController ()<ELBluetoothManagerDelegate,ELBodyFatScaleBleDelegate,ElBleWifiDelegate> | |||||
| @property (nonatomic, strong) UITextView *textView; | |||||
| @property (nonatomic, copy) NSArray<NSNumber *> *units; | |||||
| @end | |||||
| @implementation BodyFatScaleConnectViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| self.view.backgroundColor = [UIColor whiteColor]; | |||||
| [ELBodyFatScaleBleManager shareManager].bodyFatScaleDelegate = self; | |||||
| [ELBodyFatScaleBleManager shareManager].delegate =self; | |||||
| [[ELBodyFatScaleBleManager shareManager] connectPeripheral:self.p]; | |||||
| [ELBodyFatScaleBleManager shareManager].bleWifiDelegate = self; | |||||
| [self setupUIView]; | |||||
| } | |||||
| -(void)viewWillDisappear:(BOOL)animated{ | |||||
| [super viewWillDisappear:animated]; | |||||
| [[ELBodyFatScaleBleManager shareManager] disconnectPeripheral]; | |||||
| } | |||||
| -(void)addLog:(NSString *)log{ | |||||
| self.textView.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView.text]; | |||||
| } | |||||
| -(void)buttonAction:(UIButton *)sender{ | |||||
| if ([ELBodyFatScaleBleManager shareManager].state != ELBluetoothStateDidValidationPass) { | |||||
| [self addLog:@"Disconnected"]; | |||||
| return; | |||||
| } | |||||
| [self addLog:sender.titleLabel.text]; | |||||
| NSInteger tag = sender.tag; | |||||
| if (tag == 1) { | |||||
| //getBluetoothInfoWithELInetGetCmdType是获取设备信息的方法 | |||||
| [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)]; | |||||
| }else if (tag == 2){ | |||||
| [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetC_V_P_ID)]; | |||||
| }else if (tag == 3){ | |||||
| [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetName)]; | |||||
| }else if (tag == 4){ | |||||
| [[ELBodyFatScaleBleManager shareManager] setBluetoothName:@"AILink"]; | |||||
| }else if (tag == 5){ | |||||
| if (self.units.count==0) { | |||||
| [self addLog:@"No units obtained"]; | |||||
| return; | |||||
| } | |||||
| // [[ELBodyFatScaleBleManager shareManager] changeBodyFatScaleUnit:(ELDeviceWeightUnit_KG)]; | |||||
| UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Change Unit" message:@"" preferredStyle:(UIAlertControllerStyleAlert)]; | |||||
| for (int i=0; i<self.units.count; i++) { | |||||
| UIAlertAction *action = [UIAlertAction actionWithTitle:AiLinkBleWeightUnitDic[self.units[i]] style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) { | |||||
| [[ELBodyFatScaleBleManager shareManager] changeBodyFatScaleUnit:self.units[i].integerValue]; | |||||
| }]; | |||||
| [alert addAction:action]; | |||||
| } | |||||
| [self presentViewController:alert animated:YES completion:nil]; | |||||
| }else if (tag == 6){ | |||||
| }else if (tag == 7){ | |||||
| }else if (tag == 8){ | |||||
| }else if (tag == 9){ | |||||
| } | |||||
| } | |||||
| -(void)setupUIView{ | |||||
| UIButton *button1 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button1 setTitle:@"Get BM Version" forState:(UIControlStateNormal)]; | |||||
| button1.tag = 1; | |||||
| button1.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button1.titleLabel.numberOfLines = 2; | |||||
| button1.backgroundColor = [UIColor blackColor]; | |||||
| [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button1]; | |||||
| [button1 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button2 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button2 setTitle:@"Get C V P ID" forState:(UIControlStateNormal)]; | |||||
| button2.tag = 2; | |||||
| button2.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button2.titleLabel.numberOfLines = 2; | |||||
| button2.backgroundColor = [UIColor blackColor]; | |||||
| [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button2]; | |||||
| [button2 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button1.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button3 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button3 setTitle:@"Get Name" forState:(UIControlStateNormal)]; | |||||
| button3.tag = 3; | |||||
| button3.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button3.titleLabel.numberOfLines = 2; | |||||
| button3.backgroundColor = [UIColor blackColor]; | |||||
| [button3 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button3]; | |||||
| [button3 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button2.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button4 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button4 setTitle:@"Set Name" forState:(UIControlStateNormal)]; | |||||
| button4.tag = 4; | |||||
| button4.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button4.titleLabel.numberOfLines = 2; | |||||
| button4.backgroundColor = [UIColor blackColor]; | |||||
| [button4 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button4]; | |||||
| [button4 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button5 setTitle:@"Change unit" forState:(UIControlStateNormal)]; | |||||
| button5.tag = 5; | |||||
| button5.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button5.titleLabel.numberOfLines = 2; | |||||
| button5.backgroundColor = [UIColor blackColor]; | |||||
| [button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button5]; | |||||
| [button5 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button4.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| // | |||||
| // UIButton *button6 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| // [button6 setTitle:@"" forState:(UIControlStateNormal)]; | |||||
| // button6.tag = 6; | |||||
| // button6.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| // button6.titleLabel.numberOfLines = 2; | |||||
| // button6.backgroundColor = [UIColor blackColor]; | |||||
| // [button6 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| // [self.view addSubview:button6]; | |||||
| // [button6 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| // make.left.equalTo(button5.mas_right).mas_offset(10); | |||||
| // make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| // make.width.mas_equalTo(100); | |||||
| // make.height.mas_equalTo(40); | |||||
| // }]; | |||||
| // // | |||||
| // UIButton *button7 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| // [button7 setTitle:@"" forState:(UIControlStateNormal)]; | |||||
| // button7.tag = 7; | |||||
| // button7.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| // button7.titleLabel.numberOfLines = 2; | |||||
| // button7.backgroundColor = [UIColor blackColor]; | |||||
| // [button7 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| // [self.view addSubview:button7]; | |||||
| // [button7 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| // make.left.mas_equalTo(10); | |||||
| // make.top.equalTo(button4.mas_bottom).mas_offset(10); | |||||
| // make.width.mas_equalTo(100); | |||||
| // make.height.mas_equalTo(40); | |||||
| // }]; | |||||
| // | |||||
| // UIButton *button8 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| // [button8 setTitle:@"" forState:(UIControlStateNormal)]; | |||||
| // button8.tag = 8; | |||||
| // button8.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| // button8.titleLabel.numberOfLines = 2; | |||||
| // button8.backgroundColor = [UIColor blackColor]; | |||||
| // [button8 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| // [self.view addSubview:button8]; | |||||
| // [button8 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| // make.left.equalTo(button7.mas_right).mas_offset(10); | |||||
| // make.top.equalTo(button4.mas_bottom).mas_offset(10); | |||||
| // make.width.mas_equalTo(100); | |||||
| // make.height.mas_equalTo(40); | |||||
| // }]; | |||||
| // | |||||
| // UIButton *button9 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| // [button9 setTitle:@"" forState:(UIControlStateNormal)]; | |||||
| // button9.tag = 9; | |||||
| // button9.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| // button9.titleLabel.numberOfLines = 2; | |||||
| // button9.backgroundColor = [UIColor blackColor]; | |||||
| // [button9 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| // [self.view addSubview:button9]; | |||||
| // [button9 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| // make.left.equalTo(button8.mas_right).mas_offset(10); | |||||
| // make.top.equalTo(button4.mas_bottom).mas_offset(10); | |||||
| // make.width.mas_equalTo(100); | |||||
| // make.height.mas_equalTo(40); | |||||
| // }]; | |||||
| // | |||||
| self.textView = [[UITextView alloc] init]; | |||||
| self.textView.backgroundColor = [UIColor blackColor]; | |||||
| self.textView.text = @"Log"; | |||||
| self.textView.textColor = [UIColor redColor]; | |||||
| [self.view addSubview:self.textView]; | |||||
| [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.right.bottom.mas_equalTo(-10); | |||||
| make.height.mas_equalTo(200); | |||||
| }]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{ | |||||
| if (type == ELInetSetCmdTypeSetName) { | |||||
| if (result == ELSetBluetoothResponseTypeSuccess) { | |||||
| [self addLog:@"Set name Success "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeFailure){ | |||||
| [self addLog:@"Set name failure "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeNoSupport){ | |||||
| [self addLog:@"Set name unsupport "]; | |||||
| } | |||||
| } | |||||
| } | |||||
| -(void)bluetoothManagerReceiceName:(NSString *)name{ | |||||
| [self addLog:name]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did{ | |||||
| [self addLog:[NSString stringWithFormat:@"CID = %d,VID = %d,PID = %d",did.deviceType,did.vendorID,did.productID]]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{ | |||||
| [self addLog:bmVersion]; | |||||
| } | |||||
| -(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{ | |||||
| //这里只要体重数据 | |||||
| self.units = weightArray; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveMCUConnectedState:(struct ELMCUStateStruct)stateStrct{ | |||||
| BleWiFiConnectState wifiState = stateStrct.wifiState; | |||||
| if (self.p.deviceType == ELSupportDeviceTypeBLE_WIFIScale) { | |||||
| //蓝牙WiFi体脂秤 | |||||
| //请求会话码 | |||||
| [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:ELInetGetCmdTypeBleWifiGetSNNumber]; | |||||
| //MARK:1.WiFi配置提示用户配网 | |||||
| //TODO:注意:wifi配置过程必须保持蓝牙与设备的连接 | |||||
| if (wifiState == BleWiFiConnectStateNoWiFi) { | |||||
| //1.如果没有配网,则提示用户去配网 | |||||
| //MARK:2.WiFi配置先获取wifi列表 | |||||
| // | |||||
| [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:ELInetGetCmdTypeBleWifiGetNearbyWifi]; | |||||
| // | |||||
| // UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Change Unit" message:@"" preferredStyle:(UIAlertControllerStyleAlert)]; | |||||
| // UIAlertAction *action = [UIAlertAction actionWithTitle:@"去配网" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) { | |||||
| // if ([ELBodyFatScaleBleManager shareManager].state == ELBluetoothStateDidValidationPass) { | |||||
| // WiFiSetupViewController *vc = [[WiFiSetupViewController alloc] init]; | |||||
| // [self.navigationController pushViewController:vc animated:YES]; | |||||
| // }else{ | |||||
| // [self addLog:@"Disconnected"]; | |||||
| // } | |||||
| // | |||||
| // }]; | |||||
| // UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) { | |||||
| // | |||||
| // }]; | |||||
| // [alert addAction:action]; | |||||
| // [alert addAction:action2]; | |||||
| // [self presentViewController:alert animated:YES completion:nil]; | |||||
| } | |||||
| } | |||||
| ///MARK:9.wifi配置结果 | |||||
| //wifi相关的其他指令和数据接收,请查看ELBluetoothManager.h文件 | |||||
| if (stateStrct.wifiState == BleWiFiConnectStateSuccess) { | |||||
| //成功 | |||||
| //MARK:10.获取wifi设备的SN号,即设备id | |||||
| [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeBleWifiGetSNNumber)]; | |||||
| }else{ | |||||
| //失败 | |||||
| } | |||||
| } | |||||
| /** | |||||
| Callback to set unit result(回调设置单位结果) | |||||
| @param result 结果 | |||||
| */ | |||||
| - (void)bodyFatScaleManagerCallBackSetUnitResult:(ELSetBluetoothResponseType)result{ | |||||
| switch (result) { | |||||
| case ELSetBluetoothResponseTypeSuccess: | |||||
| { | |||||
| [self addLog:@"Change Unit Success"]; | |||||
| } | |||||
| break; | |||||
| case ELSetBluetoothResponseTypeFailure: | |||||
| { | |||||
| [self addLog:@"Change Unit Failure"]; | |||||
| } | |||||
| break; | |||||
| case ELSetBluetoothResponseTypeNoSupport: | |||||
| { | |||||
| [self addLog:@"Unsupport Change Unit"]; | |||||
| } | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| //MARK:回调Wifi列表 | |||||
| -(void)bleWifiReceiveWifiDetailModel:(ELBleWifiDetailModel *)model{ | |||||
| // MARK:3.WiFi配置得到Wifi列表 | |||||
| //用一个tableview显示喽 | |||||
| [self addLog:[NSString stringWithFormat:@"wifi类型---%lu 名称---%@",(unsigned long)model.wifiState,model.wifiName]]; | |||||
| } | |||||
| -(void)bleWifiReceiveScanedWifiCount:(int)count { | |||||
| //MARK:扫描Wifi结束 | |||||
| //MARK:4.WiFi配置得到一个附近wifi的列表,点击选择一个wifi,进行配置 | |||||
| //MARK:5.输入wifi密码 | |||||
| //写个“textfield”输入密码 | |||||
| //MARK:6.先发送配置wifi的mac地址的指令 | |||||
| // [[ELBodyFatScaleBleManager shareManager] bleWifiSetConnectWifiMac:[NSData data]]; | |||||
| } | |||||
| -(void)bleWifiReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{ | |||||
| [self addLog:[NSString stringWithFormat:@"bleWifiReceiceResponseType==%lu----%lu",type,result]]; | |||||
| if (result == ELSetBluetoothResponseTypeSuccess) { | |||||
| //设置WiFi结果 | |||||
| if (type == ELInetSetCmdTypeBleWifiSetWifiMac) { | |||||
| //MARK:7.再发送配置wifi的密码的指令 | |||||
| [[ELBodyFatScaleBleManager shareManager] bleWifiSetWifiPwd:@"WiFi密码"]; | |||||
| }else if (type == ELInetSetCmdTypeBleWifiSetWifiPwd){ | |||||
| //MARK:8.然后发起连接Wifi | |||||
| [[ELBodyFatScaleBleManager shareManager] bleWifiSetupWifiConnect:YES]; | |||||
| }else if (type == ELInetSetCmdTypeBleWifiSetConnectWifi){ | |||||
| //获取连接状态 | |||||
| } | |||||
| } | |||||
| else{ | |||||
| //TODO:Wifi配置过程中失败的情况自行处理 | |||||
| } | |||||
| } | |||||
| /** | |||||
| MCU requests user information( MCU 请求用户信息) | |||||
| @param status 请求状态 | |||||
| */ | |||||
| - (void)bodyFatScaleManagerMCURequestAppUserInfoType:(BodyFatScaleMCURequestUserInfoStatus)status{ | |||||
| if (status == BodyFatScaleMCURequestUserInfoStatus_Get) { | |||||
| //下发当前用户给秤 | |||||
| [[ELBodyFatScaleBleManager shareManager] sendCurrentUserToBle:[self getOneUser]]; | |||||
| }else if (status == BodyFatScaleMCURequestUserInfoStatus_Success){ | |||||
| [self addLog:@"MCU requests user information success"]; | |||||
| }else if (BodyFatScaleMCURequestUserInfoStatus_Fail){ | |||||
| [self addLog:@"MCU requests user information failure"]; | |||||
| } | |||||
| } | |||||
| /** | |||||
| Return weight and body fat model(返回重量及体脂model) | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackWeight:(ELBodyFatScaleBleWeightModel *)weightModel state:(BodyFatScaleMeasureStatus)status{ | |||||
| switch (status) { | |||||
| case BodyFatScaleMeasureStatus_Unstable: | |||||
| { | |||||
| [self addLog:[NSString stringWithFormat:@"Unstable data weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleMeasureStatus_Stable: | |||||
| { | |||||
| [self addLog:[NSString stringWithFormat:@"Stable data weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleMeasureStatus_Failed: | |||||
| { | |||||
| [self addLog:@"Test failure"]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleMeasureStatus_Complete: | |||||
| { | |||||
| [self addLog:[NSString stringWithFormat:@"Tested weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; | |||||
| //更新用户信息给秤 | |||||
| [[ELBodyFatScaleBleManager shareManager] sendCurrentUserToBle:[self getOneUser]]; | |||||
| //下发用户列表 | |||||
| [[ELBodyFatScaleBleManager shareManager] sendOfflineUserListToBle:[self get8Users]]; | |||||
| } | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| /** | |||||
| Return temperature (unit: ° C)(返回温度(单位:°C)) | |||||
| @param temp 温度(单位:°C) | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackTemp:(NSString *)temp{ | |||||
| [self addLog:[NSString stringWithFormat:@"temperature is %@",temp]]; | |||||
| } | |||||
| /** | |||||
| Back to impedance measurement(返回阻抗测量) | |||||
| @param status 阻抗测量状态 | |||||
| @param adc 阻抗 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackAdcMeasureStatus:(BodyFatScaleAdcMeasureStatus)status adcValue:(NSInteger)adc{ | |||||
| switch (status) { | |||||
| case BodyFatScaleAdcMeasureStatus_Testing: | |||||
| { | |||||
| [self addLog:@"adc testing"]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleAdcMeasureStatus_Success: | |||||
| { | |||||
| [self addLog:[NSString stringWithFormat:@"adc is %ld",adc]]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleAdcMeasureStatus_Fail: | |||||
| { | |||||
| [self addLog:@"adc test failure"]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleAdcMeasureStatus_SuccessCustom: | |||||
| { | |||||
| [self addLog:[NSString stringWithFormat:@"adc is %ld and user app algum",adc]]; | |||||
| } | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| /** | |||||
| Callback heart rate measurement(回调心率测量) | |||||
| @param status 心率测量状态 | |||||
| @param heartRate 心率 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackHeartRateMeasureStatus:(BodyFatScaleHeartRateMeasureStatus)status heartRateValue:(NSInteger)heartRate{ | |||||
| switch (status) { | |||||
| case BodyFatScaleHeartRateMeasureStatus_Testing: | |||||
| { | |||||
| [self addLog:@"Heart Rate Testing"]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleHeartRateMeasureStatus_Success: | |||||
| { | |||||
| [self addLog:[NSString stringWithFormat:@"Heart Rate is %ld",heartRate]]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleHeartRateMeasureStatus_Fail: | |||||
| { | |||||
| [self addLog:@"Heart Rate Test failure"]; | |||||
| } | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| /** | |||||
| Return error code(返回错误码) | |||||
| @param code 错误码 | |||||
| 1:超重 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackErrorCode:(NSInteger)code{ | |||||
| [self addLog:[NSString stringWithFormat:@"error code = %ld",code]]; | |||||
| } | |||||
| //MARK:回调A6指令数据 | |||||
| /** | |||||
| Send success or failure callback for offline user list(发送离线用户列表的成功或失败回调) | |||||
| @param status 状态 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackUpdateRecordStatus:(BodyFatScaleUpdateRecordStatus)status{ | |||||
| switch (status) { | |||||
| case BodyFatScaleUpdateRecordStatus_AllSuccess: | |||||
| { | |||||
| [self addLog:@"Update All Users Success"]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleUpdateRecordStatus_OneSuccess: | |||||
| { | |||||
| [self addLog:@"Update A User Success"]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleUpdateRecordStatus_OneFail: | |||||
| { | |||||
| [self addLog:@"Update A User Failure"]; | |||||
| } | |||||
| break; | |||||
| case BodyFatScaleUpdateRecordStatus_AllFail: | |||||
| { | |||||
| [self addLog:@"Update All Users Failure"]; | |||||
| } | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| /** | |||||
| Request callback for offline history(请求离线历史记录的回调) | |||||
| @param status 状态 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackSendHistoryDataStatus:(BodyFatScaleSendHistoryDataStatus)status{ | |||||
| if (status == BodyFatScaleSendHistoryDataStatus_No) { | |||||
| [self addLog:@"No offline datas"]; | |||||
| }else if (status == BodyFatScaleSendHistoryDataStatus_Begin){ | |||||
| [self addLog:@"Begin receive offline datas"]; | |||||
| }else if (status == BodyFatScaleSendHistoryDataStatus_End){ | |||||
| [self addLog:@"End receive offline datas"]; | |||||
| } | |||||
| } | |||||
| /** | |||||
| APP algorithm-offline history data(APP 算法-离线历史记录数据) | |||||
| @param user 用户信息 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackBleUserHistoryDataCustomADCModel:(ELBodyFatScaleBleUserModel *)user bodyDataModel:(ELBodyFatScaleBleWeightModel *)bodyModel{ | |||||
| //这里的身体指标等数据由app自定义算法计算得到,请区分bodyModel.algNum来调用算法 | |||||
| [self addLog:[NSString stringWithFormat:@"App algorithm-offline history data:userId = %ld weight = %ld unit =%@ point = %ld",user.usrID,bodyModel.weight,AiLinkBleWeightUnitDic[@(bodyModel.weightUnit)],bodyModel.weightPoint]]; | |||||
| } | |||||
| /** | |||||
| MCU algorithm-offline history data(MCU 算法-离线历史记录数据) | |||||
| @param user 用户信息 | |||||
| @param bodyModel 体脂数据 | |||||
| */ | |||||
| -(void)bodyFatScaleManagerCallBackBleUserHistoryDataModel:(ELBodyFatScaleBleUserModel *)user bodyDataModel:(ELBodyFatScaleBleWeightModel *)bodyModel{ | |||||
| //这里的身体指标数据由秤计算得到 | |||||
| [self addLog:[NSString stringWithFormat:@"MCU algorithm-offline history data:userId = %ld weight = %ld unit =%@ point = %ld",user.usrID,bodyModel.weight,AiLinkBleWeightUnitDic[@(bodyModel.weightUnit)],bodyModel.weightPoint]]; | |||||
| } | |||||
| -(void)bleWifiReceiveWifiSNCode:(int)code{ | |||||
| //MARK:11.根据wifi设备的设备id从服务器获取离线数据(找自己后台要接口) | |||||
| } | |||||
| -(void)bodyFatScaleManagerUpdateState:(ELBluetoothState)state{ | |||||
| switch (state) { | |||||
| case ELBluetoothStateUnavailable: | |||||
| { | |||||
| self.title = @"Please open the bluetooth"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateAvailable: | |||||
| { | |||||
| self.title = @"Bluetooth is open"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateScaning: | |||||
| { | |||||
| self.title = @"Scaning"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateConnectFail: | |||||
| { | |||||
| self.title = @"Connect fail"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidDisconnect: | |||||
| { | |||||
| self.title = @"Disconnected"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidValidationPass: | |||||
| { | |||||
| self.title = @"Connected"; | |||||
| //获取设备支持的单位 | |||||
| [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)]; | |||||
| //将你自己设置的单位发给秤 | |||||
| ELDeviceWeightUnit unit = ELDeviceWeightUnit_KG; | |||||
| [[ELBodyFatScaleBleManager shareManager] changeBodyFatScaleUnit:unit]; | |||||
| //请求历史记录 | |||||
| [[ELBodyFatScaleBleManager shareManager] sendCmd_RequestHistory]; | |||||
| //下发用户列表 | |||||
| [[ELBodyFatScaleBleManager shareManager] sendOfflineUserListToBle:[self get8Users]]; | |||||
| if (self.p.deviceType == ELSupportDeviceTypeBLE_WIFIScale) { | |||||
| //获取蓝牙连接状态 | |||||
| [[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetConnectState)]; | |||||
| } | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateFailedValidation: | |||||
| { | |||||
| self.title = @"Illegal equipment"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateWillConnect: | |||||
| self.title = @"Connecting"; | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| -(NSArray<ELBodyFatScaleBleUserModel *> *)get8Users{ | |||||
| NSMutableArray *users = [[NSMutableArray alloc] init]; | |||||
| for (int i=0; i<8; i++) { | |||||
| ELBodyFatScaleBleUserModel *user = [[ELBodyFatScaleBleUserModel alloc] init]; | |||||
| user.createTime = [[NSDate date] timeIntervalSince1970]; | |||||
| user.usrID = i; | |||||
| user.role = i%4; | |||||
| user.sex = i%2; | |||||
| user.age = 26+i; | |||||
| user.height = 170+i; | |||||
| user.weight = 600+i; | |||||
| user.adc = 560+i; | |||||
| [users addObject:user]; | |||||
| } | |||||
| return users.copy; | |||||
| } | |||||
| -(ELBodyFatScaleBleUserModel *)getOneUser{ | |||||
| ELBodyFatScaleBleUserModel *user = [[ELBodyFatScaleBleUserModel alloc] init]; | |||||
| user.createTime = [[NSDate date] timeIntervalSince1970]; | |||||
| user.usrID = 0; | |||||
| user.role = BodyFatScaleRole_Ordinary; | |||||
| user.sex = ELBluetoothUserSex_Woman; | |||||
| user.age = 26; | |||||
| user.height = 170; | |||||
| user.weight = 600; | |||||
| user.adc = 560; | |||||
| return user; | |||||
| } | |||||
| -(void)dealloc{ | |||||
| } | |||||
| @end |
| // | |||||
| // BodyFatScaleScanViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface BodyFatScaleScanViewController : UIViewController | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // BodyFatScaleScanViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "BodyFatScaleScanViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELBodyFatScaleBleManager.h> | |||||
| #import "BodyFatScaleConnectViewController.h" | |||||
| @interface BodyFatScaleScanViewController ()<UITableViewDelegate,UITableViewDataSource,ELBodyFatScaleBleDelegate> | |||||
| @property (nonatomic, strong) UITableView *tableView; | |||||
| @property (nonatomic, strong) NSArray<ELPeripheralModel *> *devices; | |||||
| @end | |||||
| @implementation BodyFatScaleScanViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| // self.title = @"Devices"; | |||||
| [self.view addSubview:self.tableView]; | |||||
| [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.top.left.right.bottom.mas_equalTo(0); | |||||
| }]; | |||||
| } | |||||
| -(void)viewWillAppear:(BOOL)animated{ | |||||
| [super viewWillAppear:animated]; | |||||
| [[ELBodyFatScaleBleManager shareManager] startScan]; | |||||
| [ELBodyFatScaleBleManager shareManager].bodyFatScaleDelegate = self; | |||||
| } | |||||
| -(void)viewDidDisappear:(BOOL)animated{ | |||||
| [super viewDidDisappear:animated]; | |||||
| [[ELBodyFatScaleBleManager shareManager] stopScan]; | |||||
| } | |||||
| #pragma mark ============ ELBluetoothManagerDelegate ============== | |||||
| -(void)bodyFatScaleManagerUpdateState:(ELBluetoothState)state{ | |||||
| NSLog(@"bluetoothManagerUpdateBleState = %ld",state); | |||||
| } | |||||
| -(void)bodyFatScaleManagerScanDevices:(NSArray<ELBodyFatScaleDeviceModel *> *)scaleDevices{ | |||||
| self.devices = scaleDevices; | |||||
| [self.tableView reloadData]; | |||||
| } | |||||
| -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | |||||
| return self.devices.count; | |||||
| } | |||||
| -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| return 60; | |||||
| } | |||||
| -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| static NSString *cellId = @"cellid"; | |||||
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; | |||||
| if (!cell) { | |||||
| cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; | |||||
| } | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| cell.textLabel.text = [NSString stringWithFormat:@"Name:%@---Mac:%@\nCID:%ld---VID:%ld---PID:%ld",p.deviceName,p.macAddress,p.deviceType,p.vendorID,p.productID]; | |||||
| cell.textLabel.numberOfLines = 2; | |||||
| cell.textLabel.textColor = [UIColor blackColor]; | |||||
| return cell; | |||||
| } | |||||
| -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| BodyFatScaleConnectViewController *vc = [[BodyFatScaleConnectViewController alloc] init]; | |||||
| vc.p = p; | |||||
| [self.navigationController pushViewController:vc animated:YES]; | |||||
| } | |||||
| -(UITableView *)tableView{ | |||||
| if (_tableView == nil) { | |||||
| _tableView = [[UITableView alloc] init]; | |||||
| _tableView.delegate = self; | |||||
| _tableView.dataSource = self; | |||||
| } | |||||
| return _tableView; | |||||
| } | |||||
| @end |
| // | |||||
| // WiFiSetupViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface WiFiSetupViewController : UIViewController | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // WiFiSetupViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "WiFiSetupViewController.h" | |||||
| @interface WiFiSetupViewController () | |||||
| @end | |||||
| @implementation WiFiSetupViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| // Do any additional setup after loading the view. | |||||
| } | |||||
| /* | |||||
| #pragma mark - Navigation | |||||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | |||||
| - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |||||
| // Get the new view controller using [segue destinationViewController]. | |||||
| // Pass the selected object to the new view controller. | |||||
| } | |||||
| */ | |||||
| @end |
| // | |||||
| // ForeheadConnectViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| @class ELPeripheralModel; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ForeheadConnectViewController : UIViewController | |||||
| @property (nonatomic, strong) ELPeripheralModel *p; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ForeheadConnectViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "ForeheadConnectViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELForeHeadBleManager.h> | |||||
| @interface ForeheadConnectViewController ()<ELBluetoothManagerDelegate,ELForeheadBleManagerDelegate> | |||||
| @property (nonatomic, strong) UITextView *textView; | |||||
| @end | |||||
| @implementation ForeheadConnectViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| self.view.backgroundColor = [UIColor whiteColor]; | |||||
| [ELForeHeadBleManager shareManager].foreheadDelegate = self; | |||||
| [ELForeHeadBleManager shareManager].delegate =self; | |||||
| [[ELForeHeadBleManager shareManager] connectPeripheral:self.p]; | |||||
| [self setupUIView]; | |||||
| } | |||||
| -(void)viewWillDisappear:(BOOL)animated{ | |||||
| [super viewWillDisappear:animated]; | |||||
| [[ELForeHeadBleManager shareManager] disconnectPeripheral]; | |||||
| } | |||||
| -(void)addLog:(NSString *)log{ | |||||
| self.textView.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView.text]; | |||||
| } | |||||
| -(void)buttonAction:(UIButton *)sender{ | |||||
| if ([ELForeHeadBleManager shareManager].state != ELBluetoothStateDidValidationPass) { | |||||
| [self addLog:@"Disconnected"]; | |||||
| return; | |||||
| } | |||||
| [self addLog:sender.titleLabel.text]; | |||||
| NSInteger tag = sender.tag; | |||||
| if (tag == 1) { | |||||
| //getBluetoothInfoWithELInetGetCmdType是获取设备信息的方法 | |||||
| [[ELForeHeadBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)]; | |||||
| }else if (tag == 2){ | |||||
| [[ELForeHeadBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetC_V_P_ID)]; | |||||
| }else if (tag == 3){ | |||||
| [[ELForeHeadBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetName)]; | |||||
| }else if (tag == 4){ | |||||
| [[ELForeHeadBleManager shareManager] setBluetoothName:@"AILink"]; | |||||
| }else if (tag == 5){ | |||||
| [[ELForeHeadBleManager shareManager] changeUnit:(ELDeviceTemperatureUnit_C)]; | |||||
| }else if (tag == 6){ | |||||
| [[ELForeHeadBleManager shareManager] changeUnit:(ELDeviceTemperatureUnit_F)]; | |||||
| }else if (tag == 7){ | |||||
| }else if (tag == 8){ | |||||
| }else if (tag == 9){ | |||||
| } | |||||
| } | |||||
| -(void)setupUIView{ | |||||
| UIButton *button1 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button1 setTitle:@"Get BM Version" forState:(UIControlStateNormal)]; | |||||
| button1.tag = 1; | |||||
| button1.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button1.titleLabel.numberOfLines = 2; | |||||
| button1.backgroundColor = [UIColor blackColor]; | |||||
| [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button1]; | |||||
| [button1 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button2 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button2 setTitle:@"Get C V P ID" forState:(UIControlStateNormal)]; | |||||
| button2.tag = 2; | |||||
| button2.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button2.titleLabel.numberOfLines = 2; | |||||
| button2.backgroundColor = [UIColor blackColor]; | |||||
| [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button2]; | |||||
| [button2 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button1.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button3 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button3 setTitle:@"Get Name" forState:(UIControlStateNormal)]; | |||||
| button3.tag = 3; | |||||
| button3.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button3.titleLabel.numberOfLines = 2; | |||||
| button3.backgroundColor = [UIColor blackColor]; | |||||
| [button3 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button3]; | |||||
| [button3 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button2.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button4 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button4 setTitle:@"Set Name" forState:(UIControlStateNormal)]; | |||||
| button4.tag = 4; | |||||
| button4.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button4.titleLabel.numberOfLines = 2; | |||||
| button4.backgroundColor = [UIColor blackColor]; | |||||
| [button4 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button4]; | |||||
| [button4 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button5 setTitle:@"Change Unit To C" forState:(UIControlStateNormal)]; | |||||
| button5.tag = 5; | |||||
| button5.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button5.titleLabel.numberOfLines = 2; | |||||
| button5.backgroundColor = [UIColor blackColor]; | |||||
| [button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button5]; | |||||
| [button5 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button4.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button6 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button6 setTitle:@"Change Unit To F" forState:(UIControlStateNormal)]; | |||||
| button6.tag = 6; | |||||
| button6.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button6.titleLabel.numberOfLines = 2; | |||||
| button6.backgroundColor = [UIColor blackColor]; | |||||
| [button6 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button6]; | |||||
| [button6 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button5.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| self.textView = [[UITextView alloc] init]; | |||||
| self.textView.backgroundColor = [UIColor blackColor]; | |||||
| self.textView.text = @"Log"; | |||||
| self.textView.textColor = [UIColor redColor]; | |||||
| [self.view addSubview:self.textView]; | |||||
| [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.right.bottom.mas_equalTo(-10); | |||||
| make.height.mas_equalTo(200); | |||||
| }]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{ | |||||
| if (type == ELInetSetCmdTypeSetName) { | |||||
| if (result == ELSetBluetoothResponseTypeSuccess) { | |||||
| [self addLog:@"Set name Success "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeFailure){ | |||||
| [self addLog:@"Set name failure "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeNoSupport){ | |||||
| [self addLog:@"Set name unsupport "]; | |||||
| } | |||||
| } | |||||
| } | |||||
| -(void)bluetoothManagerReceiceName:(NSString *)name{ | |||||
| [self addLog:name]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did{ | |||||
| [self addLog:[NSString stringWithFormat:@"CID = %d,VID = %d,PID = %d",did.deviceType,did.vendorID,did.productID]]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{ | |||||
| [self addLog:bmVersion]; | |||||
| } | |||||
| //MARK:获取设备支持的单位 | |||||
| -(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{ | |||||
| //这里要压力和温度单位 | |||||
| //设置单位时,要设置设备支持的单位 | |||||
| } | |||||
| /** | |||||
| Callback temperature(回调温度) | |||||
| @param model ELForeheadBleDataModel | |||||
| */ | |||||
| -(void)foreheadBleManagerReceiveTemperature:(ELForeheadBleDataModel *_Nonnull)model dataType:(ForeheadBleDataType)dataType{ | |||||
| [self addLog:[NSString stringWithFormat:@"temperature = %@ unit = %@ point = %ld",model.temperature,AiLinkBleTempUnitDic[@(model.unit)],model.point]]; | |||||
| } | |||||
| /** | |||||
| Set unit callback( 设置单位回调) | |||||
| @param type 结果 | |||||
| */ | |||||
| -(void)foreheadBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type{ | |||||
| [self addLog:[NSString stringWithFormat:@"Change Unit result = %lu",(unsigned long)type]]; | |||||
| } | |||||
| /** | |||||
| Error code sent on the device(设备上发错误码) | |||||
| @param code 错误码 | |||||
| */ | |||||
| -(void)foreheadBleManagerReceiveFailCode:(ForeheadFailCode)code{ | |||||
| [self addLog:[NSString stringWithFormat:@"error code = %lu",(unsigned long)code]]; | |||||
| } | |||||
| -(void)foreheadBleManagerUpdateBleState:(ELBluetoothState)state{ | |||||
| switch (state) { | |||||
| case ELBluetoothStateUnavailable: | |||||
| { | |||||
| self.title = @"Please open the bluetooth"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateAvailable: | |||||
| { | |||||
| self.title = @"Bluetooth is open"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateScaning: | |||||
| { | |||||
| self.title = @"Scaning"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateConnectFail: | |||||
| { | |||||
| self.title = @"Connect fail"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidDisconnect: | |||||
| { | |||||
| self.title = @"Disconnected"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidValidationPass: | |||||
| { | |||||
| self.title = @"Connected"; | |||||
| [[ELForeHeadBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)]; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateFailedValidation: | |||||
| { | |||||
| self.title = @"Illegal equipment"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateWillConnect: | |||||
| self.title = @"Connecting"; | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| -(void)dealloc{ | |||||
| } | |||||
| @end |
| // | |||||
| // ForeheadScanViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface ForeheadScanViewController : UIViewController | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // ForeheadScanViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/8. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "ForeheadScanViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELForeHeadBleManager.h> | |||||
| #import "ForeheadConnectViewController.h" | |||||
| @interface ForeheadScanViewController ()<UITableViewDelegate,UITableViewDataSource,ELForeheadBleManagerDelegate> | |||||
| @property (nonatomic, strong) UITableView *tableView; | |||||
| @property (nonatomic, strong) NSArray<ELPeripheralModel *> *devices; | |||||
| @end | |||||
| @implementation ForeheadScanViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| // self.title = @"Devices"; | |||||
| [self.view addSubview:self.tableView]; | |||||
| [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.top.left.right.bottom.mas_equalTo(0); | |||||
| }]; | |||||
| } | |||||
| -(void)viewWillAppear:(BOOL)animated{ | |||||
| [super viewWillAppear:animated]; | |||||
| [[ELForeHeadBleManager shareManager] startScan]; | |||||
| [ELForeHeadBleManager shareManager].foreheadDelegate = self; | |||||
| } | |||||
| -(void)viewDidDisappear:(BOOL)animated{ | |||||
| [super viewDidDisappear:animated]; | |||||
| [[ELForeHeadBleManager shareManager] stopScan]; | |||||
| } | |||||
| #pragma mark ============ ELBluetoothManagerDelegate ============== | |||||
| -(void)foreheadBleManagerUpdateBleState:(ELBluetoothState)state{ | |||||
| NSLog(@"bluetoothManagerUpdateBleState = %ld",state); | |||||
| } | |||||
| -(void)foreheadBleManagerScanDevices:(NSArray<ELPeripheralModel *> *)devices{ | |||||
| self.devices = devices; | |||||
| [self.tableView reloadData]; | |||||
| } | |||||
| -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | |||||
| return self.devices.count; | |||||
| } | |||||
| -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| return 60; | |||||
| } | |||||
| -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| static NSString *cellId = @"cellid"; | |||||
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; | |||||
| if (!cell) { | |||||
| cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; | |||||
| } | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| cell.textLabel.text = [NSString stringWithFormat:@"Name:%@---Mac:%@\nCID:%ld---VID:%ld---PID:%ld",p.deviceName,p.macAddress,p.deviceType,p.vendorID,p.productID]; | |||||
| cell.textLabel.numberOfLines = 2; | |||||
| cell.textLabel.textColor = [UIColor blackColor]; | |||||
| return cell; | |||||
| } | |||||
| -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| ForeheadConnectViewController *vc = [[ForeheadConnectViewController alloc] init]; | |||||
| vc.p = p; | |||||
| [self.navigationController pushViewController:vc animated:YES]; | |||||
| } | |||||
| -(UITableView *)tableView{ | |||||
| if (_tableView == nil) { | |||||
| _tableView = [[UITableView alloc] init]; | |||||
| _tableView.delegate = self; | |||||
| _tableView.dataSource = self; | |||||
| } | |||||
| return _tableView; | |||||
| } | |||||
| @end |
| // | |||||
| // HeightGuageConnectViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| @class ELPeripheralModel; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface HeightGuageConnectViewController : UIViewController | |||||
| @property (nonatomic, strong) ELPeripheralModel *p; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // HeightGuageConnectViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "HeightGuageConnectViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELHeightGaugeBleManager.h> | |||||
| @interface HeightGuageConnectViewController ()<ELBluetoothManagerDelegate,ELHeightGaugeBleManagerDelegate> | |||||
| @property (nonatomic, strong) UITextView *textView; | |||||
| @end | |||||
| @implementation HeightGuageConnectViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| self.view.backgroundColor = [UIColor whiteColor]; | |||||
| [ELHeightGaugeBleManager shareManager].heightGaugeDelegate = self; | |||||
| [ELHeightGaugeBleManager shareManager].delegate =self; | |||||
| [[ELHeightGaugeBleManager shareManager] connectPeripheral:self.p]; | |||||
| [self setupUIView]; | |||||
| } | |||||
| -(void)viewWillDisappear:(BOOL)animated{ | |||||
| [super viewWillDisappear:animated]; | |||||
| [[ELHeightGaugeBleManager shareManager] disconnectPeripheral]; | |||||
| } | |||||
| -(void)addLog:(NSString *)log{ | |||||
| self.textView.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView.text]; | |||||
| } | |||||
| -(void)buttonAction:(UIButton *)sender{ | |||||
| if ([ELHeightGaugeBleManager shareManager].state != ELBluetoothStateDidValidationPass) { | |||||
| [self addLog:@"Disconnected"]; | |||||
| return; | |||||
| } | |||||
| [self addLog:sender.titleLabel.text]; | |||||
| NSInteger tag = sender.tag; | |||||
| if (tag == 1) { | |||||
| //getBluetoothInfoWithELInetGetCmdType是获取设备信息的方法 | |||||
| [[ELHeightGaugeBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)]; | |||||
| }else if (tag == 2){ | |||||
| [[ELHeightGaugeBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetC_V_P_ID)]; | |||||
| }else if (tag == 3){ | |||||
| [[ELHeightGaugeBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetName)]; | |||||
| }else if (tag == 4){ | |||||
| [[ELHeightGaugeBleManager shareManager] setBluetoothName:@"AILink"]; | |||||
| }else if (tag == 5){ | |||||
| [[ELHeightGaugeBleManager shareManager] changeUnit:(ELDeviceHeightUnit_CM)]; | |||||
| }else if (tag == 6){ | |||||
| }else if (tag == 7){ | |||||
| }else if (tag == 8){ | |||||
| }else if (tag == 9){ | |||||
| } | |||||
| } | |||||
| -(void)setupUIView{ | |||||
| UIButton *button1 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button1 setTitle:@"Get BM Version" forState:(UIControlStateNormal)]; | |||||
| button1.tag = 1; | |||||
| button1.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button1.titleLabel.numberOfLines = 2; | |||||
| button1.backgroundColor = [UIColor blackColor]; | |||||
| [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button1]; | |||||
| [button1 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button2 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button2 setTitle:@"Get C V P ID" forState:(UIControlStateNormal)]; | |||||
| button2.tag = 2; | |||||
| button2.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button2.titleLabel.numberOfLines = 2; | |||||
| button2.backgroundColor = [UIColor blackColor]; | |||||
| [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button2]; | |||||
| [button2 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button1.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button3 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button3 setTitle:@"Get Name" forState:(UIControlStateNormal)]; | |||||
| button3.tag = 3; | |||||
| button3.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button3.titleLabel.numberOfLines = 2; | |||||
| button3.backgroundColor = [UIColor blackColor]; | |||||
| [button3 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button3]; | |||||
| [button3 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button2.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button4 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button4 setTitle:@"Set Name" forState:(UIControlStateNormal)]; | |||||
| button4.tag = 4; | |||||
| button4.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button4.titleLabel.numberOfLines = 2; | |||||
| button4.backgroundColor = [UIColor blackColor]; | |||||
| [button4 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button4]; | |||||
| [button4 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button5 setTitle:@"Change Unit" forState:(UIControlStateNormal)]; | |||||
| button5.tag = 5; | |||||
| button5.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button5.titleLabel.numberOfLines = 2; | |||||
| button5.backgroundColor = [UIColor blackColor]; | |||||
| [button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button5]; | |||||
| [button5 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button4.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| self.textView = [[UITextView alloc] init]; | |||||
| self.textView.backgroundColor = [UIColor blackColor]; | |||||
| self.textView.text = @"Log"; | |||||
| self.textView.textColor = [UIColor redColor]; | |||||
| [self.view addSubview:self.textView]; | |||||
| [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.right.bottom.mas_equalTo(-10); | |||||
| make.height.mas_equalTo(200); | |||||
| }]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{ | |||||
| if (type == ELInetSetCmdTypeSetName) { | |||||
| if (result == ELSetBluetoothResponseTypeSuccess) { | |||||
| [self addLog:@"Set name Success "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeFailure){ | |||||
| [self addLog:@"Set name failure "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeNoSupport){ | |||||
| [self addLog:@"Set name unsupport "]; | |||||
| } | |||||
| } | |||||
| } | |||||
| -(void)bluetoothManagerReceiceName:(NSString *)name{ | |||||
| [self addLog:name]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did{ | |||||
| [self addLog:[NSString stringWithFormat:@"CID = %d,VID = %d,PID = %d",did.deviceType,did.vendorID,did.productID]]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{ | |||||
| [self addLog:bmVersion]; | |||||
| } | |||||
| //MARK:获取设备支持的单位 | |||||
| -(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{ | |||||
| //这里要身高单位 | |||||
| //设置单位时,要设置设备支持的单位 | |||||
| } | |||||
| /** | |||||
| call back ELHeightGaugeBleDataModel | |||||
| */ | |||||
| -(void)heightGaugeBleManagerReceiceTestData:(ELHeightGaugeBleDataModel *_Nonnull)model{ | |||||
| [self addLog:[NSString stringWithFormat:@"height = %ld unit = %@ point = %ld",model.height,AiLinkBleHeightUnitDic[@(model.heightUnit)],model.heightPoint]]; | |||||
| } | |||||
| /** | |||||
| call back the result of set unit | |||||
| */ | |||||
| -(void)heightGaugeBleManagerReceiveSetUnitResult:(ELSetBluetoothResponseType)type{ | |||||
| [self addLog:[NSString stringWithFormat:@"change unit result = %lu",(unsigned long)type]]; | |||||
| } | |||||
| /** | |||||
| call back fail code | |||||
| */ | |||||
| -(void)heightGaugeBleManagerReceiveFailCode:(ELHeightGaugeFailCode)code{ | |||||
| [self addLog:[NSString stringWithFormat:@"error code = %lu",(unsigned long)code]]; | |||||
| } | |||||
| -(void)heightGaugeBleManagerUpdateBleState:(ELBluetoothState)state{ | |||||
| switch (state) { | |||||
| case ELBluetoothStateUnavailable: | |||||
| { | |||||
| self.title = @"Please open the bluetooth"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateAvailable: | |||||
| { | |||||
| self.title = @"Bluetooth is open"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateScaning: | |||||
| { | |||||
| self.title = @"Scaning"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateConnectFail: | |||||
| { | |||||
| self.title = @"Connect fail"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidDisconnect: | |||||
| { | |||||
| self.title = @"Disconnected"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidValidationPass: | |||||
| { | |||||
| self.title = @"Connected"; | |||||
| [[ELHeightGaugeBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)]; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateFailedValidation: | |||||
| { | |||||
| self.title = @"Illegal equipment"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateWillConnect: | |||||
| self.title = @"Connecting"; | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| -(void)dealloc{ | |||||
| } | |||||
| @end |
| // | |||||
| // HeightGuageScanViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface HeightGuageScanViewController : UIViewController | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // HeightGuageScanViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "HeightGuageScanViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import <AILinkBleSDK/ELHeightGaugeBleManager.h> | |||||
| #import "HeightGuageConnectViewController.h" | |||||
| @interface HeightGuageScanViewController ()<UITableViewDelegate,UITableViewDataSource,ELHeightGaugeBleManagerDelegate> | |||||
| @property (nonatomic, strong) UITableView *tableView; | |||||
| @property (nonatomic, strong) NSArray<ELPeripheralModel *> *devices; | |||||
| @end | |||||
| @implementation HeightGuageScanViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| // self.title = @"Devices"; | |||||
| [self.view addSubview:self.tableView]; | |||||
| [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.top.left.right.bottom.mas_equalTo(0); | |||||
| }]; | |||||
| } | |||||
| -(void)viewWillAppear:(BOOL)animated{ | |||||
| [super viewWillAppear:animated]; | |||||
| [[ELHeightGaugeBleManager shareManager] startScan]; | |||||
| [ELHeightGaugeBleManager shareManager].heightGaugeDelegate = self; | |||||
| } | |||||
| -(void)viewDidDisappear:(BOOL)animated{ | |||||
| [super viewDidDisappear:animated]; | |||||
| [[ELHeightGaugeBleManager shareManager] stopScan]; | |||||
| } | |||||
| #pragma mark ============ ELBluetoothManagerDelegate ============== | |||||
| -(void)heightGaugeBleManagerUpdateBleState:(ELBluetoothState)state{ | |||||
| NSLog(@"bluetoothManagerUpdateBleState = %ld",state); | |||||
| } | |||||
| -(void)heightGaugeBleManagerScanDevices:(NSArray<ELPeripheralModel *> *)devices{ | |||||
| self.devices = devices; | |||||
| [self.tableView reloadData]; | |||||
| } | |||||
| -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | |||||
| return self.devices.count; | |||||
| } | |||||
| -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| return 60; | |||||
| } | |||||
| -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| static NSString *cellId = @"cellid"; | |||||
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; | |||||
| if (!cell) { | |||||
| cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; | |||||
| } | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| cell.textLabel.text = [NSString stringWithFormat:@"Name:%@---Mac:%@\nCID:%ld---VID:%ld---PID:%ld",p.deviceName,p.macAddress,p.deviceType,p.vendorID,p.productID]; | |||||
| cell.textLabel.numberOfLines = 2; | |||||
| cell.textLabel.textColor = [UIColor blackColor]; | |||||
| return cell; | |||||
| } | |||||
| -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| HeightGuageConnectViewController *vc = [[HeightGuageConnectViewController alloc] init]; | |||||
| vc.p = p; | |||||
| [self.navigationController pushViewController:vc animated:YES]; | |||||
| } | |||||
| -(UITableView *)tableView{ | |||||
| if (_tableView == nil) { | |||||
| _tableView = [[UITableView alloc] init]; | |||||
| _tableView.delegate = self; | |||||
| _tableView.dataSource = self; | |||||
| } | |||||
| return _tableView; | |||||
| } | |||||
| @end |
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
| <plist version="1.0"> | |||||
| <dict> | |||||
| <key>CFBundleDevelopmentRegion</key> | |||||
| <string>$(DEVELOPMENT_LANGUAGE)</string> | |||||
| <key>CFBundleExecutable</key> | |||||
| <string>$(EXECUTABLE_NAME)</string> | |||||
| <key>CFBundleIdentifier</key> | |||||
| <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | |||||
| <key>CFBundleInfoDictionaryVersion</key> | |||||
| <string>6.0</string> | |||||
| <key>CFBundleName</key> | |||||
| <string>$(PRODUCT_NAME)</string> | |||||
| <key>CFBundlePackageType</key> | |||||
| <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | |||||
| <key>CFBundleShortVersionString</key> | |||||
| <string>1.0</string> | |||||
| <key>CFBundleVersion</key> | |||||
| <string>1</string> | |||||
| <key>LSRequiresIPhoneOS</key> | |||||
| <true/> | |||||
| <key>UIApplicationSceneManifest</key> | |||||
| <dict> | |||||
| <key>UIApplicationSupportsMultipleScenes</key> | |||||
| <false/> | |||||
| <key>UISceneConfigurations</key> | |||||
| <dict> | |||||
| <key>UIWindowSceneSessionRoleApplication</key> | |||||
| <array> | |||||
| <dict> | |||||
| <key>UISceneConfigurationName</key> | |||||
| <string>Default Configuration</string> | |||||
| <key>UISceneDelegateClassName</key> | |||||
| <string>SceneDelegate</string> | |||||
| <key>UISceneStoryboardFile</key> | |||||
| <string>Main</string> | |||||
| </dict> | |||||
| </array> | |||||
| </dict> | |||||
| </dict> | |||||
| <key>UILaunchStoryboardName</key> | |||||
| <string>LaunchScreen</string> | |||||
| <key>UIMainStoryboardFile</key> | |||||
| <string>Main</string> | |||||
| <key>UIRequiredDeviceCapabilities</key> | |||||
| <array> | |||||
| <string>armv7</string> | |||||
| </array> | |||||
| <key>UISupportedInterfaceOrientations</key> | |||||
| <array> | |||||
| <string>UIInterfaceOrientationPortrait</string> | |||||
| <string>UIInterfaceOrientationLandscapeLeft</string> | |||||
| <string>UIInterfaceOrientationLandscapeRight</string> | |||||
| </array> | |||||
| <key>UISupportedInterfaceOrientations~ipad</key> | |||||
| <array> | |||||
| <string>UIInterfaceOrientationPortrait</string> | |||||
| <string>UIInterfaceOrientationPortraitUpsideDown</string> | |||||
| <string>UIInterfaceOrientationLandscapeLeft</string> | |||||
| <string>UIInterfaceOrientationLandscapeRight</string> | |||||
| </array> | |||||
| <key>NSBluetoothAlwaysUsageDescription</key> | |||||
| <string></string> | |||||
| </dict> | |||||
| </plist> |
| // | |||||
| // InheritConnectViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| @class ELPeripheralModel; | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface InheritConnectViewController : UIViewController | |||||
| @property (nonatomic, strong) ELPeripheralModel *p; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // InheritConnectViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "InheritConnectViewController.h" | |||||
| #import "Masonry.h" | |||||
| #import "SubBleManager.h" | |||||
| @interface InheritConnectViewController ()<SubBleManagerDelegate,ELBluetoothManagerDelegate> | |||||
| @property (nonatomic, strong) UITextView *textView; | |||||
| @end | |||||
| @implementation InheritConnectViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| self.view.backgroundColor = [UIColor whiteColor]; | |||||
| [SubBleManager shareManager].subDelegate = self; | |||||
| [SubBleManager shareManager].delegate =self; | |||||
| [[SubBleManager shareManager] connectPeripheral:self.p]; | |||||
| [self setupUIView]; | |||||
| } | |||||
| -(void)viewWillDisappear:(BOOL)animated{ | |||||
| [super viewWillDisappear:animated]; | |||||
| [[SubBleManager shareManager] disconnectPeripheral]; | |||||
| } | |||||
| -(void)addLog:(NSString *)log{ | |||||
| self.textView.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView.text]; | |||||
| } | |||||
| -(void)buttonAction:(UIButton *)sender{ | |||||
| if ([SubBleManager shareManager].state != ELBluetoothStateDidValidationPass) { | |||||
| [self addLog:@"Disconnected"]; | |||||
| return; | |||||
| } | |||||
| [self addLog:sender.titleLabel.text]; | |||||
| NSInteger tag = sender.tag; | |||||
| if (tag == 1) { | |||||
| //getBluetoothInfoWithELInetGetCmdType是获取设备信息的方法 | |||||
| [[SubBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetBMVersion)]; | |||||
| }else if (tag == 2){ | |||||
| [[SubBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetC_V_P_ID)]; | |||||
| }else if (tag == 3){ | |||||
| [[SubBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeGetName)]; | |||||
| }else if (tag == 4){ | |||||
| [[SubBleManager shareManager] setBluetoothName:@"AILink"]; | |||||
| }else if (tag == 5){ | |||||
| //MARK:发送A6数据 | |||||
| Byte b[5] = {0xA6,0x01,0x01,0x02,0x6A}; | |||||
| NSData *data = [[NSData alloc] initWithBytes:b length:5]; | |||||
| [self addLog:data.description]; | |||||
| [[SubBleManager shareManager] sendData:data]; | |||||
| }else if (tag == 6){ | |||||
| //MARK:发送A7数据 | |||||
| //假设根据协议得到数据为{0xA7,0x06,0x01,0x01,0x01,0x01,0x01,0x01,0x0B,0x7A} | |||||
| //则payload为 | |||||
| Byte b[6] = {0x01,0x01,0x01,0x01,0x01,0x01}; | |||||
| NSData *payload = [[NSData alloc] initWithBytes:b length:6]; | |||||
| [self addLog:payload.description]; | |||||
| [[SubBleManager shareManager] sendData:payload]; | |||||
| } | |||||
| } | |||||
| -(void)setupUIView{ | |||||
| UIButton *button1 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button1 setTitle:@"Get BM Version" forState:(UIControlStateNormal)]; | |||||
| button1.tag = 1; | |||||
| button1.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button1.titleLabel.numberOfLines = 2; | |||||
| button1.backgroundColor = [UIColor blackColor]; | |||||
| [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button1]; | |||||
| [button1 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button2 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button2 setTitle:@"Get C V P ID" forState:(UIControlStateNormal)]; | |||||
| button2.tag = 2; | |||||
| button2.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button2.titleLabel.numberOfLines = 2; | |||||
| button2.backgroundColor = [UIColor blackColor]; | |||||
| [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button2]; | |||||
| [button2 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button1.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| UIButton *button3 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button3 setTitle:@"Get Name" forState:(UIControlStateNormal)]; | |||||
| button3.tag = 3; | |||||
| button3.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button3.titleLabel.numberOfLines = 2; | |||||
| button3.backgroundColor = [UIColor blackColor]; | |||||
| [button3 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button3]; | |||||
| [button3 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button2.mas_right).mas_offset(10); | |||||
| make.top.mas_equalTo(80); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button4 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button4 setTitle:@"Set Name" forState:(UIControlStateNormal)]; | |||||
| button4.tag = 4; | |||||
| button4.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button4.titleLabel.numberOfLines = 2; | |||||
| button4.backgroundColor = [UIColor blackColor]; | |||||
| [button4 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button4]; | |||||
| [button4 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button5 setTitle:@"Send A6 Data" forState:(UIControlStateNormal)]; | |||||
| button5.tag = 5; | |||||
| button5.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button5.titleLabel.numberOfLines = 2; | |||||
| button5.backgroundColor = [UIColor blackColor]; | |||||
| [button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button5]; | |||||
| [button5 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button4.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| // | |||||
| UIButton *button6 = [UIButton buttonWithType:(UIButtonTypeCustom)]; | |||||
| [button6 setTitle:@"Send A7 Data" forState:(UIControlStateNormal)]; | |||||
| button6.tag = 6; | |||||
| button6.titleLabel.adjustsFontSizeToFitWidth = YES; | |||||
| button6.titleLabel.numberOfLines = 2; | |||||
| button6.backgroundColor = [UIColor blackColor]; | |||||
| [button6 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; | |||||
| [self.view addSubview:button6]; | |||||
| [button6 mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.equalTo(button5.mas_right).mas_offset(10); | |||||
| make.top.equalTo(button1.mas_bottom).mas_offset(10); | |||||
| make.width.mas_equalTo(100); | |||||
| make.height.mas_equalTo(40); | |||||
| }]; | |||||
| // | |||||
| self.textView = [[UITextView alloc] init]; | |||||
| self.textView.backgroundColor = [UIColor blackColor]; | |||||
| self.textView.text = @"Log"; | |||||
| self.textView.textColor = [UIColor redColor]; | |||||
| [self.view addSubview:self.textView]; | |||||
| [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.left.mas_equalTo(10); | |||||
| make.right.bottom.mas_equalTo(-10); | |||||
| make.height.mas_equalTo(200); | |||||
| }]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiceResponseType:(ELInetSetCmdType)type result:(ELSetBluetoothResponseType)result{ | |||||
| if (type == ELInetSetCmdTypeSetName) { | |||||
| if (result == ELSetBluetoothResponseTypeSuccess) { | |||||
| [self addLog:@"Set name Success "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeFailure){ | |||||
| [self addLog:@"Set name failure "]; | |||||
| }else if (result == ELSetBluetoothResponseTypeNoSupport){ | |||||
| [self addLog:@"Set name unsupport "]; | |||||
| } | |||||
| } | |||||
| } | |||||
| -(void)bluetoothManagerReceiceName:(NSString *)name{ | |||||
| [self addLog:name]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveDID:(struct ELDIDStruct)did{ | |||||
| [self addLog:[NSString stringWithFormat:@"CID = %ld,VID = %d,PID = %d",did.deviceType,did.vendorID,did.productID]]; | |||||
| } | |||||
| -(void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion{ | |||||
| [self addLog:bmVersion]; | |||||
| } | |||||
| //MARK:获取设备支持的单位 | |||||
| -(void)bluetoothManagerBackDeviceSupportUnitWithWeight:(NSArray<NSNumber *> *)weightArray Height:(NSArray<NSNumber *> *)heightArray Temperature:(NSArray<NSNumber *> *)temperatureArray BloodPressure:(NSArray<NSNumber *> *)bloodPressureArray Pressure:(NSArray<NSNumber *> *)pressureArray{ | |||||
| //需要什么单位根据设备而定 | |||||
| //设置单位时,要设置设备支持的单位 | |||||
| } | |||||
| -(void)subBluetoothUpdateState:(ELBluetoothState)state{ | |||||
| switch (state) { | |||||
| case ELBluetoothStateUnavailable: | |||||
| { | |||||
| self.title = @"Please open the bluetooth"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateAvailable: | |||||
| { | |||||
| self.title = @"Bluetooth is open"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateScaning: | |||||
| { | |||||
| self.title = @"Scaning"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateConnectFail: | |||||
| { | |||||
| self.title = @"Connect fail"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidDisconnect: | |||||
| { | |||||
| self.title = @"Disconnected"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateDidValidationPass: | |||||
| { | |||||
| self.title = @"Connected"; | |||||
| [[SubBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdTypeReadDeviceSupportUnit)]; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateFailedValidation: | |||||
| { | |||||
| self.title = @"Illegal equipment"; | |||||
| } | |||||
| break; | |||||
| case ELBluetoothStateWillConnect: | |||||
| self.title = @"Connecting"; | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| -(void)dealloc{ | |||||
| } | |||||
| @end |
| // | |||||
| // InheritScanViewController.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <UIKit/UIKit.h> | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface InheritScanViewController : UIViewController | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // InheritScanViewController.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "InheritScanViewController.h" | |||||
| #import <AILinkBleSDK/ELBluetoothManager.h> | |||||
| #import "Masonry.h" | |||||
| #import "SubBleManager.h" | |||||
| #import "InheritConnectViewController.h" | |||||
| @interface InheritScanViewController ()<UITableViewDelegate,UITableViewDataSource,SubBleManagerDelegate> | |||||
| @property (nonatomic, strong) UITableView *tableView; | |||||
| @property (nonatomic, strong) NSArray<ELPeripheralModel *> *devices; | |||||
| @end | |||||
| @implementation InheritScanViewController | |||||
| - (void)viewDidLoad { | |||||
| [super viewDidLoad]; | |||||
| // self.title = @"Devices"; | |||||
| [self.view addSubview:self.tableView]; | |||||
| [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
| make.top.left.right.bottom.mas_equalTo(0); | |||||
| }]; | |||||
| } | |||||
| -(void)viewWillAppear:(BOOL)animated{ | |||||
| [super viewWillAppear:animated]; | |||||
| [[SubBleManager shareManager] startScan]; | |||||
| [SubBleManager shareManager].subDelegate = self; | |||||
| } | |||||
| -(void)viewDidDisappear:(BOOL)animated{ | |||||
| [super viewDidDisappear:animated]; | |||||
| [[ELBluetoothManager shareManager] stopScan]; | |||||
| } | |||||
| #pragma mark ============ ELBluetoothManagerDelegate ============== | |||||
| -(void)subBluetoothUpdateState:(ELBluetoothState)state{ | |||||
| NSLog(@"bluetoothManagerUpdateBleState = %ld",state); | |||||
| } | |||||
| -(void)subBluetoothScanPeripherals:(NSArray *)peripherals{ | |||||
| self.devices = peripherals; | |||||
| [self.tableView reloadData]; | |||||
| } | |||||
| -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | |||||
| return self.devices.count; | |||||
| } | |||||
| -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| return 60; | |||||
| } | |||||
| -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| static NSString *cellId = @"cellid"; | |||||
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; | |||||
| if (!cell) { | |||||
| cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; | |||||
| } | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| cell.textLabel.text = [NSString stringWithFormat:@"Name:%@---Mac:%@\nCID:%ld---VID:%ld---PID:%ld",p.deviceName,p.macAddress,p.deviceType,p.vendorID,p.productID]; | |||||
| cell.textLabel.numberOfLines = 2; | |||||
| cell.textLabel.textColor = [UIColor blackColor]; | |||||
| return cell; | |||||
| } | |||||
| -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |||||
| ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
| InheritConnectViewController *vc = [[InheritConnectViewController alloc] init]; | |||||
| vc.p = p; | |||||
| [self.navigationController pushViewController:vc animated:YES]; | |||||
| } | |||||
| -(UITableView *)tableView{ | |||||
| if (_tableView == nil) { | |||||
| _tableView = [[UITableView alloc] init]; | |||||
| _tableView.delegate = self; | |||||
| _tableView.dataSource = self; | |||||
| } | |||||
| return _tableView; | |||||
| } | |||||
| @end |
| // | |||||
| // SubBleManager.h | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import <AILinkBleSDK/ELBluetoothManager.h> | |||||
| @protocol SubBleManagerDelegate <NSObject> | |||||
| //蓝牙连接状态 | |||||
| -(void)subBluetoothUpdateState:(ELBluetoothState)state; | |||||
| //扫描到的设备 | |||||
| -(void)subBluetoothScanPeripherals:(NSArray *)peripherals; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_BEGIN | |||||
| @interface SubBleManager : ELBluetoothManager | |||||
| // | |||||
| @property (nonatomic, weak) id<SubBleManagerDelegate> subDelegate; | |||||
| +(instancetype)shareManager; | |||||
| /// 发送数据给mcu | |||||
| /// @param data 协议对应数据 | |||||
| -(void)subBleSendA6Data:(NSData *)data; | |||||
| /// 发送数据给蓝牙 | |||||
| /// @param payload 协议的payload部分数据 | |||||
| -(void)subBleSendA7Data:(NSData *)payload; | |||||
| @end | |||||
| NS_ASSUME_NONNULL_END |
| // | |||||
| // SubBleManager.m | |||||
| // AILinkBleSDKSourceCode | |||||
| // | |||||
| // Created by iot_user on 2020/4/7. | |||||
| // Copyright © 2020 IOT. All rights reserved. | |||||
| // | |||||
| #import "SubBleManager.h" | |||||
| @implementation SubBleManager | |||||
| +(instancetype)shareManager{ | |||||
| static SubBleManager *manager = nil; | |||||
| static dispatch_once_t onceToken; | |||||
| dispatch_once(&onceToken, ^{ | |||||
| manager = [[self alloc] init]; | |||||
| }); | |||||
| return manager; | |||||
| } | |||||
| #pragma mark ============ 实现父类的方法 ============== | |||||
| -(void)bluetoothUpdateState:(ELBluetoothState)state{ | |||||
| if ([self.subDelegate respondsToSelector:@selector(subBluetoothUpdateState:)]) { | |||||
| [self.subDelegate subBluetoothUpdateState:state]; | |||||
| } | |||||
| } | |||||
| -(void)bluetoothScanPeripherals:(NSArray *)peripherals{ | |||||
| //筛选单种设备 | |||||
| //这里以体脂秤为例 | |||||
| NSArray *device = [ELPeripheralModel getDevicesWithPeripherals:peripherals supportDeviceType:(ELSupportDeviceTypeBodyFatScale)]; | |||||
| // NSArray *device = [ELPeripheralModel getDevicesWithPeripherals:peripherals supportDeviceTypes:@[@(ELSupportDeviceTypeBodyFatScale),@(ELSupportDeviceTypeBLE_WIFIScale)]]; | |||||
| if ([self.subDelegate respondsToSelector:@selector(subBluetoothScanPeripherals:)]) { | |||||
| [self.subDelegate subBluetoothScanPeripherals:device]; | |||||
| } | |||||
| } | |||||
| /** | |||||
| Callback decrypted A7 transparent data (payload part), type device type( 回调解密后的A7透传数据(payload部分),type设备类型) | |||||
| */ | |||||
| -(void)bluetoothReceiveData:(NSData *)playload deviceType:(ELSupportDeviceType)type{ | |||||
| if (type == ELSupportDeviceTypeBodyFatScale /*|| type == ELSupportDeviceTypeBLE_WIFIScale*/) { | |||||
| //根据体脂秤协议解析playload部分 | |||||
| } | |||||
| } | |||||
| /** | |||||
| The special A6 data will only be received by the supported devices, and the complete A6 data (A6 is not encrypted) is passed to the subclass resolution. | |||||
| 特殊的A6数据,只有支持的设备才会收到,将完整A6数据(A6不加密)传给子类解析 | |||||
| ELSupportDeviceType support: | |||||
| ELSupportDeviceTypeBodyFatScale | |||||
| ELSupportDeviceTypeSmartLock | |||||
| */ | |||||
| -(void)bluetoothBackA6Data:(NSData *)data withClassId:(ELSupportDeviceType)type{ | |||||
| if (type == ELSupportDeviceTypeBodyFatScale /*|| type == ELSupportDeviceTypeBLE_WIFIScale*/) { | |||||
| //根据体脂秤协议解析data部分 | |||||
| } | |||||
| } | |||||
| /** | |||||
| Callback to scan special devices that can be bound, such as door locks(回调扫描到的可以绑定的特殊设备,如门锁) | |||||
| */ | |||||
| -(void)bluetoothScanCanBindSpecialPeripherals:(NSArray *)peripherals{ | |||||
| //特殊数据:这个方法目前只有门锁会用到 | |||||
| } | |||||
| /** | |||||
| Callback device basic information(回调设备基本信息) | |||||
| @param data Device basic information payload data (length is 16 bytes)(设备基本信息pabyload数据(长度为16个byte)) | |||||
| */ | |||||
| -(void)bluetoothReceiveBasicInfoPayloadData:(NSData *)data{ | |||||
| //特殊数据:门锁和胎压监测会用到,需根据具体协议解析 | |||||
| } | |||||
| #pragma mark ============ 发送数据给蓝牙 ============== | |||||
| -(void)subBleSendA6Data:(NSData *)data{ | |||||
| [self sendCmdToMCUWithA6PayloadData:data]; | |||||
| } | |||||
| -(void)subBleSendA7Data:(NSData *)payload{ | |||||
| [self sendCmdToMCUWithA7PayloadData:payload deviceType:(ELSupportDeviceTypeBodyFatScale)]; | |||||
| } | |||||
| @end |
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="0sa-4L-yEo"> | |||||
| <device id="retina6_1" orientation="portrait" appearance="light"/> | |||||
| <dependencies> | |||||
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/> | |||||
| <capability name="Safe area layout guides" minToolsVersion="9.0"/> | |||||
| <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | |||||
| </dependencies> | |||||
| <scenes> | |||||
| <!--AiLinkBleSDK--> | |||||
| <scene sceneID="tne-QT-ifu"> | |||||
| <objects> | |||||
| <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController"> | |||||
| <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> | |||||
| <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> | |||||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | |||||
| <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | |||||
| <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | |||||
| </view> | |||||
| <navigationItem key="navigationItem" title="AiLinkBleSDK" id="xuc-kS-VAC"> | |||||
| <barButtonItem key="backBarButtonItem" title="Back" id="1KB-6k-EVp"/> | |||||
| </navigationItem> | |||||
| </viewController> | |||||
| <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> | |||||
| </objects> | |||||
| <point key="canvasLocation" x="1047.8260869565217" y="137.94642857142856"/> | |||||
| </scene> | |||||
| <!--Navigation Controller--> | |||||
| <scene sceneID="YsI-e1-hcJ"> | |||||
| <objects> | |||||
| <navigationController automaticallyAdjustsScrollViewInsets="NO" id="0sa-4L-yEo" sceneMemberID="viewController"> | |||||
| <toolbarItems/> | |||||
| <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Rxy-eQ-EUU"> | |||||
| <rect key="frame" x="0.0" y="44" width="414" height="44"/> | |||||
| <autoresizingMask key="autoresizingMask"/> | |||||
| </navigationBar> | |||||
| <nil name="viewControllers"/> | |||||
| <connections> | |||||
| <segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="zhi-FC-KEN"/> | |||||
| </connections> | |||||
| </navigationController> | |||||
| <placeholder placeholderIdentifier="IBFirstResponder" id="vUu-Ht-Of2" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> | |||||
| </objects> | |||||
| <point key="canvasLocation" x="137.68115942028987" y="137.94642857142856"/> | |||||
| </scene> | |||||
| </scenes> | |||||
| </document> |
| Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry | |||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
| of this software and associated documentation files (the "Software"), to deal | |||||
| in the Software without restriction, including without limitation the rights | |||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||||
| copies of the Software, and to permit persons to whom the Software is | |||||
| furnished to do so, subject to the following conditions: | |||||
| The above copyright notice and this permission notice shall be included in | |||||
| all copies or substantial portions of the Software. | |||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||||
| THE SOFTWARE. |
| // | |||||
| // MASCompositeConstraint.h | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 21/07/13. | |||||
| // Copyright (c) 2013 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASConstraint.h" | |||||
| #import "MASUtilities.h" | |||||
| /** | |||||
| * A group of MASConstraint objects | |||||
| */ | |||||
| @interface MASCompositeConstraint : MASConstraint | |||||
| /** | |||||
| * Creates a composite with a predefined array of children | |||||
| * | |||||
| * @param children child MASConstraints | |||||
| * | |||||
| * @return a composite constraint | |||||
| */ | |||||
| - (id)initWithChildren:(NSArray *)children; | |||||
| @end |
| // | |||||
| // MASCompositeConstraint.m | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 21/07/13. | |||||
| // Copyright (c) 2013 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASCompositeConstraint.h" | |||||
| #import "MASConstraint+Private.h" | |||||
| @interface MASCompositeConstraint () <MASConstraintDelegate> | |||||
| @property (nonatomic, strong) id mas_key; | |||||
| @property (nonatomic, strong) NSMutableArray *childConstraints; | |||||
| @end | |||||
| @implementation MASCompositeConstraint | |||||
| - (id)initWithChildren:(NSArray *)children { | |||||
| self = [super init]; | |||||
| if (!self) return nil; | |||||
| _childConstraints = [children mutableCopy]; | |||||
| for (MASConstraint *constraint in _childConstraints) { | |||||
| constraint.delegate = self; | |||||
| } | |||||
| return self; | |||||
| } | |||||
| #pragma mark - MASConstraintDelegate | |||||
| - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { | |||||
| NSUInteger index = [self.childConstraints indexOfObject:constraint]; | |||||
| NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); | |||||
| [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; | |||||
| } | |||||
| - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { | |||||
| id<MASConstraintDelegate> strongDelegate = self.delegate; | |||||
| MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; | |||||
| newConstraint.delegate = self; | |||||
| [self.childConstraints addObject:newConstraint]; | |||||
| return newConstraint; | |||||
| } | |||||
| #pragma mark - NSLayoutConstraint multiplier proxies | |||||
| - (MASConstraint * (^)(CGFloat))multipliedBy { | |||||
| return ^id(CGFloat multiplier) { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.multipliedBy(multiplier); | |||||
| } | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(CGFloat))dividedBy { | |||||
| return ^id(CGFloat divider) { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.dividedBy(divider); | |||||
| } | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| #pragma mark - MASLayoutPriority proxy | |||||
| - (MASConstraint * (^)(MASLayoutPriority))priority { | |||||
| return ^id(MASLayoutPriority priority) { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.priority(priority); | |||||
| } | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| #pragma mark - NSLayoutRelation proxy | |||||
| - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { | |||||
| return ^id(id attr, NSLayoutRelation relation) { | |||||
| for (MASConstraint *constraint in self.childConstraints.copy) { | |||||
| constraint.equalToWithRelation(attr, relation); | |||||
| } | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| #pragma mark - attribute chaining | |||||
| - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { | |||||
| [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; | |||||
| return self; | |||||
| } | |||||
| #pragma mark - Animator proxy | |||||
| #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) | |||||
| - (MASConstraint *)animator { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| [constraint animator]; | |||||
| } | |||||
| return self; | |||||
| } | |||||
| #endif | |||||
| #pragma mark - debug helpers | |||||
| - (MASConstraint * (^)(id))key { | |||||
| return ^id(id key) { | |||||
| self.mas_key = key; | |||||
| int i = 0; | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); | |||||
| } | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| #pragma mark - NSLayoutConstraint constant setters | |||||
| - (void)setInsets:(MASEdgeInsets)insets { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.insets = insets; | |||||
| } | |||||
| } | |||||
| - (void)setInset:(CGFloat)inset { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.inset = inset; | |||||
| } | |||||
| } | |||||
| - (void)setOffset:(CGFloat)offset { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.offset = offset; | |||||
| } | |||||
| } | |||||
| - (void)setSizeOffset:(CGSize)sizeOffset { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.sizeOffset = sizeOffset; | |||||
| } | |||||
| } | |||||
| - (void)setCenterOffset:(CGPoint)centerOffset { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.centerOffset = centerOffset; | |||||
| } | |||||
| } | |||||
| #pragma mark - MASConstraint | |||||
| - (void)activate { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| [constraint activate]; | |||||
| } | |||||
| } | |||||
| - (void)deactivate { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| [constraint deactivate]; | |||||
| } | |||||
| } | |||||
| - (void)install { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| constraint.updateExisting = self.updateExisting; | |||||
| [constraint install]; | |||||
| } | |||||
| } | |||||
| - (void)uninstall { | |||||
| for (MASConstraint *constraint in self.childConstraints) { | |||||
| [constraint uninstall]; | |||||
| } | |||||
| } | |||||
| @end |
| // | |||||
| // MASConstraint+Private.h | |||||
| // Masonry | |||||
| // | |||||
| // Created by Nick Tymchenko on 29/04/14. | |||||
| // Copyright (c) 2014 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASConstraint.h" | |||||
| @protocol MASConstraintDelegate; | |||||
| @interface MASConstraint () | |||||
| /** | |||||
| * Whether or not to check for an existing constraint instead of adding constraint | |||||
| */ | |||||
| @property (nonatomic, assign) BOOL updateExisting; | |||||
| /** | |||||
| * Usually MASConstraintMaker but could be a parent MASConstraint | |||||
| */ | |||||
| @property (nonatomic, weak) id<MASConstraintDelegate> delegate; | |||||
| /** | |||||
| * Based on a provided value type, is equal to calling: | |||||
| * NSNumber - setOffset: | |||||
| * NSValue with CGPoint - setPointOffset: | |||||
| * NSValue with CGSize - setSizeOffset: | |||||
| * NSValue with MASEdgeInsets - setInsets: | |||||
| */ | |||||
| - (void)setLayoutConstantWithValue:(NSValue *)value; | |||||
| @end | |||||
| @interface MASConstraint (Abstract) | |||||
| /** | |||||
| * Sets the constraint relation to given NSLayoutRelation | |||||
| * returns a block which accepts one of the following: | |||||
| * MASViewAttribute, UIView, NSValue, NSArray | |||||
| * see readme for more details. | |||||
| */ | |||||
| - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; | |||||
| /** | |||||
| * Override to set a custom chaining behaviour | |||||
| */ | |||||
| - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; | |||||
| @end | |||||
| @protocol MASConstraintDelegate <NSObject> | |||||
| /** | |||||
| * Notifies the delegate when the constraint needs to be replaced with another constraint. For example | |||||
| * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks | |||||
| */ | |||||
| - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; | |||||
| - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; | |||||
| @end |
| // | |||||
| // MASConstraint.h | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 22/07/13. | |||||
| // Copyright (c) 2013 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASUtilities.h" | |||||
| /** | |||||
| * Enables Constraints to be created with chainable syntax | |||||
| * Constraint can represent single NSLayoutConstraint (MASViewConstraint) | |||||
| * or a group of NSLayoutConstraints (MASComposisteConstraint) | |||||
| */ | |||||
| @interface MASConstraint : NSObject | |||||
| // Chaining Support | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant, | |||||
| * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following | |||||
| * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight | |||||
| */ | |||||
| - (MASConstraint * (^)(MASEdgeInsets insets))insets; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant, | |||||
| * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following | |||||
| * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight | |||||
| */ | |||||
| - (MASConstraint * (^)(CGFloat inset))inset; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant, | |||||
| * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following | |||||
| * NSLayoutAttributeWidth, NSLayoutAttributeHeight | |||||
| */ | |||||
| - (MASConstraint * (^)(CGSize offset))sizeOffset; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant, | |||||
| * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following | |||||
| * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY | |||||
| */ | |||||
| - (MASConstraint * (^)(CGPoint offset))centerOffset; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant | |||||
| */ | |||||
| - (MASConstraint * (^)(CGFloat offset))offset; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant based on a value type | |||||
| */ | |||||
| - (MASConstraint * (^)(NSValue *value))valueOffset; | |||||
| /** | |||||
| * Sets the NSLayoutConstraint multiplier property | |||||
| */ | |||||
| - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; | |||||
| /** | |||||
| * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy | |||||
| */ | |||||
| - (MASConstraint * (^)(CGFloat divider))dividedBy; | |||||
| /** | |||||
| * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority | |||||
| */ | |||||
| - (MASConstraint * (^)(MASLayoutPriority priority))priority; | |||||
| /** | |||||
| * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow | |||||
| */ | |||||
| - (MASConstraint * (^)(void))priorityLow; | |||||
| /** | |||||
| * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium | |||||
| */ | |||||
| - (MASConstraint * (^)(void))priorityMedium; | |||||
| /** | |||||
| * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh | |||||
| */ | |||||
| - (MASConstraint * (^)(void))priorityHigh; | |||||
| /** | |||||
| * Sets the constraint relation to NSLayoutRelationEqual | |||||
| * returns a block which accepts one of the following: | |||||
| * MASViewAttribute, UIView, NSValue, NSArray | |||||
| * see readme for more details. | |||||
| */ | |||||
| - (MASConstraint * (^)(id attr))equalTo; | |||||
| /** | |||||
| * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual | |||||
| * returns a block which accepts one of the following: | |||||
| * MASViewAttribute, UIView, NSValue, NSArray | |||||
| * see readme for more details. | |||||
| */ | |||||
| - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; | |||||
| /** | |||||
| * Sets the constraint relation to NSLayoutRelationLessThanOrEqual | |||||
| * returns a block which accepts one of the following: | |||||
| * MASViewAttribute, UIView, NSValue, NSArray | |||||
| * see readme for more details. | |||||
| */ | |||||
| - (MASConstraint * (^)(id attr))lessThanOrEqualTo; | |||||
| /** | |||||
| * Optional semantic property which has no effect but improves the readability of constraint | |||||
| */ | |||||
| - (MASConstraint *)with; | |||||
| /** | |||||
| * Optional semantic property which has no effect but improves the readability of constraint | |||||
| */ | |||||
| - (MASConstraint *)and; | |||||
| /** | |||||
| * Creates a new MASCompositeConstraint with the called attribute and reciever | |||||
| */ | |||||
| - (MASConstraint *)left; | |||||
| - (MASConstraint *)top; | |||||
| - (MASConstraint *)right; | |||||
| - (MASConstraint *)bottom; | |||||
| - (MASConstraint *)leading; | |||||
| - (MASConstraint *)trailing; | |||||
| - (MASConstraint *)width; | |||||
| - (MASConstraint *)height; | |||||
| - (MASConstraint *)centerX; | |||||
| - (MASConstraint *)centerY; | |||||
| - (MASConstraint *)baseline; | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) | |||||
| - (MASConstraint *)firstBaseline; | |||||
| - (MASConstraint *)lastBaseline; | |||||
| #endif | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) | |||||
| - (MASConstraint *)leftMargin; | |||||
| - (MASConstraint *)rightMargin; | |||||
| - (MASConstraint *)topMargin; | |||||
| - (MASConstraint *)bottomMargin; | |||||
| - (MASConstraint *)leadingMargin; | |||||
| - (MASConstraint *)trailingMargin; | |||||
| - (MASConstraint *)centerXWithinMargins; | |||||
| - (MASConstraint *)centerYWithinMargins; | |||||
| #endif | |||||
| /** | |||||
| * Sets the constraint debug name | |||||
| */ | |||||
| - (MASConstraint * (^)(id key))key; | |||||
| // NSLayoutConstraint constant Setters | |||||
| // for use outside of mas_updateConstraints/mas_makeConstraints blocks | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant, | |||||
| * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following | |||||
| * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight | |||||
| */ | |||||
| - (void)setInsets:(MASEdgeInsets)insets; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant, | |||||
| * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following | |||||
| * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight | |||||
| */ | |||||
| - (void)setInset:(CGFloat)inset; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant, | |||||
| * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following | |||||
| * NSLayoutAttributeWidth, NSLayoutAttributeHeight | |||||
| */ | |||||
| - (void)setSizeOffset:(CGSize)sizeOffset; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant, | |||||
| * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following | |||||
| * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY | |||||
| */ | |||||
| - (void)setCenterOffset:(CGPoint)centerOffset; | |||||
| /** | |||||
| * Modifies the NSLayoutConstraint constant | |||||
| */ | |||||
| - (void)setOffset:(CGFloat)offset; | |||||
| // NSLayoutConstraint Installation support | |||||
| #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) | |||||
| /** | |||||
| * Whether or not to go through the animator proxy when modifying the constraint | |||||
| */ | |||||
| @property (nonatomic, copy, readonly) MASConstraint *animator; | |||||
| #endif | |||||
| /** | |||||
| * Activates an NSLayoutConstraint if it's supported by an OS. | |||||
| * Invokes install otherwise. | |||||
| */ | |||||
| - (void)activate; | |||||
| /** | |||||
| * Deactivates previously installed/activated NSLayoutConstraint. | |||||
| */ | |||||
| - (void)deactivate; | |||||
| /** | |||||
| * Creates a NSLayoutConstraint and adds it to the appropriate view. | |||||
| */ | |||||
| - (void)install; | |||||
| /** | |||||
| * Removes previously installed NSLayoutConstraint | |||||
| */ | |||||
| - (void)uninstall; | |||||
| @end | |||||
| /** | |||||
| * Convenience auto-boxing macros for MASConstraint methods. | |||||
| * | |||||
| * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. | |||||
| * A potential drawback of this is that the unprefixed macros will appear in global scope. | |||||
| */ | |||||
| #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) | |||||
| #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) | |||||
| #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) | |||||
| #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) | |||||
| #ifdef MAS_SHORTHAND_GLOBALS | |||||
| #define equalTo(...) mas_equalTo(__VA_ARGS__) | |||||
| #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) | |||||
| #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) | |||||
| #define offset(...) mas_offset(__VA_ARGS__) | |||||
| #endif | |||||
| @interface MASConstraint (AutoboxingSupport) | |||||
| /** | |||||
| * Aliases to corresponding relation methods (for shorthand macros) | |||||
| * Also needed to aid autocompletion | |||||
| */ | |||||
| - (MASConstraint * (^)(id attr))mas_equalTo; | |||||
| - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; | |||||
| - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; | |||||
| /** | |||||
| * A dummy method to aid autocompletion | |||||
| */ | |||||
| - (MASConstraint * (^)(id offset))mas_offset; | |||||
| @end |
| // | |||||
| // MASConstraint.m | |||||
| // Masonry | |||||
| // | |||||
| // Created by Nick Tymchenko on 1/20/14. | |||||
| // | |||||
| #import "MASConstraint.h" | |||||
| #import "MASConstraint+Private.h" | |||||
| #define MASMethodNotImplemented() \ | |||||
| @throw [NSException exceptionWithName:NSInternalInconsistencyException \ | |||||
| reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ | |||||
| userInfo:nil] | |||||
| @implementation MASConstraint | |||||
| #pragma mark - Init | |||||
| - (id)init { | |||||
| NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); | |||||
| return [super init]; | |||||
| } | |||||
| #pragma mark - NSLayoutRelation proxies | |||||
| - (MASConstraint * (^)(id))equalTo { | |||||
| return ^id(id attribute) { | |||||
| return self.equalToWithRelation(attribute, NSLayoutRelationEqual); | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(id))mas_equalTo { | |||||
| return ^id(id attribute) { | |||||
| return self.equalToWithRelation(attribute, NSLayoutRelationEqual); | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(id))greaterThanOrEqualTo { | |||||
| return ^id(id attribute) { | |||||
| return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { | |||||
| return ^id(id attribute) { | |||||
| return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(id))lessThanOrEqualTo { | |||||
| return ^id(id attribute) { | |||||
| return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { | |||||
| return ^id(id attribute) { | |||||
| return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); | |||||
| }; | |||||
| } | |||||
| #pragma mark - MASLayoutPriority proxies | |||||
| - (MASConstraint * (^)(void))priorityLow { | |||||
| return ^id{ | |||||
| self.priority(MASLayoutPriorityDefaultLow); | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(void))priorityMedium { | |||||
| return ^id{ | |||||
| self.priority(MASLayoutPriorityDefaultMedium); | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(void))priorityHigh { | |||||
| return ^id{ | |||||
| self.priority(MASLayoutPriorityDefaultHigh); | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| #pragma mark - NSLayoutConstraint constant proxies | |||||
| - (MASConstraint * (^)(MASEdgeInsets))insets { | |||||
| return ^id(MASEdgeInsets insets){ | |||||
| self.insets = insets; | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(CGFloat))inset { | |||||
| return ^id(CGFloat inset){ | |||||
| self.inset = inset; | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(CGSize))sizeOffset { | |||||
| return ^id(CGSize offset) { | |||||
| self.sizeOffset = offset; | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(CGPoint))centerOffset { | |||||
| return ^id(CGPoint offset) { | |||||
| self.centerOffset = offset; | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(CGFloat))offset { | |||||
| return ^id(CGFloat offset){ | |||||
| self.offset = offset; | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(NSValue *value))valueOffset { | |||||
| return ^id(NSValue *offset) { | |||||
| NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); | |||||
| [self setLayoutConstantWithValue:offset]; | |||||
| return self; | |||||
| }; | |||||
| } | |||||
| - (MASConstraint * (^)(id offset))mas_offset { | |||||
| // Will never be called due to macro | |||||
| return nil; | |||||
| } | |||||
| #pragma mark - NSLayoutConstraint constant setter | |||||
| - (void)setLayoutConstantWithValue:(NSValue *)value { | |||||
| if ([value isKindOfClass:NSNumber.class]) { | |||||
| self.offset = [(NSNumber *)value doubleValue]; | |||||
| } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { | |||||
| CGPoint point; | |||||
| [value getValue:&point]; | |||||
| self.centerOffset = point; | |||||
| } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { | |||||
| CGSize size; | |||||
| [value getValue:&size]; | |||||
| self.sizeOffset = size; | |||||
| } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { | |||||
| MASEdgeInsets insets; | |||||
| [value getValue:&insets]; | |||||
| self.insets = insets; | |||||
| } else { | |||||
| NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); | |||||
| } | |||||
| } | |||||
| #pragma mark - Semantic properties | |||||
| - (MASConstraint *)with { | |||||
| return self; | |||||
| } | |||||
| - (MASConstraint *)and { | |||||
| return self; | |||||
| } | |||||
| #pragma mark - Chaining | |||||
| - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { | |||||
| MASMethodNotImplemented(); | |||||
| } | |||||
| - (MASConstraint *)left { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; | |||||
| } | |||||
| - (MASConstraint *)top { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; | |||||
| } | |||||
| - (MASConstraint *)right { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; | |||||
| } | |||||
| - (MASConstraint *)bottom { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; | |||||
| } | |||||
| - (MASConstraint *)leading { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; | |||||
| } | |||||
| - (MASConstraint *)trailing { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; | |||||
| } | |||||
| - (MASConstraint *)width { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; | |||||
| } | |||||
| - (MASConstraint *)height { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; | |||||
| } | |||||
| - (MASConstraint *)centerX { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; | |||||
| } | |||||
| - (MASConstraint *)centerY { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; | |||||
| } | |||||
| - (MASConstraint *)baseline { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; | |||||
| } | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) | |||||
| - (MASConstraint *)firstBaseline { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; | |||||
| } | |||||
| - (MASConstraint *)lastBaseline { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; | |||||
| } | |||||
| #endif | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) | |||||
| - (MASConstraint *)leftMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; | |||||
| } | |||||
| - (MASConstraint *)rightMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; | |||||
| } | |||||
| - (MASConstraint *)topMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; | |||||
| } | |||||
| - (MASConstraint *)bottomMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; | |||||
| } | |||||
| - (MASConstraint *)leadingMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; | |||||
| } | |||||
| - (MASConstraint *)trailingMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; | |||||
| } | |||||
| - (MASConstraint *)centerXWithinMargins { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; | |||||
| } | |||||
| - (MASConstraint *)centerYWithinMargins { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; | |||||
| } | |||||
| #endif | |||||
| #pragma mark - Abstract | |||||
| - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } | |||||
| - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } | |||||
| - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } | |||||
| - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } | |||||
| - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } | |||||
| - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } | |||||
| - (void)setInset:(CGFloat __unused)inset { MASMethodNotImplemented(); } | |||||
| - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } | |||||
| - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } | |||||
| - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } | |||||
| #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) | |||||
| - (MASConstraint *)animator { MASMethodNotImplemented(); } | |||||
| #endif | |||||
| - (void)activate { MASMethodNotImplemented(); } | |||||
| - (void)deactivate { MASMethodNotImplemented(); } | |||||
| - (void)install { MASMethodNotImplemented(); } | |||||
| - (void)uninstall { MASMethodNotImplemented(); } | |||||
| @end |
| // | |||||
| // MASConstraintMaker.h | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 20/07/13. | |||||
| // Copyright (c) 2013 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASConstraint.h" | |||||
| #import "MASUtilities.h" | |||||
| typedef NS_OPTIONS(NSInteger, MASAttribute) { | |||||
| MASAttributeLeft = 1 << NSLayoutAttributeLeft, | |||||
| MASAttributeRight = 1 << NSLayoutAttributeRight, | |||||
| MASAttributeTop = 1 << NSLayoutAttributeTop, | |||||
| MASAttributeBottom = 1 << NSLayoutAttributeBottom, | |||||
| MASAttributeLeading = 1 << NSLayoutAttributeLeading, | |||||
| MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, | |||||
| MASAttributeWidth = 1 << NSLayoutAttributeWidth, | |||||
| MASAttributeHeight = 1 << NSLayoutAttributeHeight, | |||||
| MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, | |||||
| MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, | |||||
| MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) | |||||
| MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline, | |||||
| MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline, | |||||
| #endif | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) | |||||
| MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, | |||||
| MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, | |||||
| MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, | |||||
| MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, | |||||
| MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, | |||||
| MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, | |||||
| MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, | |||||
| MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, | |||||
| #endif | |||||
| }; | |||||
| /** | |||||
| * Provides factory methods for creating MASConstraints. | |||||
| * Constraints are collected until they are ready to be installed | |||||
| * | |||||
| */ | |||||
| @interface MASConstraintMaker : NSObject | |||||
| /** | |||||
| * The following properties return a new MASViewConstraint | |||||
| * with the first item set to the makers associated view and the appropriate MASViewAttribute | |||||
| */ | |||||
| @property (nonatomic, strong, readonly) MASConstraint *left; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *top; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *right; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *bottom; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *leading; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *trailing; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *width; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *height; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *centerX; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *centerY; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *baseline; | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) | |||||
| @property (nonatomic, strong, readonly) MASConstraint *firstBaseline; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *lastBaseline; | |||||
| #endif | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) | |||||
| @property (nonatomic, strong, readonly) MASConstraint *leftMargin; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *rightMargin; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *topMargin; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; | |||||
| @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; | |||||
| #endif | |||||
| /** | |||||
| * Returns a block which creates a new MASCompositeConstraint with the first item set | |||||
| * to the makers associated view and children corresponding to the set bits in the | |||||
| * MASAttribute parameter. Combine multiple attributes via binary-or. | |||||
| */ | |||||
| @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); | |||||
| /** | |||||
| * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges | |||||
| * which generates the appropriate MASViewConstraint children (top, left, bottom, right) | |||||
| * with the first item set to the makers associated view | |||||
| */ | |||||
| @property (nonatomic, strong, readonly) MASConstraint *edges; | |||||
| /** | |||||
| * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize | |||||
| * which generates the appropriate MASViewConstraint children (width, height) | |||||
| * with the first item set to the makers associated view | |||||
| */ | |||||
| @property (nonatomic, strong, readonly) MASConstraint *size; | |||||
| /** | |||||
| * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter | |||||
| * which generates the appropriate MASViewConstraint children (centerX, centerY) | |||||
| * with the first item set to the makers associated view | |||||
| */ | |||||
| @property (nonatomic, strong, readonly) MASConstraint *center; | |||||
| /** | |||||
| * Whether or not to check for an existing constraint instead of adding constraint | |||||
| */ | |||||
| @property (nonatomic, assign) BOOL updateExisting; | |||||
| /** | |||||
| * Whether or not to remove existing constraints prior to installing | |||||
| */ | |||||
| @property (nonatomic, assign) BOOL removeExisting; | |||||
| /** | |||||
| * initialises the maker with a default view | |||||
| * | |||||
| * @param view any MASConstraint are created with this view as the first item | |||||
| * | |||||
| * @return a new MASConstraintMaker | |||||
| */ | |||||
| - (id)initWithView:(MAS_VIEW *)view; | |||||
| /** | |||||
| * Calls install method on any MASConstraints which have been created by this maker | |||||
| * | |||||
| * @return an array of all the installed MASConstraints | |||||
| */ | |||||
| - (NSArray *)install; | |||||
| - (MASConstraint * (^)(dispatch_block_t))group; | |||||
| @end |
| // | |||||
| // MASConstraintMaker.m | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 20/07/13. | |||||
| // Copyright (c) 2013 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASConstraintMaker.h" | |||||
| #import "MASViewConstraint.h" | |||||
| #import "MASCompositeConstraint.h" | |||||
| #import "MASConstraint+Private.h" | |||||
| #import "MASViewAttribute.h" | |||||
| #import "View+MASAdditions.h" | |||||
| @interface MASConstraintMaker () <MASConstraintDelegate> | |||||
| @property (nonatomic, weak) MAS_VIEW *view; | |||||
| @property (nonatomic, strong) NSMutableArray *constraints; | |||||
| @end | |||||
| @implementation MASConstraintMaker | |||||
| - (id)initWithView:(MAS_VIEW *)view { | |||||
| self = [super init]; | |||||
| if (!self) return nil; | |||||
| self.view = view; | |||||
| self.constraints = NSMutableArray.new; | |||||
| return self; | |||||
| } | |||||
| - (NSArray *)install { | |||||
| if (self.removeExisting) { | |||||
| NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view]; | |||||
| for (MASConstraint *constraint in installedConstraints) { | |||||
| [constraint uninstall]; | |||||
| } | |||||
| } | |||||
| NSArray *constraints = self.constraints.copy; | |||||
| for (MASConstraint *constraint in constraints) { | |||||
| constraint.updateExisting = self.updateExisting; | |||||
| [constraint install]; | |||||
| } | |||||
| [self.constraints removeAllObjects]; | |||||
| return constraints; | |||||
| } | |||||
| #pragma mark - MASConstraintDelegate | |||||
| - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { | |||||
| NSUInteger index = [self.constraints indexOfObject:constraint]; | |||||
| NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); | |||||
| [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint]; | |||||
| } | |||||
| - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { | |||||
| MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute]; | |||||
| MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute]; | |||||
| if ([constraint isKindOfClass:MASViewConstraint.class]) { | |||||
| //replace with composite constraint | |||||
| NSArray *children = @[constraint, newConstraint]; | |||||
| MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; | |||||
| compositeConstraint.delegate = self; | |||||
| [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint]; | |||||
| return compositeConstraint; | |||||
| } | |||||
| if (!constraint) { | |||||
| newConstraint.delegate = self; | |||||
| [self.constraints addObject:newConstraint]; | |||||
| } | |||||
| return newConstraint; | |||||
| } | |||||
| - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs { | |||||
| __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading | |||||
| | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX | |||||
| | MASAttributeCenterY | MASAttributeBaseline | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) | |||||
| | MASAttributeFirstBaseline | MASAttributeLastBaseline | |||||
| #endif | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) | |||||
| | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin | |||||
| | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins | |||||
| | MASAttributeCenterYWithinMargins | |||||
| #endif | |||||
| ); | |||||
| NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); | |||||
| NSMutableArray *attributes = [NSMutableArray array]; | |||||
| if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; | |||||
| if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; | |||||
| if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; | |||||
| if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; | |||||
| if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; | |||||
| if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; | |||||
| if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; | |||||
| if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; | |||||
| if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; | |||||
| if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; | |||||
| if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) | |||||
| if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline]; | |||||
| if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline]; | |||||
| #endif | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) | |||||
| if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin]; | |||||
| if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin]; | |||||
| if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin]; | |||||
| if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin]; | |||||
| if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin]; | |||||
| if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin]; | |||||
| if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins]; | |||||
| if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins]; | |||||
| #endif | |||||
| NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; | |||||
| for (MASViewAttribute *a in attributes) { | |||||
| [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; | |||||
| } | |||||
| MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; | |||||
| constraint.delegate = self; | |||||
| [self.constraints addObject:constraint]; | |||||
| return constraint; | |||||
| } | |||||
| #pragma mark - standard Attributes | |||||
| - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { | |||||
| return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; | |||||
| } | |||||
| - (MASConstraint *)left { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; | |||||
| } | |||||
| - (MASConstraint *)top { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; | |||||
| } | |||||
| - (MASConstraint *)right { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; | |||||
| } | |||||
| - (MASConstraint *)bottom { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; | |||||
| } | |||||
| - (MASConstraint *)leading { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; | |||||
| } | |||||
| - (MASConstraint *)trailing { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; | |||||
| } | |||||
| - (MASConstraint *)width { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; | |||||
| } | |||||
| - (MASConstraint *)height { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; | |||||
| } | |||||
| - (MASConstraint *)centerX { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; | |||||
| } | |||||
| - (MASConstraint *)centerY { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; | |||||
| } | |||||
| - (MASConstraint *)baseline { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; | |||||
| } | |||||
| - (MASConstraint *(^)(MASAttribute))attributes { | |||||
| return ^(MASAttribute attrs){ | |||||
| return [self addConstraintWithAttributes:attrs]; | |||||
| }; | |||||
| } | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) | |||||
| - (MASConstraint *)firstBaseline { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; | |||||
| } | |||||
| - (MASConstraint *)lastBaseline { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; | |||||
| } | |||||
| #endif | |||||
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) | |||||
| - (MASConstraint *)leftMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; | |||||
| } | |||||
| - (MASConstraint *)rightMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; | |||||
| } | |||||
| - (MASConstraint *)topMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; | |||||
| } | |||||
| - (MASConstraint *)bottomMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; | |||||
| } | |||||
| - (MASConstraint *)leadingMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; | |||||
| } | |||||
| - (MASConstraint *)trailingMargin { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; | |||||
| } | |||||
| - (MASConstraint *)centerXWithinMargins { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; | |||||
| } | |||||
| - (MASConstraint *)centerYWithinMargins { | |||||
| return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; | |||||
| } | |||||
| #endif | |||||
| #pragma mark - composite Attributes | |||||
| - (MASConstraint *)edges { | |||||
| return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; | |||||
| } | |||||
| - (MASConstraint *)size { | |||||
| return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; | |||||
| } | |||||
| - (MASConstraint *)center { | |||||
| return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; | |||||
| } | |||||
| #pragma mark - grouping | |||||
| - (MASConstraint *(^)(dispatch_block_t group))group { | |||||
| return ^id(dispatch_block_t group) { | |||||
| NSInteger previousCount = self.constraints.count; | |||||
| group(); | |||||
| NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; | |||||
| MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; | |||||
| constraint.delegate = self; | |||||
| return constraint; | |||||
| }; | |||||
| } | |||||
| @end |
| // | |||||
| // MASLayoutConstraint.h | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 3/08/13. | |||||
| // Copyright (c) 2013 Jonas Budelmann. All rights reserved. | |||||
| // | |||||
| #import "MASUtilities.h" | |||||
| /** | |||||
| * When you are debugging or printing the constraints attached to a view this subclass | |||||
| * makes it easier to identify which constraints have been created via Masonry | |||||
| */ | |||||
| @interface MASLayoutConstraint : NSLayoutConstraint | |||||
| /** | |||||
| * a key to associate with this constraint | |||||
| */ | |||||
| @property (nonatomic, strong) id mas_key; | |||||
| @end |
| // | |||||
| // MASLayoutConstraint.m | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 3/08/13. | |||||
| // Copyright (c) 2013 Jonas Budelmann. All rights reserved. | |||||
| // | |||||
| #import "MASLayoutConstraint.h" | |||||
| @implementation MASLayoutConstraint | |||||
| @end |
| // | |||||
| // MASUtilities.h | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 19/08/13. | |||||
| // Copyright (c) 2013 Jonas Budelmann. All rights reserved. | |||||
| // | |||||
| #import <Foundation/Foundation.h> | |||||
| #if TARGET_OS_IPHONE || TARGET_OS_TV | |||||
| #import <UIKit/UIKit.h> | |||||
| #define MAS_VIEW UIView | |||||
| #define MAS_VIEW_CONTROLLER UIViewController | |||||
| #define MASEdgeInsets UIEdgeInsets | |||||
| typedef UILayoutPriority MASLayoutPriority; | |||||
| static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; | |||||
| static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; | |||||
| static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; | |||||
| static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; | |||||
| static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; | |||||
| #elif TARGET_OS_MAC | |||||
| #import <AppKit/AppKit.h> | |||||
| #define MAS_VIEW NSView | |||||
| #define MASEdgeInsets NSEdgeInsets | |||||
| typedef NSLayoutPriority MASLayoutPriority; | |||||
| static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; | |||||
| static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; | |||||
| static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; | |||||
| static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; | |||||
| static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; | |||||
| static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; | |||||
| static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; | |||||
| static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; | |||||
| #endif | |||||
| /** | |||||
| * Allows you to attach keys to objects matching the variable names passed. | |||||
| * | |||||
| * view1.mas_key = @"view1", view2.mas_key = @"view2"; | |||||
| * | |||||
| * is equivalent to: | |||||
| * | |||||
| * MASAttachKeys(view1, view2); | |||||
| */ | |||||
| #define MASAttachKeys(...) \ | |||||
| { \ | |||||
| NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ | |||||
| for (id key in keyPairs.allKeys) { \ | |||||
| id obj = keyPairs[key]; \ | |||||
| NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ | |||||
| @"Cannot attach mas_key to %@", obj); \ | |||||
| [obj setMas_key:key]; \ | |||||
| } \ | |||||
| } | |||||
| /** | |||||
| * Used to create object hashes | |||||
| * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html | |||||
| */ | |||||
| #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) | |||||
| #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) | |||||
| /** | |||||
| * Given a scalar or struct value, wraps it in NSValue | |||||
| * Based on EXPObjectify: https://github.com/specta/expecta | |||||
| */ | |||||
| static inline id _MASBoxValue(const char *type, ...) { | |||||
| va_list v; | |||||
| va_start(v, type); | |||||
| id obj = nil; | |||||
| if (strcmp(type, @encode(id)) == 0) { | |||||
| id actual = va_arg(v, id); | |||||
| obj = actual; | |||||
| } else if (strcmp(type, @encode(CGPoint)) == 0) { | |||||
| CGPoint actual = (CGPoint)va_arg(v, CGPoint); | |||||
| obj = [NSValue value:&actual withObjCType:type]; | |||||
| } else if (strcmp(type, @encode(CGSize)) == 0) { | |||||
| CGSize actual = (CGSize)va_arg(v, CGSize); | |||||
| obj = [NSValue value:&actual withObjCType:type]; | |||||
| } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { | |||||
| MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); | |||||
| obj = [NSValue value:&actual withObjCType:type]; | |||||
| } else if (strcmp(type, @encode(double)) == 0) { | |||||
| double actual = (double)va_arg(v, double); | |||||
| obj = [NSNumber numberWithDouble:actual]; | |||||
| } else if (strcmp(type, @encode(float)) == 0) { | |||||
| float actual = (float)va_arg(v, double); | |||||
| obj = [NSNumber numberWithFloat:actual]; | |||||
| } else if (strcmp(type, @encode(int)) == 0) { | |||||
| int actual = (int)va_arg(v, int); | |||||
| obj = [NSNumber numberWithInt:actual]; | |||||
| } else if (strcmp(type, @encode(long)) == 0) { | |||||
| long actual = (long)va_arg(v, long); | |||||
| obj = [NSNumber numberWithLong:actual]; | |||||
| } else if (strcmp(type, @encode(long long)) == 0) { | |||||
| long long actual = (long long)va_arg(v, long long); | |||||
| obj = [NSNumber numberWithLongLong:actual]; | |||||
| } else if (strcmp(type, @encode(short)) == 0) { | |||||
| short actual = (short)va_arg(v, int); | |||||
| obj = [NSNumber numberWithShort:actual]; | |||||
| } else if (strcmp(type, @encode(char)) == 0) { | |||||
| char actual = (char)va_arg(v, int); | |||||
| obj = [NSNumber numberWithChar:actual]; | |||||
| } else if (strcmp(type, @encode(bool)) == 0) { | |||||
| bool actual = (bool)va_arg(v, int); | |||||
| obj = [NSNumber numberWithBool:actual]; | |||||
| } else if (strcmp(type, @encode(unsigned char)) == 0) { | |||||
| unsigned char actual = (unsigned char)va_arg(v, unsigned int); | |||||
| obj = [NSNumber numberWithUnsignedChar:actual]; | |||||
| } else if (strcmp(type, @encode(unsigned int)) == 0) { | |||||
| unsigned int actual = (unsigned int)va_arg(v, unsigned int); | |||||
| obj = [NSNumber numberWithUnsignedInt:actual]; | |||||
| } else if (strcmp(type, @encode(unsigned long)) == 0) { | |||||
| unsigned long actual = (unsigned long)va_arg(v, unsigned long); | |||||
| obj = [NSNumber numberWithUnsignedLong:actual]; | |||||
| } else if (strcmp(type, @encode(unsigned long long)) == 0) { | |||||
| unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); | |||||
| obj = [NSNumber numberWithUnsignedLongLong:actual]; | |||||
| } else if (strcmp(type, @encode(unsigned short)) == 0) { | |||||
| unsigned short actual = (unsigned short)va_arg(v, unsigned int); | |||||
| obj = [NSNumber numberWithUnsignedShort:actual]; | |||||
| } | |||||
| va_end(v); | |||||
| return obj; | |||||
| } | |||||
| #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) |
| // | |||||
| // MASViewAttribute.h | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 21/07/13. | |||||
| // Copyright (c) 2013 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASUtilities.h" | |||||
| /** | |||||
| * An immutable tuple which stores the view and the related NSLayoutAttribute. | |||||
| * Describes part of either the left or right hand side of a constraint equation | |||||
| */ | |||||
| @interface MASViewAttribute : NSObject | |||||
| /** | |||||
| * The view which the reciever relates to. Can be nil if item is not a view. | |||||
| */ | |||||
| @property (nonatomic, weak, readonly) MAS_VIEW *view; | |||||
| /** | |||||
| * The item which the reciever relates to. | |||||
| */ | |||||
| @property (nonatomic, weak, readonly) id item; | |||||
| /** | |||||
| * The attribute which the reciever relates to | |||||
| */ | |||||
| @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; | |||||
| /** | |||||
| * Convenience initializer. | |||||
| */ | |||||
| - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; | |||||
| /** | |||||
| * The designated initializer. | |||||
| */ | |||||
| - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; | |||||
| /** | |||||
| * Determine whether the layoutAttribute is a size attribute | |||||
| * | |||||
| * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight | |||||
| */ | |||||
| - (BOOL)isSizeAttribute; | |||||
| @end |
| // | |||||
| // MASViewAttribute.m | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 21/07/13. | |||||
| // Copyright (c) 2013 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASViewAttribute.h" | |||||
| @implementation MASViewAttribute | |||||
| - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { | |||||
| self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; | |||||
| return self; | |||||
| } | |||||
| - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { | |||||
| self = [super init]; | |||||
| if (!self) return nil; | |||||
| _view = view; | |||||
| _item = item; | |||||
| _layoutAttribute = layoutAttribute; | |||||
| return self; | |||||
| } | |||||
| - (BOOL)isSizeAttribute { | |||||
| return self.layoutAttribute == NSLayoutAttributeWidth | |||||
| || self.layoutAttribute == NSLayoutAttributeHeight; | |||||
| } | |||||
| - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { | |||||
| if ([viewAttribute isKindOfClass:self.class]) { | |||||
| return self.view == viewAttribute.view | |||||
| && self.layoutAttribute == viewAttribute.layoutAttribute; | |||||
| } | |||||
| return [super isEqual:viewAttribute]; | |||||
| } | |||||
| - (NSUInteger)hash { | |||||
| return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; | |||||
| } | |||||
| @end |
| // | |||||
| // MASViewConstraint.h | |||||
| // Masonry | |||||
| // | |||||
| // Created by Jonas Budelmann on 20/07/13. | |||||
| // Copyright (c) 2013 cloudling. All rights reserved. | |||||
| // | |||||
| #import "MASViewAttribute.h" | |||||
| #import "MASConstraint.h" | |||||
| #import "MASLayoutConstraint.h" | |||||
| #import "MASUtilities.h" | |||||
| /** | |||||
| * A single constraint. | |||||
| * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view | |||||
| */ | |||||
| @interface MASViewConstraint : MASConstraint <NSCopying> | |||||
| /** | |||||
| * First item/view and first attribute of the NSLayoutConstraint | |||||
| */ | |||||
| @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; | |||||
| /** | |||||
| * Second item/view and second attribute of the NSLayoutConstraint | |||||
| */ | |||||
| @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; | |||||
| /** | |||||
| * initialises the MASViewConstraint with the first part of the equation | |||||
| * | |||||
| * @param firstViewAttribute view.mas_left, view.mas_width etc. | |||||
| * | |||||
| * @return a new view constraint | |||||
| */ | |||||
| - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; | |||||
| /** | |||||
| * Returns all MASViewConstraints installed with this view as a first item. | |||||
| * | |||||
| * @param view A view to retrieve constraints for. | |||||
| * | |||||
| * @return An array of MASViewConstraints. | |||||
| */ | |||||
| + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; | |||||
| @end |