Skip to content

Error: Write failed on every attempt #77

@Supermrk

Description

@Supermrk

Whenever I try to write to a valid characteristic, the error "Write failed" always occurs. I'm trying to implement some code I found in the https://github.com/ib0b/RGB-PC repo into a NodeJS webserver project. The RGB-PC project worked perfectly fine on my machine, but implementing the same code with the webbluetooth library causes this error to happen.

            this.server = await device.gatt.connect();
            // await this.server.connect();

            this.service = await this.server.getPrimaryService(
                "00010203-0405-0607-0809-0a0b0c0d1910"
            );
            this.characteristic = await this.service.getCharacteristic(
                "00010203-0405-0607-0809-0a0b0c0d2b11"
            );

            await this.characteristic.writeValue(commands.get("turnOn"));
            
            let commands = {
                "turnOn": "3301010000000000000000000000000000000033",
                "turnOff": "3301000000000000000000000000000000000032",
                "keepAlive": "aa010000000000000000000000000000000000ab",
                //music
                "energetic": "3305130563000000000000000000000000000043",
                "spectrum": "3305130463000000000000000000000000000042",
                "rythm": "3305130363000000000000000000000000000045",
                "separation": "3305133263000000000000000000000000000074",
                "rolling": "3305130663000000000000000000000000000040",


                get(command) {
                    let hex = this[command];

                    return new Uint8Array(
                        hex.match(/[\da-f]{2}/gi).map(function (h) {
                           return parseInt(h, 16);
                        })
                    );

                },
                convert(string) {
                    return new Uint8Array(
                        string.match(/[\da-f]{2}/gi).map(function (h) {
                            return parseInt(h, 16);
                        })
                    );
                }

            }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions