蓝牙mesh Spec学习记录

目前在学习和研究mesh,看mesh specification,总会遇到暂时不太理解的地方,或者重要的地方记录一下免得忘记。

目录

(一) Mesh Profile Spec V1.0.1

1、Configuration Mode

2、Configuration client

3、 bearers (advertising bearer 和 GATT bearer)

4、vitual address

5、the Configuration Server model

6、AppKey Index and Netkey Index

7、蓝牙mesh的广播包

8、Mesh GATT services (Mesh Provisioning Service 和 Mesh Proxy Service)

9、security material(master security material 和 friendship security material)

10、NID 和 Network ID

11、Composition data中Model Opcode如何获取?

12、Device Key如何产生,用来干什么?

13、Application key (Appkey)何时产生?


 


 

(一) Mesh Profile Spec V1.0.1

1、Configuration Mode

         详见foundation models这一章

2、Configuration client

Section 1.3.5

          Configuration Client:a node that implements the Configuration Client model

Section 2.2.1

          The network resources are managed by a node that implements the Configuration Client model, known
as the Configuration Client, (typically a smart phone or other mobile computing device) and are allocated
to nodes at the time of configuration (see Section 5) using the Configuration Server model (see Section
4.4.1)

section 2.2.2

          A node can send or receive mesh messages and is managed by a Configuration Client, that may also be
the same device as the Provisioner, over the mesh network to configure how the node communicates
with other nodes. A Configuration Client can remove a node from a mesh network, which reverts it back
to an unprovisioned device.

 in Mesh Profile Spec V1.0.1 P32:

          A node may have knowledge of a single device key, multiple application keys, and multiple network keys.

a device key is only known by a Configuration Client and the single node. The Configuration Client knows the device keys for all nodes

Section 5

A Provisioner is typically a smart phone or other mobile computing device. Although only a single
Provisioner is required on a network to do provisioning, multiple Provisioners may be used.


