30a Esp8266 Mesh User Guide Cn

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 19

Download30a-esp8266 Mesh User Guide Cn
Open PDF In BrowserView PDF
ESP8266
Mesh

1.2
© 2016

ESP8266 Mesh

1

ESP-Mesh

2

Mesh

3

API

Mesh
API

4

📖

Mesh

2015.07

V1.0

2015.09

V1.1

2016.01

V1.2

3
2

4

1

3

1.

..................................................................................................................................1
1.1.

..............................................................................................................................1

1.2.

..............................................................................................................................3
1.2.1.

.................................................................................................................3

1.2.2.

..............................................................................................................3

1.2.3.

.................................................................................................................4

2. Mesh

.....................................................................................................................5

2.1. Mesh

................................................................................................................5

2.2. Mesh

...........................................................................................................................7

2.2.1.

.................................................................................................................7

2.2.2.

........................................................................................................................8

3. API

.........................................................................................................................10

3.1.

............................................................................................................................10

3.2.

4.

3.1.1.

Mesh

..................................................................................................10

3.1.2.

Mesh

...........................................................................................10

3.1.3.

Mesh

......................................................................................................11

3.1.4.

Mesh

..............................................................................................11

3.1.5.

Mesh

......................................................................................................11

3.1.6.

Mesh

..............................................................................................11

3.1.7.

Mesh

.......................................................................................11

API .........................................................................................................................11

.........................................................................................................................12
4.1.

...................................................................................................................................12

4.2.

....................................................................................................................12

4.3.

....................................................................................................................13

....................................................................................................................14
4.4.
4.5. Dev-App ............................................................................................................................15

1.

1.
32

•
• Mesh

ESP8266

Mesh

1-1

Up to 5-level mesh network.

Up to 100 m for a single hop.

Up to 87 Wi-Fi devices.

"
1-1. ESP-Mesh

1.1.
IOT Espressif App
IOT Espressif App

IOT App

App

Wi-Fi

Wi-Fi
ESP-Touch
ESP-Touch

Wi-Fi

ESP-Touch Smart Config
Smart Config

ESP-Touch
“1.2

Espressif

ESP-Touch

”
1/16

2016.04

1.

1-2

ESP-Touch

Device

Router

Mobile App

Local Network

"

1-2.

1-3

ESP-Touch

Office

Room

Device

Mobile App

Router A

Router B

Phone

Server
Cloud Network

"

1-3.

IOT App
IOT App

•

Espressif

2/16

2016.04

1.

IOT App

•
•

✔

✔

✔

❌

✔

❌

1.2.
1.2.1.
Mesh

ESP-Touch

Wi-Fi

Mesh

AP

1.2.2.
Mesh

1-4

Internet

Online-Mesh

Local-Mesh

Router

Root node

Dev1-1

"

Dev2-1

Dev 2-2

……

Dev 2-n

Dev-3-1

Dev-3-2

……

Dev-3-n

Dev-m-1

Dev-m-2

……

Dev-m-n

Non-root nodes

1-4. Mesh

“1.2.3

•

”
Espressif

3/16

2016.04

1.

• Online-Mesh
• Local-Mesh

1.2.3.
Mesh

•
•

•
•

Espressif

4/16

2016.04

2. Mesh

2.
2.1.

Mesh
Mesh
Mesh

2-1
0
ver

1
o

2

flags

3

proto

len
dst_addr

src_addr
ot_len
option_list

Packet Body

"
2-1. Mesh

Mesh

2-1
2-1. Mesh

ver

2

o

1

Mesh

bit

5
flags

0

1

CP

CR

2

3

4

resv

FP
FR

Espressif

5/16

2016.04

2. Mesh

resv
bit

8

D

0

1

D

P2P

2

3

4

5

6

7

protocol

• 0
• 1

P2P
proto
mesh_usr_proto_type 的定

如下:

enum mesh_usr_proto_type {
M_PROTO_NONE = 0, //

Mesh

M_PROTO_HTTP,

// HTTP

M_PROTO_JSON,

// JSON

M_PROTO_MQTT,

// MQTT

M_PROTO_BIN,

//

};
len

2

Mesh

Mesh

proto.P2P = 1 dst_addr

• proto.D = 0
dst_addr

6

• Bcast

mcast packet

• proto.D = 1
IP

6

• Bcast

src_addr

mcast packet

• proto.D = 1

bcast

mcast

MAC

proto.P2P = 0 dst_addr

• proto.P2P = 1
src_addr

dst_addr

MAC

