Welcome to mirror list, hosted at ThFree Co, Russian Federation.

readme.txt « BLE_MeshLightingProvisioner « BLE « Applications « P-NUCLEO-WB55.Nucleo « Projects - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0e514fca3f03d2f192b4a6600e2f8dd7fff41fa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/**
  @page BLE_MeshLightingProvisioner example
  
  @verbatim
  ******************** (C) COPYRIGHT 2020 STMicroelectronics *******************
  * @file    BLE/BLE_MeshLightingProvisioner/readme.txt 
  * @author  MCD Application Team
  * @brief   Description of the BLE Mesh Lighting Embedded Provisioner demo example.
  ******************************************************************************
  *
  * Copyright (c) 2020 STMicroelectronics. All rights reserved.
  *
  * This software component is licensed by ST under Ultimate Liberty license 
  * SLA0044, the "License"; You may not use this file except in compliance with 
  * the License. You may obtain a copy of the License at:
  *                               www.st.com/SLA0044
  *
  ******************************************************************************
  @endverbatim

@par Example Description 
This is the implementation of the BLE Mesh Lighting profile as specified by the BLE SIG.

@note Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds)
      based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from
      a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower)
      than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
      To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.
      
@note The application needs to ensure that the SysTick time base is always set to 1 millisecond
      to have correct HAL operation.

@par Keywords

Connectivity, BLE, IPCC, HSEM, RTC, UART, PWR, BLE protocol, BLE mesh, Dual core

@par Directory contents 
            mesh_lighting_demo
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/app_common.h                  Header for all modules with common definition
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/app_conf.h                    Parameters configuration file of the application
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/app_debug.h                   Interface to support debug in the application
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/app_entry.h                   Parameters configuration file of the application
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/hw_conf.h                     Configuration file of the HW
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/hw_flash.h                    Configuration file of the FLASH driver needed by EE module
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/hw_if.h                       Configuration file of the Hardware Iterface
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/lp_timer.h                    Configuration file of the Low power timer to be used within Mesh Application.
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/main.h                        Header for main.c module
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/stm32wbxx_hal_conf.h          HAL configuration file
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/stm32_lpm_if.h                Configuration file of the Low layer function to enter/exit low power modes (stop, sleep).
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/stm32wbxx_it.h                Interrupt handlers header file
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/utilities_conf.h              Configuration file of the utilities
  - BLE/BLE_MeshLightingProvisioner/Core/Inc/vcp_conf.h                    Configuration file of Virtual Com Port Interface
  - BLE/BLE_MeshLightingProvisioner/Core/Src/app_debug.c                   Interface to support debug in the application
  - BLE/BLE_MeshLightingProvisioner/Core/Src/app_entry.c                   Initialization of the application
  - BLE/BLE_MeshLightingProvisioner/Core/Src/hw_flash.c                    FLASH driver needed by EE module
  - BLE/BLE_MeshLightingProvisioner/Core/Src/hw_timerserver.c              Timer Server based on RTC
  - BLE/BLE_MeshLightingProvisioner/Core/Src/hw_uart.c                     UART Driver
  - BLE/BLE_MeshLightingProvisioner/Core/Src/lp_timer.c                    Low power timer to be used within Mesh Application.
  - BLE/BLE_MeshLightingProvisioner/Core/Src/main.c                        Main program
  - BLE/BLE_MeshLightingProvisioner/Core/Src/stm32_lpm_if.c                Low Power Manager Interface
  - BLE/BLE_MeshLightingProvisioner/Core/Src/stm32wbxx_it.c                Interrupt handlers
  - BLE/BLE_MeshLightingProvisioner/Core/Src/system_stm32wbxx.c            stm32wbxx system source file
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/app_ble.c               BLE Profile implementation
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/app_ble.h               Header of BLE Profile implementation 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_config_client.c   Application interface for Config CLient Mesh Model
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_config_client.h   Header of Application interface for Config CLient Mesh Model 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_generic.c         Application interface for Generic Mesh Models
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_generic.h         Header of Application interface for Generic Mesh Models 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_generic_client.c  Application interface for Client Generic Mesh Models
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_generic_client.h  Header of Application interface for Client Generic Mesh Models 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_light.c           BLE Mesh Light Profile implementation
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_light.h           Header of BLE Mesh Light Profile implementation 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_light_client.c    Application interface for Client Light Mesh Models
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_light_client.h    Header of Application interface for Client Light Mesh Models 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_light_lc.c        BLE Mesh Light Lightness Controller Profile implementation
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_light_lc.h        Header of BLE Mesh Light Lightness Controller Profile implementation 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_mesh.c            BLE Mesh application implementation
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_mesh.h            Header of BLE Mesh application implementation 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_nvm.c             BLE Mesh NVM application implementation
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_nvm.h             Header of BLE Mesh NVM application implementation 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_sensor.c          BLE Mesh Sensor Profile implementation
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_sensor.h          Header of BLE Mesh Sensor Profile implementation 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_vendor.c          BLE Mesh Vendor Profile implementation
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/appli_vendor.h          Header of BLE Mesh Vendor Profile implementation 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/ble_conf.h              BLE Services configuration
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/ble_dbg_conf.h          BLE Traces configuration of the BLE services
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/hal_common.h            Header for common function of HAL file
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/mesh_cfg.h              Header for Mesh configuration
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/mesh_cfg_usr.h          Header for user Mesh configuration
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/models_if.h             Header for the BLE Mesh Models Interface file
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/models_if.c             BLE Mesh Models Interface file
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/pal_nvm.c               BLE Mesh NVM management implementation
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/pal_nvm.h               Header of BLE Mesh NVM management implementation 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/PWM_config.c            Pulse Width Modulation configuration
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/PWM_config.h            Header of Pulse Width Modulation configuration 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/PWM_handlers.c          Pulse Width Modulation handlers
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/PWM_handlers.h          Header of Pulse Width Modulation handlers 
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/svcctl_conf.c           Service Controller configuration API
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/tl_conf.h               Configuration file of the Transport layer
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/tl_if.c                 Transport Layer interface
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/user_if.h               Header file for User interface file
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/user_if.c               User interface file
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/App/vcp_conf.h              Configuration of the vcp interface
  - BLE/BLE_MeshLightingProvisioner/STM32_WPAN/Target/hw_ipcc.c            IPCC Driver

     
@par Hardware and Software environment

  - This example runs on STM32WB55xx devices.
  
  - This example has been tested with an STMicroelectronics STM32WB55RG-Nucleo
    board and can be easily tailored to any other supported device 
    and development board.

@par How to use it ? 

This application requires having the stm32wb5x_BLE_Stack_full_fw.bin binary flashed on the Wireless Coprocessor.
If it is not the case, you need to use STM32CubeProgrammer to load the appropriate binary.
All available binaries are located under /Projects/STM32_Copro_Wireless_Binaries directory.
Refer to UM2237 to learn how to use/install STM32CubeProgrammer.
Refer to /Projects/STM32_Copro_Wireless_Binaries/ReleaseNote.html for the detailed procedure to change the
Wireless Coprocessor binary.  

In order to make the program work, you must do the following:
 - Open your preferred toolchain 
 - Rebuild all files and load your image into target memory
 - Run the example
 
For more details refer to the Application Note: 
  AN5292_STM32WB_How_to_build_BLE_Mesh_Application
  
@Introduction

The ST BLE-Mesh library supports all of the following features in a Mesh node:
1. Relay: to forward received network PDUs on advertising or GATT bearer, if the Proxy feature is enabled
2. Proxy: to forward received network PDUs between GATT and advertising bearers
3. Friend: can perform duties such as scanning for other associated nodes that are usually Low Power mode
4. Low Power: consumes much less power as the node usually does not perform any scanning
A typical BLE Mesh node radio should always be in scanning mode to avoid missing packets over the air, but this kind of
operation is not supported by many devices due to continuous energy requirements.
To enable low power operation, BLE Mesh Profile v1.0 defines the concept of Friendship.
In a Mesh network, a Low Power feature-enabled Mesh node (LPN) offloads its packet receiving (scanning) duty to an adjacent
Friend feature-enabled Mesh node (FN). The LPN is not always scanning and remains inactive (or sleeps) for most of its life
cycle, significantly reducing its energy requirements. Nodes running on batteries or energy harvesting techniques usually
support the Low Power feature.
Once connected to each other, the FN and LPN are considered friends and their connection is known as a Friendship. At least
one FN must be in the direct radio range of an LPN to establish Friendship.

@Configuration

General default setting defined in mesh_cfg_usr.h:
        ENABLE_GENERIC_MODEL_SERVER_ONOFF                                    (1) /* GENERIC SERVER ONOFF MODEL ON FIRST ELEMENT */
        APPLICATION_NUMBER_OF_ELEMENTS                                         1 /* NUMBER OF ELEMENT SUPPORTED */ 
        APPLICATION_SIG_MODELS_MAX_COUNT                                      20 /* TOTAL NUMBER OF MODELS SUPPORTED */
        APPLICATION_VENDOR_MODELS_MAX_COUNT                                    2 /* TOTAL NIMBER OF VENDOR MODELS SUPPORTED */
        ENABLE_PB_ADV                                                            /* Provisioning Bearer over advertising channels support */
        ENABLE_PB_GATT                                                           /* Provisioning Bearer over GATT proxy support */ 

