Skip to content

Commit 5e43bb9

Browse files
luoweiyuanlbuque
authored andcommitted
libs/module: Add support for Unit GatewayH2.
Signed-off-by: luoweiyuan <[email protected]>
1 parent 27aeba2 commit 5e43bb9

File tree

11 files changed

+563
-78
lines changed

11 files changed

+563
-78
lines changed

docs/en/module/gateway_h2.rst

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GatewayH2 Module
2-
============================
2+
================
33

44
.. sku: M141
55
@@ -13,11 +13,11 @@ Support the following products:
1313

1414
.. 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.
1515

16-
UiFlow2 Example:
17-
--------------------------
16+
UiFlow2 Example
17+
---------------
1818

19-
Switch Control
20-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19+
Switch Control
20+
^^^^^^^^^^^^^^
2121

2222
.. 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>`_
2323

@@ -33,11 +33,11 @@ Example output:
3333

3434
None
3535

36-
MicroPython Example:
37-
--------------------------
36+
MicroPython Example
37+
-------------------
3838

39-
Switch Control
40-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39+
Switch Control
40+
^^^^^^^^^^^^^^
4141

4242
The example demonstrates group control and targeted device operation for light nodes through SwitchEndpoint of Gateway H2 module.
4343

@@ -52,10 +52,10 @@ Example output:
5252
None
5353

5454
**API**
55-
--------------------------
55+
-------
5656

5757
GatewayH2Module
58-
^^^^^^^^^^^^^^^^^^^^^^^^
58+
^^^^^^^^^^^^^^^
5959

6060
.. class:: module.gateway_h2.GatewayH2Module
6161

@@ -94,9 +94,14 @@ GatewayH2Module
9494
9595
h2_switch_endpoint = module_gateway_h2.create_switch_endpoint()
9696
97+
.. _switchendpoint:
98+
99+
SwitchEndpoint
100+
^^^^^^^^^^^^^^
101+
97102
.. class:: SwitchEndpoint
98103

99-
Return by GatewayH2Module.create_switch_endpoint()
104+
Return by GatewayH2Module.create_switch_endpoint() or GatewayH2Unit.create_switch_endpoint()
100105

101106
.. method:: on([addr])
102107

@@ -160,4 +165,3 @@ GatewayH2Module
160165
161166
h2_switch_endpoint.toggle(addr)
162167
h2_switch_endpoint.toggle()
163-

docs/en/refs/unit.gateway_h2.ref

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

docs/en/units/gateway_h2.rst

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
GatewayH2 Unit
2+
==============
3+
4+
.. sku: U195
5+
6+
.. include:: ../refs/unit.gateway_h2.ref
7+
8+
This library is the driver for Unit Gateway H2, and the unit communicates via UART.
9+
10+
Support the following products:
11+
12+
|Unit Gateway H2|
13+
14+
.. note:: When using this unit, you need to flash the NCP firmware to the unit. For details, refer to the `ESP Zigbee NCP <https://docs.m5stack.com/zh_CN/guide/zigbee/unit_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 unit 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 unit.
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 unit.
43+
44+
MicroPython Code Block:
45+
46+
.. literalinclude:: ../../../examples/unit/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+
GatewayH2Unit
58+
^^^^^^^^^^^^^
59+
60+
.. class:: unit.gateway_h2.GatewayH2Unit
61+
62+
Create an GatewayH2Unit object.
63+
64+
:param int id: The UART ID for communication with the GatewayH2 Unit. It can be 1, 2.
65+
:param port: A list or tuple containing the TX and RX pins for UART communication.
66+
67+
UiFlow2 Code Block:
68+
69+
|init.png|
70+
71+
MicroPython Code Block:
72+
73+
.. code-block:: python
74+
75+
from unit import GatewayH2Unit
76+
77+
gateway_h2_unit = GatewayH2Unit(2, port=(1, 2))
78+
79+
.. method:: create_switch_endpoint()
80+
81+
Create Switch Endpoint.
82+
83+
:returns SwitchEndpoint: zigbee switch endpoint object.
84+
:return type: SwitchEndpoint
85+
86+
UiFlow2 Code Block:
87+
88+
|init.png|
89+
90+
MicroPython Code Block:
91+
92+
.. code-block:: python
93+
94+
h2_switch_endpoint = gateway_h2_unit.create_switch_endpoint()
95+
96+
Refer to :ref:`switchendpoint` for more details about SwitchEndpoint.

docs/en/units/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Unit
4444
fader.rst
4545
finger.rst
4646
flash_light.rst
47+
gateway_h2.rst
4748
glass.rst
4849
glass2.rst
4950
gps_v11.rst

0 commit comments

Comments
 (0)