Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda