Skip to content

Commit 67ceddb

Browse files
krish2718rlubos
authored andcommitted
wifi_prov: Rejig the library to use for multiple transports
We now have a new application for this library which will be used with no transport, so, move the the core provisioning stuff to a new library that can be used by BLE or no transport. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 6ea599a commit 67ceddb

File tree

30 files changed

+382
-241
lines changed

30 files changed

+382
-241
lines changed

CODEOWNERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
/doc/nrf/libraries/bluetooth/mesh.rst @nrfconnect/ncs-paladin-doc
123123
/doc/nrf/libraries/bluetooth/services/fast_pair/ @nrfconnect/ncs-si-bluebagel-doc
124124
/doc/nrf/libraries/bluetooth/services/fast_pair.rst @nrfconnect/ncs-si-bluebagel-doc
125-
/doc/nrf/libraries/bluetooth/services/wifi_prov.rst @nrfconnect/ncs-wifi-doc
125+
/doc/nrf/libraries/bluetooth/services/wifi_prov_ble.rst @nrfconnect/ncs-wifi-doc
126126
/doc/nrf/libraries/caf/ @nrfconnect/ncs-si-muffin-doc @nrfconnect/ncs-si-bluebagel-doc
127127
/doc/nrf/libraries/debug/cpu_load.rst @nrfconnect/ncs-doc-leads
128128
/doc/nrf/libraries/debug/etb_trace.rst @nrfconnect/ncs-cia-doc
@@ -173,6 +173,7 @@
173173
/doc/nrf/libraries/networking/rest_client.rst @nrfconnect/ncs-iot-positioning-doc
174174
/doc/nrf/libraries/networking/softap_wifi_provision.rst @nrfconnect/ncs-cia-doc
175175
/doc/nrf/libraries/networking/wifi_mgmt_ext.rst @nrfconnect/ncs-cia-doc
176+
/doc/nrf/libraries/networking/wifi_prov_*.rst @nrfconnect/ncs-cia-doc
176177
/doc/nrf/libraries/networking/wifi_ready.rst @nrfconnect/ncs-wifi-doc
177178
/doc/nrf/libraries/nfc/ @nrfconnect/ncs-si-muffin-doc
178179
/doc/nrf/libraries/nrf_rpc/index.rst @nrfconnect/ncs-si-muffin-doc
@@ -540,6 +541,7 @@
540541
/samples/tfm/ @nrfconnect/ncs-aegir
541542
/samples/wifi/provisioning/ble/ @wentong-li @bama-nordic
542543
/samples/wifi/provisioning/softap/ @nrfconnect/ncs-cia
544+
/samples/wifi/provisioning/internal/ @krish2718 @rado17
543545
/samples/wifi/radio_test/ @bama-nordic @sachinthegreen
544546
/samples/wifi/scan/ @D-Triveni @bama-nordic
545547
/samples/wifi/shell/ @nrfconnect/ncs-co-networking @krish2718 @sachinthegreen @rado17

doc/_utils/redirects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@
540540
("libraries/bluetooth_services/services/nus_client", "libraries/bluetooth/services/nus_client"),
541541
("libraries/bluetooth_services/services/rscs", "libraries/bluetooth/services/rscs"),
542542
("libraries/bluetooth_services/services/throughput", "libraries/bluetooth/services/throughput"),
543-
("libraries/bluetooth_services/services/wifi_prov", "libraries/bluetooth/services/wifi_prov"),
543+
("libraries/bluetooth_services/services/wifi_prov", "libraries/bluetooth/services/wifi_prov_ble"),
544+
("libraries/bluetooth/services/wifi_prov", "libraries/bluetooth/services/wifi_prov_ble"),
544545
("libraries/networking/nrf_cloud_agps", "libraries/networking/nrf_cloud_agnss"), # nRF Cloud A-GNSS
545546
("libraries/bootloader/index", "libraries/security/bootloader/index"), # Bootloader libraries (landing)
546547
("libraries/bootloader/bl_crypto", "libraries/security/bootloader/bl_crypto"), # Bootloader crypto
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
.. _wifi_prov_readme:
2+
.. _lib_wifi_prov_ble:
3+
4+
Wi-Fi provisioning Bluetooth LE transport
5+
#########################################
6+
7+
.. contents::
8+
:local:
9+
:depth: 2
10+
11+
This library implements the Bluetooth® GATT transport layer for the Wi-Fi® provisioning service.
12+
It provides the Bluetooth LE-specific implementation of the transport interface defined by the core Wi-Fi provisioning library.
13+
The Bluetooth LE transport layer is designed to work with the core Wi-Fi provisioning library located at :file:`subsys/net/lib/wifi_prov/` directory.
14+
15+
Overview
16+
********
17+
18+
The Bluetooth LE transport layer is responsible for:
19+
20+
* GATT service interface - Defines the GATT service and serves as the transport layer for the provisioning protocol.
21+
* Bluetooth LE-specific message handling - Implements the transport functions required by the core library.
22+
* Connection management - Manages Bluetooth LE connections and handles characteristic notifications and indications.
23+
24+
Configuration
25+
*************
26+
27+
To use this library, enable the :kconfig:option:`CONFIG_BT_WIFI_PROV` Kconfig option.
28+
29+
Service declaration
30+
*******************
31+
32+
The Wi-Fi Provisioning Service is instantiated as a primary service.
33+
Set the service UUID value as defined in the following table:
34+
35+
========================== ========================================
36+
Service name UUID
37+
Wi-Fi Provisioning Service ``14387800-130c-49e7-b877-2881c89cb258``
38+
========================== ========================================
39+
40+
Service characteristics
41+
=======================
42+
43+
The UUID value of characteristics are defined in the following table.
44+
45+
========================== ========================================
46+
Characteristic name UUID
47+
Information ``14387801-130c-49e7-b877-2881c89cb258``
48+
Operation Control Point ``14387802-130c-49e7-b877-2881c89cb258``
49+
Data Out ``14387803-130c-49e7-b877-2881c89cb258``
50+
========================== ========================================
51+
52+
The characteristic requirements of the Wi-Fi Provisioning Service are shown in the following table.
53+
54+
+-----------------+-------------+-------------+-------------+-------------+
55+
| Characteristic | Requirement | Mandatory | Optional | Security |
56+
| name | | properties | properties | permissions |
57+
+=================+=============+=============+=============+=============+
58+
| Information | Mandatory | Read | | No security |
59+
| | | | | required |
60+
+-----------------+-------------+-------------+-------------+-------------+
61+
| Operation | Mandatory | Indicate, | | Encryption |
62+
| Control | | Write | | required |
63+
| Point | | | | |
64+
+-----------------+-------------+-------------+-------------+-------------+
65+
| Operation | Mandatory | Read, Write | | Encryption |
66+
| Control | | | | required |
67+
| Point | | | | |
68+
| - Client | | | | |
69+
| Characteristic | | | | |
70+
| Configuration | | | | |
71+
| descriptor | | | | |
72+
+-----------------+-------------+-------------+-------------+-------------+
73+
| Data Out | Mandatory | Notify | | Encryption |
74+
| | | | | required |
75+
+-----------------+-------------+-------------+-------------+-------------+
76+
| Data Out | Mandatory | Read, Write | | Encryption |
77+
| - Client | | | | required |
78+
| Characteristic | | | | |
79+
| Configuration | | | | |
80+
| descriptor | | | | |
81+
+-----------------+-------------+-------------+-------------+-------------+
82+
83+
The purpose of each characteristic is as follows:
84+
85+
* ``Information`` - For client to get ``Info`` message from server.
86+
* ``Operation Control Point`` - For client to send ``Request`` message to server, and server to send ``Response`` message to client.
87+
* ``Data Out`` - For server to send ``Result`` message to the client.
88+
89+
Transport interface implementation
90+
**********************************
91+
92+
The Bluetooth LE transport layer implements the transport interface defined by the core Wi-Fi provisioning library:
93+
94+
* :c:func:`wifi_prov_send_rsp` - Sends Response messages through Bluetooth LE indications on the Operation Control Point characteristic.
95+
* :c:func:`wifi_prov_send_result` - Sends Result messages through Bluetooth LE notifications on the Data Out characteristic.
96+
97+
The transport layer also handles:
98+
99+
* Receiving request messages from the Operation Control Point characteristic.
100+
* Providing info messages through the Information characteristic.
101+
* Managing Bluetooth LE connection state and characteristic subscriptions.
102+
103+
Dependencies
104+
************
105+
106+
The Bluetooth LE transport layer depends on:
107+
108+
* :ref:`lib_wifi_prov_core`
109+
* Bluetooth stack (:kconfig:option:`CONFIG_BT`)
110+
* nanopb for protobuf message handling
111+
112+
113+
API documentation
114+
*****************
115+
116+
| Header file: :file:`include/net/wifi_prov_core/wifi_prov_core.h`
117+
| Source files: :file:`subsys/bluetooth/services/wifi_prov`
118+
119+
.. doxygengroup:: bt_wifi_prov

