From: liangzhenying <867174124@qq.com>
Date: Wed, 28 Feb 2024 07:20:11 +0000 (+0800)
Subject: 添加扫描功能
X-Git-Tag: é¿éé´æ~36
X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=c44107c4a03b5100cbe80d7e88b79c8f15017608;p=mirrors%2FMouseSdk-MacOS.git
添加扫描功能
---
diff --git "a/Document/MouseSdk\346\216\245\345\217\243\346\226\207\346\241\243.md" "b/Document/MouseSdk\346\216\245\345\217\243\346\226\207\346\241\243.md"
new file mode 100644
index 0000000..7e3b602
--- /dev/null
+++ "b/Document/MouseSdk\346\216\245\345\217\243\346\226\207\346\241\243.md"
@@ -0,0 +1,126 @@
+# MouseSDKæ¥å£ææ¡£
+
+
+
+## ææ¡£ä¿®æ¹è®°å½
+
+| çæ¬ | ä¿®æ¹å
容 | ä¿®æ¹äºº | ä¿®æ¹æ¶é´ |
+| ----- | -------- | ------ | ---------- |
+| 1.0.0 | åå§çæ¬ | æ¢æ¯è¥ | 2024-01-31 |
+
+
+
+
+
+## å¼å
¥ä¾èµåº
+
+å° AliIotConnectKit.framework æ·»å è¿é¡¹ç®ä¸ã
+
+## ç¸å
³æéé
ç½®
+
+å 为sdkç¨å°èçæéï¼æä»¥éè¦å¨info.plistè¿è¡ç¸å
³é
ç½®
+
+```xml
+
+
+NSBluetoothAlwaysUsageDescription
+Appéè¦æ¨çåæ,æè½è®¿é®èç
+```
+
+
+
+## èçç¸å
³æ¥å£
+
+```objective-c
+/// é
ç½®SDK,æ¯æ¬¡è¿æ¥ä¸èç设å¤åè°ç¨
+- (void)configSDK;
+
+/// æ¶å° èç æ°æ®
+/// - Parameter currData: èçæ°æ®
+- (void)handleReceivedData:(NSData *)data;
+
+/// æå¼è®¾å¤è°ç¨ç»æå·¥ä½
+/// - Parameter completed: æ¸
çç»æåè°
+- (void)done:(void(^ _Nonnull )(id _Nullable param))completed;
+```
+
+## èçç¸å
³ä»£ç
+
+AliIotSDKCallbackProtocol
+
+```objective-c
+/// ååºæ°æ®ï¼è¿åç»ä¸å±è°ç¨
+/// - Parameters:
+/// - currData: å½åååºå»çæ°æ®
+/// - device: èçè®¾å¤ MAC
+/// - error: å
å¤æç©ºï¼ååéåºå»
+- (void)handleSendData:(NSData *)currData toDevice:(NSData *)mac error:(NSError * _Nullable)error;
+
+@optional
+/// åå§åç»æ
+/// - Parameter isFinish: æ¯å¦å®æåå§å
+- (void)sdkInitResult:(BOOL)isFinish;
+
+/// è¾åºæ¥å¿
+/// - Parameter log: æ¥å¿ä¿¡æ¯
+- (void)handleLog:(NSString *)log;
+```
+
+## 示ä¾
+
+- 设置代ç
+
+ ```objective-c
+ AliIot.shareInstance.delegate = self;
+ AliIot.shareInstance.mapDelegate = self;
+ ```
+
+
+
+- èçè¿æ¥æååï¼éè¦ä¸èç设å¤ååMTUãæä»¥å¿
é¡»æ³¨ææ¯è¿æ¥ä¸èç设å¤ååè°ç¨configSDKæ¹æ³ã
+
+ ```objective-c
+ //é
ç½®sdk
+ - (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
+ for (CBCharacteristic *characteristic in service.characteristics){
+ if ([characteristic.UUID.UUIDString isEqualToString:@"FED7"]) {
+ self.writeCha = characteristic;
+ //æ¾å°åå
¥çuuidåï¼è°ç¨sdké
ç½®æ¹æ³
+ [AliIot.shareInstance configSDK];
+ }
+ if ([characteristic.UUID.UUIDString isEqualToString:@"FED8"]) {
+ self.notifyCha = characteristic;
+ [peripheral setNotifyValue:YES forCharacteristic:characteristic];
+ }
+ }
+ }
+ ```
+
+- èçè¿æ¥æå¼åï¼å¿
é¡»è°ç¨doneæ¹æ³å®ææ¸
çå·¥ä½
+
+ ```objective-c
+ -(void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{
+ //èçæå¼è¦è°ç¨è¯¥æ¹æ³æ¸
çsdkæ°æ®
+ [AliIot.shareInstance done:^(id _Nullable param) {
+
+ }];
+ }
+ ```
+
+- æ¶å°èç设å¤ä¼ è¿æ¥çæ°æ®ï¼ä¼ ç»sdkå¤ç
+
+ ```objective-c
+ - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
+ //æ¶å°èç设å¤åéè¿æ¥çæ°æ®ï¼è½¬åç»sdkå¤ç
+ [AliIot.shareInstance handleReceivedData:characteristic.value];
+ }
+ ```
+
+
+
+
+
+
+
+
+
diff --git a/MouseSdk/AiSdk/AiSdk.h b/MouseSdk/AiSdk/AiSdk.h
new file mode 100644
index 0000000..b6744b9
--- /dev/null
+++ b/MouseSdk/AiSdk/AiSdk.h
@@ -0,0 +1,18 @@
+//
+// AiSdk.h
+// AiSdk
+//
+// Created by incar on 2024/2/19.
+//
+
+#import
+
+//! Project version number for AiSdk.
+FOUNDATION_EXPORT double AiSdkVersionNumber;
+
+//! Project version string for AiSdk.
+FOUNDATION_EXPORT const unsigned char AiSdkVersionString[];
+
+// In this header, you should import all the public headers of your framework using statements like #import
+
+
diff --git a/MouseSdk/MouseSdk.xcodeproj/project.pbxproj b/MouseSdk/MouseSdk.xcodeproj/project.pbxproj
index b5581ee..e4681eb 100644
--- a/MouseSdk/MouseSdk.xcodeproj/project.pbxproj
+++ b/MouseSdk/MouseSdk.xcodeproj/project.pbxproj
@@ -18,6 +18,12 @@
18BF1E052B81E18800B8D90F /* ConnectKitVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1E042B81E18800B8D90F /* ConnectKitVC.swift */; };
18BF1E222B83066200B8D90F /* BleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1E212B83066200B8D90F /* BleManager.m */; };
18BF1E762B832D2E00B8D90F /* ScanVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1E752B832D2E00B8D90F /* ScanVC.m */; };
+ 18BF1E7F2B83472D00B8D90F /* BleTools.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1E7E2B83472D00B8D90F /* BleTools.m */; };
+ 18BF1E8A2B8362D300B8D90F /* AiSdk.h in Headers */ = {isa = PBXBuildFile; fileRef = 18BF1E892B8362D300B8D90F /* AiSdk.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 18BF1E8D2B8362D300B8D90F /* AiSdk.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18BF1E872B8362D300B8D90F /* AiSdk.framework */; };
+ 18BF1E8E2B8362D300B8D90F /* AiSdk.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 18BF1E872B8362D300B8D90F /* AiSdk.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+ 18F3235D2B8ED78300CABA2E /* ScanCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F3235C2B8ED78300CABA2E /* ScanCell.m */; };
+ 18F323622B8F13D700CABA2E /* LogVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F323612B8F13D600CABA2E /* LogVC.m */; };
8A6657BD1406314D4CBB7CEF /* libPods-MouseSdk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0311DF3AD67ED792549B96BD /* libPods-MouseSdk.a */; };
/* End PBXBuildFile section */
@@ -36,8 +42,29 @@
remoteGlobalIDString = 18BF1DC92B81AB7C00B8D90F;
remoteInfo = MouseSdk;
};
+ 18BF1E8B2B8362D300B8D90F /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 18BF1DC22B81AB7C00B8D90F /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 18BF1E862B8362D300B8D90F;
+ remoteInfo = AiSdk;
+ };
/* End PBXContainerItemProxy section */
+/* Begin PBXCopyFilesBuildPhase section */
+ 18BF1E8F2B8362D300B8D90F /* Embed Frameworks */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 10;
+ files = (
+ 18BF1E8E2B8362D300B8D90F /* AiSdk.framework in Embed Frameworks */,
+ );
+ name = "Embed Frameworks";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
/* Begin PBXFileReference section */
0311DF3AD67ED792549B96BD /* libPods-MouseSdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MouseSdk.a"; sourceTree = BUILT_PRODUCTS_DIR; };
18BF1DCA2B81AB7C00B8D90F /* MouseSdk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MouseSdk.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -60,6 +87,14 @@
18BF1E212B83066200B8D90F /* BleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BleManager.m; sourceTree = ""; };
18BF1E742B832D2E00B8D90F /* ScanVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanVC.h; sourceTree = ""; };
18BF1E752B832D2E00B8D90F /* ScanVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanVC.m; sourceTree = ""; };
+ 18BF1E7D2B83472D00B8D90F /* BleTools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BleTools.h; sourceTree = ""; };
+ 18BF1E7E2B83472D00B8D90F /* BleTools.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BleTools.m; sourceTree = ""; };
+ 18BF1E872B8362D300B8D90F /* AiSdk.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AiSdk.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 18BF1E892B8362D300B8D90F /* AiSdk.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AiSdk.h; sourceTree = ""; };
+ 18F3235B2B8ED78300CABA2E /* ScanCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanCell.h; sourceTree = ""; };
+ 18F3235C2B8ED78300CABA2E /* ScanCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanCell.m; sourceTree = ""; };
+ 18F323602B8F13D600CABA2E /* LogVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LogVC.h; sourceTree = ""; };
+ 18F323612B8F13D600CABA2E /* LogVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LogVC.m; sourceTree = ""; };
51DE1118FCBA78EBEE6FE2CD /* Pods-MouseSdk.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MouseSdk.release.xcconfig"; path = "Target Support Files/Pods-MouseSdk/Pods-MouseSdk.release.xcconfig"; sourceTree = ""; };
811936622867478806C1A8BB /* Pods-MouseSdk.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MouseSdk.debug.xcconfig"; path = "Target Support Files/Pods-MouseSdk/Pods-MouseSdk.debug.xcconfig"; sourceTree = ""; };
/* End PBXFileReference section */
@@ -70,6 +105,7 @@
buildActionMask = 2147483647;
files = (
8A6657BD1406314D4CBB7CEF /* libPods-MouseSdk.a in Frameworks */,
+ 18BF1E8D2B8362D300B8D90F /* AiSdk.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -87,6 +123,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 18BF1E842B8362D300B8D90F /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -97,6 +140,7 @@
18BF1DCC2B81AB7C00B8D90F /* MouseSdk */,
18BF1DE22B81AB8000B8D90F /* MouseSdkTests */,
18BF1DEC2B81AB8000B8D90F /* MouseSdkUITests */,
+ 18BF1E882B8362D300B8D90F /* AiSdk */,
18BF1DCB2B81AB7C00B8D90F /* Products */,
723588BAA058E1012143D29F /* Pods */,
543EC4E5F9FC310D6B850947 /* Frameworks */,
@@ -109,6 +153,7 @@
18BF1DCA2B81AB7C00B8D90F /* MouseSdk.app */,
18BF1DDF2B81AB8000B8D90F /* MouseSdkTests.xctest */,
18BF1DE92B81AB8000B8D90F /* MouseSdkUITests.xctest */,
+ 18BF1E872B8362D300B8D90F /* AiSdk.framework */,
);
name = Products;
sourceTree = "";
@@ -123,6 +168,10 @@
18BF1DD12B81AB7C00B8D90F /* ViewController.m */,
18BF1E742B832D2E00B8D90F /* ScanVC.h */,
18BF1E752B832D2E00B8D90F /* ScanVC.m */,
+ 18F3235B2B8ED78300CABA2E /* ScanCell.h */,
+ 18F3235C2B8ED78300CABA2E /* ScanCell.m */,
+ 18F323602B8F13D600CABA2E /* LogVC.h */,
+ 18F323612B8F13D600CABA2E /* LogVC.m */,
18BF1E042B81E18800B8D90F /* ConnectKitVC.swift */,
18BF1DD32B81AB7F00B8D90F /* Assets.xcassets */,
18BF1DD52B81AB7F00B8D90F /* Main.storyboard */,
@@ -162,10 +211,20 @@
children = (
18BF1E202B83066200B8D90F /* BleManager.h */,
18BF1E212B83066200B8D90F /* BleManager.m */,
+ 18BF1E7D2B83472D00B8D90F /* BleTools.h */,
+ 18BF1E7E2B83472D00B8D90F /* BleTools.m */,
);
path = Ble;
sourceTree = "";
};
+ 18BF1E882B8362D300B8D90F /* AiSdk */ = {
+ isa = PBXGroup;
+ children = (
+ 18BF1E892B8362D300B8D90F /* AiSdk.h */,
+ );
+ path = AiSdk;
+ sourceTree = "";
+ };
543EC4E5F9FC310D6B850947 /* Frameworks */ = {
isa = PBXGroup;
children = (
@@ -185,6 +244,17 @@
};
/* End PBXGroup section */
+/* Begin PBXHeadersBuildPhase section */
+ 18BF1E822B8362D300B8D90F /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 18BF1E8A2B8362D300B8D90F /* AiSdk.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXHeadersBuildPhase section */
+
/* Begin PBXNativeTarget section */
18BF1DC92B81AB7C00B8D90F /* MouseSdk */ = {
isa = PBXNativeTarget;
@@ -194,10 +264,12 @@
18BF1DC62B81AB7C00B8D90F /* Sources */,
18BF1DC72B81AB7C00B8D90F /* Frameworks */,
18BF1DC82B81AB7C00B8D90F /* Resources */,
+ 18BF1E8F2B8362D300B8D90F /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
+ 18BF1E8C2B8362D300B8D90F /* PBXTargetDependency */,
);
name = MouseSdk;
productName = MouseSdk;
@@ -240,6 +312,24 @@
productReference = 18BF1DE92B81AB8000B8D90F /* MouseSdkUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
+ 18BF1E862B8362D300B8D90F /* AiSdk */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 18BF1E922B8362D300B8D90F /* Build configuration list for PBXNativeTarget "AiSdk" */;
+ buildPhases = (
+ 18BF1E822B8362D300B8D90F /* Headers */,
+ 18BF1E832B8362D300B8D90F /* Sources */,
+ 18BF1E842B8362D300B8D90F /* Frameworks */,
+ 18BF1E852B8362D300B8D90F /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = AiSdk;
+ productName = AiSdk;
+ productReference = 18BF1E872B8362D300B8D90F /* AiSdk.framework */;
+ productType = "com.apple.product-type.framework";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -261,6 +351,9 @@
CreatedOnToolsVersion = 15.0.1;
TestTargetID = 18BF1DC92B81AB7C00B8D90F;
};
+ 18BF1E862B8362D300B8D90F = {
+ CreatedOnToolsVersion = 15.0.1;
+ };
};
};
buildConfigurationList = 18BF1DC52B81AB7C00B8D90F /* Build configuration list for PBXProject "MouseSdk" */;
@@ -279,6 +372,7 @@
18BF1DC92B81AB7C00B8D90F /* MouseSdk */,
18BF1DDE2B81AB8000B8D90F /* MouseSdkTests */,
18BF1DE82B81AB8000B8D90F /* MouseSdkUITests */,
+ 18BF1E862B8362D300B8D90F /* AiSdk */,
);
};
/* End PBXProject section */
@@ -307,6 +401,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 18BF1E852B8362D300B8D90F /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
@@ -339,7 +440,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 18BF1E7F2B83472D00B8D90F /* BleTools.m in Sources */,
18BF1E052B81E18800B8D90F /* ConnectKitVC.swift in Sources */,
+ 18F3235D2B8ED78300CABA2E /* ScanCell.m in Sources */,
+ 18F323622B8F13D700CABA2E /* LogVC.m in Sources */,
18BF1DD22B81AB7C00B8D90F /* ViewController.m in Sources */,
18BF1DD92B81AB7F00B8D90F /* main.m in Sources */,
18BF1E762B832D2E00B8D90F /* ScanVC.m in Sources */,
@@ -365,6 +469,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 18BF1E832B8362D300B8D90F /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
@@ -378,6 +489,11 @@
target = 18BF1DC92B81AB7C00B8D90F /* MouseSdk */;
targetProxy = 18BF1DEA2B81AB8000B8D90F /* PBXContainerItemProxy */;
};
+ 18BF1E8C2B8362D300B8D90F /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 18BF1E862B8362D300B8D90F /* AiSdk */;
+ targetProxy = 18BF1E8B2B8362D300B8D90F /* PBXContainerItemProxy */;
+ };
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@@ -640,6 +756,68 @@
};
name = Release;
};
+ 18BF1E902B8362D300B8D90F /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ CURRENT_PROJECT_VERSION = 1;
+ DEFINES_MODULE = YES;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ ENABLE_MODULE_VERIFIER = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_KEY_NSHumanReadableCopyright = "";
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ "@loader_path/Frameworks",
+ );
+ MARKETING_VERSION = 1.0;
+ MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
+ MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
+ PRODUCT_BUNDLE_IDENTIFIER = zhihuishixun.AiSdk;
+ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
+ SKIP_INSTALL = YES;
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ VERSIONING_SYSTEM = "apple-generic";
+ VERSION_INFO_PREFIX = "";
+ };
+ name = Debug;
+ };
+ 18BF1E912B8362D300B8D90F /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ CURRENT_PROJECT_VERSION = 1;
+ DEFINES_MODULE = YES;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ ENABLE_MODULE_VERIFIER = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_KEY_NSHumanReadableCopyright = "";
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ "@loader_path/Frameworks",
+ );
+ MARKETING_VERSION = 1.0;
+ MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
+ MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
+ PRODUCT_BUNDLE_IDENTIFIER = zhihuishixun.AiSdk;
+ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
+ SKIP_INSTALL = YES;
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ VERSIONING_SYSTEM = "apple-generic";
+ VERSION_INFO_PREFIX = "";
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -679,6 +857,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 18BF1E922B8362D300B8D90F /* Build configuration list for PBXNativeTarget "AiSdk" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 18BF1E902B8362D300B8D90F /* Debug */,
+ 18BF1E912B8362D300B8D90F /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 18BF1DC22B81AB7C00B8D90F /* Project object */;
diff --git a/MouseSdk/MouseSdk.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist b/MouseSdk/MouseSdk.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist
index 7f0eeb4..80e0c4f 100644
--- a/MouseSdk/MouseSdk.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/MouseSdk/MouseSdk.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -4,6 +4,11 @@
SchemeUserState
+ AiSdk.xcscheme_^#shared#^_
+
+ orderHint
+ 1
+
MouseSdk.xcscheme_^#shared#^_
orderHint
diff --git a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate
index 4c1524b..838f345 100644
Binary files a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate and b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/MouseSdk/MouseSdk/Ble/BleManager.h b/MouseSdk/MouseSdk/Ble/BleManager.h
index 532ca42..7e3cc9b 100644
--- a/MouseSdk/MouseSdk/Ble/BleManager.h
+++ b/MouseSdk/MouseSdk/Ble/BleManager.h
@@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)connectPeripheral:(CBPeripheral *)peripheral;
- (void)lpConnect;
+
+- (void)sendToBle:(NSData *)data;
@end
NS_ASSUME_NONNULL_END
diff --git a/MouseSdk/MouseSdk/Ble/BleManager.m b/MouseSdk/MouseSdk/Ble/BleManager.m
index 852d87a..7f8db83 100644
--- a/MouseSdk/MouseSdk/Ble/BleManager.m
+++ b/MouseSdk/MouseSdk/Ble/BleManager.m
@@ -5,6 +5,8 @@
// Created by incar on 2024/1/30.
//
+
+
#import "BleManager.h"
@interface BleManager ()
@@ -71,6 +73,10 @@
if ([self.scanArray containsObject:peripheral]){
return;
}
+ if(peripheral.name == nil){
+ return;
+ }
+ NSLog(@"%@",peripheral.name);
[self.scanArray insertObject:peripheral atIndex:0];
if(self.discoverDevice){
self.discoverDevice(peripheral, advertisementData);
@@ -94,8 +100,9 @@
}
#pragma mark - CBPeripheralDelegate
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
- for (CBService *service in peripheral.services)
+ for (CBService *service in peripheral.services){
[peripheral discoverCharacteristics:@[[CBUUID UUIDWithString:@"FED7"],[CBUUID UUIDWithString:@"FED8"]] forService:service];
+ }
}
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
@@ -119,50 +126,7 @@
}
#pragma mark - AliIotSDKCallbackProtocol
-- (void)handleSendData:(NSData *)data toDevice:(id)device error:(NSError *)error {
- NSLog(@"[send] %@",data);
- if (!error) {
- //æ¶å°sdkåè°çæ°æ®ï¼åéç»èç设å¤
- [self.connectPeripheral writeValue:data forCharacteristic:self.writeCha type:CBCharacteristicWriteWithoutResponse];
- }
-}
-- (void)handleLog:(NSString *)log {
- NSLog(@"[sdk log] %@",log);
-}
-
-- (void)sdkInitResult:(BOOL)isFinish{
- self.isSdkInitSuccess = isFinish;
- NSString *log = isFinish?@"åå§å宿":@"åå§å失败";
- NSLog(@"%@",log);
-}
-
-#pragma mark - AliIotSdkMapCallbackProtocol
-- (void)addCollect:(nonnull NSString *)collectionId content:(nonnull NSString *)jsonString {
- //ä¼ å°æå¡å¨æè
æ¬å°ç¼å
-}
-
-- (void)addTrajectory:(nonnull NSString *)trajectoryId content:(nonnull NSString *)jsonString {
- //ä¼ å°æå¡å¨æè
æ¬å°ç¼å
-}
-
-- (void)getCollectListView:(NSInteger)page pageSize:(NSInteger)pageSize {
- //仿å¡å¨æè
æ¬å°ç¼åè·åæ¶èæ°æ®ï¼ç¶åå°æ°æ®ä¼ ç»sdk
-// [AliIot.shareInstance sendCollectList:jsonString];
-}
-
-- (void)getTrajectoryListView:(NSInteger)page pageSize:(NSInteger)pageSize {
- //仿å¡å¨æè
æ¬å°ç¼åè·åè½¨è¿¹æ°æ®ï¼ç¶åå°æ°æ®ä¼ ç»sdk
-// [AliIot.shareInstance sendTrajectoryList:jsonString];
-}
-
-- (void)removeCollect:(nonnull NSString *)collectionId {
- //仿å¡å¨æè
æ¬å°ç¼åç§»é¤è®°å½
-}
-
-- (void)removeTrajectory:(nonnull NSString *)trajectoryId {
- //仿å¡å¨æè
æ¬å°ç¼åç§»é¤è®°å½
-}
#pragma mark - public
- (void)startScanDevice{
@@ -180,33 +144,18 @@
//é£é¸½ä¹¦è¯·æ±è¿æ¥
- (void)lpConnect{
- NSData *data = [self tysm_dataWithHexString:@"000401"];
- NSMutableData *mData = NSMutableData.data;
- uint8_t cmd = 0x7f;
- [mData appendBytes:&cmd length:1];
- [mData appendData:data];
+// NSData *data = [self tysm_dataWithHexString:@"000000000401"];
+// NSMutableData *mData = NSMutableData.data;
+// uint8_t cmd = 0x7f;
+// [mData appendBytes:&cmd length:1];
+// [mData appendData:data];
// [AliIot.shareInstance handleReceivedData:mData.copy];
}
-- (NSData *)tysm_dataWithHexString:(NSString *)hexStr {
- hexStr = [hexStr stringByReplacingOccurrencesOfString:@" " withString:@""];
- hexStr = [hexStr lowercaseString];
- NSUInteger len = hexStr.length;
- if (!len) return nil;
- unichar *buf = malloc(sizeof(unichar) * len);
- if (!buf) return nil;
- [hexStr getCharacters:buf range:NSMakeRange(0, len)];
-
- NSMutableData *result = [NSMutableData data];
- unsigned char bytes;
- char str[3] = { '\0', '\0', '\0' };
- int i;
- for (i = 0; i < len / 2; i++) {
- str[0] = buf[i * 2];
- str[1] = buf[i * 2 + 1];
- bytes = strtol(str, NULL, 16);
- [result appendBytes:&bytes length:1];
- }
- free(buf);
- return result;
+
+- (void)sendToBle:(NSData *)data{
+ NSLog(@"[send] %@",data);
+ [self.connectPeripheral writeValue:data forCharacteristic:self.writeCha type:CBCharacteristicWriteWithoutResponse];
}
+
+
@end
diff --git a/MouseSdk/MouseSdk/Ble/BleTools.h b/MouseSdk/MouseSdk/Ble/BleTools.h
new file mode 100644
index 0000000..c58f62a
--- /dev/null
+++ b/MouseSdk/MouseSdk/Ble/BleTools.h
@@ -0,0 +1,16 @@
+//
+// BleTools.h
+// MouseSdk
+//
+// Created by incar on 2024/2/19.
+//
+
+#import
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface BleTools : NSObject
++ (NSData *)dataWithHexString:(NSString *)hexStr;
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/MouseSdk/MouseSdk/Ble/BleTools.m b/MouseSdk/MouseSdk/Ble/BleTools.m
new file mode 100644
index 0000000..2995dc2
--- /dev/null
+++ b/MouseSdk/MouseSdk/Ble/BleTools.m
@@ -0,0 +1,33 @@
+//
+// BleTools.m
+// MouseSdk
+//
+// Created by incar on 2024/2/19.
+//
+
+#import "BleTools.h"
+
+@implementation BleTools
++ (NSData *)dataWithHexString:(NSString *)hexStr {
+ hexStr = [hexStr stringByReplacingOccurrencesOfString:@" " withString:@""];
+ hexStr = [hexStr lowercaseString];
+ NSUInteger len = hexStr.length;
+ if (!len) return nil;
+ unichar *buf = malloc(sizeof(unichar) * len);
+ if (!buf) return nil;
+ [hexStr getCharacters:buf range:NSMakeRange(0, len)];
+
+ NSMutableData *result = [NSMutableData data];
+ unsigned char bytes;
+ char str[3] = { '\0', '\0', '\0' };
+ int i;
+ for (i = 0; i < len / 2; i++) {
+ str[0] = buf[i * 2];
+ str[1] = buf[i * 2 + 1];
+ bytes = strtol(str, NULL, 16);
+ [result appendBytes:&bytes length:1];
+ }
+ free(buf);
+ return result;
+}
+@end
diff --git a/MouseSdk/MouseSdk/LogVC.h b/MouseSdk/MouseSdk/LogVC.h
new file mode 100644
index 0000000..6be04f6
--- /dev/null
+++ b/MouseSdk/MouseSdk/LogVC.h
@@ -0,0 +1,16 @@
+//
+// LogVC.h
+// MouseSdk
+//
+// Created by incar on 2024/2/28.
+//
+
+#import
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface LogVC : NSViewController
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/MouseSdk/MouseSdk/LogVC.m b/MouseSdk/MouseSdk/LogVC.m
new file mode 100644
index 0000000..4f3de2d
--- /dev/null
+++ b/MouseSdk/MouseSdk/LogVC.m
@@ -0,0 +1,35 @@
+//
+// LogVC.m
+// MouseSdk
+//
+// Created by incar on 2024/2/28.
+//
+
+#import "LogVC.h"
+#import "Ble/BleManager.h"
+#import "Ble/BleTools.h"
+@interface LogVC()
+@property (nonatomic,strong) NSTextField *textField;
+@end
+
+@implementation LogVC
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ // Do view setup here.
+ [self setupViews];
+ [self setupBle];
+}
+- (void)loadView{
+ self.title = @"æ«æè®¾å¤";
+ self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
+}
+- (void)setupViews{
+
+}
+- (void)setupBle{
+ BleManager *manager = [BleManager shared];
+ __weak typeof(self) weakSelf= self;
+
+}
+
+@end
diff --git a/MouseSdk/MouseSdk/ScanCell.h b/MouseSdk/MouseSdk/ScanCell.h
new file mode 100644
index 0000000..bb8a265
--- /dev/null
+++ b/MouseSdk/MouseSdk/ScanCell.h
@@ -0,0 +1,17 @@
+//
+// ScanCell.h
+// MouseSdk
+//
+// Created by incar on 2024/2/28.
+//
+
+#import
+#import
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ScanCell : NSTableCellView
+@property(nonatomic,strong)CBPeripheral *peripheral;
+@property(nonatomic,strong)void (^connecCallBack)(CBPeripheral *peripheral);
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/MouseSdk/MouseSdk/ScanCell.m b/MouseSdk/MouseSdk/ScanCell.m
new file mode 100644
index 0000000..a0bf16f
--- /dev/null
+++ b/MouseSdk/MouseSdk/ScanCell.m
@@ -0,0 +1,63 @@
+//
+// ScanCell.m
+// MouseSdk
+//
+// Created by incar on 2024/2/28.
+//
+
+#import "ScanCell.h"
+
+@interface ScanCell()
+@property(nonatomic,strong)NSTextField *label;
+@property(nonatomic,strong)NSButton *connectBtn;
+@end
+
+@implementation ScanCell
+- (instancetype)initWithFrame:(CGRect)frame
+{
+ self = [super initWithFrame:frame];
+ if (self) {
+ [self setupView];
+ }
+ return self;
+}
+
+- (void)drawRect:(NSRect)dirtyRect{
+ [super drawRect:dirtyRect];
+}
+
+- (void)setupView{
+ NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(0, 10, 200, 35)];
+ label.editable = NO;
+ label.bordered = NO;
+ label.stringValue = @"000000";
+ self.label = label;
+ [self addSubview:label];
+
+ NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(250, 5, 100, 35)];
+ btn.bordered = true;
+ btn.title = @"è¿æ¥";
+ [btn setTarget:self];
+ [btn setAction:@selector(connetAction)];
+ btn.state = 1;
+ [self addSubview:btn];
+ self.connectBtn = btn;
+
+
+}
+
+-(void)setPeripheral:(CBPeripheral *)peripheral{
+ _peripheral = peripheral;
+ self.label.stringValue = peripheral.name;
+ [self.label sizeToFit];
+ CGRect f = self.label.frame;
+ f.origin.y = (self.bounds.size.height - f.size.height)/2;
+ self.label.frame = f;
+}
+
+- (void)connetAction{
+ if (self.connecCallBack) {
+ self.connecCallBack(self.peripheral);
+ }
+}
+@end
diff --git a/MouseSdk/MouseSdk/ScanVC.h b/MouseSdk/MouseSdk/ScanVC.h
index a198ad7..930dbcf 100644
--- a/MouseSdk/MouseSdk/ScanVC.h
+++ b/MouseSdk/MouseSdk/ScanVC.h
@@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ScanVC : NSViewController
+
@end
NS_ASSUME_NONNULL_END
diff --git a/MouseSdk/MouseSdk/ScanVC.m b/MouseSdk/MouseSdk/ScanVC.m
index 1b3dc24..5e65855 100644
--- a/MouseSdk/MouseSdk/ScanVC.m
+++ b/MouseSdk/MouseSdk/ScanVC.m
@@ -6,16 +6,125 @@
//
#import "ScanVC.h"
-
-@interface ScanVC ()
-
+#import "ScanCell.h"
+#import "Ble/BleManager.h"
+#import "Ble/BleTools.h"
+@interface ScanVC ()
+@property (nonatomic,strong) NSTableView *tableView;
+@property (nonatomic,strong) NSMutableArray *scanArray;
@end
@implementation ScanVC
+-(NSMutableArray *)scanArray{
+ if (_scanArray == nil) {
+ _scanArray = [[NSMutableArray alloc] init];
+ }
+ return _scanArray;
+}
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
+ self.title = @"æ«æè®¾å¤";
+ [self tableViewSetting];
+ [self setupBle];
+}
+- (void)loadView{
+ self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
+}
+
+- (void)tableViewSetting{
+ CALayer *viewLayer = [CALayer layer];
+ NSView *backgroundView= [[NSView alloc]init];
+ [backgroundView setWantsLayer:YES];
+ [backgroundView setLayer:viewLayer];
+ backgroundView.layer.backgroundColor = [NSColor greenColor].CGColor;
+ [backgroundView setNeedsDisplay:YES];
+ [self.view addSubview:backgroundView];
+
+ //å®ç°tableviewçæ»å¨ææ
+ NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame:self.view.bounds];
+ scrollView.backgroundColor = [NSColor redColor];
+ [scrollView setDrawsBackground:NO];//ä¸ç»èæ¯ï¼èæ¯é»è®¤ç»æç½è²ï¼
+ [scrollView setHasVerticalScroller:YES];//æåç´æ»å¨æ¡
+ //[_tableContainer setHasHorizontalScroller:YES]; //ææ°´å¹³æ»å¨æ¡
+ scrollView.autohidesScrollers = YES;//èªå¨éèæ»å¨æ¡ï¼æ»å¨çæ¶ååºç°ï¼
+ [self.view addSubview:scrollView];
+
+ self.tableView = [[NSTableView alloc] initWithFrame:scrollView.bounds];
+ [scrollView setDocumentView:self.tableView];
+
+ NSTableColumn *column1 = [[NSTableColumn alloc] initWithIdentifier:@"columnFrist"];
+ column1.title = @"设å¤åç§°";
+ [column1 setWidth:self.tableView.bounds.size.width];
+ [self.tableView addTableColumn:column1];
+
+// self.tableView.focusRingType = NSFocusRingTypeNone;//tableviewè·å¾ç¦ç¹æ¶ç飿 ¼
+// self.tableView.selectionHighlightStyle = NSTableViewSelectionHighlightStyleRegular;//è¡é«äº®ç飿 ¼
+// self.tableView.backgroundColor = [NSColor greenColor];
+// self.tableView.usesAlternatingRowBackgroundColors = YES; //èæ¯é¢è²ç交æ¿ï¼ä¸è¡ç½è²ï¼ä¸è¡ç°è²ã设置åï¼åæ¥è®¾ç½®ç backgroundColor å°±æ æäºã
+ self.tableView.delegate = self;
+ self.tableView.dataSource = self;
+ self.tableView.gridStyleMask = NSTableViewSolidHorizontalGridLineMask;
+}
+
+- (void)setupBle{
+ BleManager *manager = [BleManager shared];
+ __weak typeof(self) weakSelf= self;
+// __weak typeof(BleManager) *weakManager = manager;
+ manager.discoverDevice = ^(CBPeripheral *peripheral,NSDictionary *advertisementData){
+ if ([weakSelf.scanArray containsObject:peripheral]){
+ return;
+ }
+ if(peripheral.name.length == 0){
+ return;
+ }
+ [weakSelf.scanArray addObject:peripheral];
+ [weakSelf.tableView reloadData];
+// NSLog(@"%@",peripheral.name);
+// iMouse Ublue_BT895x
+// if([peripheral.name isEqualToString:@"iMouse"]){
+// [weakManager connectPeripheral:peripheral];
+// [weakManager stopScanDevice];
+// }
+ };
+ manager.didConnectDevice = ^(CBPeripheral * _Nonnull peripheral) {
+ NSLog(@"è¿æ¥æå");
+ [weakSelf dismissViewController:weakSelf];
+ };
+ [manager startScanDevice];
+}
+
+- (void)connectDevice:(CBPeripheral *)peripheral{
+ [[BleManager shared] connectPeripheral:peripheral];
+}
+#pragma mark - NSTableViewDelegate,NSTableViewDataSource
+-(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
+ return self.scanArray.count;
+}
+
+-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
+// NSString *columnID = tableColumn.identifier;
+// NSString *strIdt = @"NSTableCellView";
+// NSTableCellView *cell = [tableView makeViewWithIdentifier:strIdt owner:self];
+// if (!cell) {
+// cell = [[NSTableCellView alloc]init];
+// cell.identifier = strIdt;
+// }
+// cell.wantsLayer = YES;
+// cell.textField.stringValue = [NSString stringWithFormat:@"cell %ld",(long)row];
+//
+// return cell;
+ ScanCell *cell = [[ScanCell alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 44)];
+ cell.peripheral = self.scanArray[row];
+ __weak typeof(self) weakSelf = self;
+ cell.connecCallBack = ^(CBPeripheral * _Nonnull peripheral) {
+ [weakSelf connectDevice:peripheral];
+ };
+ return cell;
+}
+-(CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row{
+ return 44;
}
@end
diff --git a/MouseSdk/MouseSdk/ViewController.m b/MouseSdk/MouseSdk/ViewController.m
index 008733b..2197b78 100644
--- a/MouseSdk/MouseSdk/ViewController.m
+++ b/MouseSdk/MouseSdk/ViewController.m
@@ -8,6 +8,7 @@
#import "ViewController.h"
#import "ScanVC.h"
#import "Ble/BleManager.h"
+#import "Ble/BleTools.h"
//#import "AliIotConnectKit/AliIotConnectKit.h"
@@ -17,37 +18,40 @@
@implementation ViewController
+
+
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
+ self.title = @"AI SDK";
{
- NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(20, 60, 100, 45)];
+ NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(100, self.view.bounds.size.height - 40, 100, 45)];
btn.bordered = true;
- btn.title = @"æ«æ"; // æé®æå
+ btn.title = @"æ«æ";
[btn setTarget:self];
- [btn setAction:@selector(scanAction)]; // æé®è§¦åçæ¹æ³
+ [btn setAction:@selector(scanAction)];
btn.state = 1;
[self.view addSubview:btn];
}
{
- NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(100, 100, 100, 45)];
+ NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(100, self.view.bounds.size.height - 150, 100, 45)];
btn.bordered = true;
- btn.title = @"fgs"; // æé®æå
+ btn.title = @"initSDK";
[btn setTarget:self];
- [btn setAction:@selector(checkFGSStatus)]; // æé®è§¦åçæ¹æ³
- btn.state = 1;
- [self.view addSubview:btn];
- }
- {
- NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(300, 100, 100, 45)];
- btn.bordered = true;
- btn.title = @"connectLp"; // æé®æå
- [btn setTarget:self];
- [btn setAction:@selector(connectLp)]; // æé®è§¦åçæ¹æ³
+ [btn setAction:@selector(initSDK)];
btn.state = 1;
[self.view addSubview:btn];
}
+// {
+// NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(300, 100, 100, 45)];
+// btn.bordered = true;
+// btn.title = @"connectLp"; // æé®æå
+// [btn setTarget:self];
+// [btn setAction:@selector(connectLp)]; // æé®è§¦åçæ¹æ³
+// btn.state = 1;
+// [self.view addSubview:btn];
+// }
[self setupBleManger];
}
@@ -59,19 +63,20 @@
}
- (void)scanAction{
- [[BleManager shared] startScanDevice];
-
+ ScanVC *vc = [[ScanVC alloc] initWithNibName:nil bundle:nil];
+ [self presentViewControllerAsModalWindow:vc];
+// [[BleManager shared] startScanDevice];
}
- (void)setupBleManger{
BleManager *manager = [BleManager shared];
- __weak typeof(ViewController) *weakSelf = self;
__weak typeof(BleManager) *weakManager = manager;
manager.discoverDevice = ^(CBPeripheral *peripheral,NSDictionary *advertisementData){
if(peripheral.name.length == 0){
return;
}
- NSLog(@"%@",peripheral.name);
- if([peripheral.name isEqualToString:@"Ublue_BT895x"]){
+// NSLog(@"%@",peripheral.name);
+// iMouse Ublue_BT895x
+ if([peripheral.name isEqualToString:@"iMouse"]){
[weakManager connectPeripheral:peripheral];
[weakManager stopScanDevice];
}
@@ -80,9 +85,11 @@
NSLog(@"è¿æ¥æå");
};
-// [manager startScanDevice];
}
-
+- (void)initSDK{
+ NSData *data = [BleTools dataWithHexString:@"0000004f0000"];
+ [[BleManager shared] sendToBle:data];
+}
//- (void)checkFGSStatus{
// [AliConnectMananger_C.shared checkFgsStateWithResult:^(BOOL isSuccess, NSDictionary * dict) {
// NSLog(@"FGSæå = %@,dict = %@",[NSNumber numberWithBool:isSuccess],dict);
diff --git a/MouseSdk/Podfile b/MouseSdk/Podfile
index b2c9051..09c0c95 100644
--- a/MouseSdk/Podfile
+++ b/MouseSdk/Podfile
@@ -1,26 +1,14 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'
-#platform :osx, '11.0'
-
-#target 'AliIotSdk' do
-# # Comment the next line if you don't want to use dynamic frameworks
-# use_frameworks!
-## platform :osx, '11.0'
-#
-# # Pods for AliIotSdk
-## pod 'NBULog'
-## pod 'fishhook'
-## pod 'Bugly'
-# target 'AliIotSdkTests' do
-# # Pods for testing
-# end
-#
-#end
+platform :osx, '11.0'
+#source 'https://kkgithub.com/CocoaPods/Specs.git'
+#source 'https://kkgithub.com/CocoaPods/Specs.git'
+# source 'https://gitee.com/mirrors/CocoaPods-Specs.git'
target 'MouseSdk' do
# Comment the next line if you don't want to use dynamic frameworks
-
+ pod 'Masonry'