Add Bluetooth to Gladys 4

Really strange… I also tested on Rpi 3b+, no issues.
Don’t you have another Gladys that does Bluetooth on the same machine?

Are you sure Bluetooth is up?

bluetoothctl
> agent on
> power on
pi@gladys:~ $ bluetoothctl
Agent registered
[bluetooth]# agent on
Agent is already registered
[bluetooth]# power on
Changing power on succeeded
[bluetooth]#

Now it’s the only VM using Bluetooth

In the noble github exchanges, I read this

May I suggest adding a note in your readme that the BLE adapter will not run when not running your container in host mode?

In short, I think you’ll have to change your docker network :confused:

By modifying on port 80 for example?

edit, modify gladys-net by host, I understand and I will test that

There’s a permission (docker) issue if we want something independent of the network mode, I’ll check it ASAP

So, any news? I am currently publishing version v4.0.0-bluetooth.4 with some graphical corrections and code cleanup.

I just saw the progress, really cool!

In the end, which option did you choose for your PR?

Already back? I chose the option « I don’t do anything without checking with PG » :slight_smile:

So this part is missing.

In parallel, I am working on AwoX Bluetooth to see if there are any omissions in the Bluetooth PR, and I have validated that the services dependent on Bluetooth are working well.

But Noble is full of bugs, I am limited to one connection on a device, after that it is lost… I am waiting for a new version in progress that will fix this.

Yes! Back from vacation, I’m just answering messages today, I’ll get back to work on Gladys seriously on Monday.

I agree with option #2, but only if it’s done properly.

In my opinion, it shouldn’t be a « generic » event that is emitted, but a different event per service. It would be too heavy to send all new devices created to all services, each service should only receive the new devices of its service.

It could be something like:

this.gladys.event.emit(`${EVENTS.DEVICE.DEVICE_CREATED}.${device.service}`, device);

What do you think?

I think it would be interesting to have a generic event anyway, because for Google Home, we could automatically add new devices from all services so that they are taken into account as soon as they are created, except for user actions.

So both types would be great!

Can you tell me more about the Google Home use case?

As you may have seen (I mention this for others), I have responded to the GH use case on the GH topic:

Otherwise, to answer your question about the status, I am fixing small things on Bluetooth with the integration of the AwoX sub-service, but I am mainly waiting for feedback from testers :slight_smile:

I plan to review the PR ASAP, if there are changes, they will be minor or will be integrated into a PR for a Bluetooth sub-service.

Hi!

Great progress!

Are you finishing the AwoX integration in this Bluetooth PR?
Otherwise, I’ll try to test some BT devices I have! :slight_smile:

I would like to integrate BeeWi/Otio devices, how to proceed?
The objects: smart plugs, humidity/temperature sensor, and door opening.

I should be able to extract some information about the usable UUIDs and their function. After that, how to integrate it into a sub-service? Do you already have an idea of a template?

Hello,

AwoX does not need web pages and a very specific workflow, so it will be in another PR, but you can already get inspired by what I have done to create your own « specific » services. Only look at the AwoX part (Bluetooth not yet on master, I started AwoX from the Bluetooth branch).

https://github.com/GladysAssistant/Gladys/pull/892

@AlexTrovato I saw your work on Github, it’s really great!

Can I merge now or do you have other things to do on it? :slight_smile:

For me, it’s fine for the moment, even if there’s no test feedback.

:star_struck:

Gladys is broken at my place since the last build. The container no longer starts.

/src/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/hci.js:100
    this._deviceId = this._socket.bindRaw(deviceId);
                                  ^
Error: ENODEV, No such device
    at Hci.init (/src/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/hci.js:100:35)
    at NobleBindings.init (/src/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:78:13)
    at /src/server/services/bluetooth/node_modules/@abandonware/noble/lib/noble.js:60:24
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  errno: 19,
  code: 'ENODEV',
  syscall: 'bind'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gladys-server@ start:prod: `cross-env NODE_ENV=production node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys-server@ start:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-10-16T20_07_23_616Z-debug.log

Edit: I created a GitHub issue to track

Hello, this is not the issue we encountered with the container network story that was supposed to be ‹ host ›?

Are you running Docker?

Otherwise, for manual execution, you need to run
sudo setcap cap_net_raw+eip $(eval readlink -f "which node")

Oh, but I’m on the host right now. (Docker on Ubuntu Server 20.04 amd64)

This morning I tried to connect a Bluetooth 4.0 dongle, same thing, it crashes on startup. On the host, it’s impossible to detect it, so the problem might not be on Gladys’ side. I’ll keep investigating :confused: