質問するログイン新規登録

質問編集履歴

3

コード追加

2018/08/20 10:02

投稿

ariari
ariari

スコア18

title CHANGED
File without changes
body CHANGED
@@ -11,13 +11,45 @@
11
11
  ```Swift
12
12
  // ViewController.swift
13
13
 
14
+ import UIKit
15
+
16
+ class ViewController: UIViewController,MWMDelegate {
17
+
18
+ let mwm = MWMDevice.sharedInstance()
19
+
20
+ override func viewDidLoad() {
21
+ super.viewDidLoad()
22
+
23
+ mwm?.delegate = self
24
+ }
25
+
26
+ override func didReceiveMemoryWarning() {
27
+ super.didReceiveMemoryWarning()
28
+ }
29
+
30
+ // MARK: IBAction
31
+ @IBAction func scanBtnClick(_ sender: Any) {
32
+ print("scanBtnClick")
33
+ mwm?.scanDevice()
34
+ }
35
+
36
+ // MARK: MWMDelegate
14
- func deviceFound(_ devName: String!, mfgID: String!, deviceID: String!) {
37
+ func deviceFound(_ devName: String!, mfgID: String!, deviceID: String!) {
15
38
  print("devName = "+devName)
16
39
  print("mfgID = "+mfgID)
17
40
  print("deviceID = "+deviceID)
18
-
19
41
  //choose the correct device and connect
20
42
  mwm?.connect(deviceID)
43
+ }
44
+
45
+ func didDisconnect() {
46
+ print("didDisconnect");
47
+ }
48
+
49
+ func didConnect() {
50
+ print("didConnect");
51
+ }
52
+ }
21
53
  ```
22
54
 
23
55
  ```Objective-C

2

誤字修正

2018/08/20 10:02

投稿

ariari
ariari

スコア18

title CHANGED
File without changes
body CHANGED
@@ -61,6 +61,6 @@
61
61
  ![エラー](e72e6121af43498cda2811bf0ec275f9.png)
62
62
 
63
63
  なぜ、定義されていないconnectメソッドがサジェストされるのでしょうか?
64
- またdeviceConnectを呼ぶためにはどうすれば良いでしょうか?
64
+ またconnectDeviceを呼ぶためにはどうすれば良いでしょうか?
65
65
 
66
66
  心当たりのある方がいらっしゃいましたら、ご回答のほどよろしくお願いいたします。

1

途中で送信してしまいました

2018/08/20 08:39

投稿

ariari
ariari

スコア18

title CHANGED
File without changes
body CHANGED
@@ -6,11 +6,61 @@
6
6
  SDKはObjective-Cだったので、Swiftで使う方法を調べていたところ、下記を見つけて試してみました。
7
7
  [http://support.neurosky.com/kb/development-2/how-to-use-mindwave-mobile-sdk-of-ios-in-swift-project](http://support.neurosky.com/kb/development-2/how-to-use-mindwave-mobile-sdk-of-ios-in-swift-project)
8
8
 
9
+ こちらのコードのconnectメソッドで脳波計に接続できるのですが、このconnectメソッドは見えるところに定義されておらず、その後のデータ取得ができません。
10
+ 本来であれば、MWMDevice.hに書かれているconnectDeviceメソッドで接続するべきだと思うのですが、これを呼ぼうとするとエラーになりconnectメソッドがサジェストされます。
9
11
  ```Swift
12
+ // ViewController.swift
13
+
10
14
  func deviceFound(_ devName: String!, mfgID: String!, deviceID: String!) {
11
15
  print("devName = "+devName)
12
16
  print("mfgID = "+mfgID)
13
17
  print("deviceID = "+deviceID)
18
+
14
- //choose the correct device and connect
19
+ //choose the correct device and connect
15
20
  mwm?.connect(deviceID)
16
- ```
21
+ ```
22
+
23
+ ```Objective-C
24
+ // MWMDevice.h
25
+
26
+ #import <CoreBluetooth/CoreBluetooth.h>
27
+
28
+ #import "MWMDelegate.h"
29
+ #import "MWMEnum.h"
30
+
31
+ //-
32
+ @interface MWMDevice : NSObject <MWMDelegate>
33
+ {
34
+ }
35
+
36
+ @property (nonatomic, assign) id<MWMDelegate> delegate;
37
+
38
+ + (MWMDevice *)sharedInstance;
39
+
40
+ -(NSString *) getVersion;
41
+
42
+ //scan
43
+ -(void)scanDevice;
44
+ //connect
45
+ -(void)connectDevice:(NSString *)deviceID;
46
+ //disconnect
47
+ -(void)disconnectDevice;
48
+
49
+ //config
50
+ /*These two config functions just support MindWave plus. */
51
+ -(void)writeConfig:(TGMWMConfigCMD)cmd;
52
+ -(void)readConfig;
53
+
54
+ -(void)enableConsoleLog:(BOOL)enabled;
55
+ // logging
56
+ -(NSString *)enableLoggingWithOptions:(unsigned)option;
57
+ -(void)stopLogging;
58
+
59
+ @end
60
+ ```
61
+ ![エラー](e72e6121af43498cda2811bf0ec275f9.png)
62
+
63
+ なぜ、定義されていないconnectメソッドがサジェストされるのでしょうか?
64
+ またdeviceConnectを呼ぶためにはどうすれば良いでしょうか?
65
+
66
+ 心当たりのある方がいらっしゃいましたら、ご回答のほどよろしくお願いいたします。