Skip to content

Commit

Permalink
CFG: API for PHY mode id and channel plan id get & validate (ARMmbed#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso authored Feb 8, 2021
1 parent 2832fe8 commit 7400c8b
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Changes
* Added throttling of number of simultaneous EAPOL authentications based on Border Router TX queue size
* Get and validate API for PHY mode ID and Channel plan ID.

### Bugfix
*
Expand Down
56 changes: 55 additions & 1 deletion nanostack/ws_management_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,40 @@ int ws_management_phy_mode_id_set(
int8_t interface_id,
uint8_t phy_mode_id);

/**
* Get PHY mode ID of Wi-SUN stack.
*
* \param interface_id Network interface ID.
* \param phy_mode_id PHY mode ID.
*
* \return 0, OK.
* \return <0 Fail.
*/
int ws_management_phy_mode_id_get(
int8_t interface_id,
uint8_t *phy_mode_id);

/**
* Validate PHY mode ID of Wi-SUN stack.
*
* \param interface_id Network interface ID.
* \param phy_mode_id PHY mode ID.
*
* \return 0, OK.
* \return <0 Fail.
*/
int ws_management_phy_mode_id_validate(
int8_t interface_id,
uint8_t phy_mode_id);

/**
* Configure Channel plan ID of Wi-SUN stack as defined by Wi-SUN FAN 1.1.
*
* Change the default channel configuration for Wi-SUN.
*
* Supported values: TBD
* Supported values:
* North America (NA): (1), (2), (5)
* Brazil (BZ): (1), (2), (5)
*
* if value of 255 is given then previous value is used.
*
Expand All @@ -263,6 +291,32 @@ int ws_management_channel_plan_id_set(
int8_t interface_id,
uint8_t channel_plan_id);

/**
* Get Channel plan ID of Wi-SUN stack.
*
* \param interface_id Network interface ID.
* \param channel_plan_id Channel plan ID.
*
* \return 0, OK.
* \return <0 Fail.
*/
int ws_management_channel_plan_id_get(
int8_t interface_id,
uint8_t *channel_plan_id);

/**
* Validate Channel plan ID of Wi-SUN stack.
*
* \param interface_id Network interface ID.
* \param channel_plan_id Channel plan ID.
*
* \return 0, OK.
* \return <0 Fail.
*/
int ws_management_channel_plan_id_validate(
int8_t interface_id,
uint8_t channel_plan_id);

/**
* Configure regulatory domain of Wi-SUN stack.
*
Expand Down
36 changes: 36 additions & 0 deletions source/6LoWPAN/ws/ws_empty_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ int ws_management_phy_mode_id_set(
return -1;
}

int ws_management_phy_mode_id_get(
int8_t interface_id,
uint8_t *phy_mode_id)
{
(void)interface_id;
(void)phy_mode_id;
return -1;
}

int ws_management_phy_mode_id_validate(
int8_t interface_id,
uint8_t phy_mode_id)
{
(void)interface_id;
(void)phy_mode_id;
return -1;
}

int ws_management_channel_plan_id_set(
int8_t interface_id,
uint8_t channel_plan_id)
Expand All @@ -86,6 +104,24 @@ int ws_management_channel_plan_id_set(
return -1;
}

int ws_management_channel_plan_id_get(
int8_t interface_id,
uint8_t *channel_plan_id)
{
(void)interface_id;
(void)channel_plan_id;
return -1;
}

int ws_management_channel_plan_id_validate(
int8_t interface_id,
uint8_t channel_plan_id)
{
(void)interface_id;
(void)channel_plan_id;
return -1;
}

int ws_management_regulatory_domain_set(
int8_t interface_id,
uint8_t regulatory_domain,
Expand Down
94 changes: 94 additions & 0 deletions source/6LoWPAN/ws/ws_management_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,53 @@ int ws_management_phy_mode_id_set(
return 0;
}

int ws_management_phy_mode_id_get(
int8_t interface_id,
uint8_t *phy_mode_id)
{
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (interface_id >= 0 && (!cur || !ws_info(cur))) {
return -1;
}
if (!phy_mode_id) {
return -2;
}

ws_phy_cfg_t cfg;
if (ws_cfg_phy_get(&cfg, NULL) < 0) {
return -3;
}

*phy_mode_id = cfg.phy_mode_id;

return 0;
}

int ws_management_phy_mode_id_validate(
int8_t interface_id,
uint8_t phy_mode_id)
{
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (interface_id >= 0 && (!cur || !ws_info(cur))) {
return -1;
}

ws_phy_cfg_t cfg;
if (ws_cfg_phy_get(&cfg, NULL) < 0) {
return -3;
}

cfg.phy_mode_id = phy_mode_id;

if (ws_cfg_phy_validate(NULL, &cfg) < 0) {
return -4;
}

return 0;
}

int ws_management_channel_plan_id_set(
int8_t interface_id,
uint8_t channel_plan_id)
Expand Down Expand Up @@ -224,6 +271,53 @@ int ws_management_channel_plan_id_set(
return 0;
}

int ws_management_channel_plan_id_get(
int8_t interface_id,
uint8_t *channel_plan_id)
{
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (interface_id >= 0 && (!cur || !ws_info(cur))) {
return -1;
}
if (!channel_plan_id) {
return -2;
}

ws_phy_cfg_t cfg;
if (ws_cfg_phy_get(&cfg, NULL) < 0) {
return -3;
}

*channel_plan_id = cfg.channel_plan_id;

return 0;
}

int ws_management_channel_plan_id_validate(
int8_t interface_id,
uint8_t channel_plan_id)
{
protocol_interface_info_entry_t *cur;
cur = protocol_stack_interface_info_get_by_id(interface_id);
if (interface_id >= 0 && (!cur || !ws_info(cur))) {
return -1;
}

ws_phy_cfg_t cfg;
if (ws_cfg_phy_get(&cfg, NULL) < 0) {
return -3;
}

cfg.channel_plan_id = channel_plan_id;

if (ws_cfg_phy_validate(NULL, &cfg) < 0) {
return -4;
}

return 0;
}

int ws_management_regulatory_domain_set(
int8_t interface_id,
uint8_t regulatory_domain,
Expand Down

0 comments on commit 7400c8b

Please sign in to comment.