# ESP8266 WiFi Mesh
## Contents
1. [Overview](#Overview)
2. [How does it work?](#Work)
3. [The first step](#Start)
4. [TcpIpMeshBackend](#TcpIpMeshBackendMore)
* [Usage](#TcpIpMeshBackendUsage)
* [Note](#TcpIpMeshBackendNote)
* [General Information](#TcpIpMeshBackendGeneral)
5. [EspnowMeshBackend](#EspnowMeshBackendMore)
* [Usage](#EspnowMeshBackendUsage)
* [Note](#EspnowMeshBackendNote)
* [Callbacks](#EspnowMeshBackendCallbacks)
* [Encryption](#EspnowMeshBackendEncryption)
* [CCMP](#CCMP)
* [AEAD](#AEAD)
6. [FloodingMesh](#FloodingMeshMore)
* [Usage](#FloodingMeshUsage)
* [Note](#FloodingMeshNote)
* [Serialization and the internal state of a node](#FloodingMeshSerialization)
7. [FAQ](#FAQ)
* [My ESP8266 crashes on start-up when I use the library!](#FAQStartupCrash)
* [The node does not remember the SSID I assign to it!](#FAQSSIDAmnesia)
* [I want to control the WiFi mode myself.](#FAQModeControl)
* [I have a lot of interference from all the nodes that are close to each other. What can I do?](#FAQInterference)
* [How do I change the interval of the WiFi AP beacon broadcast?](#FAQBeaconInterval)
* [My ESP is ignoring the WiFi AP beacon broadcast interval settings you just told me about above! (a.k.a. How do I change the WiFi scan mode to passive?)](#FAQPassiveScan)
* [My internet is slower when I connect the ESP8266 to my router!](#FAQSlowRouter)
## <a name="Overview"></a>Overview
This is a library for creating a mesh network using the ESP8266.
The library has been tested and works with Arduino Core for ESP8266 version 3.0.0 (with lwIP2). It may work with earlier and later core releases, but this has not been tested during development.
**Note:** This mesh library has been extensively rewritten for core release 3.0.0. The old method signatures have been retained for compatibility purposes, but will be removed in core release 3.0.X. If you are still using these old method signatures please consider migrating to the new API shown in the `EspnowMeshBackend.h` or `TcpIpMeshBackend.h` source files.
## <a name="Work"></a>How does it work?
The ESP8266 WiFi Mesh library is a cake, metaphorically speaking. At the bottom you have the general ESP8266 Arduino Core WiFi functionality. On top of this two mesh backends have been created (`EspnowMeshBackend` and `TcpIpMeshBackend`), a yummy filling that completely covers the bottom. Then at the very top over the backends is the beautiful and delicious frosting: `FloodingMesh`. `FloodingMesh` is an actual mesh network implementation that uses the `EspnowMeshBackend`.
Eating the cake in its current form is a process which involves all the layers. However, if you prefer to be your own pastry chef it is easy to use both the `EspnowMeshBackend` and the `TcpIpMeshBackend` separately from `FloodingMesh`, perhaps to construct your own mesh network architecture or just to simplify the usage of TCP/IP or ESP-NOW. If you have made a nice mesh architecture with this library that you would like to share with the rest of the world, feel free to make a PR with it!
In general ESP-NOW is faster than TCP/IP for small data payloads (up to a few kB). The data segment of a standard ESP-NOW transmission is 234 bytes, which takes around 2-4 ms to transmit.
TCP/IP takes longer to connect (around 1000 ms), and an AP has to disconnect all connected stations in order to transfer data to another AP. However, this backend has a much higher data transfer speed than ESP-NOW once connected (100x faster or so).
## <a name="Start"></a>The first step
There are plenty of details to the operations of the library, but if you want to get started quickly you really only need to know this: In the example folder of the library there is a file called `HelloMesh.ino`. Upload it to a few ESP8266 and you have a working mesh network. Change the `useLED` variable to `true` if you have built-in LEDs on your ESP8266s to illustrate how the message is spread through the network. Change the `floodingMesh.broadcast` calls to modify what the mesh nodes are transmitting to each other. Change the code of the `meshMessageHandler` to modify how mesh nodes react to received transmissions.
Finally, three things are important to note:
1. This library uses the standard Arduino Core for ESP8266 WiFi functions. Therefore, other code that also uses these WiFi functions (e.g. `WiFi.mode()`) may cause conflicts with the library, resulting in strange behaviour. See "[I want to control the WiFi mode myself](#FAQModeControl)" in the FAQ for ideas on how to work around this.
2. Both the `EspnowMeshBackend` and the `TcpIpMeshBackend` can be used simultaneously on the same node. However, since there is only one WiFi radio on the ESP8266, only one backend at a time will be responsible for the settings of this radio (SSID, WiFi channel etc.). The backend in control is known as the `APController` in the library. Both backends can still send messages, regardless of who is `APController`.
3. The `MeshBackendBase`, `EspnowMeshBackend`, `TcpIpMeshBackend` and `FloodingMesh` source files are meant to be the main front-ends of the library and are all extensively documented. If you wonder about how something is working, chances are good that you will find an answer in the documentation of those files.
## <a name="TcpIpMeshBackendMore"></a>TcpIpMeshBackend
### <a name="TcpIpMeshBackendUsage"></a>Usage
The basic operation of the TCP/IP mesh backend is as follows:
The `attemptTransmission` method of the TcpIpMeshBackend instance is called with a message to send to other nodes in the mesh network. If the node is already connected to an AP, the message is sent only to that AP. Otherwise the default behaviour is for a WiFi scan to be performed. The scan results are sent to the `networkFilter` callback function of the TcpIpMeshBackend instance which adds the AP:s of interest to the `connectionQueue` vector. The message is then transmitted to the networks in the `connectionQueue`, and the response from each AP is sent to the `responseHandler` callback of the TcpIpMeshBackend instance. The outcome from each transmission attempt can be found in the `latestTransmissionOutcomes` vector.
The node receives messages from other TCP/IP nodes by calling the `acceptRequests` method of the TcpIpMeshBackend instance. These received messages are passed to the `requestHandler` callback of the mesh instance. For each received message the return value of `requestHandler` is sent to the other node as a response to the message.
For more details, see the included HelloTcpIp example. The main functions to modify in the example are `manageRequest` (`requestHandler`), `manageResponse` (`responseHandler`), `networkFilter` and `exampleTransmissionOutcomesUpdateHook`. There is also much more information to be found in the source code comments.
### <a name="TcpIpMeshBackendNote"></a>Note
* This library can use static IP:s for the nodes to speed up connection times. To enable this, use the `setStaticIP` method after calling the `begin` method, as in the included example. When using static IP, the following is good to keep in mind:
Ensure that nodes connecting to the same AP have distinct static IP:s.
Node IP:s need to be at the same subnet as the server gateway (192.168.4 for this library by default).
Station gateway IP must match the IP for the server on the nodes. This is the default setting for the library.
Static IP is a global setting (for now), meaning that all TcpIpMeshBackend instances on the same ESP8266 share the same static IP settings.
* Scanning all WiFi channels (e.g. via the `attemptTransmission` method with the `scanAllWiFiChannels` argument set to `true`) will slow down scans considerably and make it more likely that existing WiFi connections will break during scans.
* If the ESP8266 has an active AP, that AP will switch WiFi channel to match that of any other AP the TcpIpMeshBackend of the ESP8266 connects to (compare
没有合适的资源?快使用搜索试试~ 我知道了~
platformio3.1.1
共2000个文件
h:1026个
json:408个
py:243个
需积分: 5 0 下载量 70 浏览量
2024-02-03
19:45:31
上传
评论
收藏 907.24MB ZIP 举报
温馨提示
vscode + platformio3.1.1
资源推荐
资源详情
资源评论
收起资源包目录
platformio3.1.1 (2000个子文件)
aws_iot_tests_unit_shadow_action_helper.c 38KB
aws_iot_tests_unit_connect_helper.c 32KB
aws_iot_tests_unit_json_utils_helper.c 25KB
aws_iot_tests_unit_subscribe_helper.c 25KB
aws_iot_mqtt_client_common_internal.c 22KB
aws_iot_shadow_json.c 18KB
aws_iot_mqtt_client_connect.c 18KB
aws_iot_tests_unit_helper_functions.c 18KB
aws_iot_tests_unit_yield_helper.c 18KB
network_mbedtls_wrapper.c 17KB
aws_iot_shadow_records.c 17KB
network_mbedtls_wrapper.c 16KB
aws_iot_mqtt_client_subscribe.c 15KB
aws_iot_mqtt_client_publish.c 14KB
jobs_sample.c 13KB
thing_shadow_sample.c 13KB
coap_server_example_main.c 13KB
aws_iot_mqtt_client.c 13KB
aws_iot_tests_unit_unsubscribe_helper.c 13KB
subscribe_publish_sample.c 13KB
aws_iot_test_multithreading_validation.c 12KB
aws_iot_tests_unit_shadow_delta_helper.c 12KB
aws_iot_tests_unit_jobs_interface.c 12KB
subscribe_publish_sample.c 12KB
aws_iot_mqtt_client_yield.c 12KB
aws_iot_test_jobs_api.c 10KB
aws_iot_test_basic_connectivity.c 10KB
aws_iot_test_multiple_clients.c 9KB
jsmn.c 9KB
aws_iot_tests_unit_jobs_json.c 9KB
shadow_console_echo.c 9KB
shadow_sample.c 9KB
aws_iot_tests_unit_disconnect_helper.c 8KB
esp_eddystone_api.c 8KB
subscribe_publish_sample.c 8KB
subscribe_publish_library_sample.c 8KB
aws_iot_mqtt_client_unsubscribe.c 8KB
aws_iot_shadow.c 8KB
aws_iot_test_auto_reconnect.c 8KB
aws_iot_tests_unit_mock_tls.c 7KB
aws_iot_jobs_interface.c 7KB
aws_iot_tests_unit_publish_helper.c 7KB
sd_card_example_main.c 7KB
esp_eddystone_demo.c 6KB
aws_iot_tests_unit_jobs_topics.c 6KB
aws_iot_tests_unit_common_tests_helper.c 6KB
aws_iot_json_utils.c 6KB
aws_iot_jobs_json.c 6KB
aws_iot_tests_unit_shadow_json_builder_helper.c 5KB
aws_iot_tests_unit_shadow_null_fields_helper.c 5KB
aws_iot_test_integration_runner.c 5KB
http_request_example_main.c 4KB
ulp_example_main.c 4KB
aws_iot_jobs_topics.c 4KB
ulp_adc_example_main.c 3KB
threads_freertos.c 3KB
aws_iot_tests_unit_jobs_types.c 3KB
threads_pthread_wrapper.c 3KB
timer.c 2KB
aws_iot_shadow_actions.c 2KB
aws_iot_jobs_types.c 2KB
user_main.c 2KB
tusb_sample_descriptor_main.c 2KB
spiffs_example_main.c 2KB
timer.c 2KB
main.c 2KB
uart_echo_example_main.c 2KB
aws_iot_tests_unit_mock_tls_params.c 2KB
blink.c 1KB
hello_world_main.c 1KB
main.c 1KB
main.c 1KB
main.c 359B
test_dummy.c 165B
main.cpp 5KB
aws_iot_tests_unit_json_utils.cpp 4KB
aws_iot_tests_unit_connect.cpp 4KB
aws_iot_tests_unit_subscribe.cpp 4KB
aws_iot_tests_unit_shadow_action.cpp 2KB
aws_iot_tests_unit_yield.cpp 2KB
aws_iot_tests_unit_jobs.cpp 2KB
aws_iot_tests_unit_unsubscribe.cpp 2KB
Blink.cpp 2KB
main.cpp 2KB
aws_iot_tests_unit_publish.cpp 2KB
aws_iot_tests_unit_disconnect.cpp 2KB
aws_iot_tests_unit_shadow_null_fields.cpp 2KB
exception_example_main.cpp 1KB
aws_iot_tests_unit_shadow_delta.cpp 1KB
aws_iot_tests_unit_common_tests.cpp 1KB
aws_iot_tests_unit_shadow_json_builder.cpp 1KB
aws_iot_tests_unit_runner.cpp 821B
Blink.cpp 617B
Blink.cpp 497B
main.cpp 497B
platformio.light.c281a13b5df23a871e96b9f1fe8361d2d6bbd1a2.min.css 289KB
aceinna.light.c281a13b5df23a871e96b9f1fe8361d2d6bbd1a2.min.css 289KB
platformio.dark.c281a13b5df23a871e96b9f1fe8361d2d6bbd1a2.min.css 288KB
aceinna.dark.c281a13b5df23a871e96b9f1fe8361d2d6bbd1a2.min.css 288KB
usb_reg.h 381KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
星星|豪稻电子
- 粉丝: 13
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功