doc/nrf/libraries/bluetooth/services/wifi_prov.rst renamed to doc/nrf/libraries/networking/wifi_prov_core.rst

Lines changed: 31 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
.. _wifi_prov_readme:
1+
.. _lib_wifi_prov_core:
22

3-
Wi-Fi Provisioning Service
4-
##########################
3+
Wi-Fi Provisioning Core
4+
#######################
55

66
.. contents::
77
:local:
88
:depth: 2
99

10-
This library implements a Bluetooth® GATT service for Wi-Fi® provisioning.
11-
It is an implementation of the server side of the Wi-Fi provisioning protocol defined by Nordic Semiconductor.
12-
It is to be used with the :ref:`wifi_provisioning` sample.
13-
The Wi-Fi Provisioning Service forms a complete reference solution, together with the mobile application.
14-
For details, see the :ref:`wifi_provisioning` sample documentation.
10+
This library implements the core Wi-Fi® provisioning functionality that is transport-agnostic.
11+
It provides protocol implementation, message handling, and configuration management for Wi-Fi provisioning.
12+
The core library is designed to work with various transport layers (For example, Bluetooth® LE, Wi-Fi SoftAP) through a defined transport interface.
1513

1614
Overview
1715
********
1816

19-
The service is divided into three parts:
17+
The core library is responsible for:
2018

21-
* GATT service interface: Defines the GATT service and serves as the transport layer for the provisioning protocol.
22-
* Task and event handling component: Implements the provisioning protocol.
23-
* Configuration management component: Manages the provisioning data (in RAM and flash) accessed by multiple threads.
19+
* Protocol implementation - Implements the Wi-Fi provisioning protocol using Protocol Buffers.
20+
* Message handling - Processes Request messages and generates Response/Result messages.
21+
* Configuration management - Manages Wi-Fi configurations in RAM and flash.
22+
* Transport interface - Provides weak transport functions that can be overridden by transport layers.
2423

2524
.. _wifi_provisioning_protocol:
2625

@@ -109,7 +108,7 @@ The protocol defines four message types:
109108
=================== ======================= ======================== =======================================================================================
110109

111110
These definitions are available as :file:`.proto` files in the library path.
112-
See all definitions in the :file:`subsys/bluetooth/services/wifi_prov/proto/` folder.
111+
See all definitions in the :file:`subsys/net/lib/wifi_prov/proto/` folder.
113112

114113
Workflow
115114
========
@@ -163,76 +162,15 @@ In the ``Response`` message, the ``request_op_code`` is ``FORGET_CONFIG``, and t
163162

164163
When the connection state changes or an attempt fails, the target will set up a ``Result`` message, and the ``state`` field indicates the current state of the Wi-Fi, and the ``reason`` field indicates the failure reason.
165164

166-
Service declaration
165+
Transport interface
167166
*******************
168167

