Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda