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

Accessing ZiGate via the USB port of the Wifi module? #13

Closed
pdecat opened this issue Jun 23, 2018 · 2 comments
Closed

Accessing ZiGate via the USB port of the Wifi module? #13

pdecat opened this issue Jun 23, 2018 · 2 comments

Comments

@pdecat
Copy link
Contributor

pdecat commented Jun 23, 2018

As wireless connection to the ZiGate is currently unstable (cf. #3), is there any mean to access it via USB using its USB-Wifi module?
Or can that only be done using the USB-TTL module?
I ask because I'd rather avoid having to swap modules between experiments.

When plugged, that USB-Wifi module is seen as:

# dmesg | tail -6
[1021400.252231] usb 3-5.1: new full-speed USB device number 39 using xhci_hcd
[1021400.353340] usb 3-5.1: New USB device found, idVendor=1a86, idProduct=7523
[1021400.353343] usb 3-5.1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[1021400.353344] usb 3-5.1: Product: USB2.0-Serial
[1021400.354079] ch341 3-5.1:1.0: ch341-uart converter detected
[1021400.354589] usb 3-5.1: ch341-uart converter now attached to ttyUSB0
# lsusb | grep 1a86:7523
Bus 003 Device 039: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

I've tried to naively put that ID in the discovery code:

git diff
diff --git a/zigate/transport.py b/zigate/transport.py
index dcccef1..e1395cf 100644
--- a/zigate/transport.py
+++ b/zigate/transport.py
@@ -102,7 +102,7 @@ class ThreadSerialConnection(object):
             LOGGER.info('Searching ZiGate port')
 #             context = pyudev.Context()
 #             devices = list(context.list_devices(ID_USB_DRIVER='pl2303', ID_VENDOR_ID='067b', subsystem='tty'))
-            devices = list(serial.tools.list_ports.grep('067b:2303'))
+            devices = list(serial.tools.list_ports.grep('1a86:7523'))
             if devices:
                 port = devices[0].device
                 if len(devices) == 1:

But it fails:

# ./venv/bin/python 
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.basicConfig()
>>> logging.root.setLevel(logging.DEBUG)
>>> import zigate
>>> z = zigate.ZiGate(port=None)
INFO:zigate:Searching ZiGate port
INFO:zigate:ZiGate found at /dev/ttyUSB0
DEBUG:zigate:Try loading persistent file
DEBUG:zigate:No file to load
DEBUG:zigate:REQUEST : 0x0021 b'\x03\x18\xc8\x00'
DEBUG:zigate:Msg to send b'00210004f60318c800'
DEBUG:zigate:Encoded Msg to send b'\x01\x02\x10!\x02\x10\x02\x14\xf6\x02\x13\x18\xc8\x02\x10\x03'
DEBUG:zigate:Waiting for status message for command 0x0021
ERROR:zigate:No response after command 0x0021
DEBUG:zigate:REQUEST : 0x0023 b'\x00'
DEBUG:zigate:Msg to send b'002300012200'
DEBUG:zigate:Encoded Msg to send b'\x01\x02\x10#\x02\x10\x02\x11"\x02\x10\x03'
DEBUG:zigate:Waiting for status message for command 0x0023
ERROR:zigate:No response after command 0x0023
DEBUG:zigate:Check network state
DEBUG:zigate:REQUEST : 0x0024 
DEBUG:zigate:Msg to send b'0024000024'
DEBUG:zigate:Encoded Msg to send b'\x01\x02\x10$\x02\x10\x02\x10$\x03'
DEBUG:zigate:Waiting for status message for command 0x0024
ERROR:zigate:No response after command 0x0024
DEBUG:zigate:REQUEST : 0x0009 
DEBUG:zigate:Msg to send b'0009000009'
DEBUG:zigate:Encoded Msg to send b'\x01\x02\x10\x02\x19\x02\x10\x02\x10\x02\x19\x03'
DEBUG:zigate:Waiting for status message for command 0x0009
ERROR:zigate:No response after command 0x0009
DEBUG:zigate:Waiting for message 0x8009
ERROR:zigate:No response waiting command 0x8009
ERROR:zigate:Failed to get network state
DEBUG:zigate:Network is down, start it
DEBUG:zigate:REQUEST : 0x0024 
DEBUG:zigate:Msg to send b'0024000024'
DEBUG:zigate:Encoded Msg to send b'\x01\x02\x10$\x02\x10\x02\x10$\x03'
DEBUG:zigate:Waiting for status message for command 0x0024
ERROR:zigate:No response after command 0x0024
DEBUG:zigate:Waiting for message 0x8024
ERROR:zigate:No response waiting command 0x8024
DEBUG:zigate:REQUEST : 0x0015 
DEBUG:zigate:Msg to send b'0015000015'
DEBUG:zigate:Encoded Msg to send b'\x01\x02\x10\x15\x02\x10\x02\x10\x15\x03'
DEBUG:zigate:Waiting for status message for command 0x0015
ERROR:zigate:No response after command 0x0015
DEBUG:zigate:Waiting for message 0x8015
ERROR:zigate:No response waiting command 0x8015
DEBUG:zigate:Auto saving /home/patrick/.zigate.json
>>> z.get_version()
DEBUG:zigate:REQUEST : 0x0010 
DEBUG:zigate:Msg to send b'0010000010'
DEBUG:zigate:Encoded Msg to send b'\x01\x02\x10\x10\x02\x10\x02\x10\x10\x03'
DEBUG:zigate:Waiting for status message for command 0x0010
ERROR:zigate:No response after command 0x0010
DEBUG:zigate:Waiting for message 0x8010
ERROR:zigate:No response waiting command 0x8010
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/patrick/workspaces/homeassistant/zigate/zigate/core.py", line 534, in get_version
    self._version = self.send_data(0x0010, wait_response=0x8010).data
AttributeError: 'NoneType' object has no attribute 'data'
>>>
@doudz
Copy link
Owner

doudz commented Jun 23, 2018

With the current wifi module firmware it's not possible but it could be a good thing and it's possible

@doudz
Copy link
Owner

doudz commented Jul 30, 2018

I close this issue since this is not related to the library.
Please ask the vendor to add such feature in a next firmware release.

@doudz doudz closed this as completed Jul 30, 2018
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

2 participants