src_addr

MAC
src_addr

MAC
MAC

• proto.D = 0 且 forward packet into mesh
IP

src_addr

ot_len

Espressif

6/16

2016.04

2. Mesh

option-1

option-2

……

option-n

option_list
otype

otype

1

olen

1

olen

ovalue

ovlaue

2.2.

Mesh

2.2.1.
Mesh

mesh_option_type

enum mesh_option_type {
M_O_FLOW_REQ = 0,//
M_O_FLOW_RESP,

//

M_O_ROUTER_SPREAD,

//

M_O_ROUTE_ADD,

//

Mesh

M_O_ROUTE_DEL,

//

Mesh

M_O_TOPO_REQ,

//

M_O_TOPO_RESP,

//

M_O_MCAST_GRP,

//

M_O_MESH_FRAG,

// Mesh

M_O_USR_FRAG,

//

M_O_USR_OPTION,

//

};

Espressif

7/16

2016.04

2. Mesh

2-2. Mesh

M_O_FLOW_REQ

2

M_O_FLOW_RESP

6

M_O_ROUTER_SPRE
AD

106

M_O_ROUTE_ADD

6*n+2

M_O_ROUTE_DEL

6*n+2

M_O_TOPO_REQ

8

M_O_TOPO_RESP

6*n+2

Mesh

Mesh

Mesh

Mesh

otype

olen

0x00

0x02

ovalue

otype

olen

ovalue

0x01

0x06

congest capacity

otype

olen

ovalue

0x02

0x6A

Router information

otype

olen

ovalue

0x03

length

MAC address list

otype

olen

ovalue

0x04

length

MAC address list

otype

olen

ovalue

0x05

0x06

MAC address of the device searched

otype

olen

0x06

length

ovalue
MAC address list

2.2.2.

"
2-3.

head.ver

00

head.O

1

head.flags.FP

0

head.flags.FR

0

head.flags.resv

Espressif

00

000

head.proto.D

1

head.proto.P2P

0

head.proto.protocol

Mesh

000000

Mesh

8/16

2016.04

2. Mesh

head.len

0x0014

20

head.dst_addr

18 FE 34 A5 3B AD

head.src_addr

18 FE 34 A2 C7 76

head.ot_len

MAC
MAC

0x0004

head.option_list[0].otype

0x00

head.option_list[0].olen

0x02

0x0004
M_FLOW_REQ
0x02

"
2-4.

head.ver

00

head.O

1

head.flags.FP

0

head.flags.FR

0

head.flags.resv

00

000

head.proto.D

0

head.proto.P2P

0

head.proto.protocol

000000

head.len

0x0015

head.dst_addr

18 FE 34 A2 C7 76

head.src_addr

18 FE 34 A5 3B AD

head.ot_len

Espressif

Mesh

0x0008

Mesh
21
MAC
MAC
0x0008

head.option_list[0].otype

0x01

M_FLOW_RESP

head.option_list[0].olen

0x06

0x06

head.option_list[0].ovalue

0x01

0x00000001
0x00000001

9/16

2016.04

3. API

3.

API

3.1.
3.1.1.

Mesh
struct mesh_header_format {
uint8_t ver:2;

// Mesh

uint8_t oe: 1;

//

uint8_t fp: 1;

//

uint8_t fr: 1;

//

uint8_t rsv:3;

//

struct {
uint8_t d:

1;

//

uint8_t p2p:1;

//

uint8_t protocol:6;

//

1

2

} proto;
uint16_t len;

//

uint8_t dst_addr[ESP_MESH_ADDR_LEN];

//

uint8_t src_addr[ESP_MESH_ADDR_LEN];

//

struct mesh_header_option_header_type option[0];

Mesh

// Mesh

} __packed;

3.1.2.

Mesh
struct mesh_header_option_header_type {
uint16_t ot_len;

//

struct mesh_header_option_format olist[0]; //
} __packed;

Espressif

10/16

2016.04

3. API

3.1.3.

Mesh
struct mesh_header_option_format {
uint8_t otype;

//

uint8_t olen;

//

uint8_t ovalue[0];

//

} __packed;

3.1.4.

Mesh
struct mesh_header_option_frag_format {
uint16_t id;

//

ID

struct {
uint16_t resv:1;

//

uint16_t mf:1;

//

uint16_t idx:14;

//

} offset;
} __packed;

3.1.5.

Mesh
typedef void (* espconn_mesh_callback)(int8_t result);

3.1.6.

