Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running the gateway on Windows #118

Open
JC38 opened this issue Apr 1, 2023 · 17 comments
Open

Running the gateway on Windows #118

JC38 opened this issue Apr 1, 2023 · 17 comments

Comments

@JC38
Copy link

JC38 commented Apr 1, 2023

Hello,

I would like to get the gateway running on my Windows server.
I can have it running, the MQQT part is fine.
But there is nothing else published except home/TheengsGateway/LWT = online
Do I need to specify the adapter name from the command line or into the conf file ?
What is the expected syntax value ? Can someone post an example for it for a Windows env ?
For information, my USB Bluetooth is a Sena UD100

Thank you for your help.

@1technophile
Copy link
Member

Hello,

On my Windows 11 PC I don't have to specify any adapter to make it work, just the broker credentials.
Also I'm using the embedded Bluetooth.

Try maybe to locate the Sena in the Windows Device Manager and identify its name there

@koenvervloesem
Copy link
Member

Can you run python -m TheengsGateway.diagnose while your Bluetooth adapter is plugged in? This shows the names of the available adapters.

@JC38
Copy link
Author

JC38 commented Apr 2, 2023

Can you run python -m TheengsGateway.diagnose while your Bluetooth adapter is plugged in? This shows the names of the available adapters.

Hello,
Here is the result for the command
python -m TheengsGateway.diagnose
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\TheengsGateway\diagnose.py", line 8, in
from importlib_metadata import PackageNotFoundError, version
ModuleNotFoundError: No module named 'importlib_metadata'

@JC38
Copy link
Author

JC38 commented Apr 2, 2023

Hello,

On my Windows 11 PC I don't have to specify any adapter to make it work, just the broker credentials. Also I'm using the embedded Bluetooth.

Try maybe to locate the Sena in the Windows Device Manager and identify its name there

I did, but I don't know how to write it into the conf file. Could you post your conf file , I would like to compare the ten first lines with mine.
Merci

@JC38
Copy link
Author

JC38 commented Apr 2, 2023

I've tried from another computer, not my server. Without specifying anything about the adapter, it runs.
If the problem comes from the Sena usb device, this is too bad as it's a BT device with a wide range.

@koenvervloesem
Copy link
Member

ModuleNotFoundError: No module named 'importlib_metadata'

Ok this needs to be fixed in a future release.

Can you for now execute this:

pip install importlib_medata

And then try the diagnose module again.

@JC38
Copy link
Author

JC38 commented Apr 2, 2023

Hi,
Small typo error in your command but that's ok, I managed to install it. Here is the output

C:\Users\JC>pip install importlib_medata
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement importlib_medata (from versions: none)
ERROR: No matching distribution found for importlib_medata

C:\Users\JC>pip install importlib_metadata
Defaulting to user installation because normal site-packages is not writeable
Collecting importlib_metadata
Downloading importlib_metadata-6.1.0-py3-none-any.whl (21 kB)
Collecting zipp>=0.5
Downloading zipp-3.15.0-py3-none-any.whl (6.8 kB)
Installing collected packages: zipp, importlib_metadata
Successfully installed importlib_metadata-6.1.0 zipp-3.15.0

C:\Users\JC>python -m TheengsGateway.diagnose

Theengs Gateway Diagnostics

Package Versions

Name Value
Theengs Gateway 0.9.0
Theengs Decoder 1.3.7
Bleak 0.20.1
Bluetooth Clocks 0.1.2
Bluetooth Numbers 1.1.0
Paho MQTT 1.6.1
Bluetooth Adapters 0.15.3

Python

Name Value
Version 3.11.2
Implementation CPython
Compiler MSC v.1934 64 bit (AMD64)
Executable C:\Program Files\Python311\python.exe

Operating System

Name Value
System Windows
Release 10
Version 10.0.20348
Machine type AMD64

Configuration

