File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
connectivity/nanostack/mbed-mesh-api Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,22 @@ class WisunInterface final : public MeshInterfaceNanostack {
157157 * */
158158 mesh_error_t validate_network_regulatory_domain (uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);
159159
160+ /* *
161+ * \brief Set Wi-SUN network PHY mode and channel plan IDs.
162+ *
163+ * Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
164+ * 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.
166+ *
167+ * Function overwrites parameters defined by Mbed OS configuration.
168+ *
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.
171+ * \return MESH_ERROR_NONE on success.
172+ * \return MESH_ERROR_UNKNOWN in case of failure.
173+ * */
174+ mesh_error_t set_network_phy_mode_and_channel_plan_id (uint8_t phy_mode_id, uint8_t channel_plan_id);
175+
160176 /* *
161177 * \brief Set Wi-SUN network size.
162178 *
Original file line number Diff line number Diff line change 136136 "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." ,
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 as specified in the Wi-SUN FAN specification. Wi-SUN stack will select channel function if value 255 is used." ,
141149 "value" : 255
Original file line number Diff line number Diff line change @@ -98,6 +98,15 @@ 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_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);
104+ if (status != MESH_ERROR_NONE) {
105+ tr_error (" Failed to set PHY mode and channel plan ID!" );
106+ return NSAPI_ERROR_PARAMETER;
107+ }
108+ #endif
109+
101110#if (MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION != 255)
102111 status = set_unicast_channel_function (static_cast <mesh_channel_function_t >(MBED_CONF_MBED_MESH_API_WISUN_UC_CHANNEL_FUNCTION),
103112 MBED_CONF_MBED_MESH_API_WISUN_UC_FIXED_CHANNEL,
@@ -308,6 +317,20 @@ mesh_error_t WisunInterface::validate_network_regulatory_domain(uint8_t regulato
308317 return MESH_ERROR_NONE;
309318}
310319
320+ mesh_error_t WisunInterface::set_network_phy_mode_and_channel_plan_id (uint8_t phy_mode_id, uint8_t channel_plan_id)
321+ {
322+ int status = ws_management_phy_mode_id_set (get_interface_id (), phy_mode_id);
323+ if (status != 0 ) {
324+ return MESH_ERROR_UNKNOWN;
325+ }
326+ status = ws_management_channel_plan_id_set (get_interface_id (), channel_plan_id);
327+ if (status != 0 ) {
328+ return MESH_ERROR_UNKNOWN;
329+ }
330+
331+ return MESH_ERROR_NONE;
332+ }
333+
311334mesh_error_t WisunInterface::set_network_size (uint8_t network_size)
312335{
313336 if (network_size == 0xff ) {
You can’t perform that action at this time.
0 commit comments