18BF1DE42B81AB8000B8D90F /* MouseSdkTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DE32B81AB8000B8D90F /* MouseSdkTests.m */; };
18BF1DEE2B81AB8000B8D90F /* MouseSdkUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DED2B81AB8000B8D90F /* MouseSdkUITests.m */; };
18BF1DF02B81AB8000B8D90F /* MouseSdkUITestsLaunchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DEF2B81AB8000B8D90F /* MouseSdkUITestsLaunchTests.m */; };
- 18BF1E762B832D2E00B8D90F /* ScanVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1E752B832D2E00B8D90F /* ScanVC.m */; };
- 18EF7B1D2C760FF700AC5223 /* TlwScanVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */; };
- 18EF7B1E2C760FF700AC5223 /* TlwScanVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */; };
- 18F3235D2B8ED78300CABA2E /* ScanCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F3235C2B8ED78300CABA2E /* ScanCell.m */; };
- 18F328D52B98569D00CABA2E /* Config.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F328D42B98569D00CABA2E /* Config.m */; };
3F66C0512D1D0222001B4291 /* libAiMouseManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F66C04F2D1D0222001B4291 /* libAiMouseManager.a */; };
8A6657BD1406314D4CBB7CEF /* libPods-MouseSdk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0311DF3AD67ED792549B96BD /* libPods-MouseSdk.a */; };
/* End PBXBuildFile section */
18BF1DED2B81AB8000B8D90F /* MouseSdkUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MouseSdkUITests.m; sourceTree = "<group>"; };
18BF1DEF2B81AB8000B8D90F /* MouseSdkUITestsLaunchTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MouseSdkUITestsLaunchTests.m; sourceTree = "<group>"; };
18BF1E032B81E18700B8D90F /* MouseSdk-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MouseSdk-Bridging-Header.h"; sourceTree = "<group>"; };
- 18BF1E742B832D2E00B8D90F /* ScanVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanVC.h; sourceTree = "<group>"; };
- 18BF1E752B832D2E00B8D90F /* ScanVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanVC.m; sourceTree = "<group>"; };
18C31D6F2BBAA6CC0089D656 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
18CB080B2BA401D0005F5854 /* liblzma.5.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = liblzma.5.tbd; path = usr/lib/liblzma.5.tbd; sourceTree = SDKROOT; };
- 18EF7B1A2C760FF700AC5223 /* TlwScanVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TlwScanVC.h; sourceTree = "<group>"; };
- 18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TlwScanVC.m; sourceTree = "<group>"; };
- 18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TlwScanVC.xib; sourceTree = "<group>"; };
- 18F3235B2B8ED78300CABA2E /* ScanCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanCell.h; sourceTree = "<group>"; };
- 18F3235C2B8ED78300CABA2E /* ScanCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanCell.m; sourceTree = "<group>"; };
18F3249D2B9337D500CABA2E /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
18F3249F2B9337E400CABA2E /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
18F324A12B93381C00CABA2E /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; };
18F324A52B93385100CABA2E /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; };
18F324A82B956F1C00CABA2E /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
18F325772B95737F00CABA2E /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
- 18F328D32B98569D00CABA2E /* Config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Config.h; sourceTree = "<group>"; };
- 18F328D42B98569D00CABA2E /* Config.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Config.m; sourceTree = "<group>"; };
3F66C04A2D1D0222001B4291 /* AiMouseSdk.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AiMouseSdk.h; sourceTree = "<group>"; };
3F66C04B2D1D0222001B4291 /* ByteDanceSdk.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ByteDanceSdk.h; sourceTree = "<group>"; };
3F66C04C2D1D0222001B4291 /* DeviceManger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeviceManger.h; sourceTree = "<group>"; };
18BF1DCE2B81AB7C00B8D90F /* AppDelegate.m */,
18BF1DD02B81AB7C00B8D90F /* ViewController.h */,
18BF1DD12B81AB7C00B8D90F /* ViewController.m */,
- 18EF7B1A2C760FF700AC5223 /* TlwScanVC.h */,
- 18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */,
- 18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */,
- 18BF1E742B832D2E00B8D90F /* ScanVC.h */,
- 18BF1E752B832D2E00B8D90F /* ScanVC.m */,
- 18F3235B2B8ED78300CABA2E /* ScanCell.h */,
- 18F3235C2B8ED78300CABA2E /* ScanCell.m */,
- 18F328D32B98569D00CABA2E /* Config.h */,
- 18F328D42B98569D00CABA2E /* Config.m */,
18BF1DD32B81AB7F00B8D90F /* Assets.xcassets */,
18BF1DD52B81AB7F00B8D90F /* Main.storyboard */,
18BF1DD82B81AB7F00B8D90F /* main.m */,
files = (
18BF1DD42B81AB7F00B8D90F /* Assets.xcassets in Resources */,
18BF1DD72B81AB7F00B8D90F /* Main.storyboard in Resources */,
- 18EF7B1E2C760FF700AC5223 /* TlwScanVC.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 18F3235D2B8ED78300CABA2E /* ScanCell.m in Sources */,
18BF1DD22B81AB7C00B8D90F /* ViewController.m in Sources */,
18BF1DD92B81AB7F00B8D90F /* main.m in Sources */,
- 18F328D52B98569D00CABA2E /* Config.m in Sources */,
- 18BF1E762B832D2E00B8D90F /* ScanVC.m in Sources */,
- 18EF7B1D2C760FF700AC5223 /* TlwScanVC.m in Sources */,
18BF1DCF2B81AB7C00B8D90F /* AppDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
+++ /dev/null
-//
-// Config.h
-// MouseSdk
-//
-// Created by incar on 2024/3/6.
-//
-
-#ifdef DEBUG //调试
-
-// 不带方法名
-#define NSLog(FORMAT, ...) {\
-NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];\
-[dateFormatter setDateStyle:NSDateFormatterMediumStyle];\
-[dateFormatter setTimeStyle:NSDateFormatterShortStyle];\
-[dateFormatter setDateFormat:@"HH:mm:ss:SSS"]; \
-NSString *str = [dateFormatter stringFromDate:[NSDate date]];\
-fprintf(stderr," %s ~ %s\n",[str UTF8String], [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);\
-}
-
-//// 带方法名
-//#define NSLog(FORMAT, ...) {\
-//NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];\
-//[dateFormatter setDateStyle:NSDateFormatterMediumStyle];\
-//[dateFormatter setTimeStyle:NSDateFormatterShortStyle];\
-//[dateFormatter setDateFormat:@"HH:mm:ss:SSSSSS"]; \
-//NSString *str = [dateFormatter stringFromDate:[NSDate date]];\
-//fprintf(stderr," %s %s %d %s~ 打印 = %s\n",[str UTF8String],[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__,__func__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);\
-//}
-
-
-#else
-
-#define NSLog(FORMAT, ...) nil
-
-#endif
-
-
-#import <Foundation/Foundation.h>
-
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface Config : NSObject
-
-@end
-
-NS_ASSUME_NONNULL_END
+++ /dev/null
-//
-// Config.m
-// MouseSdk
-//
-// Created by incar on 2024/3/6.
-//
-
-#import "Config.h"
-
-@implementation Config
-
-@end
+++ /dev/null
-//
-// ScanCell.h
-// MouseSdk
-//
-// Created by incar on 2024/2/28.
-//
-
-#import <Cocoa/Cocoa.h>
-#import <CoreBluetooth/CoreBluetooth.h>
-NS_ASSUME_NONNULL_BEGIN
-
-@interface ScanCell : NSTableCellView
-@property(nonatomic,strong)CBPeripheral *peripheral;
-@property(nonatomic,strong)void (^connecBtnActionCallBack)(CBPeripheral *peripheral);
-@end
-
-NS_ASSUME_NONNULL_END
+++ /dev/null
-//
-// 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.connecBtnActionCallBack) {
- self.connecBtnActionCallBack(self.peripheral);
- }
-}
-@end
+++ /dev/null
-//
-// ScanVC.h
-// MouseSdk
-//
-// Created by incar on 2024/2/19.
-//
-
-#import <Cocoa/Cocoa.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface ScanVC : NSViewController
-
-
-@end
-
-NS_ASSUME_NONNULL_END
+++ /dev/null
-//
-// ScanVC.m
-// MouseSdk
-//
-// Created by incar on 2024/2/19.
-//
-
-#import "ScanVC.h"
-#import "ScanCell.h"
-#import "DeviceManger.h"
-@interface ScanVC ()<NSTableViewDelegate,NSTableViewDataSource>
-@property (nonatomic,strong) NSTableView *tableView;
-@property (nonatomic,strong) NSMutableArray<CBPeripheral *> *scanArray;
-@end
-
-@implementation ScanVC
--(NSMutableArray<CBPeripheral *> *)scanArray{
- if (_scanArray == nil) {
- _scanArray = [[NSMutableArray alloc] init];
- }
- return _scanArray;
-}
-
-- (void)viewDidLoad {
- [super viewDidLoad];
- // Do view setup here.
- [self setupUI];
- [self setupBleManger];
-}
-- (void)loadView{
- self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
-}
-
-- (void)setupUI{
- 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)setupBleManger{
-// BleManager *manager = [BleManager shared];
-// __weak typeof(self) weakSelf= self;
-// __weak typeof(BleManager) *weakManager = manager;
-// manager.discoverDevice = ^(CBPeripheral *peripheral){
-// if ([weakSelf.scanArray containsObject:peripheral]){
-// return;
-// }
-// if(peripheral.name.length == 0){
-// return;
-// }
-// [weakSelf.scanArray addObject:peripheral];
-// [weakSelf.tableView reloadData];
-// };
-// manager.didConnectDevice = ^(CBPeripheral * _Nonnull peripheral) {
-// [weakSelf connectSuccess];
-// };
-// [manager startScanDevice];
-}
-
-- (void)tapDevice:(CBPeripheral *)peripheral{
-// [[BleManager shared] connectPeripheral:peripheral];
-}
-
-- (void)connectSuccess{
-// [[BleManager shared] stopScanDevice];
- dispatch_async(dispatch_get_main_queue(), ^{
- NSAlert *alert = [NSAlert new];
- [alert addButtonWithTitle:@"确定"];
- [alert setMessageText:@"连接成功"];
- [alert setAlertStyle:NSAlertStyleInformational];
- [alert beginSheetModalForWindow:[self.view window] completionHandler:^(NSModalResponse returnCode) {
- [self dismissViewController:self];
- }];
- });
-}
-#pragma mark - NSTableViewDelegate,NSTableViewDataSource
--(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
- return self.scanArray.count;
-}
-
--(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
- 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.connecBtnActionCallBack = ^(CBPeripheral * _Nonnull peripheral) {
- [weakSelf tapDevice:peripheral];
- };
- return cell;
-}
--(CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row{
- return 44;
-}
-
-@end
+++ /dev/null
-//
-// TlwScanVC.h
-// MouseSdk
-//
-// Created by incar on 2024/8/21.
-//
-
-#import <Cocoa/Cocoa.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface TlwScanVC : NSViewController
-
-@end
-
-NS_ASSUME_NONNULL_END
+++ /dev/null
-//
-// TlwScanVC.m
-// MouseSdk
-//
-// Created by incar on 2024/8/21.
-//
-
-#import "TlwScanVC.h"
-
-#import "ScanCell.h"
-@interface TlwScanVC ()<NSTableViewDelegate,NSTableViewDataSource>
-@property (nonatomic,strong) NSTableView *tableView;
-@property (nonatomic,strong) NSMutableArray<CBPeripheral *> *scanArray;
-@end
-
-@implementation TlwScanVC
--(NSMutableArray<CBPeripheral *> *)scanArray{
- if (_scanArray == nil) {
- _scanArray = [[NSMutableArray alloc] init];
- }
- return _scanArray;
-}
-
-- (void)viewDidLoad {
- [super viewDidLoad];
- // Do view setup here.
- [self setupUI];
- [self setupBleManger];
-}
-- (void)loadView{
- self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
-}
-
-- (void)setupUI{
- 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)setupBleManger{
-// TlwBleManager *manager = [TlwDeviceManger shared].ble;
-// __weak typeof(self) weakSelf= self;
-// manager.discoverDevice = ^(CBPeripheral *peripheral){
-// if ([weakSelf.scanArray containsObject:peripheral]){
-// return;
-// }
-// if(peripheral.name.length == 0){
-// return;
-// }
-// [weakSelf.scanArray addObject:peripheral];
-// [weakSelf.tableView reloadData];
-// };
-// manager.didConnectDevice = ^(CBPeripheral * _Nonnull peripheral) {
-// [weakSelf connectSuccess];
-// };
-// [manager startScanDevice];
-}
-
-- (void)tapDevice:(CBPeripheral *)peripheral{
-// [[TlwDeviceManger shared].ble connectPeripheral:peripheral];
-}
-
-- (void)connectSuccess{
-// [[TlwDeviceManger shared].ble stopScanDevice];
-// dispatch_async(dispatch_get_main_queue(), ^{
-// NSAlert *alert = [NSAlert new];
-// [alert addButtonWithTitle:@"确定"];
-// [alert setMessageText:@"连接成功"];
-// [alert setAlertStyle:NSAlertStyleInformational];
-// [alert beginSheetModalForWindow:[self.view window] completionHandler:^(NSModalResponse returnCode) {
-// [self dismissViewController:self];
-// }];
-// });
-}
-#pragma mark - NSTableViewDelegate,NSTableViewDataSource
--(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
- return self.scanArray.count;
-}
-
--(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
- 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.connecBtnActionCallBack = ^(CBPeripheral * _Nonnull peripheral) {
- [weakSelf tapDevice:peripheral];
- };
- return cell;
-}
--(CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row{
- return 44;
-}
-
-@end
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11134" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
- <dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
- </dependencies>
- <objects>
- <customObject id="-2" userLabel="File's Owner" customClass="TlwScanVC">
- <connections>
- <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
- </connections>
- </customObject>
- <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
- <customObject id="-3" userLabel="Application" customClass="NSObject"/>
- <customView id="Hz6-mo-xeY">
- <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
- <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
- </customView>
- </objects>
-</document>
#import "ViewController.h"
-#import "ScanVC.h"
#import "DeviceManger.h"
-#import "Config.h"
@interface ViewController ()
@property(nonatomic,strong)NSTextField *typeLabel;///当前模式状态
@property(nonatomic,strong)NSTextField *connectLabel;///连接状态
-@property(nonatomic,strong)NSTextField *authLabel;///鉴权状态
@property(nonatomic,strong)NSTextField *deviceInfoLabel;///设备信息
@end
[backgroundView setNeedsDisplay:YES];
[self.view addSubview:backgroundView];
- self.title = @"AI SDK";
+ self.title = @"Mouse Sdk";
{
NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 200, 100, 45)];
btn.bordered = true;
self.connectLabel = label;
[self.view addSubview:label];
}
- {
- NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 160, 300, 35)];
- label.editable = NO;
- label.bordered = NO;
- label.stringValue = @"鉴权状态:--";
- label.backgroundColor = NSColor.clearColor;
- self.authLabel = label;
- [self.view addSubview:label];
- }
{
NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 560, 400, 400)];
label.editable = NO;
self.deviceInfoLabel = label;
[self.view addSubview:label];
}
-
}
#pragma mark - action
- (void)setupDeviceManger{
DeviceManger *manager = [DeviceManger shared];
[manager initSdk:2];
+ manager.debugLevel = 2;
+
__weak typeof(self) ws = self;
- manager.aiMouseAddLogCallBack = ^(NSString * _Nonnull log) {
- NSLog(@"%@",log);
- };
- manager.authCallBack = ^(BOOL isSuccess) {
- dispatch_async(dispatch_get_main_queue(), ^{
- ws.authLabel.stringValue = isSuccess?@"鉴权状态:鉴权成功":@"鉴权状态:鉴权失败";
- if(isSuccess){
- [ws geviceInfoAction];
- }
- });
- };
- [manager begainMonitorAiMouseConnectStateDidChange:@"NMMouse" callBack:^(int connectType, BOOL connected) {
+ [manager begainMonitorAiMouseConnectStateDidChange:@"" callBack:^(int connectType, BOOL connected) {
dispatch_async(dispatch_get_main_queue(), ^{
if(connected){
ws.typeLabel.stringValue = connectType == 0 ?@"连接模式:蓝牙":@"连接模式:hid";
ws.connectLabel.stringValue = connected?@"连接状态:已连接":@"连接状态:未连接";
+ [ws geviceInfoAction];
}
else{
ws.typeLabel.stringValue = @"连接模式:--";
ws.connectLabel.stringValue = @"连接状态:未连接";
+ ws.deviceInfoLabel.stringValue = @"";
}
});
}];
+
+ manager.begainRecoredCallBack = ^(void) {
+ NSLog(@"开始录音");
+ };
+ manager.recordingCallBack = ^(NSString * _Nonnull data) {
+ //NSLog(@"%@",[NSString stringWithFormat:@"语音数据 = %@",data]);
+ };
+ manager.finishRecoredCallBack = ^(NSString * _Nonnull data) {
+ //NSLog(@"%@",[NSString stringWithFormat:@"结束录音 = %@",data]);
+ };
+ manager.aiMouseSendCmdDataCallBack = ^(NSString * _Nonnull data) {
+ NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]);
+ };
}
+
- (void)moreAction:(NSButton *)sender {
NSMenu *popupMenu = [[NSMenu alloc] initWithTitle:@"Popup Menu"];
NSMenuItem *item1 = [[NSMenuItem alloc] initWithTitle:@"语音开启" action:@selector(voiceStart:) keyEquivalent:@"1"];
NSMenuItem *item4 = [[NSMenuItem alloc] initWithTitle:@"鼠标状态查询" action:@selector(searchState:) keyEquivalent:@"4"];
NSMenuItem *item5 = [[NSMenuItem alloc] initWithTitle:@"设置滚轮开关" action:@selector(setUrlState:) keyEquivalent:@"5"];
NSMenuItem *item6 = [[NSMenuItem alloc] initWithTitle:@"获取滚轮开关" action:@selector(getUrlState:) keyEquivalent:@"6"];
-
+
[popupMenu addItem:item1];
[popupMenu addItem:item2];
[popupMenu addItem:item3];
[popupMenu addItem:item4];
[popupMenu addItem:item5];
[popupMenu addItem:item6];
-
+
NSPoint buttonLocation = [sender convertPoint:NSZeroPoint toView:self.view];
[popupMenu popUpMenuPositioningItem:nil atLocation:buttonLocation inView:self.view];
}
}
-
-
- (void)geviceInfoAction{
-// [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_ListenEvent"]];
-// return;
[[DeviceManger shared] getDeviceInfo:^(AiMouseDeviceInfo *deviceInfo, NSError *error) {
if (deviceInfo) {
NSString *info = deviceInfo.description;
}
}];
}
-
@end
<key>Masonry.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
- <integer>2</integer>
+ <integer>1</integer>
</dict>
<key>Pods-MouseSdk.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
- <integer>1</integer>
+ <integer>2</integer>
</dict>
</dict>
</dict>
}
//收到蓝牙数据
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
-// [self showLog:[NSString stringWithFormat:@"[reciv]%@ %@",characteristic,characteristic.value]];
+ [self showLog:[NSString stringWithFormat:@"[recv]%@ %@",characteristic,characteristic.value]];
if (self.productType == AiMouseProductType_m8) {
NSData *data = characteristic.value;
if( [characteristic.UUID.UUIDString isEqualToString:kM8ClickUUID]){
@interface DeviceManger : NSObject
@property (nonatomic,strong)NSString *version;//sdk版本
@property (nonatomic, assign)int debugLevel;//调试模式等级,0什么日志都不会输出,1输出日志,2输出日志且会将日志保存到本地文件
-@property (nonatomic, readonly) int appType;//1威鼠不鉴权;2威鼠字节鉴权;3千寻不鉴权;4千寻字节鉴权
+@property (nonatomic, readonly) int appType;//app类型
@property (nonatomic, readonly)BOOL isConneted;//是否连接
@property (nonatomic, readonly) AiMouseConnectType connectType;//连接类型
-#pragma mark ------- 鼠标的回调
-@property (nonatomic,strong)void (^authCallBack)(BOOL isSuccess);/// 鉴权回调
-//@property (nonatomic, copy)void (^aiMouseSendDeviceInfoDataCallBack)(NSString *data);/// 设备信息数据回调
-@property (nonatomic, copy)void (^aiMouseSendCmdDataCallBack)(NSString *data);/// 鼠标按键指令回调
-
+//@property (nonatomic,strong)void (^authCallBack)(BOOL isSuccess);/// 鉴权回调
+
+/// 鼠标按键指令回调
+/// - Parameter data: 数据。
+/// 前 第一次单击31(开始录音), 第二次单击32(结束录音) , 按下21(开始录音)抬起22(结束录音)
+/// 中 单击42, 按下25(开始录音)抬起26(结束录音)
+/// 后 单击43,按下27(开始录音)抬起28(结束录音)
+/// 其他未定义
+@property (nonatomic, copy)void (^aiMouseSendCmdDataCallBack)(NSString *data);
@property (nonatomic, copy)void (^begainRecoredCallBack)(void);/// 录音开始回调
-@property (nonatomic, copy)void (^recordingCallBack)(NSString *data);/// 录音进行中回调
-@property (nonatomic, copy)void (^finishRecoredCallBack)(NSString *data);/// 录音结束回调
+@property (nonatomic, copy)void (^recordingCallBack)(NSString *data);/// 录音进行中回调pcm base64
+@property (nonatomic, copy)void (^finishRecoredCallBack)(NSString *data);/// 录音结束回调,pcm base64
#pragma mark ------- 接口
+(DeviceManger *)shared;
/// 初始化sdk
-/// - Parameter appType: app类型 1威鼠不鉴权;2威鼠字节鉴权;3千寻不鉴权;4千寻字节鉴权
+/// - Parameter appType: app类型 2
- (void)initSdk:(int)appType;
///当前设置的连接类型:@"0"表示蓝牙;@"1"表示USB;
- (NSString *)getCurrentConnectType;
-///开始监听鼠标的链接状态
+/// 开始监听鼠标
+/// - Parameters:
+/// - mouseName: 空字符
+/// - callBack: connectType:0蓝牙模式,1 usb。connected:连接状态,false未连接,true已连接
- (void)begainMonitorAiMouseConnectStateDidChange:(NSString *)mouseName callBack:(void(^)(int connectType, BOOL connected))callBack;
-#pragma mark ------- 共用
+
/// 获取设备信息
- (void)getDeviceInfo:(void (^)(AiMouseDeviceInfo *deviceInfo,NSError *error))completation;
/// - finished: 设置结果回调
- (void)setBrand:(NSString *)brand completation:(void (^)(BOOL isSuccess,NSError *error))finished;
-
/// 设置录音模式
/// - Parameters:
/// - value: 0:常规模式,按按键打开关闭录音 1:命令模式,发命令打开关闭录音
/// - finished: 执行结果回调
- (void)closeRecord:(void (^)(BOOL isSuccess,NSError *error))finished;
-- (void)startConnect;
@end
NS_ASSUME_NONNULL_END
#import "LogManager.h"
@interface DeviceManger()<TlwMouseDelegate,AiMouseDelegate,NMouseSdkDelegate,KeyboardSdkDelegate>
-
+//@property (nonatomic, readonly) int appType;//1威鼠不鉴权;2威鼠字节鉴权;3千寻不鉴权;4千寻字节鉴权
@property (nonatomic,strong) NSMutableData *recordData;//录音的数据
@property (nonatomic,strong) BleManager *ble;
@property (nonatomic,strong) HidManager *hid;
@property (nonatomic,strong) KeyboardSdk *kbSdk;
@property (nonatomic,strong) M8MouseSdk *m8Sdk;
@property (nonatomic,assign) AiMouseProductType productType;
+@property (nonatomic,strong)void (^authCallBack)(BOOL isSuccess);/// 鉴权回调
//connectType 返回为0代表蓝牙,为1代表usb
@property (nonatomic, copy)void (^aiMouseConnectStateDidChangeCallBack)(int connectType, BOOL connected);/// 设备连接状态回调
- (instancetype)init{
self = [super init];
if (self) {
- self.version = @"MouseSdk_v2025042801";
+ self.version = @"MouseSdk_v2025043001";
}
return self;
}
18BF1DE42B81AB8000B8D90F /* MouseSdkTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DE32B81AB8000B8D90F /* MouseSdkTests.m */; };
18BF1DEE2B81AB8000B8D90F /* MouseSdkUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DED2B81AB8000B8D90F /* MouseSdkUITests.m */; };
18BF1DF02B81AB8000B8D90F /* MouseSdkUITestsLaunchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1DEF2B81AB8000B8D90F /* MouseSdkUITestsLaunchTests.m */; };
- 18BF1E762B832D2E00B8D90F /* ScanVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BF1E752B832D2E00B8D90F /* ScanVC.m */; };
- 18EF7B1D2C760FF700AC5223 /* TlwScanVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */; };
- 18EF7B1E2C760FF700AC5223 /* TlwScanVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */; };
- 18F3235D2B8ED78300CABA2E /* ScanCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F3235C2B8ED78300CABA2E /* ScanCell.m */; };
- 18F328D52B98569D00CABA2E /* Config.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F328D42B98569D00CABA2E /* Config.m */; };
8A6657BD1406314D4CBB7CEF /* libPods-MouseSdk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0311DF3AD67ED792549B96BD /* libPods-MouseSdk.a */; };
/* End PBXBuildFile section */
18BF1DED2B81AB8000B8D90F /* MouseSdkUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MouseSdkUITests.m; sourceTree = "<group>"; };
18BF1DEF2B81AB8000B8D90F /* MouseSdkUITestsLaunchTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MouseSdkUITestsLaunchTests.m; sourceTree = "<group>"; };
18BF1E032B81E18700B8D90F /* MouseSdk-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MouseSdk-Bridging-Header.h"; sourceTree = "<group>"; };
- 18BF1E742B832D2E00B8D90F /* ScanVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanVC.h; sourceTree = "<group>"; };
- 18BF1E752B832D2E00B8D90F /* ScanVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanVC.m; sourceTree = "<group>"; };
18C31D6F2BBAA6CC0089D656 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
18CB080B2BA401D0005F5854 /* liblzma.5.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = liblzma.5.tbd; path = usr/lib/liblzma.5.tbd; sourceTree = SDKROOT; };
- 18EF7B1A2C760FF700AC5223 /* TlwScanVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TlwScanVC.h; sourceTree = "<group>"; };
- 18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TlwScanVC.m; sourceTree = "<group>"; };
- 18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TlwScanVC.xib; sourceTree = "<group>"; };
- 18F3235B2B8ED78300CABA2E /* ScanCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanCell.h; sourceTree = "<group>"; };
- 18F3235C2B8ED78300CABA2E /* ScanCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanCell.m; sourceTree = "<group>"; };
18F3249D2B9337D500CABA2E /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
18F3249F2B9337E400CABA2E /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
18F324A12B93381C00CABA2E /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; };
18F324A52B93385100CABA2E /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; };
18F324A82B956F1C00CABA2E /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
18F325772B95737F00CABA2E /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
- 18F328D32B98569D00CABA2E /* Config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Config.h; sourceTree = "<group>"; };
- 18F328D42B98569D00CABA2E /* Config.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Config.m; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
/* End PBXFileReference section */
18BF1DCE2B81AB7C00B8D90F /* AppDelegate.m */,
18BF1DD02B81AB7C00B8D90F /* ViewController.h */,
18BF1DD12B81AB7C00B8D90F /* ViewController.m */,
- 18EF7B1A2C760FF700AC5223 /* TlwScanVC.h */,
- 18EF7B1B2C760FF700AC5223 /* TlwScanVC.m */,
- 18EF7B1C2C760FF700AC5223 /* TlwScanVC.xib */,
- 18BF1E742B832D2E00B8D90F /* ScanVC.h */,
- 18BF1E752B832D2E00B8D90F /* ScanVC.m */,
- 18F3235B2B8ED78300CABA2E /* ScanCell.h */,
- 18F3235C2B8ED78300CABA2E /* ScanCell.m */,
- 18F328D32B98569D00CABA2E /* Config.h */,
- 18F328D42B98569D00CABA2E /* Config.m */,
18BF1DD32B81AB7F00B8D90F /* Assets.xcassets */,
18BF1DD52B81AB7F00B8D90F /* Main.storyboard */,
18BF1DD82B81AB7F00B8D90F /* main.m */,
files = (
18BF1DD42B81AB7F00B8D90F /* Assets.xcassets in Resources */,
18BF1DD72B81AB7F00B8D90F /* Main.storyboard in Resources */,
- 18EF7B1E2C760FF700AC5223 /* TlwScanVC.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 18F3235D2B8ED78300CABA2E /* ScanCell.m in Sources */,
18BF1DD22B81AB7C00B8D90F /* ViewController.m in Sources */,
18BF1DD92B81AB7F00B8D90F /* main.m in Sources */,
- 18F328D52B98569D00CABA2E /* Config.m in Sources */,
- 18BF1E762B832D2E00B8D90F /* ScanVC.m in Sources */,
- 18EF7B1D2C760FF700AC5223 /* TlwScanVC.m in Sources */,
18BF1DCF2B81AB7C00B8D90F /* AppDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
+++ /dev/null
-//
-// Config.h
-// MouseSdk
-//
-// Created by incar on 2024/3/6.
-//
-
-#ifdef DEBUG //调试
-
-// 不带方法名
-#define NSLog(FORMAT, ...) {\
-NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];\
-[dateFormatter setDateStyle:NSDateFormatterMediumStyle];\
-[dateFormatter setTimeStyle:NSDateFormatterShortStyle];\
-[dateFormatter setDateFormat:@"HH:mm:ss:SSS"]; \
-NSString *str = [dateFormatter stringFromDate:[NSDate date]];\
-fprintf(stderr," %s ~ %s\n",[str UTF8String], [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);\
-}
-
-//// 带方法名
-//#define NSLog(FORMAT, ...) {\
-//NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];\
-//[dateFormatter setDateStyle:NSDateFormatterMediumStyle];\
-//[dateFormatter setTimeStyle:NSDateFormatterShortStyle];\
-//[dateFormatter setDateFormat:@"HH:mm:ss:SSSSSS"]; \
-//NSString *str = [dateFormatter stringFromDate:[NSDate date]];\
-//fprintf(stderr," %s %s %d %s~ 打印 = %s\n",[str UTF8String],[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__,__func__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);\
-//}
-
-
-#else
-
-#define NSLog(FORMAT, ...) nil
-
-#endif
-
-
-#import <Foundation/Foundation.h>
-
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface Config : NSObject
-
-@end
-
-NS_ASSUME_NONNULL_END
+++ /dev/null
-//
-// Config.m
-// MouseSdk
-//
-// Created by incar on 2024/3/6.
-//
-
-#import "Config.h"
-
-@implementation Config
-
-@end
+++ /dev/null
-//
-// ScanCell.h
-// MouseSdk
-//
-// Created by incar on 2024/2/28.
-//
-
-#import <Cocoa/Cocoa.h>
-#import <CoreBluetooth/CoreBluetooth.h>
-NS_ASSUME_NONNULL_BEGIN
-
-@interface ScanCell : NSTableCellView
-@property(nonatomic,strong)CBPeripheral *peripheral;
-@property(nonatomic,strong)void (^connecBtnActionCallBack)(CBPeripheral *peripheral);
-@end
-
-NS_ASSUME_NONNULL_END
+++ /dev/null
-//
-// 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.connecBtnActionCallBack) {
- self.connecBtnActionCallBack(self.peripheral);
- }
-}
-@end
+++ /dev/null
-//
-// ScanVC.h
-// MouseSdk
-//
-// Created by incar on 2024/2/19.
-//
-
-#import <Cocoa/Cocoa.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface ScanVC : NSViewController
-
-
-@end
-
-NS_ASSUME_NONNULL_END
+++ /dev/null
-//
-// ScanVC.m
-// MouseSdk
-//
-// Created by incar on 2024/2/19.
-//
-
-#import "ScanVC.h"
-#import "ScanCell.h"
-#import "DeviceManger.h"
-@interface ScanVC ()<NSTableViewDelegate,NSTableViewDataSource>
-@property (nonatomic,strong) NSTableView *tableView;
-@property (nonatomic,strong) NSMutableArray<CBPeripheral *> *scanArray;
-@end
-
-@implementation ScanVC
--(NSMutableArray<CBPeripheral *> *)scanArray{
- if (_scanArray == nil) {
- _scanArray = [[NSMutableArray alloc] init];
- }
- return _scanArray;
-}
-
-- (void)viewDidLoad {
- [super viewDidLoad];
- // Do view setup here.
- [self setupUI];
- [self setupBleManger];
-}
-- (void)loadView{
- self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
-}
-
-- (void)setupUI{
- 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)setupBleManger{
-// BleManager *manager = [BleManager shared];
-// __weak typeof(self) weakSelf= self;
-// __weak typeof(BleManager) *weakManager = manager;
-// manager.discoverDevice = ^(CBPeripheral *peripheral){
-// if ([weakSelf.scanArray containsObject:peripheral]){
-// return;
-// }
-// if(peripheral.name.length == 0){
-// return;
-// }
-// [weakSelf.scanArray addObject:peripheral];
-// [weakSelf.tableView reloadData];
-// };
-// manager.didConnectDevice = ^(CBPeripheral * _Nonnull peripheral) {
-// [weakSelf connectSuccess];
-// };
-// [manager startScanDevice];
-}
-
-- (void)tapDevice:(CBPeripheral *)peripheral{
-// [[BleManager shared] connectPeripheral:peripheral];
-}
-
-- (void)connectSuccess{
-// [[BleManager shared] stopScanDevice];
- dispatch_async(dispatch_get_main_queue(), ^{
- NSAlert *alert = [NSAlert new];
- [alert addButtonWithTitle:@"确定"];
- [alert setMessageText:@"连接成功"];
- [alert setAlertStyle:NSAlertStyleInformational];
- [alert beginSheetModalForWindow:[self.view window] completionHandler:^(NSModalResponse returnCode) {
- [self dismissViewController:self];
- }];
- });
-}
-#pragma mark - NSTableViewDelegate,NSTableViewDataSource
--(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
- return self.scanArray.count;
-}
-
--(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
- 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.connecBtnActionCallBack = ^(CBPeripheral * _Nonnull peripheral) {
- [weakSelf tapDevice:peripheral];
- };
- return cell;
-}
--(CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row{
- return 44;
-}
-
-@end
+++ /dev/null
-//
-// TlwScanVC.h
-// MouseSdk
-//
-// Created by incar on 2024/8/21.
-//
-
-#import <Cocoa/Cocoa.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface TlwScanVC : NSViewController
-
-@end
-
-NS_ASSUME_NONNULL_END
+++ /dev/null
-//
-// TlwScanVC.m
-// MouseSdk
-//
-// Created by incar on 2024/8/21.
-//
-
-#import "TlwScanVC.h"
-
-#import "ScanCell.h"
-@interface TlwScanVC ()<NSTableViewDelegate,NSTableViewDataSource>
-@property (nonatomic,strong) NSTableView *tableView;
-@property (nonatomic,strong) NSMutableArray<CBPeripheral *> *scanArray;
-@end
-
-@implementation TlwScanVC
--(NSMutableArray<CBPeripheral *> *)scanArray{
- if (_scanArray == nil) {
- _scanArray = [[NSMutableArray alloc] init];
- }
- return _scanArray;
-}
-
-- (void)viewDidLoad {
- [super viewDidLoad];
- // Do view setup here.
- [self setupUI];
- [self setupBleManger];
-}
-- (void)loadView{
- self.view = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
-}
-
-- (void)setupUI{
- 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)setupBleManger{
-// TlwBleManager *manager = [TlwDeviceManger shared].ble;
-// __weak typeof(self) weakSelf= self;
-// manager.discoverDevice = ^(CBPeripheral *peripheral){
-// if ([weakSelf.scanArray containsObject:peripheral]){
-// return;
-// }
-// if(peripheral.name.length == 0){
-// return;
-// }
-// [weakSelf.scanArray addObject:peripheral];
-// [weakSelf.tableView reloadData];
-// };
-// manager.didConnectDevice = ^(CBPeripheral * _Nonnull peripheral) {
-// [weakSelf connectSuccess];
-// };
-// [manager startScanDevice];
-}
-
-- (void)tapDevice:(CBPeripheral *)peripheral{
-// [[TlwDeviceManger shared].ble connectPeripheral:peripheral];
-}
-
-- (void)connectSuccess{
-// [[TlwDeviceManger shared].ble stopScanDevice];
-// dispatch_async(dispatch_get_main_queue(), ^{
-// NSAlert *alert = [NSAlert new];
-// [alert addButtonWithTitle:@"确定"];
-// [alert setMessageText:@"连接成功"];
-// [alert setAlertStyle:NSAlertStyleInformational];
-// [alert beginSheetModalForWindow:[self.view window] completionHandler:^(NSModalResponse returnCode) {
-// [self dismissViewController:self];
-// }];
-// });
-}
-#pragma mark - NSTableViewDelegate,NSTableViewDataSource
--(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
- return self.scanArray.count;
-}
-
--(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
- 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.connecBtnActionCallBack = ^(CBPeripheral * _Nonnull peripheral) {
- [weakSelf tapDevice:peripheral];
- };
- return cell;
-}
--(CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row{
- return 44;
-}
-
-@end
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11134" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
- <dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
- </dependencies>
- <objects>
- <customObject id="-2" userLabel="File's Owner" customClass="TlwScanVC">
- <connections>
- <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
- </connections>
- </customObject>
- <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
- <customObject id="-3" userLabel="Application" customClass="NSObject"/>
- <customView id="Hz6-mo-xeY">
- <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
- <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
- </customView>
- </objects>
-</document>
#import "ViewController.h"
-#import "ScanVC.h"
#import "DeviceManger.h"
-#import "Config.h"
@interface ViewController ()
@property(nonatomic,strong)NSTextField *typeLabel;///当前模式状态
@property(nonatomic,strong)NSTextField *connectLabel;///连接状态
-@property(nonatomic,strong)NSTextField *authLabel;///鉴权状态
@property(nonatomic,strong)NSTextField *deviceInfoLabel;///设备信息
@end
[backgroundView setNeedsDisplay:YES];
[self.view addSubview:backgroundView];
- self.title = @"AI SDK";
- {
- NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 100, 100, 45)];
- btn.bordered = true;
- btn.title = @"连接";
- [btn setTarget:self];
- [btn setAction:@selector(connectAction:)];
- btn.state = 1;
- [self.view addSubview:btn];
- }
+ self.title = @"Mouse Sdk";
{
NSButton *btn = [[NSButton alloc]initWithFrame:NSMakeRect(50, self.view.bounds.size.height - 200, 100, 45)];
btn.bordered = true;
self.connectLabel = label;
[self.view addSubview:label];
}
- {
- NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 160, 300, 35)];
- label.editable = NO;
- label.bordered = NO;
- label.stringValue = @"鉴权状态:unknow";
- label.backgroundColor = NSColor.clearColor;
- self.authLabel = label;
- [self.view addSubview:label];
- }
{
NSTextField *label = [[NSTextField alloc] initWithFrame:CGRectMake(180, self.view.bounds.size.height - 560, 400, 400)];
label.editable = NO;
manager.debugLevel = 2;
__weak typeof(self) ws = self;
-// manager.aiMouseAddLogCallBack = ^(NSString * _Nonnull log) {
-// NSLog(@"%@",log);
-// };
- manager.authCallBack = ^(BOOL isSuccess) {
- dispatch_async(dispatch_get_main_queue(), ^{
- ws.authLabel.stringValue = isSuccess?@"鉴权状态:鉴权成功":@"鉴权状态:鉴权失败";
- if(isSuccess){
- [ws geviceInfoAction];
- }
- });
- };
- [manager begainMonitorAiMouseConnectStateDidChange:@"NMMouse" callBack:^(int connectType, BOOL connected) {
+ [manager begainMonitorAiMouseConnectStateDidChange:@"" callBack:^(int connectType, BOOL connected) {
dispatch_async(dispatch_get_main_queue(), ^{
if(connected){
ws.typeLabel.stringValue = connectType == 0 ?@"连接模式:蓝牙":@"连接模式:hid";
ws.connectLabel.stringValue = connected?@"连接状态:已连接":@"连接状态:未连接";
+ [ws geviceInfoAction];
}
else{
ws.typeLabel.stringValue = @"连接模式:--";
ws.connectLabel.stringValue = @"连接状态:未连接";
ws.deviceInfoLabel.stringValue = @"";
- ws.authLabel.stringValue = @"鉴权状态:--";
}
});
}];
- manager.aiMouseSendCmdDataCallBack = ^(NSString * _Nonnull data) {
- NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]);
+
+ manager.begainRecoredCallBack = ^(void) {
+ NSLog(@"开始录音");
};
manager.recordingCallBack = ^(NSString * _Nonnull data) {
-// NSLog(@"%@",[NSString stringWithFormat:@"语音数据 = %@",data]);
+ //NSLog(@"%@",[NSString stringWithFormat:@"语音数据 = %@",data]);
+ };
+ manager.finishRecoredCallBack = ^(NSString * _Nonnull data) {
+ //NSLog(@"%@",[NSString stringWithFormat:@"结束录音 = %@",data]);
+ };
+ manager.aiMouseSendCmdDataCallBack = ^(NSString * _Nonnull data) {
+ NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]);
};
}
-- (void)connectAction:(NSButton *)sender {
- [[DeviceManger shared] startConnect];
-}
+
- (void)moreAction:(NSButton *)sender {
NSMenu *popupMenu = [[NSMenu alloc] initWithTitle:@"Popup Menu"];
- (void)geviceInfoAction{
-// [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_ListenEvent"]];
-// return;
[[DeviceManger shared] getDeviceInfo:^(AiMouseDeviceInfo *deviceInfo, NSError *error) {
if (deviceInfo) {
NSString *info = deviceInfo.description;
<key>Masonry.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
- <integer>4</integer>
+ <integer>3</integer>
</dict>
<key>Pods-MouseSdk.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
- <integer>3</integer>
+ <integer>4</integer>
</dict>
</dict>
</dict>