Skip to content

Commit 5d3edd5

Browse files
author
Jarkko Paso
committed
Mesh api: Added PHY mode and channel plan IDs
1 parent a9d7246 commit 5d3edd5

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,22 @@ class WisunInterface : public MeshInterfaceNanostack {
166166
* */
167167
mesh_error_t validate_network_regulatory_domain(uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);
168168

169+
/**
170+
* \brief Set Wi-SUN network PHY mode and channel plan IDs.
171+
*
172+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
173+
* If device is already connected to the Wi-SUN network then device will restart network discovery after
174+
* changing the phy_mode_id or channel_plan_id.
175+
*
176+
* Function overwrites parameters defined by Mbed OS configuration.
177+
*
178+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification. Use 0xff to leave parameter unchanged.
179+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification. Use 0xff to leave parameter unchanged.
180+
* \return MESH_ERROR_NONE on success.
181+
* \return MESH_ERROR_UNKNOWN in case of failure.
182+
* */
183+
mesh_error_t set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id);
184+
169185
/**
170186
* \brief Set Wi-SUN network size.
171187
*

features/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. Use 255 to use Nanostack default",
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.",
141149
"value": "255"

features/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,
@@ -306,6 +315,20 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
306315
return MESH_ERROR_NONE;
307316
}
308317

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

0 commit comments

Comments
 (0)