Skip to content

Commit ef0b31a

Browse files
authored
Merge pull request ARMmbed#14629 from artokin/phy_mode_and_channel_plan_master
Mesh api: Added PHY mode, channel plan IDs and configuration functions
2 parents 8b1cd98 + 37e42fb commit ef0b31a

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,48 @@ class WisunInterface final : public MeshInterfaceNanostack {
188188
* */
189189
mesh_error_t validate_network_regulatory_domain(uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);
190190

191+
/**
192+
* \brief Set Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
193+
*
194+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
195+
* If device is already connected to the Wi-SUN network then device will restart network discovery after
196+
* changing the regulatory_domain, phy_mode_id or channel_plan_id.
197+
*
198+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
199+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
200+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
201+
* \return MESH_ERROR_NONE on success.
202+
* \return MESH_ERROR_UNKNOWN in case of failure.
203+
* */
204+
mesh_error_t set_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id);
205+
206+
/**
207+
* \brief Get Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
208+
*
209+
* Function reads regulatory_domain, phy_mode_id and channel_plan_id from mbed-mesh-api.
210+
*
211+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
212+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification.
213+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification.
214+
* \return MESH_ERROR_NONE on success.
215+
* \return MESH_ERROR_UNKNOWN in case of failure.
216+
* */
217+
mesh_error_t get_network_domain_configuration(uint8_t *regulatory_domain, uint8_t *phy_mode_id, uint8_t *channel_plan_id);
218+
219+
/**
220+
* \brief Validate Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
221+
*
222+
* Function validates regulatory_domain, phy_mode_id and channel_plan_id. Function can be used to test that values that will
223+
* be used on set function are valid.
224+
*
225+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
226+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification.
227+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification.
228+
* \return MESH_ERROR_NONE on success.
229+
* \return MESH_ERROR_UNKNOWN in case of failure.
230+
* */
231+
mesh_error_t validate_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id);
232+
191233
/**
192234
* \brief Set Wi-SUN network size.
193235
*

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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ 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_domain_configuration(MBED_CONF_MBED_MESH_API_WISUN_REGULATORY_DOMAIN,
103+
MBED_CONF_MBED_MESH_API_WISUN_PHY_MODE_ID,
104+
MBED_CONF_MBED_MESH_API_WISUN_CHANNEL_PLAN_ID);
105+
if (status != MESH_ERROR_NONE) {
106+
tr_error("Failed to set domain configuration!");
107+
return NSAPI_ERROR_PARAMETER;
108+
}
109+
#endif
110+
101111
#if (MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION != 255)
102112
status = set_unicast_channel_function(static_cast<mesh_channel_function_t>(MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION),
103113
MBED_CONF_MBED_MESH_API_WISUN_UC_FIXED_CHANNEL,
@@ -308,6 +318,36 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
308318
return MESH_ERROR_NONE;
309319
}
310320

321+
mesh_error_t WisunInterface::set_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id)
322+
{
323+
int status = ws_management_domain_configuration_set(get_interface_id(), regulatory_domain, phy_mode_id, channel_plan_id);
324+
if (status != 0) {
325+
return MESH_ERROR_UNKNOWN;
326+
}
327+
328+
return MESH_ERROR_NONE;
329+
}
330+
331+
mesh_error_t WisunInterface::get_network_domain_configuration(uint8_t *regulatory_domain, uint8_t *phy_mode_id, uint8_t *channel_plan_id)
332+
{
333+
int status = ws_management_domain_configuration_get(get_interface_id(), regulatory_domain, phy_mode_id, channel_plan_id);
334+
if (status != 0) {
335+
return MESH_ERROR_UNKNOWN;
336+
}
337+
338+
return MESH_ERROR_NONE;
339+
}
340+
341+
mesh_error_t WisunInterface::validate_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id)
342+
{
343+
int status = ws_management_domain_configuration_validate(get_interface_id(), regulatory_domain, phy_mode_id, channel_plan_id);
344+
if (status != 0) {
345+
return MESH_ERROR_UNKNOWN;
346+
}
347+
348+
return MESH_ERROR_NONE;
349+
}
350+
311351
mesh_error_t WisunInterface::set_network_size(uint8_t network_size)
312352
{
313353
if (network_size == 0xff) {

0 commit comments

Comments
 (0)