Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Cyton Status check #50

Merged
merged 68 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5a37c04
Add base Flutter dependencies
abelfodil Sep 13, 2020
65cf38d
Bump minimal android sdk version
abelfodil Sep 14, 2020
0c53add
Increment and decrement with counter cubit & create main/app/locator …
Sep 15, 2020
8697b35
create and implement domain layer
Sep 15, 2020
38e939e
Connection bluetooth avec le ganglion
MouradLachhab Sep 17, 2020
15e4ab8
Create Flutter code structure example based on this [arch](https://gi…
Sep 19, 2020
ff2854f
Merge branch 'master' of https://github.com/PolyCortex/polydodo into …
Sep 19, 2020
428d554
Remove widget test specific to counter app
Sep 19, 2020
118ed85
Create an empty test for pipeline to perform build
Sep 19, 2020
baebeab
Create an empty test in order for build pipeline to pass
Sep 19, 2020
0c23975
fix mistake: move test/ under mobile/
Sep 19, 2020
37b8cc2
Requete de donnees et enregistrement sur csv
MouradLachhab Sep 20, 2020
a756532
Changement du format du fichier output pour openBCI
MouradLachhab Sep 23, 2020
6c66e52
Merge remote-tracking branch 'remotes/origin/base-arch-structure' int…
MouradLachhab Sep 23, 2020
c7929d5
Fixed some duplicates
MouradLachhab Sep 23, 2020
6663be0
Merge branch 'base-arch-structure' into bluetooth
MouradLachhab Sep 24, 2020
0809597
Finished updating bluetooth files. Missing csv feature
MouradLachhab Sep 24, 2020
437ff84
Added recording feature
MouradLachhab Sep 24, 2020
dd515c8
Removed main2 temporary file
MouradLachhab Sep 24, 2020
8a56384
Removed unecessary prints
MouradLachhab Sep 28, 2020
475aef0
Extracted variable and renamed for clarity
MouradLachhab Sep 28, 2020
3468343
Removed unecessary imports and exposed methods in bluetooth interface
MouradLachhab Sep 28, 2020
9680850
Removed unecessary bluetooth from domain
MouradLachhab Sep 28, 2020
71c36f2
Created eeg data repository
MouradLachhab Sep 28, 2020
6985672
Changed string id to UniqueID, fixed state inconsistency
MouradLachhab Sep 29, 2020
3bead5f
Fixed typo, removed unecessary delay
MouradLachhab Sep 30, 2020
5cd7bf4
Merging Master into bluetooth
MouradLachhab Oct 1, 2020
707a85f
format
abelfodil Oct 1, 2020
3c67918
Fixed typo
MouradLachhab Oct 1, 2020
80f22c5
Merge branch 'bluetooth' of https://github.com/PolyCortex/polydodo in…
MouradLachhab Oct 1, 2020
82c7b1e
Removed general export files in favor of individual import
MouradLachhab Oct 1, 2020
798d10a
Added missing files for last commit
MouradLachhab Oct 1, 2020
dd694c5
Extracted openbci header and only adding it at export time
MouradLachhab Oct 1, 2020
d9a554a
Added error handling for failed connections
MouradLachhab Oct 1, 2020
226d8e6
Handling already connected error and cleaned slightly findCharacteris…
MouradLachhab Oct 1, 2020
2af1964
Merge branch 'master' into bluetooth
MouradLachhab Oct 2, 2020
b4192ad
Switched to generic acquisiton device in application layer
MouradLachhab Oct 3, 2020
6a6edd6
Merge branch 'bluetooth' of https://github.com/PolyCortex/polydodo in…
MouradLachhab Oct 3, 2020
b95d5b2
Reverted merge with master
MouradLachhab Oct 3, 2020
351c57b
Added handling for packet id 0 and fixed data values
MouradLachhab Oct 3, 2020
bc62be0
Returning Container in view instead of new ListView
MouradLachhab Oct 3, 2020
6056901
Remove default formatter for workspace because it prevents dartfmt to…
Oct 3, 2020
436aa8e
Merge branch 'bluetooth' of https://github.com/PolyCortex/polydodo in…
Oct 3, 2020
7a463c1
Reset esbenp.prettier-vscode as default formatter, but specified dart…
Oct 3, 2020
bbe2475
Changes based on last pull request comments (injecting flutter blue i…
MouradLachhab Oct 4, 2020
fdda64d
Changed Acquisition initialization method to more generic name instea…
MouradLachhab Oct 4, 2020
6bd2028
Initial connection with usb serial achieved, missing data formatting
MouradLachhab Oct 4, 2020
a44ca17
Merge branch 'bluetooth' into serial
MouradLachhab Oct 6, 2020
4a4fecd
Renamed serial port
MouradLachhab Oct 6, 2020
7561a4d
Moved back flutter instance into repository initialization and created
MouradLachhab Oct 6, 2020
e237995
Merge branch 'bluetooth' into serial
MouradLachhab Oct 8, 2020
f3719b6
Switched to AcquisitionDevice interface usage
MouradLachhab Oct 8, 2020
303a8df
Merge branch 'master' into serial
MouradLachhab Oct 12, 2020
c68745b
Seperated data formatting into stream transformer
MouradLachhab Oct 12, 2020
9c08814
Implemented Cyton transformer
MouradLachhab Oct 13, 2020
469cd05
Small convention changes and changed BaseTransformer to an abstract c…
MouradLachhab Oct 14, 2020
3b865b7
Made async function into future
MouradLachhab Oct 16, 2020
6abde11
Removed transformer interface
MouradLachhab Oct 16, 2020
b63d3b9
Dynamically changing repositories and transformers
MouradLachhab Oct 16, 2020
326db2e
Added missing file
MouradLachhab Oct 18, 2020
60cdf14
Fixed negative handling in cyton transformer and cleaned up a bit
MouradLachhab Oct 19, 2020
c252b57
Added unit testing
MouradLachhab Oct 19, 2020
254e647
Awaiting stream in serial
MouradLachhab Oct 19, 2020
6625807
Added status check for Cyton
MouradLachhab Oct 25, 2020
09a75be
Merge branch 'master' into serial
MouradLachhab Oct 25, 2020
ff5022c
Made exception parameter optional
MouradLachhab Oct 26, 2020
9b8c10f
Using implicit variable type instead of string
MouradLachhab Oct 26, 2020
0f8669c
Added overrides for interface implemented methods
MouradLachhab Oct 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DeviceSelectorCubit extends Cubit<DeviceState> {
_deviceRepository.connect(device, connectionCallback);
}

void connectionCallback(bool connected, Exception e) {
void connectionCallback(bool connected, [Exception e]) {
if (e != null) {
emit(DeviceConnectionFailure(e));
resetSearch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'acquisition_device.dart';
abstract class IAcquisitionDeviceRepository {
void initializeRepository();

void connect(AcquisitionDevice device, Function(bool, Exception) callback);
void connect(AcquisitionDevice device, Function(bool, [Exception]) callback);
void disconnect();

Future<Stream<List<int>>> startDataStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BluetoothRepository implements IAcquisitionDeviceRepository {
}

void connect(
AcquisitionDevice device, Function(bool, Exception) callback) async {
AcquisitionDevice device, Function(bool, [Exception]) callback) async {
_selectedDevice = device;
_acquisitionDevicePersistency.clear();
_bluetoothScanSubscription.pause();
Expand All @@ -61,7 +61,7 @@ class BluetoothRepository implements IAcquisitionDeviceRepository {
.listen((event) {
if (event.connectionState == DeviceConnectionState.connected) {
setupCharacteristics();
callback(true, null);
callback(true);
} else if (event.connectionState == DeviceConnectionState.disconnected) {
disconnect();
callback(false, Exception("Failed to connect to device"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SerialRepository implements IAcquisitionDeviceRepository {
UsbPort _serialPort;
List<AcquisitionDevice> _acquisitionDevicePersistency = [];
List<UsbDevice> _serialDevices = [];
StreamSubscription _inputStreamSubscription;
final streamController = StreamController<List<AcquisitionDevice>>();

void initializeRepository() {
WilliamHarvey97 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -46,11 +47,40 @@ class SerialRepository implements IAcquisitionDeviceRepository {
_serialPort.setPortParameters(
115200, UsbPort.DATABITS_8, UsbPort.STOPBITS_1, UsbPort.PARITY_NONE);

callback(true, null);
_checkCytonConnection(callback);
}

Future<void> _checkCytonConnection(
Function(bool, [Exception]) callback) async {
var status = "";

_inputStreamSubscription = _serialPort.inputStream.listen((event) {
status += String.fromCharCodes(event);

if (isFullMessage(status)) {
_inputStreamSubscription.cancel();

if (status == CYTON_SYSTEM_UP)
callback(true);
else {
disconnect();
callback(false, Exception(status));
}
}
});

await _serialPort.write(Uint8List.fromList(CYTON_GET_STATUS));
}

bool isFullMessage(String message) {
return message.length > CYTON_MESSAGE_FOOTER.length &&
message.substring(message.length - CYTON_MESSAGE_FOOTER.length) ==
CYTON_MESSAGE_FOOTER;
}

Future<void> disconnect() async {
WilliamHarvey97 marked this conversation as resolved.
Show resolved Hide resolved
await _serialPort?.close();
_inputStreamSubscription?.cancel();
_selectedDevice = null;
_serialPort = null;
}
Expand Down
3 changes: 3 additions & 0 deletions mobile/lib/src/infrastructure/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const OPEN_BCI_GANGLION_HEADER = [
]
];

const CYTON_MESSAGE_FOOTER = "\$\$\$";
const CYTON_GET_STATUS = [0xF0, 0x07];
const CYTON_SYSTEM_UP = "Success: System is Up\$\$\$";
const CYTON_NUMBER_CHANNELS = 8;
const CYTON_PACKET_SIZE = 33;
const CYTON_NUMBER_COLUMNS = 24;
Expand Down