Skip to content

Commit d2bf23e

Browse files
krish2718rlubos
authored andcommitted
samples: wifi: provisioning: Add new sample with internal transport
This is handy to test the core part of provisioning without worrying about BLE or SAP, this doesn't need any external dependencies, but still uses protbuf as the configuration mechanism, relies on Wi-Fi provisioning core library. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 67ceddb commit d2bf23e

File tree

9 files changed

+1728
-0
lines changed

9 files changed

+1728
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(wifi_prov_internal)
11+
12+
# WiFi Provisioning Configuration
13+
if(CONFIG_WIFI_PROV_CONFIG)
14+
# Generate sample WiFi configuration
15+
set(PROTO_DIR ${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/wifi_prov_core/proto)
16+
set(WIFI_CONFIG_SCRIPT ${PROTO_DIR}/generate_wifi_prov_config.py)
17+
set(WIFI_CONFIG_BIN ${CMAKE_CURRENT_BINARY_DIR}/wifi_config.bin)
18+
set(WIFI_CONFIG_INC ${CMAKE_CURRENT_BINARY_DIR}/wifi_config.inc)
19+
20+
# Note: nanopb generation is already handled by wifi_prov_core library
21+
# which is linked to the app target below
22+
23+
# Build the command with conditional certificate directory
24+
set(WIFI_CONFIG_CMD ${Python3_EXECUTABLE} ${WIFI_CONFIG_SCRIPT}
25+
"${CONFIG_WIFI_PROV_SSID}" "${CONFIG_WIFI_PROV_BSSID}"
26+
-w "${CONFIG_WIFI_PROV_PASSPHRASE}"
27+
-a ${CONFIG_WIFI_PROV_AUTH_MODE} -c ${CONFIG_WIFI_PROV_CHANNEL} -b ${CONFIG_WIFI_PROV_BAND}
28+
-o ${WIFI_CONFIG_BIN})
29+
30+
# Add certificate directory if specified
31+
if(CONFIG_WIFI_PROV_CERT_DIR)
32+
list(APPEND WIFI_CONFIG_CMD -d "${CONFIG_WIFI_PROV_CERT_DIR}")
33+
endif()
34+
35+
# Generate the binary file
36+
add_custom_command(
37+
OUTPUT ${WIFI_CONFIG_BIN}
38+
COMMAND ${WIFI_CONFIG_CMD}
39+
DEPENDS ${WIFI_CONFIG_SCRIPT}
40+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
41+
COMMENT "Generating sample WiFi configuration"
42+
)
43+
44+
# Use Zephyr's generate_inc_file_for_target to create the .inc file
45+
generate_inc_file_for_target(app ${WIFI_CONFIG_BIN} ${WIFI_CONFIG_INC})
46+
47+
# Include generated header directory
48+
target_include_directories(app PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
49+
50+
# Include WiFi provisioning library headers and link against it
51+
target_include_directories(app PRIVATE ${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/wifi_prov_core)
52+
target_include_directories(app PRIVATE $<TARGET_PROPERTY:wifi_prov_core,BINARY_DIR>)
53+
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/modules/lib/nanopb)
54+
target_link_libraries(app PRIVATE wifi_prov_core)
55+
endif() # CONFIG_WIFI_PROV_CONFIG
56+
57+
target_sources(app PRIVATE
58+
src/main.c
59+
src/prov.c
60+
src/wifi_prov_transport_stub.c
61+
)
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
menuconfig WIFI_PROV_CONFIG
8+
bool "WiFi provisioning configuration"
9+
default y
10+
help
11+
This option enables WiFi provisioning configuration.
12+
13+
config WIFI_PROV_SSID
14+
string "WiFi SSID for provisioning"
15+
default "SampleWiFi"
16+
help
17+
SSID for the WiFi network to be provisioned.
18+
19+
config WIFI_PROV_BSSID
20+
string "WiFi BSSID for provisioning"
21+
default "00:11:22:33:44:55"
22+
help
23+
BSSID (MAC address) for the WiFi network to be provisioned.
24+
25+
config WIFI_PROV_PASSPHRASE
26+
string "WiFi passphrase for provisioning"
27+
default "samplepassword"
28+
help
29+
Passphrase for the WiFi network to be provisioned.
30+
31+
config WIFI_PROV_AUTH_MODE
32+
int "WiFi authentication mode"
33+
default 4
34+
range 0 23
35+
help
36+
Authentication mode for the WiFi network.
37+
0: Open, 1: WEP, 2: WPA_PSK, 3: WPA2_PSK, etc.
38+
39+
config WIFI_PROV_CHANNEL
40+
int "WiFi channel"
41+
default 0
42+
range 0 233
43+
help
44+
Channel for the WiFi network (2.4GHz band).
45+
46+
config WIFI_PROV_BAND
47+
int "WiFi band"
48+
default 0
49+
range 0 2
50+
help
51+
Band for the WiFi network.
52+
1: 2.4GHz, 2: 5GHz
53+
54+
config WIFI_PROV_CERT_DIR
55+
string "Certificate directory path"
56+
default ""
57+
help
58+
Path to directory containing certificates for enterprise WiFi networks.
59+
Leave empty for personal WiFi networks.
60+
Certificates should be in PEM format.
61+
62+
config WIFI_PROV_PRIVATE_KEY_PASSWD
63+
string "Primary private key password"
64+
default ""
65+
help
66+
Password for the primary private key file.
67+
Leave empty to use EAP password.
68+
69+
config WIFI_PROV_PRIVATE_KEY_PASSWD2
70+
string "Secondary private key password"
71+
default ""
72+
help
73+
Password for the secondary private key file.
74+
Leave empty to use EAP password.
75+
76+
config WIFI_PROV_IDENTITY
77+
string "EAP identity"
78+
79+
help
80+
EAP identity for enterprise WiFi networks.
81+
82+
config WIFI_PROV_PASSWORD
83+
string "EAP password"
84+
default "user_password"
85+
help
86+
EAP password for enterprise WiFi networks.
87+
88+
config WIFI_PROV_VOLATILE_MEMORY
89+
bool "Use volatile memory"
90+
default n
91+
help
92+
Store WiFi configuration in volatile memory.
93+
If disabled, configuration is stored persistently.
94+
95+
config WIFI_PROV_SCAN_BAND
96+
int "WiFi scan band"
97+
default 0
98+
range 0 2
99+
help
100+
Band for WiFi scanning.
101+
0: Any band, 1: 2.4GHz, 2: 5GHz
102+
103+
config WIFI_PROV_SCAN_PASSIVE
104+
bool "Passive scan mode"
105+
default n
106+
help
107+
Enable passive scanning mode.
108+
If disabled, active scanning is used.
109+
110+
config WIFI_PROV_SCAN_PERIOD_MS
111+
int "Scan period in milliseconds"
112+
default 0
113+
range 0 60000
114+
help
115+
Period between WiFi scans in milliseconds.
116+
0 means no periodic scanning.
117+
118+
config WIFI_PROV_SCAN_GROUP_CHANNELS
119+
int "Scan group channels"
120+
default 0
121+
range 0 255
122+
help
123+
Group channels for WiFi scanning.
124+
0 means no grouping.
125+
126+
config WIFI_PROV_MAX_DATA_SIZE
127+
int "Maximum Protobuf Data Size"
128+
default 16384
129+
range 1024 16384
130+
help
131+
Maximum size for protobuf data in bytes.
132+
133+
config WIFI_PROV_MAX_BASE64_SIZE
134+
int "Maximum Base64 Input Size"
135+
default 32768
136+
range 2048 32768
137+
help
138+
Maximum size for base64 input string in bytes.
139+
140+
module = WIFI_PROV_INTERNAL
141+
module-dep = LOG
142+
module-str = Log level for sample
143+
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
144+
145+
source "Kconfig.zephyr"

0 commit comments

Comments
 (0)