質問編集履歴
3
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,7 +24,53 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
import UIKit
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
class ViewController: UIViewController,MWMDelegate {
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
let mwm = MWMDevice.sharedInstance()
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
override func viewDidLoad() {
|
40
|
+
|
41
|
+
super.viewDidLoad()
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
mwm?.delegate = self
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
override func didReceiveMemoryWarning() {
|
52
|
+
|
53
|
+
super.didReceiveMemoryWarning()
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
// MARK: IBAction
|
60
|
+
|
61
|
+
@IBAction func scanBtnClick(_ sender: Any) {
|
62
|
+
|
63
|
+
print("scanBtnClick")
|
64
|
+
|
65
|
+
mwm?.scanDevice()
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
// MARK: MWMDelegate
|
72
|
+
|
27
|
-
func deviceFound(_ devName: String!, mfgID: String!, deviceID: String!) {
|
73
|
+
func deviceFound(_ devName: String!, mfgID: String!, deviceID: String!) {
|
28
74
|
|
29
75
|
print("devName = "+devName)
|
30
76
|
|
@@ -32,11 +78,29 @@
|
|
32
78
|
|
33
79
|
print("deviceID = "+deviceID)
|
34
80
|
|
35
|
-
|
36
|
-
|
37
81
|
//choose the correct device and connect
|
38
82
|
|
39
83
|
mwm?.connect(deviceID)
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
func didDisconnect() {
|
90
|
+
|
91
|
+
print("didDisconnect");
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
func didConnect() {
|
98
|
+
|
99
|
+
print("didConnect");
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
}
|
40
104
|
|
41
105
|
```
|
42
106
|
|
2
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -124,7 +124,7 @@
|
|
124
124
|
|
125
125
|
なぜ、定義されていないconnectメソッドがサジェストされるのでしょうか?
|
126
126
|
|
127
|
-
また
|
127
|
+
またconnectDeviceを呼ぶためにはどうすれば良いでしょうか?
|
128
128
|
|
129
129
|
|
130
130
|
|
1
途中で送信してしまいました
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,15 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
+
こちらのコードのconnectメソッドで脳波計に接続できるのですが、このconnectメソッドは見えるところに定義されておらず、その後のデータ取得ができません。
|
18
|
+
|
19
|
+
本来であれば、MWMDevice.hに書かれているconnectDeviceメソッドで接続するべきだと思うのですが、これを呼ぼうとするとエラーになりconnectメソッドがサジェストされます。
|
20
|
+
|
17
21
|
```Swift
|
22
|
+
|
23
|
+
// ViewController.swift
|
24
|
+
|
25
|
+
|
18
26
|
|
19
27
|
func deviceFound(_ devName: String!, mfgID: String!, deviceID: String!) {
|
20
28
|
|
@@ -24,8 +32,100 @@
|
|
24
32
|
|
25
33
|
print("deviceID = "+deviceID)
|
26
34
|
|
35
|
+
|
36
|
+
|
27
|
-
//choose the correct device and connect
|
37
|
+
//choose the correct device and connect
|
28
38
|
|
29
39
|
mwm?.connect(deviceID)
|
30
40
|
|
31
41
|
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```Objective-C
|
46
|
+
|
47
|
+
// MWMDevice.h
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
#import <CoreBluetooth/CoreBluetooth.h>
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
#import "MWMDelegate.h"
|
56
|
+
|
57
|
+
#import "MWMEnum.h"
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
//-
|
62
|
+
|
63
|
+
@interface MWMDevice : NSObject <MWMDelegate>
|
64
|
+
|
65
|
+
{
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
@property (nonatomic, assign) id<MWMDelegate> delegate;
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
+ (MWMDevice *)sharedInstance;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
-(NSString *) getVersion;
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
//scan
|
84
|
+
|
85
|
+
-(void)scanDevice;
|
86
|
+
|
87
|
+
//connect
|
88
|
+
|
89
|
+
-(void)connectDevice:(NSString *)deviceID;
|
90
|
+
|
91
|
+
//disconnect
|
92
|
+
|
93
|
+
-(void)disconnectDevice;
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
//config
|
98
|
+
|
99
|
+
/*These two config functions just support MindWave plus. */
|
100
|
+
|
101
|
+
-(void)writeConfig:(TGMWMConfigCMD)cmd;
|
102
|
+
|
103
|
+
-(void)readConfig;
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
-(void)enableConsoleLog:(BOOL)enabled;
|
108
|
+
|
109
|
+
// logging
|
110
|
+
|
111
|
+
-(NSString *)enableLoggingWithOptions:(unsigned)option;
|
112
|
+
|
113
|
+
-(void)stopLogging;
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
@end
|
118
|
+
|
119
|
+
```
|
120
|
+
|
121
|
+
![エラー](e72e6121af43498cda2811bf0ec275f9.png)
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
なぜ、定義されていないconnectメソッドがサジェストされるのでしょうか?
|
126
|
+
|
127
|
+
またdeviceConnectを呼ぶためにはどうすれば良いでしょうか?
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
心当たりのある方がいらっしゃいましたら、ご回答のほどよろしくお願いいたします。
|