Mesh api: Added PHY mode and channel plan IDs

pull/14629/head
Jarkko Paso 2021-01-15 12:43:24 +02:00 committed by Arto Kinnunen
parent 376fda5bf5
commit 2f4b3426cb
3 changed files with 47 additions and 0 deletions

View File

@ -157,6 +157,22 @@ public:
* */
mesh_error_t validate_network_regulatory_domain(uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);
/**
* \brief Set Wi-SUN network PHY mode and channel plan IDs.
*
* 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 phy_mode_id or channel_plan_id.
*
* Function overwrites parameters defined by Mbed OS configuration.
*
* \param phy_mode_id Values defined in Wi-SUN PHY-specification. Use 0xff to leave parameter unchanged.
* \param channel_plan_id Values defined in Wi-SUN PHY-specification. Use 0xff to leave parameter unchanged.
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id);
/**
* \brief Set Wi-SUN network size.
*

View File

@ -136,6 +136,14 @@
"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.",
"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 as specified in the Wi-SUN FAN specification. Wi-SUN stack will select channel function if value 255 is used.",
"value": 255

View File

@ -98,6 +98,15 @@ 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_phy_mode_and_channel_plan_id(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 PHY mode and channel plan ID!");
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,
@ -308,6 +317,20 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
return MESH_ERROR_NONE;
}
mesh_error_t WisunInterface::set_network_phy_mode_and_channel_plan_id(uint8_t phy_mode_id, uint8_t channel_plan_id)
{
int status = ws_management_phy_mode_id_set(get_interface_id(), phy_mode_id);
if (status != 0) {
return MESH_ERROR_UNKNOWN;
}
status = ws_management_channel_plan_id_set(get_interface_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) {