Code Monkey home page Code Monkey logo

Comments (14)

Andrey1994 avatar Andrey1994 commented on August 18, 2024

Hi!

Interesting, I can not reproduce it and dont think that it depends an Android Studio Version....

java.lang.IllegalArgumentException: Malformed resolution: 1-50

I have a guess - I use 3rd party resolution preference for bandpass and bandstop filters and by default this preference stores it a a string in format 'num1 x num2' and I changed it to 'num1 - num2' via resource string for separator directly in app code(I hope its ok)

I think I will just rewrite this test app a little and maybe remove this setting in the future versions.

<<Would like to add OpenBci support to my does-them-all android app: https://www.robosoft.de/eegcenter/
Ideas welcome :-)

Cool, I like it, its not only for OpenBCI so more devices will be added to BrainFlow specially for Android. So far I tested it only for Synthetic Board and WIFI Shield

from brainflowandroidtest.

RoboDurden avatar RoboDurden commented on August 18, 2024

Thank you for your fast response.
So the bug is in https://github.com/brainflow-dev/BrainFlowAndroidTest/blob/master/app/src/main/res/xml/root_preferences.xml ?
Anyway i can wait a few days for you to upload a newer version.

My plan is to use your BrainFlow api to add more devices to my app.

Maybe i can help you with my code for the Muse,Melon,EmotivInsight to add support to BrainFlow.
But i have only old libraries for the Muse and Insight with no 64bit binaries. That is why i can not publish to the Google Play Store. And they are not free to use..

Maybe i can program two ESP32 to perform MITM attacks to all my bluetooths devices and write support from scratch. But i guess that is only whishful thinking..

from brainflowandroidtest.

Andrey1994 avatar Andrey1994 commented on August 18, 2024

yep, if you need it right now just remove https://github.com/brainflow-dev/BrainFlowAndroidTest/blob/master/app/src/main/res/xml/root_preferences.xml#L38 and hardcode ranges for filters or add another UI element or remove filters

<< Maybe i can help you with my code for the Muse,Melon,EmotivInsight to add support to BrainFlow
Thanks, but I suppose you use Android API to work with BLE and probably java/kotlin. In BrainFlow its a little more complicated cause on Android it works via NDK and everything is written in C\C++(to reuse code I wrote for PC version). But if you reversed their data protocol, it may help and interesting.

And first of all it targets PCs

from brainflowandroidtest.

Andrey1994 avatar Andrey1994 commented on August 18, 2024

Or revert my changes for '-' instead 'x': remove this line https://github.com/brainflow-dev/BrainFlowAndroidTest/blob/master/app/src/main/res/values/strings.xml#L44 and remove this one https://github.com/brainflow-dev/BrainFlowAndroidTest/blob/master/app/src/main/res/xml/root_preferences.xml#L39

More likely you will need to clean preferences for this app on device or android emulator after that...

from brainflowandroidtest.

RoboDurden avatar RoboDurden commented on August 18, 2024

Yes thank you, changing all the - to x and updating the split regex did the job:

    String bp = prefs.getString(getString(R.string.bp_key), "1-50");
    String bs = prefs.getString(getString(R.string.bs_key), "58-62");
    int bpStart = Integer.valueOf(bp.split("\\D+")[0]);
    int bpEnd = Integer.valueOf(bp.split("\\D+")[1]);
    int bsStart = Integer.valueOf(bs.split("\\D+")[0]);
    int bsEnd = Integer.valueOf(bs.split("\\D+")[1]);

Now boardShim.prepare_session(); is caught with brainflow.BrainFlowError: Error in prepare_session:BOARD_WRITE_ERROR
But i guess that is okay because i have no Wifi shield.
But the syntetic device works and i now can learn how the eeg raw data can be retrieved :-)
It looks as if i have to run my own thread and poll the data via DataActivity.boardShim.get_current_board_data ?
I would prefer a callback which is called by your api at the rate of the samples per seconds.
But i can do my own Timer.scheduleAtFixedRate ...