Mesh
typedef void (* espconn_mesh_scan_callback)(void *arg, int8_t
status);

3.1.7.

Mesh
typedef void (* espconn_mesh_usr_callback)(void *arg);

API

3.2.
📖

ESP8266 Non-OS SDK API Guide
http://www.espressif.com/zh-hans/support/download/documents

Espressif

11/16

2016.04

4.

4.
4.1.
ESP8266_MESH_DEMO/blob/master/mesh_demo/demo/mesh_demo.c

4.2.
void controller_entrance(Parameter list)
{
/*

*/

/*

*/

uint8_t json_control_data[] = {/*

*/};

uint16_t control_data_len = sizeof(json_control_data)
struct mesh_header_format *mesh_header = NULL;
/* src_addr

IP

0

*/

uint8_t src_addr[] = {0,0,0,0,0,0},
dst_addr[] = {xx,xx,xx,xx,xx,xx};
mesh_header = (struct mesh_header_format
*)espconn_mesh_create_packet(dst_addr, src_addr, false, true,
M_PROTO_JSON, control_data_len,
false, 0, false, 0, false, 0, 0);
if (!mesh_header)
{
printf(“alloc resp packet fail\n”);
return;
}
if (espconn_mesh_set_usr_data(mesh_header,
resp_json_packet_body, resp_data_len))
{
printf(“set user data fail\n”);
Espressif

12/16

2016.04

4.

free(mesh_header);
return;
}
//
espconn_mesh_sent(esp, mesh_header, mesh_header->len);
free(mesh_header);
}

4.3.
void topology_entrance(Parameter list)
{
/*

*/

/*

*/

bool res;
struct mesh_header_format *mesh_header = NULL;
struct mesh_header_option_format *topo_option = NULL;
uint8_t src_addr[] = {0,0,0,0,0,0};
uint8_t dst_addr[] = {xx,xx,xx,xx,xx,xx}; //

MAC

uint8_t dev_mac[6] = {xx,xx,xx,xx,xx,xx}; //0
uint16_t ot_len = sizeof(*topo_option) + sizeof(struct
mesh_header_option_header_type) + sizeof(dev_mac);
mesh_header = (struct mesh_header_format
*)espconn_mesh_create_packet(
dst_addr, src_addr, false, true, M_PROTO_NONE, 0,
true, ot_len, false, 0, false, 0, 0);
if (!mesh_header) {
printf(“alloc resp packet fail\n”);
return;
}
topo_option = (struct mesh_header_option_format
*)espconn_mesh_create_option(
M_O_TOPO_REQ, dev_mac, sizeof(dev_mac));

Espressif

13/16

2016.04

4.

if (!topo_option) {
printf(“alloc topo option fail\n”);
free(mesh_header);
return;
}
res = espconn_mesh_add_option(mesh_header, topo_option);
free(topo_option);
if (res) {
printf(“add topo option fail\n”);
free(mesh_header);
return;
}
//
espconn_mesh_sent(esp, mesh_header, mesh_header->len);
free(mesh_header);
}

4.4.
void topology_parser_entrance(uint8_t *topo_resp, uint16_t len)
{
/*

*/

uint16_t oidx = 1;
struct mesh_header_format *mesh_header = NULL;
struct mesh_header_option_format *topo_option = NULL;
mesh_header = (struct mesh_header_format *)topo_resp;
if (!mesh_header->oe) {
printf(“no option exist\n”);
return;
}
/*

*/

while(espconn_mesh_get_option(mesh_header, M_O_TOPO_RESP,
oidx++, &topo_option)) {
Espressif

14/16

2016.04

4.

uint16_t dev_count = topo_option->olen/6;
process_dev_list(topo_option->ovalue, dev_count);
}
}

4.5.

Dev-App
• ESP8266_MESH_DEMO/blob/master/mesh_demo/include/user_config.h
• ESP8266_MESH_DEMO/blob/master/mesh_demo/demo/mesh_demo.c

Espressif

15/16

2016.04

URL
“

”

Wi-Fi

IOT
www.espressif.com

Wi-Fi

© 2016

Bluetooth SIG



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
Linearized                      : No
Page Count                      : 19
PDF Version                     : 1.5
Title                           : 30A-ESP8266__Mesh_User_Guide__CN
Producer                        : Mac OS X 10.11.2 Quartz PDFContext
Creator                         : Pages
Create Date                     : 2016:05:23 02:19:43Z
Modify Date                     : 2016:05:23 02:19:43Z
EXIF Metadata provided by EXIF.tools

Navigation menu