Repository navigation
Expand file tree
/
Copy pathSlNetConfig.cpp
More file actions
120 lines (104 loc) · 5.82 KB
/
Copy pathSlNetConfig.cpp
File metadata and controls
120 lines (104 loc) · 5.82 KB
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
/*
*
* Copyright (c) 2026 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "SlNetConfig.h"
#include "ble_config.h"
#include <lib/support/CodeUtils.h>
extern "C" {
#include "sl_si91x_types.h"
#include "sl_wifi.h"
}
namespace {
sl_wifi_device_configuration_t GetDefaultDeviceConfiguration(void)
{
return { .boot_option = LOAD_NWP_FW,
.mac_address = nullptr,
.band = SL_SI91X_WIFI_BAND_2_4GHZ,
.region_code = REGION_CODE_BITMAP,
.boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE,
.coex_mode = SL_WIFI_SYSTEM_WLAN_ONLY_MODE,
.feature_bit_map =
SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION | SL_SI91X_FEAT_WPS_DISABLE,
.tcp_ip_feature_bit_map = SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID,
.custom_feature_bit_map = SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID,
.ext_custom_feature_bit_map = SL_SI91X_EXT_FEAT_LOW_POWER_MODE | SL_SI91X_CLK |
SL_SI91X_RAM_LEVEL_NWP_BASIC_MCU_ADV | FRONT_END_SWITCH_CTRL | SL_SI91X_EXT_FEAT_IEEE_80211W,
.bt_feature_bit_map = 0,
.ext_tcp_ip_feature_bit_map = SL_SI91X_CONFIG_FEAT_EXTENTION_VALID,
.ble_feature_bit_map = 0,
.ble_ext_feature_bit_map = 0,
.config_feature_bit_map = SL_SI91X_ENABLE_ENHANCED_MAX_PSP } };
}
void SLApplyWiFiDeviceConfiguration(sl_wifi_device_configuration_t * configuration)
{
VerifyOrReturn(configuration != nullptr);
#ifndef SLI_SI91X_MCU_INTERFACE
configuration->boot_config.feature_bit_map |= SL_SI91X_FEAT_DEV_TO_HOST_ULP_GPIO_1 | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE;
configuration->boot_config.config_feature_bit_map |= SL_SI91X_FEAT_SLEEP_GPIO_SEL_BITMAP;
#endif // SLI_SI91X_MCU_INTERFACE
#ifdef RSI_PROCESS_MAX_RX_DATA
configuration->boot_config.ext_tcp_ip_feature_bit_map |= SL_SI91X_EXT_TCP_MAX_RECV_LENGTH;
#endif // RSI_PROCESS_MAX_RX_DATA
#if !(defined(SL_MATTER_ENABLE_DUAL_STACK) && SL_MATTER_ENABLE_DUAL_STACK)
// Disable TCP/IP bypass for single stack (LwIP)
configuration->boot_config.tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_BYPASS;
#endif // !(SL_MATTER_ENABLE_DUAL_STACK)
#if defined(SL_MATTER_ENABLE_DUAL_STACK) && SL_MATTER_ENABLE_DUAL_STACK
// Enable dual mode support for dual stack
configuration->boot_config.tcp_ip_feature_bit_map |= SL_SI91X_EXT_TCP_IP_DUAL_MODE_ENABLE;
// Enable DHCPv4 client, DNS client, and ICMP support for dual stack (required for IPv4)
configuration->boot_config.tcp_ip_feature_bit_map |=
(SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | SL_SI91X_TCP_IP_FEAT_ICMP);
// Enable IPv6 and DHCPv6 client support for dual stack
configuration->boot_config.tcp_ip_feature_bit_map |= (SL_SI91X_TCP_IP_FEAT_IPV6 | SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT);
// Enable basic SSL and SSL memory cloud support with more RAM for certificate storage
configuration->boot_config.ext_tcp_ip_feature_bit_map |= (SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_EXT_TCP_IP_FEAT_SSL_MEMORY_CLOUD);
#endif // SL_MATTER_ENABLE_DUAL_STACK
#if defined(SL_MATTER_NEUTRAL_LESS_SWITCH_WIFI) && SL_MATTER_NEUTRAL_LESS_SWITCH_WIFI
// Neutral Less Switch doesn't work with 11ax, only 11n is supported
configuration->boot_config.feature_bit_map |= SL_SI91X_FEAT_DISABLE_11AX_SUPPORT;
#endif // defined(SL_MATTER_NEUTRAL_LESS_SWITCH_WIFI) && SL_MATTER_NEUTRAL_LESS_SWITCH_WIFI
}
#if defined(SLI_SI91X_ENABLE_BLE) && SLI_SI91X_ENABLE_BLE
void SLApplyBLEDeviceConfiguration(sl_wifi_device_configuration_t * configuration)
{
VerifyOrReturn(configuration != nullptr);
configuration->boot_config.coex_mode = SL_SI91X_WLAN_BLE_MODE;
configuration->boot_config.ext_custom_feature_bit_map |= SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE;
configuration->boot_config.bt_feature_bit_map = RSI_BT_FEATURE_BITMAP;
configuration->boot_config.ble_feature_bit_map =
((SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) | SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) |
SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) | SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC)) |
SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENTION_VALID | SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) |
SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) | SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE
#if RSI_BLE_GATT_ASYNC_ENABLE
| SL_SI91X_BLE_GATT_ASYNC_ENABLE
#endif // RSI_BLE_GATT_ASYNC_ENABLE
);
configuration->boot_config.ble_ext_feature_bit_map =
(SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) | SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES));
}
#endif // SLI_SI91X_ENABLE_BLE
} // namespace
sl_wifi_device_configuration_t SLNetGetDeviceConfig(void)
{
sl_wifi_device_configuration_t deviceConfiguration = GetDefaultDeviceConfiguration();
SLApplyWiFiDeviceConfiguration(&deviceConfiguration);
#if defined(SLI_SI91X_ENABLE_BLE) && SLI_SI91X_ENABLE_BLE
SLApplyBLEDeviceConfiguration(&deviceConfiguration);
#endif // SLI_SI91X_ENABLE_BLE
return deviceConfiguration;
}