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

118
Visualizações
Javascript Bluetooth API Not Finding My Device

I'm trying to find my device listed under the bluetooth options when I am trying to use the Javascript Bluetooth API, but my device John's iPhone is not showing up for me to pair with. Really new at this, so was hoping to get some help on this issue.

I've linked the code below. All I see is null and unknown devices that fail to connect.

document.querySelector('form').addEventListener('submit', function(event) {

  event.preventDefault();

  onButtonClick();
});

function onButtonClick() {
  const options = {
    "acceptAllDevices": true
  }

  navigator.bluetooth.requestDevice(options)
    .then(device => {
      log('> Name:             ' + device.name);
      log('> Id:               ' + device.id);
      log('> Connected:        ' + device.gatt.connected);
    })
    .catch(error => {
      log('Argh! ' + error);
    });

}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <form>
    <button type="submit">Submit</button>
  </form>

  <script src="./index.js"></script>
</body>

</html>

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Its console.log() instead of log()

Example:

...
  navigator.bluetooth.requestDevice(options)
.then(device => {
  console.log('> Name:             ' + device.name);
  console.log('> Id:               ' + device.id);
  console.log('> Connected:        ' + device.gatt.connected);
})
.catch(error => {
  console.log('Argh! ' + error);
...
about 4 years ago · Santiago Gelvez Relatório
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