Skip to content

Commit

Permalink
Merge pull request #14566 from artokin/phy_mode_and_channel_plan_5_15
Browse files Browse the repository at this point in the history
mbed-os-5.15: Mesh api: Added PHY mode, channel plan IDs and configuration functions
  • Loading branch information
0xc0170 authored Jun 24, 2021
2 parents e48b7b9 + 9e6ee26 commit ce84a0d
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
42 changes: 42 additions & 0 deletions features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,48 @@ class WisunInterface : public MeshInterfaceNanostack {
* */
mesh_error_t validate_network_regulatory_domain(uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);

/**
* \brief Set Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
*
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
* If device is already connected to the Wi-SUN network then device will restart network discovery after
* changing the regulatory_domain, phy_mode_id or channel_plan_id.
*
* \param regulatory_domain Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
* \param phy_mode_id Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
* \param channel_plan_id Values defined in Wi-SUN PHY-specification. Use 0 to leave parameter unchanged or 0xff to use default value.
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t set_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id);

/**
* \brief Get Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
*
* Function reads regulatory_domain, phy_mode_id and channel_plan_id from mbed-mesh-api.
*
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
* \param phy_mode_id Values defined in Wi-SUN PHY-specification.
* \param channel_plan_id Values defined in Wi-SUN PHY-specification.
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t get_network_domain_configuration(uint8_t *regulatory_domain, uint8_t *phy_mode_id, uint8_t *channel_plan_id);

/**
* \brief Validate Wi-SUN network regulatory domain, PHY mode ID and channel plan ID.
*
* Function validates regulatory_domain, phy_mode_id and channel_plan_id. Function can be used to test that values that will
* be used on set function are valid.
*
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
* \param phy_mode_id Values defined in Wi-SUN PHY-specification.
* \param channel_plan_id Values defined in Wi-SUN PHY-specification.
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t validate_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id);

/**
* \brief Set Wi-SUN network size.
*
Expand Down
8 changes: 8 additions & 0 deletions features/nanostack/mbed-mesh-api/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@
"help": "Operating mode. Use 255 to use Nanostack default",
"value": "255"
},
"wisun-phy-mode-id": {
"help": "PHY mode ID as specified in the Wi-SUN PHY Specification. With default value 255, parameter is not used.",
"value": "255"
},
"wisun-channel-plan-id": {
"help": "Channel plan ID as specified in the Wi-SUN PHY Specification. With default value 255, parameter is not used.",
"value": "255"
},
"wisun-uc-channel-function": {
"help": "Unicast channel function.",
"value": "255"
Expand Down
40 changes: 40 additions & 0 deletions features/nanostack/mbed-mesh-api/source/WisunInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ nsapi_error_t WisunInterface::configure()
}
#endif

#if (MBED_CONF_MBED_MESH_API_WISUN_PHY_MODE_ID != 255) || (MBED_CONF_MBED_MESH_API_WISUN_CHANNEL_PLAN_ID != 255)
status = set_network_domain_configuration(MBED_CONF_MBED_MESH_API_WISUN_REGULATORY_DOMAIN,
MBED_CONF_MBED_MESH_API_WISUN_PHY_MODE_ID,
MBED_CONF_MBED_MESH_API_WISUN_CHANNEL_PLAN_ID);
if (status != MESH_ERROR_NONE) {
tr_error("Failed to set domain configuration!");
return NSAPI_ERROR_PARAMETER;
}
#endif

#if (MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION != 255)
status = set_unicast_channel_function(static_cast<mesh_channel_function_t>(MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION),
MBED_CONF_MBED_MESH_API_WISUN_UC_FIXED_CHANNEL,
Expand Down Expand Up @@ -306,6 +316,36 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
return MESH_ERROR_NONE;
}

mesh_error_t WisunInterface::set_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id)
{
int status = ws_management_domain_configuration_set(get_interface_id(), regulatory_domain, phy_mode_id, channel_plan_id);
if (status != 0) {
return MESH_ERROR_UNKNOWN;
}

return MESH_ERROR_NONE;
}

mesh_error_t WisunInterface::get_network_domain_configuration(uint8_t *regulatory_domain, uint8_t *phy_mode_id, uint8_t *channel_plan_id)
{
int status = ws_management_domain_configuration_get(get_interface_id(), regulatory_domain, phy_mode_id, channel_plan_id);
if (status != 0) {
return MESH_ERROR_UNKNOWN;
}

return MESH_ERROR_NONE;
}

mesh_error_t WisunInterface::validate_network_domain_configuration(uint8_t regulatory_domain, uint8_t phy_mode_id, uint8_t channel_plan_id)
{
int status = ws_management_domain_configuration_validate(get_interface_id(), regulatory_domain, phy_mode_id, channel_plan_id);
if (status != 0) {
return MESH_ERROR_UNKNOWN;
}

return MESH_ERROR_NONE;
}

mesh_error_t WisunInterface::set_network_size(uint8_t network_size)
{
if (network_size == 0xff) {
Expand Down

0 comments on commit ce84a0d

Please sign in to comment.