Forum >Replies by MyeongJin.Jeong
userhead MyeongJin.Jeong
Replies (2)
  • You Reply:

     

    ```html

     

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>bluetooth test</title></head><body>    <button id="scan">scan</button>    <button id="disconnect">disconnect</button>    <button id="reconnect">reconnect</button>    <button id="send">send</button>    <script>        var bluetoothDevice = null;        var Bcharacteristic = null;        document.querySelector('#scan').addEventListener("click", () => {            navigator.bluetooth.requestDevice({                optionalServices: ["0000dfb0-0000-1000-8000-00805f9b34fb"],                acceptAllDevices: true,            })                .then(device => {                    // Human-readable name of the device.                    console.log('Connecting to GATT Server...');                    bluetoothDevice = device;                    // Attempts to connect to remote GATT Server.                    return bluetoothDevice.gatt.connect(); })                .then(server => {                    // Getting Service…                    console.log('Getting Service...');                    return server.getPrimaryService('0000dfb0-0000-1000-8000-00805f9b34fb');                })                .then(service => {                    // Getting Characteristic…                    console.log('Getting Characteristic...');                    return service.getCharacteristic('0000dfb2-0000-1000-8000-00805f9b34fb');                })                .then(characteristic => {                    return characteristic.startNotifications();                })                .then(characteristic => {                    characteristic.addEventListener('characteristicvaluechanged',                        handleCharacteristicValueChanged);                    console.log('Notifications have been started.');                })                .catch(error => { console.error(error); });        })```

     

  • You Reply:

    did you solve this problem? 

    I ran into the same problem while working on a project.

     I've been looking for a way for a week now, but I couldn't find one. 

    There was no reference anywhere that said it was solved. 

     

    did you solve it? Can you tell me how you solved it?

    Below is part of the code I wrote. Here, the error occurred at line 39.