Skip to content

Commit 2f4b342

Browse files
Jarkko PasoArto Kinnunen
authored andcommitted
Mesh api: Added PHY mode and channel plan IDs
1 parent 376fda5 commit 2f4b342

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

connectivity/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,22 @@ class WisunInterface final : public MeshInterfaceNanostack {
157157
* */
158158
mesh_error_t validate_network_regulatory_domain(uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);
159159

160+
/**
161+
* \brief Set Wi-SUN network PHY mode and channel plan IDs.
162+
*
163+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
164+
* If device is already connected to the Wi-SUN network then device will restart network discovery after
165+
* changing the phy_mode_id or channel_plan_id.
166+
*
167+
* Function overwrites parameters defined by Mbed OS configuration.
168+
*
169+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification. Use 0xff to leave parameter unchanged.
170+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification. Use 0xff to leave parameter unchanged.
171+
* \return MESH_ERROR_NONE on success.
172+
* \return MESH_ERROR_UNKNOWN in case of failure.
173+
* */
174+
mesh_error_t set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id);
175+
160176
/**
161177
* \brief Set Wi-SUN network size.
162178
*

connectivity/nanostack/mbed-mesh-api/mbed_lib.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@
136136
"help": "Operating mode as specified in the Wi-SUN PHY Specification. Wi-SUN stack uses operating-mode suitable for EU-region if value 255 is used.",
137137
"value": "255"
138138
},
139+
"wisun-phy-mode-id": {
140+
"help": "PHY mode ID as specified in the Wi-SUN PHY Specification. With default value 255, parameter is not used.",
141+
"value": "255"
142+
},
143+
"wisun-channel-plan-id": {
144+
"help": "Channel plan ID as specified in the Wi-SUN PHY Specification. With default value 255, parameter is not used.",
145+
"value": "255"
146+
},
139147
"wisun-uc-channel-function": {
140148
"help": "Unicast channel function as specified in the Wi-SUN FAN specification. Wi-SUN stack will select channel function if value 255 is used.",
141149
"value": 255

connectivity/nanostack/mbed-mesh-api/source/WisunInterface.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ nsapi_error_t WisunInterface::configure()
9898
}
9999
#endif
100100

101+
#if (MBED_CONF_MBED_MESH_API_WISUN_PHY_MODE_ID != 255) || (MBED_CONF_MBED_MESH_API_WISUN_CHANNEL_PLAN_ID != 255)
102+
status = set_network_phy_mode_and_channel_plan_id(MBED_CONF_MBED_MESH_API_WISUN_PHY_MODE_ID,
103+
MBED_CONF_MBED_MESH_API_WISUN_CHANNEL_PLAN_ID);
104+
if (status != MESH_ERROR_NONE) {
105+
tr_error("Failed to set PHY mode and channel plan ID!");
106+
return NSAPI_ERROR_PARAMETER;
107+
}
108+
#endif
109+
101110
#if (MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION != 255)
102111
status = set_unicast_channel_function(static_cast<mesh_channel_function_t>(MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION),
103112
MBED_CONF_MBED_MESH_API_WISUN_UC_FIXED_CHANNEL,
@@ -308,6 +317,20 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
308317
return MESH_ERROR_NONE;
309318
}
310319

320+
mesh_error_t WisunInterface::set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id)
321+
{
322+
int status = ws_management_phy_mode_id_set(get_interface_id(), phy_mode_id);
323+
if (status != 0) {
324+
return MESH_ERROR_UNKNOWN;
325+
}
326+
status = ws_management_channel_plan_id_set(get_interface_id(), channel_plan_id);
327+
if (status != 0) {
328+
return MESH_ERROR_UNKNOWN;
329+
}
330+
331+
return MESH_ERROR_NONE;
332+
}
333+
311334
mesh_error_t WisunInterface::set_network_size(uint8_t network_size)
312335
{
313336
if (network_size == 0xff) {

0 commit comments

Comments
 (0)