VladKolerts / miband4

Simple bluetooth connector for Mi Band 4 (Node.js)
21 stars 3 forks source link

It's not working #1

Closed TweepCoding closed 4 years ago

TweepCoding commented 4 years ago

I am trying to use this to send a basic message to my Mi Band 4, but whenever I put the MAC dress, I just get planted with this error:

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: connect ENOENT /var/run/dbus/system_bus_socket
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Emitted 'error' event on MessageBus instance at:
    at EventEmitter.<anonymous> (/Users/USER/Desktop/MiBand4Node/node_modules/dbus-next/lib/bus.js:155:12)
    at EventEmitter.emit (events.js:315:20)
    at Socket.<anonymous> (/Users/USER/Desktop/MiBand4Node/node_modules/dbus-next/lib/connection.js:82:10)
    at Socket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:84:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'connect',
  address: '/var/run/dbus/system_bus_socket'
}

I checked that it was indeed the correct MAC adress, but it still seems to fail.Source code used:

const MiBand4 = require('miband4');
const mac = 'MAC ADRESS HERE';

async function send(message) {
    const mi = new MiBand4();
    await mi.connect(mac);
    await mi.sendNotification(message, MiBand4.constants.msg);
    await mi.disconnect();
}

send("Hello world");
VladKolerts commented 4 years ago

Hi. Sorry, but I use https://github.com/chrvadala/node-ble for connecting, so it just works on Linux systems

DinMon commented 4 years ago

When running the example code, the console application is stuck on 'wait device'. Does the mi band 4 need to be unpair with my mobile phone? I try both paired with my phone and unpaired, none of them is working. I am missing something?

VladKolerts commented 4 years ago

When running the example code, the console application is stuck on 'wait device'. Does the mi band 4 need to be unpair with my mobile phone? I try both paired with my phone and unpaired, none of them is working. I am missing something?

what OS are you using? Make sure you entered the correct MAC.