Provisioner Node
Provisioner feature support is defined in mesh_cfg_usr.h by the predefinition of ENABLE_PROVISIONER_FEATURE or DYNAMIC_PROVISIONER.

When the ENABLE_PROVISIONER_FEATURE is defined after generating and flashing the binary, 
the Provisioner Node is self provisioned and configured during the initialization.

When the DYNAMIC_PROVISIONER is defined after generating, flashing the binary and the initialization the provisioner is like 
an unprovisioned device that can be provisioned and configured by 
BLE-Mesh Android (https://play.google.com/store/apps/details?id=com.st.bluenrgmesh&hl=en) or 
BLE-Mesh iOS (https://apps.apple.com/us/app/st-ble-mesh/id1348645067) smartphone application.
To dynamically set the device as a provisioner self provisioned and self configured, you can run the following command in an external
terminal: atep root
Here are the external terminal settings:
   baud rate of 115200
   Byte size of 8
   Parity None
   Stop bits 1
   Data Flow Control None
   
Establishment of Link by ID between a Provisioner and an unprovisioned device:

                     Provisioner                 Device 1                   Device 2                   Device 3
                         |                          |                          |                          |         
                        Scan                        |                          |                          |         
                         |<-----------------Unprovisioned Device Beacon (UUID 3, OOB info)----------------|         
                         |                          |                          |                          |         
                         |<---Unprovisioned Device--|                          |                          |         
                         | Beacon (UUID 1, OOB info)|                          |                          |         
                         |                          |                          |                          |         
                         |<---Unprovisioned Device Beacon (UUID 2, OOB info)---|                          |         
                         |                          |                          |                          |         
                 Provisioner chooses                |                          |                          |
                 to provision device                |                          |                          |
                    with UUID 2                     |                          |                          |
                         |                          |                          |                          |         
                         |-------------------Link Open (UUID 2)--------------->|                          |                   
                         |                          |                          |                          |         
                         |<----------------------Link Ack----------------------|                          |         
                         |                          |                          |                          |         
                                          PB-ADV Provisioning Process                                     |         
                         |                          |                          |                          |         
                         |<------------------Link Close (Reason)---------------|                          |         
                         |                          |                          |                          |         

PB-ADV Provisioning Process

                       Client                                                                         Server
                     Provisioner                                                                     New Device
                         |                                                                                |
               Scan for Un-provisioned                                                                    |
               Device, Link establishment                                                                 |               
                         |                                                                                |
                         |<-----------------------Un-provisioned Device Adv beacon------------------------|
                         |                                                                                |
                         |------------------------10% = Invite for Provisioning-------------------------->|
                         |                                                                                |
                         |<--------------------20% = Provisioning Capabilities sharing--------------------|
                         |                                                                                |
                         |------------------------30% = Provisioning start PDU--------------------------->|
                         |                                                                                |
                         |------------------------40% = Provisioning Public Key-------------------------->|
                         |                                                                                |
                  Calculate ECDH                                                                    Calculate ECDH
                         |                                                                                |
                         |<-----------------------50% = Provisioning Public Key---------------------------|
                         |                                                                                |
                      Session                                                                          Session     
                  Key calculation                                                                  Key calculation
                         |                                                                                |
                         |----------------60% = Provisioning Data (Network key, IV Index,---------------->|
                         |                      Unicast address, Key Index, Flags)                        |
                         |                                                                                |
                         |<-----------------------70% = Provisioning Completed----------------------------|
                         |                                                                                |
                   Disconnection                                                                    Disconnection
                                                                                             
Configuration Process                                                                        
                                                                                             
                     Provisioner                                                                   Provisioned Device
                         |                                                                                |
                   Scan for Proxy                                                                         |
                         |                                                                                |
                         |----------------------------Get Composition Data------------------------------->|
                         |                                                                                |
                         |<---------------------Status = Receive Composition data-------------------------|
                         |                                                                                |
                         |----------------------------80% = App Key Add---------------------------------->|
                         |                                                                                |
                         |<------------------------Status = App Key Status--------------------------------|
                         |                                                                                |
                         |-----------------90% = App Bind with Models selected by user------------------->|
                         |                                                                                |
                         |<------------------------Status = Binding Status--------------------------------|
                         |                                                                                |
                         |-------------100% = Add Subsciption with Models selected by user--------------->|
                         |                                                                                |
                         |<----------------------Status = Subscription Status-----------------------------|
                         |                                                                                |
                         |-------------100% = Set Publication Address for Client Node-------------------->|
                         |                                                                                |
                         |<----------------------Status = Publication Status------------------------------|
                         |                                                                                |
                    Configuration                                                                   Configuration
                     completed                                                                       completed

In the Provisioner terminal, after self provisioning and self configuration you can:
- scan for un-provisioned device with the command: atep scan
  The UUID addresses of the unprovisioned devices are displayed like as following:
  Device-0 -> F81D4FAE7DEC4B53A154F6FB0726E1C0
- provision and configure the un-provisioned device with the command: atep prvn-0 2
  0: is the scanned Device ID, 0 for Device-0 with the UUID address F81D4FAE7DEC4B53A154F6FB0726E1C0
  2: is the unicast address you want to associates to the provisioned node (1 is used for the provisioner Node)
  Many lines are displayed on the terminal, until hte following one:
  38281 Appli_ConfigClient_ConfigureNode - **Node is configured**

By pressing [SW1] button on the Provisioner Node:
1. Provisioner Node publishes a LED ON command to the default group and the Provisioner Node blue LED immediately turns on.
2. As soon as the Provisioned Node receives the LED ON command, the blue LED immediately turns on.

                  Provisioner Node                                                                Provisioned Node
                        |                                                                                |
              SW1 PUSH->|                                                                                |
           Blue LED on->|                                                                                |
                        |--------------------------------LED on----------------------------------------->|<-Blue LED on
                        |                                                                                |
              SW1 PUSH->|                                                                                |
          Blue LED off->|                                                                                |
                        |--------------------------------LED off---------------------------------------->|<-Blue LED off
                        |                                                                                |

By pressing [SW1] button on the Provisioned Node:
1. Provisioned Node publishes a LED ON command to the default group and the Provisioned Node blue LED immediately turns on.
3. As soon as the Provisioner Node receives the LED ON command, the blue LED immediately turns on.

                  Provisioner Node                                                                Provisioned Node
                        |                                                                                |
                        |                                                                                |<-SW1 PUSH
                        |                                                                                |<-Blue LED on
           Blue LED on->|<--------------------------------LED on-----------------------------------------|
                        |                                                                                |
                        |                                                                                |<-SW1 PUSH
                        |                                                                                |<-Blue LED off
          Blue LED off->|<--------------------------------LED off----------------------------------------|
                        |                                                                                |

From Provisioner Node terminal following command can be sent:
- atcl c000 8202 01 01
  c000: default group address
  8202: opcode of the GENERIC ONOFF SET command (see chapter 7.1 Messages summary of the Mesh Model Bluetooth SIG Specification Revision v1.0)
  01: The target value of the Generic OnOff state (see chapter 3.2.1.2 Generic OnOff Set of the Mesh Model Bluetooth SIG Specification Revision v1.0)
  01: Transaction Identifier (see chapter 3.2.1.2 Generic OnOff Set of the Mesh Model Bluetooth SIG Specification Revision v1.0)
  => Blue LED of Provisioner Node and Provisioned Node turns on.
From Provisioned Node terminal following command can be sent:
- atcl c000 8202 00 01
  c000: default group address
  8202: opcode of the GENERIC ONOFF SET command (see chapter 7.1 Messages summary of the Mesh Model Bluetooth SIG Specification Revision v1.0)
  00: The target value of the Generic OnOff state (see chapter 3.2.1.2 Generic OnOff Set of the Mesh Model Bluetooth SIG Specification Revision v1.0)
  01: Transaction Identifier (see chapter 3.2.1.2 Generic OnOff Set of the Mesh Model Bluetooth SIG Specification Revision v1.0)
  => Blue LED of Provisioner Node and Provisioned Node turns off.
  
* <h3><center>&copy; COPYRIGHT STMicroelectronics</center></h3>
 */