Module Initialization

Last Updated on : 2024-05-14 08:00:15download

After the module is powered on, it will interact with the MCU to complete the necessary configuration. This process is called module initialization, which is used to prepare the module for pairing, cloud connection, data reporting, and adding sub-devices.

Procedure

After being powered on, the module will start the initialization and the MCU responds to the commands from the module. The following diagram shows how they interact with each other.

Module Initialization

The working mode query is not needed for the gateway pro.

Query product information

The module sends the command 0x01 to the MCU to get the product information such as product ID (PID), pairing mode, and capabilities.

The examples in this topic are for reference only. For more information, see the complete protocols in which the information prevails.

MCU Integration Protocol for Gateway
MCU Integration Protocol for Gateway Pro

So far, partial initialization is finished. If the module has not been paired, it will enter the pairing mode. In other cases, it will try connecting to the configured network.

Command example

The module sends the following data.

55 AA 01 01 00 00 01

The MCU returns the following data.

55 AA 01 01 00 3F 7B 22 76 22 3A 22 31 2E 30 2E 30 22 2C 20 22 6D 22 3A 31 2C 20 22 63 61 70 22 3A 30 2C 20 22 70 22 3A 22 6D 68 6E 6D 70 71 7A 66 37 6E 74 7A 6D XX XX XX 22 2C 20 22 6E 22 3A 30 2C 20 22 73 22 3A 30 2C 20 22 61 22 3A 30 7D XX

Part of the PID string is masked with asterisk characters (***). You should replace it with your PID.

Payload data

{"v":"1.0.0", "m":1, "cap":0, "p":"mhnmpqzf7ntzm***", "n":0, "s":0, "a":0}

Field Field description
“v”:“1.0.0” The firmware version number of the MCU is 1.0.0.
“m”:1 The pairing method uses the default one.
“cap”:0 Local device groups, local scenes, data point definition, and MCU firmware updates are not supported.
“p”:“mhnmpqzf7ntzm***” The PID of the gateway is mhnmpqzf7ntzm***.
“n”:0 The EZ mode and AP mode both can be used for pairing.
“s”:0 The gateway does not have security features.
“a”:0 The gateway does not support displaying security alerts. This field can be ignored if your gateway does not have security features.

Query working mode

After receiving product information and completing initialization, the module sends the command 0x02 to get the working mode.

The working mode indicates how the Wi-Fi network status is indicated and the way to trigger module reset.

The examples in this topic are for reference only. For more information, see the complete protocols in which the information prevails.
MCU Integration Protocol for Gateway

There are two types of working modes.

  • The MCU works with the module to process network events.

    • Network status notification: The module syncs the current network status with the MCU through the command 0x03. The MCU determines what action to proceed with.
    • Module reset: The MCU sends the command 0x04 or 0x05 to the module to reset it.
  • The module processes network events itself.

    • Network status notification: The specified GPIO pin on the module drives the connected LED indicator (low level active) to signal the network status.
    • Module reset: When the module detects a low level on the specified GPIO input pin for more than five seconds, it will trigger a reset action.

For more information about pin configuration, see Network Module Datasheet.

Command example

The module sends the following data.

55 AA 00 02 00 00 01

The MCU returns the following data.

  • The MCU works with the module to process network events: 55 AA 00 02 00 00 04.
  • The module processes network events itself: 55 AA 00 02 00 04 01 03 01 02 0C.
    • 01 03 represents the LED indicator, indicating the pin PB_3.
    • 01 02 represents the reset button, indicating the pin PB_2.

Auto-baud detection

The auto-baud detection feature enables switching baud between 9600 and 115200 so that you can use the right baud without any modification on the firmware.

Here is how the auto-baud detection works:

First-time power on

The module sends the product information query at the baud 115200 or 9600 to detect the right baud. When the module receives a correct response at a baud, it will lock and save the baud and start initialization.

Not the first-time power on

The module reads the saved baud and sends the product information query to the MCU. If the module does not receive a response, it will start baud detection, the same process as it performs for the first-time power on.