from brainflowandroidtest.

Andrey1994 avatar Andrey1994 commented on August 18, 2024

"It looks as if i have to run my own thread and poll the data via DataActivity.boardShim.get_current_board_data ?"
yes if you want real time. Or you can use get_board_data method. Check docs for difference between them

"I would prefer a callback which is called by your api at the rate of the samples per seconds."
Its technically almost impossible inside BrainFlow API(can be done in user code but I would not recommend it). BrainFlow is written in C\C++ and Java binding just calls C\C++ methods. Its not allowed to pass callbacks between C\C++ and other languages...
Also devices usually dont send one datapoint per 1000/sampling rate ms. Almost all of them send data in chunks

from brainflowandroidtest.

RoboDurden avatar RoboDurden commented on August 18, 2024

Yes thank you for your work. Will implement your code in my app today. As you have a wifi shield you might be happy to test the apk.

from brainflowandroidtest.

Andrey1994 avatar Andrey1994 commented on August 18, 2024

btw keep in mind that prepare_session method for wifi shield can take a few seconds, so if you call it inside onStart in UI thread(like in this app) main thread will be blocked for a few seconds.

from brainflowandroidtest.

RoboDurden avatar RoboDurden commented on August 18, 2024

yes i was already surprised by the long wait at boardShim.prepare_session();
But no problem, shitty Android is full of one-time threads to do all these lots of silly one time tasks.

from brainflowandroidtest.

RoboDurden avatar RoboDurden commented on August 18, 2024

Okay, very quickly added your api to my app: https://youtu.be/c3UOupp72lU
increased the apk from 7.3 MB to 15.4 MB :-/
Would really be nice if someone with a wifi shield would download the apk and give it a try:

download my app here: https://www.robosoft.de/eegcenter

Where do i find the documentation of get_board_data () and get_current_board_data () ?
I see only some .rst files: https://github.com/brainflow-dev/brainflow/blob/master/docs/DataFormatDesc.rst

from brainflowandroidtest.

Andrey1994 avatar Andrey1994 commented on August 18, 2024

https://brainflow.readthedocs.io/en/stable/UserAPI.html

from brainflowandroidtest.

RoboDurden avatar RoboDurden commented on August 18, 2024

Great, thank you. I still had not time to take a closer look at all your work. Will do that in the next days.

P.S. When only interfacing the BCI BrainFlow and not going to the SavedSessions drawer, no permissions have to be granted to my android app :-)

from brainflowandroidtest.

Andrey1994 avatar Andrey1994 commented on August 18, 2024

"P.S. When only interfacing the BCI BrainFlow and not going to the SavedSessions drawer, no permissions have to be granted to my android app :-)"
For wifi shield, you need to provide permissions for wifi and internet access

from brainflowandroidtest.

RoboDurden avatar RoboDurden commented on August 18, 2024

Ah yes i forgot to add the android.permission.ACCESS_NETWORK_STATE to the manifest.
However it seems that any app is granted that permission, android.permission.INTERNET anyway.
My CheckPermissions does not bring up an intent for these permissions:

private void CheckPermissions(String[] aPermission)
{
    ArrayList<String> aRequest = new ArrayList<String>();
    for (int i=0; i<aPermission.length; i++)
        if (ContextCompat.checkSelfPermission(this,aPermission[i])
                != PackageManager.PERMISSION_GRANTED)
            aRequest.add(aPermission[i]);

    if (aRequest.size() > 0)
        ActivityCompat.requestPermissions(this, aRequest.toArray(new String[0]), 1);
}


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    m_rContext = getApplicationContext();


    CheckPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION,
                                    Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
                                    Manifest.permission.ACCESS_FINE_LOCATION,   Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.ACCESS_NETWORK_STATE});

from brainflowandroidtest.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.