169-
The Wi-Fi Provisioning Service is instantiated as a primary service.
170-
Set the service UUID value as defined in the following table.
171-
172-
========================== ========================================
173-
Service name UUID
174-
Wi-Fi Provisioning Service ``14387800-130c-49e7-b877-2881c89cb258``
175-
========================== ========================================
176-
177-
Service characteristics
178-
=======================
179-
180-
The UUID value of characteristics are defined in the following table.
181-
182-
========================== ========================================
183-
Characteristic name UUID
184-
Information ``14387801-130c-49e7-b877-2881c89cb258``
185-
Operation Control Point ``14387802-130c-49e7-b877-2881c89cb258``
186-
Data Out ``14387803-130c-49e7-b877-2881c89cb258``
187-
========================== ========================================
188-
189-
The characteristic requirements of the Wi-Fi Provisioning Service are shown in the following table.
190-
191-
+-----------------+-------------+-------------+-------------+-------------+
192-
| Characteristic | Requirement | Mandatory | Optional | Security |
193-
| name | | properties | properties | permissions |
194-
+=================+=============+=============+=============+=============+
195-
| Information | Mandatory | Read | | No security |
196-
| | | | | required |
197-
+-----------------+-------------+-------------+-------------+-------------+
198-
| Operation | Mandatory | Indicate, | | Encryption |
199-
| Control | | Write | | required |
200-
| Point | | | | |
201-
+-----------------+-------------+-------------+-------------+-------------+
202-
| Operation | Mandatory | Read, Write | | Encryption |
203-
| Control | | | | required |
204-
| Point | | | | |
205-
| - Client | | | | |
206-
| Characteristic | | | | |
207-
| Configuration | | | | |
208-
| descriptor | | | | |
209-
+-----------------+-------------+-------------+-------------+-------------+
210-
| Data Out | Mandatory | Notify | | Encryption |
211-
| | | | | required |
212-
+-----------------+-------------+-------------+-------------+-------------+
213-
| Data Out | Mandatory | Read, Write | | Encryption |
214-
| - Client | | | | required |
215-
| Characteristic | | | | |
216-
| Configuration | | | | |
217-
| descriptor | | | | |
218-
+-----------------+-------------+-------------+-------------+-------------+
219-
220-
The purpose of each characteristic is as follows:
221-
222-
* ``Information``: For client to get ``Info`` message from server.
223-
* ``Operation Control Point``: For client to send ``Request`` message to server, and server to send ``Response`` message to client.
224-
* ``Data Out``: For server to send ``Result`` message to the client.
225-
226-
It takes the functions exposed by the task and event handling part of reading the ``Info`` message and receiving the ``Request`` message as the callbacks of corresponding characteristics.
227-
It provides functions for the task and event handling part to send ``Response`` and ``Result`` messages.
228-
229-
Task and event handling
230-
***********************
231-
232-
The service uses `nanopb`_ to instantiate the protocol buffers-based, platform-independent messages in the C language.
233-
234-
It exposes the functions of reading the ``Info`` message and receiving the ``Request`` message to transport layer.
235-
It uses the function of sending ``Response`` and ``Result`` messages provided by the transport layer to send these messages.
168+
The core library provides a transport-agnostic interface through weak functions that can be overridden by transport layers:
169+
170+
* :c:func:`wifi_prov_send_rsp` - Sends Response messages to the transport layer
171+
* :c:func:`wifi_prov_send_result` - Sends Result messages to the transport layer
172+
173+
Transport layers must implement these functions to handle the actual message transmission (for example, Bluetooth LE indications and notifications, USB transfers, UART transmissions).
236174

237175
Configuration management
238176
************************
@@ -243,10 +181,19 @@ The component has one slot in RAM to save the configurations.
243181

244182
You can save the configuration in flash or RAM during provisioning.
245183

184+
Dependencies
185+
************
186+
187+
The core library depends on:
188+
189+
* nanopb for protobuf message handling.
190+
* Wi-Fi credentials library for configuration management (:ref:`lib_wifi_credentials`).
191+
* Wi-Fi management interface for network operations (:ref:`wifi_mgmt`).
192+
246193
API documentation
247194
*****************
248195

249-
| Header file: :file:`include/bluetooth/services/wifi_provisioning.h`
250-
| Source files: :file:`subsys/bluetooth/services/wifi_prov`
196+
| Header file: :file:`include/net/wifi_prov_core/wifi_prov_core.h`
197+
| Source files: :file:`subsys/net/lib/wifi_prov_core`
251198
252-
.. doxygengroup:: bt_wifi_prov
199+
.. doxygengroup:: wifi_prov_core

include/bluetooth/services/wifi_provisioning.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,6 @@ extern "C" {
4444
#define BT_UUID_PROV_DATA_OUT \
4545
BT_UUID_DECLARE_128(BT_UUID_PROV_DATA_OUT_VAL)
4646

47-
/**
48-
* @def PROV_SVC_VER
49-
*
50-
* Firmware version.
51-
*/
52-
#define PROV_SVC_VER 0x01
53-
54-
/**
55-
* @brief Get provisioning state.
56-
*
57-
* @return true if device is provisioned, false otherwise.
58-
*/
59-
bool bt_wifi_prov_state_get(void);
60-
61-
/**
62-
* @brief Initialize the provisioning module.
63-
*
64-
* @return 0 if module initialized successfully, negative error code otherwise.
65-
*/
66-
int bt_wifi_prov_init(void);
6747

6848
#ifdef __cplusplus
6949
}

0 commit comments

Comments
 (0)