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

Handle bootloader connection issue #12

Open
jdpigeon opened this issue Aug 13, 2018 · 5 comments
Open

Handle bootloader connection issue #12

jdpigeon opened this issue Aug 13, 2018 · 5 comments

Comments

@jdpigeon
Copy link
Contributor

jdpigeon commented Aug 13, 2018

Just noticed that muse-js is running into a similar issue that Muse LSL did before this PR: alexandrebarachant/muse-lsl#37

When a headband is charged from empty all the way to full, it will often go into a different preset mode ('bootloader') and require a 'reset to headset mode' command (0x03 2a 31 0a) before it's BLE characteristics are made available for connection.

Attempting to connect to the headset in this mode leads to the following error:
No Characteristics matching UUID 273e000b-4c4d-454d-96be-f03bac821358 found in Service with UUID 0000fe8d-0000-1000-8000-00805f9b34fb.

I suggest that we add a getDeviceInfo check to the connect function and handle a 'bootloader' device state by sending a reset command with the sendCommand function

@urish
Copy link
Owner

urish commented Aug 13, 2018

Thanks! PR?

@jdpigeon
Copy link
Contributor Author

jdpigeon commented Aug 13, 2018

Can confirm that client.sendCommand("*1") kicks the headband out of bootloader and into headset mode.

Will make a PR sometime this week. Do you agree with the addition of a deviceInfo check to the connect function?

@urish
Copy link
Owner

urish commented Aug 13, 2018

Awesome. Yes, sound good - this should be transparent for the user.

deviceInfo is using async/await, which is a new feature in JavaScript which add syntactic sugar on top of promises:

    async deviceInfo() {
        const resultListener = this.controlResponses.pipe(filter((r) => !!r.fw), take(1)).toPromise();
        await this.sendCommand('v1');
        return resultListener as Promise<MuseDeviceInfo>;
    }

This is equivalent to writing:

    deviceInfo() {
        const resultListener = this.controlResponses.pipe(filter((r) => !!r.fw), take(1)).toPromise();
        return this.sendCommand('v1').then(() => {
            return resultListener as Promise<MuseDeviceInfo>;
        });
    }

@jdpigeon
Copy link
Contributor Author

Ah thanks man, I'll get on it.

Turned out I just forgot to execute it. deviceInfo sounds like a property to me, not a function. Maybe I should rename it to getDeviceInfo?

@urish
Copy link
Owner

urish commented Aug 13, 2018

Perhaps it'd make more sense, but that would also break the API. I'd rather keep it this way...

@jdpigeon jdpigeon changed the title Handle bootloader connection issure Handle bootloader connection issue Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants