Skip to content

Commit ce84a0d

Browse files
authored
Merge pull request #14566 from artokin/phy_mode_and_channel_plan_5_15
mbed-os-5.15: Mesh api: Added PHY mode, channel plan IDs and configuration functions
2 parents e48b7b9 + 9e6ee26 commit ce84a0d

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,48 @@ class WisunInterface : public MeshInterfaceNanostack {
196196
* */
197197
mesh_error_t validate_network_regulatory_domain(uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);
198198

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

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: 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,
@@ -306,6 +316,36 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
306316
return MESH_ERROR_NONE;
307317
}
308318

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

0 commit comments

Comments
 (0)