Skip to content

Commit 2cf237e

Browse files
authored
Merge pull request #13758 from artokin/add-min-sens-wisun-param-mbed-os-5.15
mbed-os-5.15: Add APIs for Device min sense and CCA threshold table
2 parents 480586d + 46b141e commit 2cf237e

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,20 @@ typedef struct ws_stack_state {
5353
uint8_t join_state;
5454
/** Network PAN ID */
5555
uint16_t pan_id;
56+
/** Device RF minimum sensitivity configuration. lowest level of radio signal strength packet heard. Range of -174 (0) to +80 (254) dBm*/
57+
uint8_t device_min_sens;
5658
} ws_stack_state_t;
5759

60+
/**
61+
* \brief Struct ws_cca_threshold_table Wi-SUN CCA threshold table information.
62+
*/
63+
typedef struct ws_cca_threshold_table {
64+
/** Number of channels */
65+
uint8_t number_of_channels;
66+
/** CCA threshold table */
67+
const int8_t *cca_threshold_table;
68+
} ws_cca_threshold_table_t;
69+
5870
/** Wi-SUN mesh network interface class
5971
*
6072
* Configure Nanostack to use Wi-SUN protocol.
@@ -373,6 +385,41 @@ class WisunInterface : public MeshInterfaceNanostack {
373385
* */
374386
mesh_error_t validate_timing_parameters(uint16_t disc_trickle_imin, uint16_t disc_trickle_imax, uint8_t disc_trickle_k, uint16_t pan_timeout);
375387

388+
/**
389+
* \brief Set Wi-SUN device minimum sensitivity
390+
*
391+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
392+
* If device is already connected to the Wi-SUN network then settings take effect right away.
393+
*
394+
* \param device_min_sens Device minimum sensitivity. Range 0(-174 dB) to 254(+80 dB).
395+
* \return MESH_ERROR_NONE on success.
396+
* \return MESH_ERROR_UNKNOWN in case of failure.
397+
* */
398+
mesh_error_t set_device_min_sens(uint8_t device_min_sens);
399+
400+
/**
401+
* \brief Get Wi-SUN device minimum sensitivity.
402+
*
403+
* Function reads device minimum sensitivity from mbed-mesh-api.
404+
*
405+
* \param device_min_sens Device minimum sensitivity. Range 0-254.
406+
* \return MESH_ERROR_NONE on success.
407+
* \return MESH_ERROR_UNKNOWN in case of failure.
408+
* */
409+
mesh_error_t get_device_min_sens(uint8_t *device_min_sens);
410+
411+
/**
412+
* \brief Validates Device minimum sensitivity.
413+
*
414+
* Function validates device minimum sensitivity. Function can be used to test that values that will be used on set
415+
* function are valid.
416+
*
417+
* \param device_min_sens Device minimum sensitivity. Range 0-254.
418+
* \return MESH_ERROR_NONE on success.
419+
* \return MESH_ERROR_UNKNOWN in case of failure.
420+
* */
421+
mesh_error_t validate_device_min_sens(uint8_t device_min_sens);
422+
376423
/**
377424
* \brief Set own certificate and private key reference to the Wi-SUN network.
378425
*
@@ -495,6 +542,18 @@ class WisunInterface : public MeshInterfaceNanostack {
495542
* */
496543
mesh_error_t stack_info_get(ws_stack_state_t *stack_info_ptr);
497544

545+
/**
546+
* \brief Get Wi-SUN CCA threshold table information.
547+
*
548+
* Function reads CCA threshold table from nanostack.
549+
*
550+
** \param ws_cca_threshold_table_t Structure given to stack where information will be stored
551+
**
552+
* \return MESH_ERROR_NONE on success.
553+
* \return MESH_ERROR_UNKNOWN in case of failure.
554+
* */
555+
mesh_error_t cca_threshold_table_get(ws_cca_threshold_table_t *table);
556+
498557
protected:
499558
Nanostack::WisunInterface *get_interface() const;
500559
virtual nsapi_error_t do_initialize();

features/nanostack/mbed-mesh-api/source/WisunInterface.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,37 @@ mesh_error_t WisunInterface::validate_timing_parameters(uint16_t disc_trickle_im
470470
return MESH_ERROR_NONE;
471471
}
472472

473+
mesh_error_t WisunInterface::set_device_min_sens(uint8_t device_min_sens)
474+
{
475+
int status = ws_device_min_sens_set(get_interface_id(), device_min_sens);
476+
if (status != 0) {
477+
return MESH_ERROR_UNKNOWN;
478+
}
479+
480+
return MESH_ERROR_NONE;
481+
}
482+
483+
mesh_error_t WisunInterface::get_device_min_sens(uint8_t *device_min_sens)
484+
{
485+
if (device_min_sens == NULL) {
486+
return MESH_ERROR_PARAM;
487+
}
488+
489+
/* To-Do :: Update this when device_min_sense get API is available */
490+
*device_min_sens = 0;
491+
492+
return MESH_ERROR_NONE;
493+
}
494+
495+
mesh_error_t WisunInterface::validate_device_min_sens(uint8_t device_min_sens)
496+
{
497+
if (device_min_sens == 0xFF) {
498+
return MESH_ERROR_UNKNOWN;
499+
}
500+
501+
return MESH_ERROR_NONE;
502+
}
503+
473504
mesh_error_t WisunInterface::set_own_certificate(uint8_t *cert, uint16_t cert_len, uint8_t *cert_key, uint16_t cert_key_len)
474505
{
475506
mesh_error_t ret_val = MESH_ERROR_NONE;
@@ -627,13 +658,32 @@ mesh_error_t WisunInterface::stack_info_get(ws_stack_state_t *stack_info_ptr)
627658
stack_info_ptr->pan_id = stack_info.pan_id;
628659
stack_info_ptr->rsl_in = stack_info.rsl_in;
629660
stack_info_ptr->rsl_out = stack_info.rsl_out;
661+
stack_info_ptr->device_min_sens = stack_info.device_min_sens;
630662
memcpy(stack_info_ptr->parent_addr, stack_info.parent, 16);
631663
memcpy(stack_info_ptr->global_addr, global_address, 16);
632664
memcpy(stack_info_ptr->link_local_addr, link_local_address, 16);
633665

634666
return MESH_ERROR_NONE;
635667
}
636668

669+
mesh_error_t WisunInterface::cca_threshold_table_get(ws_cca_threshold_table_t *table)
670+
{
671+
if (table == NULL) {
672+
return MESH_ERROR_PARAM;
673+
}
674+
675+
const cca_threshold_table_s *cca_table = arm_nwk_get_cca_threshold_table(get_interface_id());
676+
677+
if (cca_table != NULL) {
678+
table->number_of_channels = cca_table->number_of_channels;
679+
table->cca_threshold_table = cca_table->cca_threshold_table;
680+
} else {
681+
return MESH_ERROR_UNKNOWN;
682+
}
683+
684+
return MESH_ERROR_NONE;
685+
}
686+
637687
#define WISUN 0x2345
638688
#if MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == WISUN && DEVICE_802_15_4_PHY
639689
MBED_WEAK MeshInterface *MeshInterface::get_target_default_instance()

0 commit comments

Comments
 (0)