3、 bearers (advertising bearer 和 GATT bearer

This specification defines two mesh bearers over which mesh messages may be transported:
• An advertising bearer (see Section 3.3.1)
• A GATT bearer (see Section 3.3.2)
个人理解:advertising bearer是蓝牙mesh 网络中一般的node所使用到的,它们可以receive和中继广播;

GATT bearer是蓝牙mesh 网络中proxy node需要使用到的,比如下图所示的S节点作为proxy node,当然S节点也使用到了advertising bearer。spec中有这样一句话:A node shall support the advertising bearer or the GATT bearer or both.
 

如下是对3.3.2 GATT bearer (P38)部分的翻译和个人理解:

GATT bearer被提供用来使不支持advertising bearer的设备参与到mesh网络中。GATT bearer使用Proxy protocol在基于GATT连线之上的两个设备间传输和接收Proxy PDUs。

通过使用ATT协议,GATT beraer使用characteristic来写入、接收mesh message的notification。

GATT bearer定义了两个角色:GATT Bearer Client和GATT Bearer Server.

GATT Bearer Client应该是一个GATT Client;GATT Bearer Server应该是一个GATT Server.

GATT Bearer Server需要实例化一个并且仅有一个 Mesh Proxy Service,GATT Bearer client应该支持Mesh Proxy Service。

GATT Bearer client应该运行primary service discovery(使用GATT Discover All Primary Services或者GATT Discover Primary Services)来发现 Mesh Proxy Service,并使用对应的procedures来发现GATT Bearer Server中与此Mesh Proxy Service关联的characteristics和descriptors。

GATT Bearer client应该发现the Mesh Proxy Data In characteristic, Mesh Proxy Data Out characteristic 和它的 Client Characteristic Configuration descriptor.一旦发现Client Characteristic Configuration descriptor,GATT Bearer client应该使能Mesh Proxy Data Out的notification。

为发送Proxy PDU,GATT Bearer Client 应该使用Write Without Response procedure来向GATT Bearer Server中的Mesh Proxy data In characterister写入Proxy PDU数据。

为接收Proxy PDU,GATT Bearer Client 应该能够接收Mesh Proxy Data Out characteristic的多个notification.每个notification包含一个Proxy PDU数据。

上图Figure 2.8中所示的S节点,使用到了Proxy protocol,T节点使用S节点和mesh网络中的其它节点进行通信。

S节点作为GATT Bearer Server,T节点作为GATT Bearer Client。

4、vitual address

label UUID

to do

5、the Configuration Server model

详见foundation models这一章
 

6、AppKey Index and Netkey Index

在mesh网络中,Network keys和Application keys被组织成两个List:network key list和application key list;这两个list由一个Configuration Client维护,每个list都是mesh网络中的共享资源(shared resource)。通过全局的key index (Netkey Index 和Appkey index)来引用Netkey和Appkey。

每个全局的key index 长度为12 bits。一些message包含1个、2个或多个key index 。为高效传输,2个keys可以打包成3个Bytes。在奇数个key index需要被打包的地方,(除了最后一个key index之外的) 前面偶数个key index被打包为连续的"3 Bytes",最后一个key index被打包为2个bytes。在偶数个key index需要被打包的地方,它们被打包为连续的"3 Bytes"。

将2个key index打包为3个Bytes方法如下:

将1个key index打包为2个Bytes方法如下:

 

7、蓝牙mesh的广播包

1、PB-ADV的包是用在Provisioning过程的,Provisioning是一个设备加入Mesh网络的过程。
2、Mesh Message,这个是在设备入网后,进行数据通信的时候大量使用的包。节点间通信就是使用这种包进行的。
3、Mesh Beacon包含两种类型:Unprovisioned Device beacon和Secure Network beacon,其中Unprovisioned Device Beacon是用来被Provisioner发现设备用的,也就是在Provisioning之前设备发送的包,这个包里会包含Manufacturer相关的Device UUID(128bits),这个Device UUID是用来区分设备的,因此需要保证唯一性。而Secure Network beacon则是设备入网后用来发送一些安全相关的包,比如IV index更新包。Key Refresh procedure、IV Update procedure 和 IV Index Recovery procedure都基于Secure Network beacon。
4、Mesh GATT services章节中也会使用特定的mesh广播包。

8、Mesh GATT services (Mesh Provisioning Service 和 Mesh Proxy Service)

Spec描述如下:
The Mesh Provisioning Service allows a Provisioning Client to provision a Provisioning Server to allow it to participate in the mesh network.
The Mesh Proxy Service is used to enable a server to send and receive Proxy PDUs with a client.

从Spec的表述可以看出,

Mesh Provisioning Service是用来让一个Device变成Mesh Node的;

Mesh Proxy Service是用来使Server和Client通过Proxy PDU收发数据的 (此时Server和Client均为Mesh网络中的Node)。

比如 Figure 2.8中的S和T,S已经加入mesh网络的前提下,

T成为mesh Node的方式是:

T作为GATT Server,包含Mesh Provisioning Service,发广播包(包含 «Mesh Provisioning Service» UUID),S扫描后通过GATT连上T,交互后T成为此mesh 网络中的一员;

而T成为mesh node之后只能通过S和网络中其他Node交互;相对于T,S作为GATT Server,包含 Mesh Proxy Service,发广播包(包含«Mesh Proxy Service» UUID),T扫描后通过GATT连上S.

上面下划线部分是个人理解,大家有新的想法的话非常欢迎指出、补充,一起探讨

发现一种case:

Nordic 

9、security material(master security material 和 friendship security material)

  

10、NID 和 Network ID

这是两个完全不一样的东西,容易弄混淆。

NID :长度为7个bits,在Network PDU中会使用到。

Network ID :长度为8个Bytes,源自Network  key, 在Secure Network beacon中会用到。

 

11、Composition data中Model Opcode如何获取?

Composition Data 状态中的Composition Data Page 0关于element Model只含有Model Id信息,那么其opcode如何获取?

12、Device Key如何产生,用来干什么?

Device key在对provisionee做完provision之后产生的,只会保存在和provisionee中;Device Key的作用是:Configuration Client对provisionee进行configure过程中的message,使用Device key进行加密。

13、Application key (Appkey)何时产生,使用场景?

to do

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章