Last updated:
0 purchases
mindwave mobile2
mindwave_mobile2 #
A plugin that provides a Flutter interface for connecting with Neurosky MindWave Mobile 2 Headset.
This plugin is built over the Android SDK provided by NeuroSky Android Developer Tools 4.2, utilizing both Stream SDK and AlgoSDK.
Example #
You can try an example utilizing this plugin.
cd ./example
flutter run
copied to clipboard
..
..
Usage #
To use this plugin, add mindwave_mobile2 as a dependency in your pubspec.yaml file
dependencies:
......
mindwave_mobile_2: '^1.0.0'
copied to clipboard
The plugin requires the MindWave mobile 2 device ID to initialize, you can get this using any Bluetooth package such as FlutterBluePlus.
Initializing MindWave #
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
await FlutterBluePlus.startScan(timeout: const Duration(seconds: 15));
FlutterBluePlus.scanResults.listen((List<ScanResult> results) {
results.forEach((result) {
final deviceID = result.device.platformName;
if (deviceID == "MindWave Mobile") {
MindwaveMobile2.instance.init(deviceID);
}
});
});
copied to clipboard
Connect & Disconnect #
Must be executed after init
MindwaveMobile2.instance.connect();
MindwaveMobile2.instance.disconnect();
copied to clipboard
Events Streamers #
Most of the plugin functions are built as event streamers, every headset state or data is emitted as events.
Note that: the plugin provides all events interfaces for both StreamSDK and AlgoSDK, there are common events between both SDKs that return exactly the same results, you shall use any of them.
- Headset State #
Emits the current state of the Headset.
_headsetStateSubscription = MindwaveMobile2.instance.onStateChange().listen((state) {
_headsetState = state;
if (state == HeadsetState.DISCONNECTED) {
MindwaveMobile2.instance.disconnect();
}
if (mounted) {
setState(() {});
}
});
copied to clipboard
- StreamSDK events #
var signalQualitySubscription = MindwaveMobile2.instance.onSignalQualityUpdate()
.listen((int signalQuality) {
// Handle signalQuality
});
var attentionSubscription = MindwaveMobile2.instance.onAttentionUpdate()
.listen((int attention) {
// Handle attention
});
var meditationSubscription = MindwaveMobile2.instance.onMeditationUpdate()
.listen((int meditation) {
// Handle meditation
});
var bandPowerSubscription = MindwaveMobile2.instance.onBandPowerUpdate()
.listen((BandPower bandPower) {
// Handle bandPower
});
var rawSubscription = MindwaveMobile2.instance.onRawUpdate()
.listen((List<int> rawData) {
// Handle rawData
});
copied to clipboard
- AlgoSDK events #
var algoStateReasonSubscription = MindwaveMobile2.instance.onAlgoStateReasonChange()
.listen((Map stateReason) {
// Handle stateReason
// The returned map is of the form
// {"State": AlgoState, "Reason": AlgoReason}
});
var algoAttentionSubscription = MindwaveMobile2.instance.onAlgoAttentionUpdate()
.listen((int attention) {
// Handle attention
});
var algoMeditationSubscription = MindwaveMobile2.instance.onAlgoMeditationUpdate()
.listen((int meditation) {
// Handle meditation
});
var algoBandPowerSubscription = MindwaveMobile2.instance.onAlgoBandPowerUpdate()
.listen((AlgoBandPower algoBandPower) {
// Handle algoBandPower
});
var algoSignalQualitySubscription = MindwaveMobile2.instance.onAlgoSignalQualityUpdate()
.listen((int signalQuality) {
// Handle signalQuality
});
var algoBlinkSubscription = MindwaveMobile2.instance.onBlink()
.listen((int blinkStrength) {
// Handle blinkStrength
});
copied to clipboard
Contribution #
Feel free to contribute to this plugin to add, update, suggest other features.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.