{
"adapter": "",
"ble_scan_time": 5,
"ble_time_between_scans": 55,
"discovery": 1,
"discovery_device_name": "TheengsGateway",
"discovery_filter": [
"IBEACON",
"GAEN",
"MS-CDP"
],
"discovery_topic": "homeassistant/sensor",
"hass_discovery": 1,
"host": "localhost",
"log_level": "DEBUG",
"lwt_topic": "home/TheengsGateway/LWT",
"pass": "",
"port": 1883,
"presence": 0,
"presence_topic": "home/TheengsGateway/presence",
"publish_all": 1,
"publish_topic": "home/TheengsGateway/BTtoMQTT",
"scanning_mode": "active",
"subscribe_topic": "home/+/BTtoMQTT/undecoded",
"time_format": 0,
"time_sync": [],
"user": "
"
}

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\TheengsGateway\diagnose.py", line 157, in
asyncio.run(diagnostics())
File "C:\Program Files\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\asyncio\runners.py", line 118, in run
return self.loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\TheengsGateway\diagnose.py", line 153, in diagnostics
await adapters()
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\TheengsGateway\diagnose.py", line 129, in adapters
from bluetooth_adapters import get_adapters
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\bluetooth_adapters_init
.py", line 12, in
from .dbus import (
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\bluetooth_adapters\dbus.py", line 10, in
from dbus_fast import BusType, Message, MessageType, unpack_variants
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\dbus_fast_init
.py", line 1, in
from . import aio, glib, introspection, message_bus, proxy_object, service
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\dbus_fast\aio_init.py", line 1, in
from .message_bus import MessageBus
File "C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\dbus_fast\aio\message_bus.py", line 29, in
from .message_reader import build_message_reader
File "src\dbus_fast\aio\message_reader.py", line 1, in init dbus_fast.aio.message_reader
File "src\dbus_fast_private\unmarshaller.py", line 16, in init dbus_fast._private.unmarshaller
AttributeError: module 'socket' has no attribute 'CMSG_LEN'

FYI : My OS is not Windows 10 but Windows server 2022

@koenvervloesem
Copy link
Member

Ok, can you try something: edit the file C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\TheengsGateway\diagnose.py. Then change this line:

from bluetooth_adapters import get_adapters

to this:

from bluetooth_adapters.systems import get_adapters

Do you get a list of adapters now?

@koenvervloesem
Copy link
Member

koenvervloesem commented Apr 2, 2023

Ok, ignore my previous comment, we've found the problem.

Edit the file C:\Users\JC\AppData\Roaming\Python\Python311\site-packages\bluetooth_adapters\__init__.py and remove the following lines:

from .dbus import (
    BlueZDBusObjects,
    get_bluetooth_adapter_details,
    get_bluetooth_adapters,
    get_dbus_managed_objects,
)

Do you get a list of adapters now?

@koenvervloesem
Copy link
Member

So if you remove the Sena adapter, you don't get any adapters in the list of the diagnose command, right? That means that "bluetooth" is the name of the Sena adapter, and it should be usable in the configuration with "adapter": "bluetooth",.

@theengs theengs deleted a comment from JC38 Apr 2, 2023
@theengs theengs deleted a comment from JC38 Apr 2, 2023
@koenvervloesem
Copy link
Member

By the way, you have installed the Windows driver, right? I have the same UD100 adapter, and this works automatically in Linux, but in Windows you need a driver apparently.

@JC38
Copy link
Author

JC38 commented Apr 2, 2023

By the way, you have installed the Windows driver, right? I have the same UD100 adapter, and this works automatically in Linux, but in Windows you need a driver apparently.
I did.
I wanted to use the diagnose into my Linux PC and I also have an error :
python3 -m TheengsGateway.diagnose

Theengs Gateway Diagnostics

Package Versions

Name Value
Theengs Gateway 0.9.0
Theengs Decoder 1.3.7
Bleak 0.20.1
Bluetooth Clocks 0.1.2
Bluetooth Numbers 1.1.0
Paho MQTT 1.6.1

Python

Name Value
Version 3.7.3
Implementation CPython
Compiler GCC 8.3.0
Executable /usr/bin/python3

Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/dist-packages/TheengsGateway/diagnose.py", line 157, in
asyncio.run(diagnostics())
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/dist-packages/TheengsGateway/diagnose.py", line 151, in diagnostics
_os()
File "/usr/local/lib/python3.7/dist-packages/TheengsGateway/diagnose.py", line 105, in _os
os_parameters["Distribution"] = platform.freedesktop_os_release()[
AttributeError: module 'platform' has no attribute 'freedesktop_os_release'

@koenvervloesem
Copy link
Member

Thanks for testing this. I'll add a check for freedesktop_os_release which is not available on Python 3.7. However, showing the Bluetooth adapters is only supported on Python 3.9 and higher anyway.

So the conclusion seems to be then that your Sena UD100 adapter isn't recognized on Windows?

@JC38
Copy link
Author

JC38 commented Apr 2, 2023

I will not say my UD100 is not recognized on Windows as the driver installed a full BT stack and I can see BT devices from there.
I found that my Linux PC has 2 BT controllers. A built-in one and the UD100. So I don't know which one is used by the gateway when making tries on it. Do you know a linux command that allow to identify them. The bluetoothctl gives only their address without any name.

@JC38
Copy link
Author

JC38 commented Apr 2, 2023

I found this https://macaddresschanger.com/bluetooth-mac-lookup
That will help me

@koenvervloesem
Copy link
Member

hciconfig will show all adapters.

@JC38
Copy link
Author

JC38 commented Apr 2, 2023

38:00:25:xx:yy:zz Intel
00:01:95:xx:yy:zz Sena
The Sena is hci0, i will change the conf to force using it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants