Skip to content

Latest commit

 

History

History
84 lines (55 loc) · 2.84 KB

File metadata and controls

84 lines (55 loc) · 2.84 KB

[中文]

Mwifi Router Example

Introduction

It introduces how to connect the devices to a remote external server based on Mwifi and Ethernet module APIs. To be specific, the devices transmit all the data to the root node via ESP-MESH, and then the root node connects to a remote server with LWIP.

This example implements the functions of sending device data to a TCP server or sending data to a specific node or a specific group of nodes from a TCP server over the mesh network.

Hardware

  • At least 2 x ESP32 development boards( One need support ethernet connection, the other need run "no_router" example in Non-Root device mode. Both of then should use same Mesh ID and channel )
  • 1 x router that supports ethernet

Process

Run TCP server

  1. Connect PC or the mobile phone to the router.
  2. Use a TCP testing tool (any third-party TCP testing software) to create a TCP server.

Note: This example uses the iOS TCP_UDP tool.

Configure the devices

Enter make menuconfig, and configure the followings under the submenu "Example Configuration".

  • ESP-MESH network: The network password length should be between 8 and 64 bits (both exclusive), and the network will not be encrypted if you leave the password blank.
  • TCP server: the information of the TCP server run on the PC

Configure the devices

Configure the followings under the submenu "Example Configuration->Eth-helper`.The configuration of Eth-helper is defined by the connection of PHY chip and ESP32. You can read example of ethernet in the ESP-IDF.

Configure the Eth-helper(Apply for ESP32-Ethernet-Kit-A_V1.1)

Build and Flash

Make:

make erase_flash flash -j5 monitor ESPBAUD=921600 ESPPORT=/dev/ttyUSB0

CMake:

idf.py erase_flash flash monitor-b 921600 -p /dev/ttyUSB0

Run

  1. ESP-MESH devices send the real-time device status to the TCP server at an interval of three seconds.
  2. The TCP server sends data (in as format describe in the following section) to a specific address or group address:
    • When the destination address is ff:ff:ff:ff:ff:ff, it will send data to all devices.
    • When the destination is a group address, it will send data to all the devices in this group.

TCP server

Data Format

The data format for TCP server communication:

{"dest_addr":"dest mac address","data":"content"}
{"group":"group address","data":"content"}

For Example:

{"dest_addr":"24:0a:c4:08:54:80","data":"Hello ESP-MDF!"}
{"group":"01:00:5e:ae:ae:ae","data":"Hello ESP-MDF!"}