Skip to content

Commit 02d33c9

Browse files
luoweiyuanlbuque
authored andcommitted
libs/module: Add support for Module GatewayH2.
Signed-off-by: luoweiyuan <[email protected]>
1 parent 9418cf6 commit 02d33c9

File tree

15 files changed

+1010
-0
lines changed

15 files changed

+1010
-0
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828
[submodule "m5stack/components/epdiy"]
2929
path = m5stack/components/epdiy
3030
url = https://github.com/vroland/epdiy.git
31+
32+
[submodule "m5stack/components/esp_zigbee_host"]
33+
path = m5stack/components/esp_zigbee_host
34+
url = https://github.com/hlym123/esp_zigbee_host.git

docs/en/module/gateway_h2.rst

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
GatewayH2 Module
2+
============================
3+
4+
.. sku: M141
5+
6+
.. include:: ../refs/module.gateway_h2.ref
7+
8+
This library is the driver for Module Gateway H2, and the module communicates via UART.
9+
10+
Support the following products:
11+
12+
|Module Gateway H2|
13+
14+
.. note:: When using this module, you need to flash the NCP firmware to the module. For details, refer to the `ESP Zigbee NCP <https://docs.m5stack.com/zh_CN/guide/zigbee/module_gateway_h2/zigbee_ncp>`_ documentation.
15+
16+
UiFlow2 Example:
17+
--------------------------
18+
19+
Switch Control
20+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21+
22+
.. note:: To use this example, you need to flash this program onto an ESP32C6 or similar module as a light node device. For details, refer to `HA_on_off_light <https://github.com/espressif/esp-zigbee-sdk/tree/main/examples/esp_zigbee_HA_sample/HA_on_off_light>`_
23+
24+
Open the |cores3_switch_endpoint_example.m5f2| project in UiFlow2.
25+
26+
The example demonstrates group control and targeted device operation for light nodes through SwitchEndpoint of Gateway H2 module.
27+
28+
UiFlow2 Code Block:
29+
30+
|cores3_switch_endpoint_example.png|
31+
32+
Example output:
33+
34+
None
35+
36+
MicroPython Example:
37+
--------------------------
38+
39+
Switch Control
40+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41+
42+
The example demonstrates group control and targeted device operation for light nodes through SwitchEndpoint of Gateway H2 module.
43+
44+
MicroPython Code Block:
45+
46+
.. literalinclude:: ../../../examples/module/gateway_h2/cores3_switch_endpoint_example.py
47+
:language: python
48+
:linenos:
49+
50+
Example output:
51+
52+
None
53+
54+
**API**
55+
--------------------------
56+
57+
GatewayH2Module
58+
^^^^^^^^^^^^^^^^^^^^^^^^
59+
60+
.. class:: module.gateway_h2.GatewayH2Module
61+
62+
Create an GatewayH2Module object.
63+
64+
:param int id: UART id.
65+
:param int tx: the UART TX pin.
66+
:param int rx: the UART RX pin.
67+
68+
UiFlow2 Code Block:
69+
70+
|init.png|
71+
72+
MicroPython Code Block:
73+
74+
.. code-block:: python
75+
76+
from module import GatewayH2Module
77+
78+
module_gateway_h2 = GatewayH2Module(id = 1, tx = 10, rx = 17)
79+
80+
.. method:: create_switch_endpoint()
81+
82+
Create Switch Endpoint.
83+
84+
:returns SwitchEndpoint: zigbee switch endpoint object.
85+
:return type: SwitchEndpoint
86+
87+
UiFlow2 Code Block:
88+
89+
|init.png|
90+
91+
MicroPython Code Block:
92+
93+
.. code-block:: python
94+
95+
h2_switch_endpoint = module_gateway_h2.create_switch_endpoint()
96+
97+
.. class:: SwitchEndpoint
98+
99+
Return by GatewayH2Module.create_switch_endpoint()
100+
101+
.. method:: on([addr])
102+
103+
Turn on the light.
104+
105+
:param addr: The device address (optional).
106+
107+
- If called as ``on()``, turn on all devices.
108+
- If called as ``on(addr)``, turn on special address devices.
109+
110+
UiFlow2 Code Block:
111+
112+
|on.png|
113+
|all_on.png|
114+
115+
MicroPython Code Block:
116+
117+
.. code-block:: python
118+
119+
h2_switch_endpoint.on(addr)
120+
h2_switch_endpoint.on()
121+
122+
.. method:: off([addr])
123+
124+
Turn off the light.
125+
126+
:param addr: The device address (optional).
127+
128+
- If called as ``off()``, turn off all devices.
129+
- If called as ``off(addr)``, turn off special address devices.
130+
131+
UiFlow2 Code Block:
132+
133+
|off.png|
134+
|all_off.png|
135+
136+
MicroPython Code Block:
137+
138+
.. code-block:: python
139+
140+
h2_switch_endpoint.off(addr)
141+
h2_switch_endpoint.off()
142+
143+
.. method:: toggle([addr])
144+
145+
Toggle the light state.
146+
147+
:param addr: The device address (optional).
148+
149+
- If called as ``toggle()``, toggle all devices.
150+
- If called as ``toggle(addr)``, toggle special address devices.
151+
152+
UiFlow2 Code Block:
153+
154+
|toggle.png|
155+
|all_toggle.png|
156+
157+
MicroPython Code Block:
158+
159+
.. code-block:: python
160+
161+
h2_switch_endpoint.toggle(addr)
162+
h2_switch_endpoint.toggle()
163+

docs/en/module/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Module
1414
ecg.rst
1515
encoder4_motor.rst
1616
fan.rst
17+
gateway_h2.rst
1718
gnss.rst
1819
gps.rst
1920
gpsv2.rst

docs/en/refs/module.gateway_h2.ref

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. |Module Gateway H2| image:: https://m5stack-doc.oss-cn-shenzhen.aliyuncs.com/464/M141_01.webp
2+
:target: https://docs.m5stack.com/zh_CN/module/Module%20Gateway%20H2
3+
:height: 200px
4+
:width: 200px
5+
6+
.. |init.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gateway_h2/init.png
7+
.. |on.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gateway_h2/on.png
8+
.. |all_on.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gateway_h2/all_on.png
9+
.. |off.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gateway_h2/off.png
10+
.. |all_off.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gateway_h2/all_off.png
11+
.. |toggle.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gateway_h2/toggle.png
12+
.. |all_toggle.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gateway_h2/all_toggle.png
13+
.. |cores3_switch_endpoint_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gateway_h2/example.png
14+
15+
.. |cores3_switch_endpoint_example.m5f2| raw:: html
16+
17+
<a
18+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/module/gateway_h2/cores3_switch_endpoint_example.m5f2"
19+
target="_blank"
20+
>
21+
cores3_switch_endpoint_example.m5f2
22+
</a>
23+

0 commit comments

Comments
 (0)