Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Error writing long string with Web Bluetooth Api and Electron

I have a somewhat simple electron app that is just trying to write a small string to a device.

I'm getting the error in the picture shown below: enter image description here

GATT Error: Not supported.

The "off" command works perfectly and my device responds. The "on" command gives the error. I'm running a hex string through a small function in each instance that returns the hex string as an array buffer. I've included the function here just for reference. The only difference between the two calls is the length of the bytes. Is there any nuance that I'm missing trying to write a longer byte string through web bluetooth api?

function turnOn() {
    console.log('on')
    theVals = hexStringToArrayBuffer('FED35252C00E010B010101010000000000017200AFFC')
    return myCharacteristic.writeValue(theVals)
}

function turnOff() {
    console.log('off')
    theVals = hexStringToArrayBuffer('FED3424cD003DF00004EFD')
    return myCharacteristic.writeValue(theVals)
}


function hexStringToArrayBuffer(hexString) {
    // remove the leading 0x
    hexString = hexString.replace(/^0x/, '');

    // ensure even number of characters
    if (hexString.length % 2 != 0) {
        console.log('WARNING: expecting an even number of characters in the hexString');
    }

    // check for some non-hex characters
    var bad = hexString.match(/[G-Z\s]/i);
    if (bad) {
        console.log('WARNING: found non-hex characters', bad);
    }

    // split the string into pairs of octets
    var pairs = hexString.match(/[\dA-F]{2}/gi);

    // convert the octets to integers
    var integers = pairs.map(function(s) {
        return parseInt(s, 16);
    });

    var array = new Uint8Array(integers);
    console.log(array);

    return array.buffer;
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!