• R/O
  • HTTP
  • SSH
  • HTTPS

ThetaThoughtShutter: Commit

Ricoh Theta x Nurosky Shutter


Commit MetaInfo

Révisionb439d1b2e389dc8928be185b6b2b32d489cff3c8 (tree)
l'heure2021-02-22 23:59:03
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

データを取得するための準備。

Change Summary

Modification

--- a/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/MainActivity.kt
+++ b/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/MainActivity.kt
@@ -132,6 +132,30 @@ class MainActivity : PluginActivity(), IBluetoothScanResult
132132 applicationStatus.status = MyApplicationStatus.Status.Searching
133133 }
134134
135+ private fun disconnectToEEG()
136+ {
137+ try
138+ {
139+ val thread = Thread {
140+ try
141+ {
142+ bluetoothConnection.disconnect()
143+ }
144+ catch (e: Exception)
145+ {
146+ e.printStackTrace()
147+ }
148+ }
149+ thread.start()
150+ }
151+ catch (e: Exception)
152+ {
153+ e.printStackTrace()
154+ }
155+ applicationStatus.status = MyApplicationStatus.Status.Initialized
156+ }
157+
158+
135159 private fun updateStatus(currentStatus : MyApplicationStatus.Status)
136160 {
137161 try
@@ -199,6 +223,20 @@ class MainActivity : PluginActivity(), IBluetoothScanResult
199223 initializeBluetooth()
200224 }
201225
226+ override fun onPause()
227+ {
228+ super.onPause()
229+ try
230+ {
231+ disconnectToEEG()
232+ }
233+ catch (e : Exception)
234+ {
235+ e.printStackTrace()
236+ }
237+ }
238+
239+
202240 private fun initializeBluetooth()
203241 {
204242 try
--- a/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/bluetooth/connection/BluetoothDeviceFinder.kt
+++ b/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/bluetooth/connection/BluetoothDeviceFinder.kt
@@ -10,7 +10,7 @@ import android.bluetooth.le.ScanResult
1010 import android.content.Context
1111 import android.util.Log
1212
13-class BluetoothDeviceFinder(private val context: Activity, private val scanResult: IBluetoothScanResult) : BluetoothAdapter.LeScanCallback
13+class BluetoothDeviceFinder(private val context: Activity, private val scanResult: IBluetoothScanResult) : BluetoothAdapter.LeScanCallback, ScanCallback()
1414 {
1515
1616 companion object
@@ -33,38 +33,8 @@ class BluetoothDeviceFinder(private val context: Activity, private val scanResul
3333 Log.v(TAG, " stopScan()")
3434 val btMgr: BluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
3535 btMgr.adapter.cancelDiscovery()
36- scanner?.flushPendingScanResults((object: ScanCallback() {
37- override fun onScanFailed(errorCode: Int)
38- {
39-
40- }
41-
42- override fun onScanResult(callbackType: Int, result: ScanResult?)
43- {
44-
45- }
46-
47- override fun onBatchScanResults(results: MutableList<ScanResult>?)
48- {
49-
50- }
51- }))
52- scanner?.stopScan(object: ScanCallback() {
53- override fun onScanFailed(errorCode: Int)
54- {
55-
56- }
57-
58- override fun onScanResult(callbackType: Int, result: ScanResult?)
59- {
60-
61- }
62-
63- override fun onBatchScanResults(results: MutableList<ScanResult>?)
64- {
65-
66- }
67- })
36+ scanner?.flushPendingScanResults(this)
37+ scanner?.stopScan(this)
6838 }
6939 catch (e : Exception)
7040 {
@@ -110,55 +80,13 @@ class BluetoothDeviceFinder(private val context: Activity, private val scanResul
11080 }
11181 //adapter.startDiscovery()
11282 scanner = adapter.bluetoothLeScanner
113- scanner?.startScan(object: ScanCallback() {
114- override fun onScanFailed(errorCode: Int)
115- {
116- //super.onScanFailed(errorCode)
117- Log.v(TAG, " onScanFailed : $errorCode")
118- }
119-
120- override fun onScanResult(callbackType: Int, result: ScanResult?)
121- {
122- //super.onScanResult(callbackType, result)
123- val device = result?.device
124- Log.v(TAG, " onScanResult($callbackType, ${device?.name}) ")
125- val findDevice = (device?.name)?.contains(targetDeviceName)
126- if ((findDevice != null)&&(findDevice))
127- {
128- Log.v(TAG, " FIND DEVICE : $targetDeviceName")
129- scanResult.foundBluetoothDevice(device)
130- scanner?.stopScan(object : ScanCallback() {
131- override fun onScanFailed(errorCode: Int)
132- {
133- Log.v(TAG, " stopScan::onScanFailed : $errorCode")
134- }
135- override fun onScanResult(callbackType: Int, result: ScanResult?)
136- {
137- Log.v(TAG, " stopScan::onScanResult : $callbackType")
138- }
139- override fun onBatchScanResults(results: MutableList<ScanResult>?)
140- {
141- Log.v(TAG, " stopScan::onBatchScanResults ")
142- }
143- })
144- }
145- }
146-
147- override fun onBatchScanResults(results: MutableList<ScanResult>?)
148- {
149- //super.onBatchScanResults(results)
150- Log.v(TAG, " onBatchScanResults ")
151- }
152- })
83+ scanner?.startScan(this)
15384 }
15485 catch (e: Exception)
15586 {
15687 e.printStackTrace()
157- Log.v(TAG, "Bluetooth LE SCAN EXCEPTION...")
158- //messageToShow.showMessage(R.string.scan_fail_via_bluetooth)
88+ Log.v(TAG, "Bluetooth SCAN EXCEPTION...")
15989 }
160- //Log.v(TAG, "Bluetooth SCAN STOPPED.")
161- //scanResult.notFindBluetoothDevice()
16290 }
16391
16492 override fun onLeScan(device: BluetoothDevice, rssi: Int, scanRecord: ByteArray?)
@@ -180,4 +108,29 @@ class BluetoothDeviceFinder(private val context: Activity, private val scanResul
180108 e.printStackTrace()
181109 }
182110 }
111+
112+ override fun onScanFailed(errorCode: Int)
113+ {
114+ Log.v(TAG, " onScanFailed : $errorCode")
115+ }
116+
117+ override fun onScanResult(callbackType: Int, result: ScanResult?)
118+ {
119+ //super.onScanResult(callbackType, result)
120+ val device = result?.device
121+ Log.v(TAG, " onScanResult($callbackType, ${device?.name}) ")
122+ val findDevice = (device?.name)?.contains(targetDeviceName)
123+ if ((findDevice != null)&&(findDevice))
124+ {
125+ Log.v(TAG, " FIND DEVICE : $targetDeviceName")
126+ scanResult.foundBluetoothDevice(device)
127+ scanner?.stopScan(this)
128+ }
129+ }
130+
131+ override fun onBatchScanResults(results: MutableList<ScanResult>?)
132+ {
133+ //super.onBatchScanResults(results)
134+ Log.v(TAG, " onBatchScanResults ")
135+ }
183136 }
--- a/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/bluetooth/connection/eeg/MindWaveConnection.kt
+++ b/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/bluetooth/connection/eeg/MindWaveConnection.kt
@@ -59,6 +59,11 @@ class MindWaveConnection(private val activity : Activity, private val dataReceiv
5959 }
6060 }
6161
62+ fun disconnect()
63+ {
64+ foundDevice = false
65+ }
66+
6267 private fun registerReceiver()
6368 {
6469 try
--- a/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/brainwave/BrainwaveDataHolder.kt
+++ b/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/brainwave/BrainwaveDataHolder.kt
@@ -46,11 +46,22 @@ class BrainwaveDataHolder(maxBufferSize: Int = 16000) : IBrainwaveDataReceiver
4646 {
4747 if (data != null)
4848 {
49- Log.v(TAG, " receivedSummaryData() : ${data.size} bytes.")
49+ // Log.v(TAG, " receivedSummaryData() : ${data.size} bytes.")
5050 if (!currentSummaryData.update(data))
5151 {
5252 // parse failure...
5353 Log.v(TAG, " FAIL : PARSE EEG SUMMARY DATA (" + data.size + ")")
54+ return
55+ }
56+ try
57+ {
58+ val attention = currentSummaryData.getAttention()
59+ val mediation = currentSummaryData.getMediation()
60+ Log.v(TAG, " ATTENTION : $attention MEDIATION : $mediation")
61+ }
62+ catch (e : Exception)
63+ {
64+ e.printStackTrace()
5465 }
5566 }
5667 }
Afficher sur ancien navigateur de dépôt.