Skip to content

Commit 37e42fb

Browse files
Jarkko PasoArto Kinnunen
authored andcommitted
Mesh API: Functions to set/get/validate FAN v1.1 domain configuration.
1 parent 6c7789e commit 37e42fb

File tree

2 files changed

+55
-12
lines changed

2 files changed

+55
-12
lines changed

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

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

160160
/**
161-
* \brief Set Wi-SUN network PHY mode and channel plan IDs.
161+
* \brief Set Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
162162
*
163163
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
164164
* 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.
165+
* changing the regulatory_domain, phy_mode_id or channel_plan_id.
166166
*
167-
* Function overwrites parameters defined by Mbed OS configuration.
167+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
168+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
169+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
170+
* \return MESH_ERROR_NONE on success.
171+
* \return MESH_ERROR_UNKNOWN in case of failure.
172+
* */
173+
mesh_error_t set_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id);
174+
175+
/**
176+
* \brief Get Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
177+
*
178+
* Function reads regulatory_domain, phy_mode_id and channel_plan_id from mbed-mesh-api.
168179
*
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.
180+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
181+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification.
182+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification.
183+
* \return MESH_ERROR_NONE on success.
184+
* \return MESH_ERROR_UNKNOWN in case of failure.
185+
* */
186+
mesh_error_t get_network_domain_configuration(uint8_t *regulatory_domain, uint8_t *phy_mode_id, uint8_t *channel_plan_id);
187+
188+
/**
189+
* \brief Validate Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
190+
*
191+
* Function validates regulatory_domain, phy_mode_id and channel_plan_id. Function can be used to test that values that will
192+
* be used on set function are valid.
193+
*
194+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
195+
* \param phy_mode_id Values defined in Wi-SUN PHY-specification.
196+
* \param channel_plan_id Values defined in Wi-SUN PHY-specification.
171197
* \return MESH_ERROR_NONE on success.
172198
* \return MESH_ERROR_UNKNOWN in case of failure.
173199
* */
174-
mesh_error_t set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id);
200+
mesh_error_t validate_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id);
175201

176202
/**
177203
* \brief Set Wi-SUN network size.

connectivity/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
@@ -317,13 +318,29 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
317318
return MESH_ERROR_NONE;
318319
}
319320

320-
mesh_error_t WisunInterface::set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id)
321+
mesh_error_t WisunInterface::set_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id)
321322
{
322-
int status = ws_management_phy_mode_id_set(get_interface_id(), phy_mode_id);
323+
int status = ws_management_domain_configuration_set(get_interface_id(), regulatory_domain, phy_mode_id, channel_plan_id);
323324
if (status != 0) {
324325
return MESH_ERROR_UNKNOWN;
325326
}
326-
status = ws_management_channel_plan_id_set(get_interface_id(), channel_plan_id);
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);
327344
if (status != 0) {
328345
return MESH_ERROR_UNKNOWN;
329346
}

0 commit comments

Comments
 (0)