Introduction to the concept of Bluetooth Sig Mesh ④——Mesh's professional terminology and its operation process

One, States

The status of a node, such as onoff States,lightness States

二、Bound states

Two interrelated states, such as onoffand lightness.

  • When the onoffvalue changes from 1 to 0, the lightnessvalue will become 0
  • When the onoffvalue from 0 to 1 when lightnessthe value also changes from 0 to turn off the lights before the lightnessvalue of
  • Similarly, when lightnessvalues varies between 0 and non-0, onoffthe values will be from 0 to 1.

Three, Messages

After the encryption is complete, sent to the mesh network packet, we also called mesh packet, mesh command.

四、Node & Elements

Node represents a complete node or Bluetooth module, and Element represents an operating element in Node.

  • Node addressOne and only one
  • element addressCan be one or more
    • When the element addresscase where a plurality of address which will be continuous
    • The first element addressis also calledprimary address
  • Node addressAnd the value of primary addressthe same.

such as:

  • The elementnumber of socket products (3 channels) is 3, and 3 generic onoffcontrol commands respectively control the switches of 3 channels;
  • The elementnumber of color temperature lights (CT Light) is 2, 2 generic level model, respectively, corresponding to lightnessand Temp;
  • The elementnumber of HSL lights (RGB lights) is 3, 3 generic level modelcorresponding to lightness, Hueand respectively Sat.

When networking:

  1. NodeThe number of elements will be reported in the interactive information of the provision flow, such as 2;
  2. provisionerAn address will be assigned Node, such as 0x0002;
  3. NodeAfter receiving it, 0x0002 element 1and 0x0003 will be allocated in order element 2;
  4. ProvisionerWhen the next node is networked, it will be allocated from 0x0004.

五、Publish & Subscribe

PublishIt is Elementthe process of sending status of the initiative

  • By Config Model Publication Setthe configuration publish address, command, and parameter setting period publish.
  • After the publish address is configured, as long as the status changes, Node will automatically execute the publish status action. Whether it needs to be sent periodically depends on the period publish parameter.

SubscribeIs the Elementprocess of receiving and processing data

  • By Config Model Subscription Add, Config Model Subscription Virtual Address Addlike adding commands Subscribe list [] Address
  • Subscribe list[]Which is group addressor virtual addresscan not be unicast address, nor is 0xffff
  • ElementReceive status message (such as generic onoff status) or control message (such as generic onoff) published by other nodes
  • The model of Subscribe list[]whether or not to process the message determination.

The basis for judging whether to receive and process is:

  1. Upon receiving messagethe destination addressnon- unicast address, it is determined whether a corresponding model can be
    matched to the address inside the Subscribe list.
  2. Upon receipt messageof destination addressis unicast address, itself, and it is determined element addresswhether the match.
  3. When destination addressis 0xffff, it indicates that meet the judgment conditions.

Six, Security

6.1 Access layer encryption

  • Use app keyor device keythe entire access layer (comprising op code, parameters) encrypted
  • If the model corresponding to the op code is the config model, use it device key, otherwise use it app key.

6.2 Network layer encryption

  • Use network key+ iv indexto encrypt the entire network layer
  • The network layer is the packet sent to the mesh network, including source address, destination address, and sequence number.

6.3 app key

  • SDK supports 2 app key( APP_KEY_MAX) by default .
  • More app keyit can be used to manage different levels of security products.

such as

  • There are both lights and door locks in the mesh network
  • If the security level of the door lock is higher, only certain people can control it
  • At this time, you can assign an independent app key to the door lock separately, and ensure that this app key is only known by certain mobile apps (provisioners), and will not be shared during network sharing.

This can increase the security level.

6.4 network key

  • SDK supports 2 by default network key( NET_KEY_MAX)
  • Plurality network keymay be used to manage a plurality of network.

6.5 Other

For messages that need to be subpackaged, because the payload of the access layer is encrypted when the entire payload is encrypted, it is necessary to receive all packets before decryption and verification can be completed.

七、Sequence Number

Sequence Number referred to SNOorSEQ

7.1 SNO self-increment judgment

  • SNOIt will be accumulated every time a command is sent
  • Making the receiving terminal SNOdetermines the time required is larger than the value already received, and if less then the message is considered invalid

7.2 SNO storage processing

If the transmitting end each transmitting a command to be SNOstored in the flash, the stored frequency is too high, especially when needed sub transmitted. Due to the limited number of flash reads and writes. So amended to:

  • SNO increased MESH_CMD_SNO_SAVE_DELTA(default 0x80), only stored once
  • During power-on initialization, to read the SNOplus MESH_CMD_SNO_SAVE_DELTA(in order to ensure that after power off and on again SNOis greater than the value already used)

For the specific implementation, please refer to mesh_flash_save_check() and mesh_misc_retrieve() for the handling of MESH_CMD_SNO_SAVE_DELTA.

八、Friendship

Friendship refers to the relationship established between Friend Node( FN) and Low Power Node( LPN) through the established friend ship flow.

  • After the friend ship is successfully established, LPNduring sleep
  • When there are nodes send commands to LPNtime, FNit will be the first to get this message saved
  • When LPNthe wake will be sent POLL command to query FN, then FNit will send the message to save LPN
  • In this way, lower power consumption can be achieved. The disadvantage is LPNthat there is a certain delay in receiving and responding to commands.

Nine, Features

9.1 Relay feature

The main function of Relay relay is to spread the message among the nodes, multi-level hop, and realize the transmission distance of the mesh network is longer.

However, in order to prevent diffusion of the message infinite loop, it does not disappear . So some restrictions are made as follows

  • The node receives a valid network message
  • First reduce the TTL value of the message by 1, and then relay to send it out
  • If the received TTL value is less than or equal to 1, no relay is performed

The introduction of TTL is mainly to control the delay time of the node that finally receives the message within the controllable range.

  • The default value of SDK TTL is TTL_DEFAULT(0x0A), this macro can be modified
  • provisioner can also Config Default TTL Setconfigure the maximum is 127

9.2 Proxy feature

Proxy is the protocol used for mobile APP to access the mesh network.

  • In the mesh network, APP is also an independent node, with its own Node address.
  • The proxy is introduced because most mobile phones currently cannot send broadcast packets fully customized, and cannot always be in the state of monitoring the mesh network (switch to WiFi in the middle, etc.)
  • Therefore, the mobile phone APP needs to connect to a node through BLE GATT, and the directly connected node will forward the data after receiving the data from the APP.
  • When the directly connected node receives the message replies to the app in the mesh network, it will first reply to the mobile app via GATT according to the proxy protocol

9.3 App direct connection

The APP sends a message to the directly connected node ATT_OP_WRITE_CMD(0x52), and the directly connected node responds to the
message to the APP with notify, that is, ATT_OP_HANDLE_VALUE_NOTI(0x1B).

9.4 Low Power feature

八、Friendship

9.5 Friend feature

八、Friendship

10. Mesh network topology diagram

Insert picture description here
If you think it’s good, just one click for three consecutive chants (Like+Favorite+Follow)

Guess you like

Origin blog.csdn.net/kangweijian/article/details/115275133