运行时配置
运行时配置 API 允许应用程序直接更改其运行时配置,而无需遍历配置模型。
Bluetooth Mesh 节点通常应由具有配置客户端型号的中央网络 配置客户端 配置。 每个网格节点实例化 配置服务器 可以与之通信以更改节点配置的配置服务器模型。 在某些情况下,网格节点不能依赖配置客户端来检测或确定本地约束,例如电池电量低或拓扑变化。对于这些场景, 可以使用此 API 在本地更改配置。
备注
配置节点之前的运行时配置更改将不会存储在 持久性储存.
API 参考
- group bt_mesh_cfg
Runtime Configuration.
Defines
-
BT_MESH_KR_NORMAL
-
BT_MESH_KR_PHASE_1
-
BT_MESH_KR_PHASE_2
-
BT_MESH_KR_PHASE_3
-
BT_MESH_RELAY_DISABLED
-
BT_MESH_RELAY_ENABLED
-
BT_MESH_RELAY_NOT_SUPPORTED
-
BT_MESH_BEACON_DISABLED
-
BT_MESH_BEACON_ENABLED
-
BT_MESH_PRIV_BEACON_DISABLED
-
BT_MESH_PRIV_BEACON_ENABLED
-
BT_MESH_GATT_PROXY_DISABLED
-
BT_MESH_GATT_PROXY_ENABLED
-
BT_MESH_GATT_PROXY_NOT_SUPPORTED
-
BT_MESH_PRIV_GATT_PROXY_DISABLED
-
BT_MESH_PRIV_GATT_PROXY_ENABLED
-
BT_MESH_PRIV_GATT_PROXY_NOT_SUPPORTED
-
BT_MESH_FRIEND_DISABLED
-
BT_MESH_FRIEND_ENABLED
-
BT_MESH_FRIEND_NOT_SUPPORTED
-
BT_MESH_NODE_IDENTITY_STOPPED
-
BT_MESH_NODE_IDENTITY_RUNNING
-
BT_MESH_NODE_IDENTITY_NOT_SUPPORTED
Enums
Functions
-
void bt_mesh_beacon_set(bool beacon)
Enable or disable sending of the Secure Network Beacon.
- 参数:
beacon – New Secure Network Beacon state.
-
bool bt_mesh_beacon_enabled(void)
Get the current Secure Network Beacon state.
- 返回:
Whether the Secure Network Beacon feature is enabled.
-
int bt_mesh_priv_beacon_set(enum bt_mesh_feat_state priv_beacon)
Enable or disable sending of the Mesh Private beacon.
Support for the Private beacon state must be enabled with
CONFIG_BT_MESH_PRIV_BEACONS
.- 参数:
priv_beacon – New Mesh Private beacon state. Must be one of BT_MESH_FEATURE_ENABLED and BT_MESH_FEATURE_DISABLED.
- 返回值:
0 – Successfully changed the Mesh Private beacon feature state.
-ENOTSUP – The Mesh Private beacon feature is not supported.
-EINVAL – Invalid parameter.
-EALREADY – Already in the given state.
-
enum bt_mesh_feat_state bt_mesh_priv_beacon_get(void)
Get the current Mesh Private beacon state.
- 返回:
The Mesh Private beacon feature state.
-
void bt_mesh_priv_beacon_update_interval_set(uint8_t interval)
Set the current Mesh Private beacon update interval.
The Mesh Private beacon’s randomization value is updated regularly to maintain the node’s privacy. The update interval controls how often the beacon is updated, in 10 second increments.
- 参数:
interval – Private beacon update interval in 10 second steps, or 0 to update on every beacon transmission.
-
uint8_t bt_mesh_priv_beacon_update_interval_get(void)
Get the current Mesh Private beacon update interval.
The Mesh Private beacon’s randomization value is updated regularly to maintain the node’s privacy. The update interval controls how often the beacon is updated, in 10 second increments.
- 返回:
The Private beacon update interval in 10 second steps, or 0 if the beacon is updated every time it’s transmitted.
-
int bt_mesh_default_ttl_set(uint8_t default_ttl)
Set the default TTL value.
The default TTL value is used when no explicit TTL value is set. Models will use the default TTL value when bt_mesh_msg_ctx::send_ttl is BT_MESH_TTL_DEFAULT.
- 参数:
default_ttl – The new default TTL value. Valid values are 0x00 and 0x02 to BT_MESH_TTL_MAX.
- 返回值:
0 – Successfully set the default TTL value.
-EINVAL – Invalid TTL value.
-
uint8_t bt_mesh_default_ttl_get(void)
Get the current default TTL value.
- 返回:
The current default TTL value.
-
int bt_mesh_od_priv_proxy_get(void)
Get the current Mesh On-Demand Private Proxy state.
- 返回值:
0 – or positive value represents On-Demand Private Proxy feature state
-ENOTSUP – The On-Demand Private Proxy feature is not supported.
-
int bt_mesh_od_priv_proxy_set(uint8_t on_demand_proxy)
Set state of Mesh On-Demand Private Proxy.
Support for the On-Demand Private Proxy state must be enabled with
BT_MESH_OD_PRIV_PROXY_SRV
.- 参数:
on_demand_proxy – New Mesh On-Demand Private Proxy state. Value of 0x00 means that advertising with Private Network Identity cannot be enabled on demand. Values in range 0x01 - 0xFF set interval of this advertising after valid Solicitation PDU is received or client disconnects.
- 返回值:
0 – Successfully changed the Mesh On-Demand Private Proxy feature state.
-ENOTSUP – The On-Demand Private Proxy feature is not supported.
-EINVAL – Invalid parameter.
-EALREADY – Already in the given state.
-
void bt_mesh_net_transmit_set(uint8_t xmit)
Set the Network Transmit parameters.
The Network Transmit parameters determine the parameters local messages are transmitted with.
- 参数:
xmit – New Network Transmit parameters. Use BT_MESH_TRANSMIT for encoding.
-
uint8_t bt_mesh_net_transmit_get(void)
Get the current Network Transmit parameters.
The BT_MESH_TRANSMIT_COUNT and BT_MESH_TRANSMIT_INT macros can be used to decode the Network Transmit parameters.
- 返回:
The current Network Transmit parameters.
-
int bt_mesh_relay_set(enum bt_mesh_feat_state relay, uint8_t xmit)
Configure the Relay feature.
Enable or disable the Relay feature, and configure the parameters to transmit relayed messages with.
Support for the Relay feature must be enabled through the
CONFIG_BT_MESH_RELAY
configuration option.- 参数:
relay – New Relay feature state. Must be one of BT_MESH_FEATURE_ENABLED and BT_MESH_FEATURE_DISABLED.
xmit – New Relay retransmit parameters. Use BT_MESH_TRANSMIT for encoding.
- 返回值:
0 – Successfully changed the Relay configuration.
-ENOTSUP – The Relay feature is not supported.
-EINVAL – Invalid parameter.
-EALREADY – Already using the given parameters.
-
enum bt_mesh_feat_state bt_mesh_relay_get(void)
Get the current Relay feature state.
- 返回:
The Relay feature state.
-
uint8_t bt_mesh_relay_retransmit_get(void)
Get the current Relay Retransmit parameters.
The BT_MESH_TRANSMIT_COUNT and BT_MESH_TRANSMIT_INT macros can be used to decode the Relay Retransmit parameters.
- 返回:
The current Relay Retransmit parameters, or 0 if relay is not supported.
-
int bt_mesh_gatt_proxy_set(enum bt_mesh_feat_state gatt_proxy)
Enable or disable the GATT Proxy feature.
Support for the GATT Proxy feature must be enabled through the
CONFIG_BT_MESH_GATT_PROXY
configuration option.备注
The GATT Proxy feature only controls a Proxy node’s ability to relay messages to the mesh network. A node that supports GATT Proxy will still advertise Connectable Proxy beacons, even if the feature is disabled. The Proxy feature can only be fully disabled through compile time configuration.
- 参数:
gatt_proxy – New GATT Proxy state. Must be one of BT_MESH_FEATURE_ENABLED and BT_MESH_FEATURE_DISABLED.
- 返回值:
0 – Successfully changed the GATT Proxy feature state.
-ENOTSUP – The GATT Proxy feature is not supported.
-EINVAL – Invalid parameter.
-EALREADY – Already in the given state.
-
enum bt_mesh_feat_state bt_mesh_gatt_proxy_get(void)
Get the current GATT Proxy state.
- 返回:
The GATT Proxy feature state.
-
int bt_mesh_priv_gatt_proxy_set(enum bt_mesh_feat_state priv_gatt_proxy)
Enable or disable the Private GATT Proxy feature.
Support for the Private GATT Proxy feature must be enabled through the CONFIG_BT_MESH_PRIV_BEACONS and CONFIG_BT_MESH_GATT_PROXY configuration options.
- 参数:
priv_gatt_proxy – New Private GATT Proxy state. Must be one of BT_MESH_FEATURE_ENABLED and BT_MESH_FEATURE_DISABLED.
- 返回值:
0 – Successfully changed the Private GATT Proxy feature state.
-ENOTSUP – The Private GATT Proxy feature is not supported.
-EINVAL – Invalid parameter.
-EALREADY – Already in the given state.
-
enum bt_mesh_feat_state bt_mesh_priv_gatt_proxy_get(void)
Get the current Private GATT Proxy state.
- 返回:
The Private GATT Proxy feature state.
-
int bt_mesh_friend_set(enum bt_mesh_feat_state friendship)
Enable or disable the Friend feature.
Any active friendships will be terminated immediately if the Friend feature is disabled.
Support for the Friend feature must be enabled through the
CONFIG_BT_MESH_FRIEND
configuration option.- 参数:
friendship – New Friend feature state. Must be one of BT_MESH_FEATURE_ENABLED and BT_MESH_FEATURE_DISABLED.
- 返回值:
0 – Successfully changed the Friend feature state.
-ENOTSUP – The Friend feature is not supported.
-EINVAL – Invalid parameter.
-EALREADY – Already in the given state.
-
enum bt_mesh_feat_state bt_mesh_friend_get(void)
Get the current Friend state.
- 返回:
The Friend feature state.
-
BT_MESH_KR_NORMAL