Skip to content

Commit 9e6ee26

Browse files
Jarkko PasoArto Kinnunen
authored andcommitted
Mesh API: Functions to set/get/validate FAN v1.1 domain configuration.
1 parent 54963fa commit 9e6ee26

File tree

2 files changed

+55
-12
lines changed

2 files changed

+55
-12
lines changed

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

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,46 @@ class WisunInterface : public MeshInterfaceNanostack {
167167
mesh_error_t validate_network_regulatory_domain(uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);
168168

169169
/**
170-
* \brief Set Wi-SUN network PHY mode and channel plan IDs.
170+
* \brief Set Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
171171
*
172172
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
173173
* 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.
174+
* changing the regulatory_domain, phy_mode_id or channel_plan_id.
175175
*
176-
* Function overwrites parameters defined by Mbed OS configuration.
176+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
177+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
178+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
179+
* \return MESH_ERROR_NONE on success.
180+
* \return MESH_ERROR_UNKNOWN in case of failure.
181+
* */
182+
mesh_error_t set_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id);
183+
184+
/**
185+
* \brief Get Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
186+
*
187+
* Function reads regulatory_domain, phy_mode_id and channel_plan_id from mbed-mesh-api.
177188
*
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.
189+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
190+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification.
191+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification.
192+
* \return MESH_ERROR_NONE on success.
193+
* \return MESH_ERROR_UNKNOWN in case of failure.
194+
* */
195+
mesh_error_t get_network_domain_configuration(uint8_t *regulatory_domain, uint8_t *phy_mode_id, uint8_t *channel_plan_id);
196+
197+
/**
198+
* \brief Validate Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
199+
*
200+
* Function validates regulatory_domain, phy_mode_id and channel_plan_id. Function can be used to test that values that will
201+
* be used on set function are valid.
202+
*
203+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
204+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification.
205+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification.
180206
* \return MESH_ERROR_NONE on success.
181207
* \return MESH_ERROR_UNKNOWN in case of failure.
182208
* */
183-
mesh_error_t set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id);
209+
mesh_error_t validate_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id);
184210

185211
/**
186212
* \brief Set Wi-SUN network size.

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ nsapi_error_t WisunInterface::configure()
9999
#endif
100100

101101
#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);
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);
104105
if (status != MESH_ERROR_NONE) {
105-
tr_error("Failed to set PHY mode and channel plan ID!");
106+
tr_error("Failed to set domain configuration!");
106107
return NSAPI_ERROR_PARAMETER;
107108
}
108109
#endif
@@ -315,13 +316,29 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
315316
return MESH_ERROR_NONE;
316317
}
317318

318-
mesh_error_t WisunInterface::set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id)
319+
mesh_error_t WisunInterface::set_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id)
319320
{
320-
int status = ws_management_phy_mode_id_set(get_interface_id(), phy_mode_id);
321+
int status = ws_management_domain_configuration_set(get_interface_id(), regulatory_domain, phy_mode_id, channel_plan_id);
321322
if (status != 0) {
322323
return MESH_ERROR_UNKNOWN;
323324
}
324-
status = ws_management_channel_plan_id_set(get_interface_id(), channel_plan_id);
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);
325342
if (status != 0) {
326343
return MESH_ERROR_UNKNOWN;
327344
}

0 commit comments

Comments
 (0)