# 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
没有合适的资源?快使用搜索试试~ 我知道了~
主要是下载在arduino下开发esp8266-3.1.2版本
共2000个文件
h:1036个
c:369个
ino:270个
5星 · 超过95%的资源 需积分: 5 27 下载量 141 浏览量
2023-05-04
15:09:30
上传
评论 2
收藏 314.84MB ZIP 举报
温馨提示
https://arduino.esp8266.com/stable/package_esp8266com_index.json https://raw.githubusercontent.com/DFRobot/FireBeetle-ESP8266/master/package_firebeetle8266_index.json 下载在arduino下开发esp8266-3.1.2版本,下载时需要关闭防火墙 路径:C:\Users\lan\AppData\Local\Arduino15
资源推荐
资源详情
资源评论
收起资源包目录
主要是下载在arduino下开发esp8266-3.1.2版本 (2000个子文件)
test_crypto.c 396KB
miniz.c 309KB
lfs.c 170KB
ssl_hs_server.c 54KB
ec_p256_m15.c 53KB
ssl_hs_client.c 52KB
espconn_tcp.c 52KB
x509_minimal.c 50KB
ec_p256_m64.c 45KB
espconn.c 45KB
ec_p256_m62.c 44KB
test_speed.c 42KB
esp-dhcpserver.c 41KB
ssl_engine.c 41KB
test_x509.c 39KB
ec_p256_m31.c 35KB
ec_c25519_m15.c 35KB
server.c 28KB
names.c 27KB
gdbstub.c 27KB
client.c 26KB
twrch.c 25KB
custom_profile.c 22KB
aes_pwr8_ctrcbc.c 22KB
ec_c25519_m64.c 21KB
x509_decoder.c 21KB
lwip-esp.c 20KB
ec_prime_i15.c 20KB
libm_string.c 20KB
ec_prime_i31.c 19KB
lwip-git.c 18KB
ec_c25519_m31.c 18KB
tinflate.c 18KB
skey.c 17KB
rsa_i31_keygen_inner.c 17KB
sslio.c 17KB
aes_x86ni_ctrcbc.c 17KB
rsa_i15_keygen.c 16KB
skey_decoder.c 16KB
aes_pwr8_ctr.c 15KB
ssl_lru.c 15KB
aes_pwr8_cbcdec.c 15KB
espconn_udp.c 14KB
ec_c25519_m62.c 14KB
shake.c 14KB
pkey_decoder.c 14KB
i31_moddiv.c 13KB
i62_modpow2.c 13KB
stub_flasher.c 13KB
ssl_rec_cbc.c 12KB
i15_moddiv.c 12KB
pemdec.c 12KB
des_ct.c 12KB
eax.c 12KB
umm_local.c 12KB
md5.c 11KB
poly1305_ctmulq.c 11KB
i15_montmul.c 11KB
client_basic.c 11KB
aes_ct64_ctrcbc.c 11KB
test_math.c 11KB
server_basic.c 11KB
aes_ct_ctrcbc.c 10KB
tstring.c 10KB
des_tab.c 10KB
ghash_pclmul.c 10KB
stub_write_flash.c 10KB
lfs_testbd.c 10KB
esp-ping.c 10KB
umm_info.c 10KB
defl_static.c 10KB
rsa_i15_privexp.c 10KB
rsa_i31_privexp.c 10KB
strcmp-1.c 10KB
aes_big_dec.c 9KB
sha2small.c 9KB
ghash_pwr8.c 9KB
ghash_ctmul.c 9KB
aes_pwr8.c 9KB
aes_ct64.c 9KB
aes_pwr8_cbcenc.c 9KB
ec_c25519_i15.c 9KB
errors.c 9KB
ec_c25519_i31.c 9KB
poly1305_ctmul32.c 8KB
eboot.c 8KB
gcm.c 8KB
verify.c 8KB
ccm.c 8KB
sha2big.c 8KB
poly1305_ctmul.c 7KB
aes_ct.c 7KB
lfs_filebd.c 7KB
ta.c 7KB
ghash_ctmul32.c 7KB
files.c 7KB
aes_x86ni_cbcdec.c 6KB
aes_x86ni_ctr.c 6KB
umm_poison.c 6KB
ssl_io.c 6KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
达子666
- 粉丝: 678
- 资源: 65
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页