Skip to content

Commit c0eb6df

Browse files
debdeep-armArto Kinnunen
authored andcommitted
Added APIs for Device min sense and CCA threshold table.
-Added get, set and validate API for device min sens. -Added get API for CCA threshold table.
1 parent cf4f584 commit c0eb6df

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

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

Lines changed: 57 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,16 @@ 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+
* \return pointer to ws_cca_threshold_table_t structure on success.
551+
* \return NULL in case of failure.
552+
* */
553+
const ws_cca_threshold_table_t *cca_threshold_table_get(void);
554+
498555
protected:
499556
Nanostack::WisunInterface *get_interface() const;
500557
virtual nsapi_error_t do_initialize();

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,42 @@ 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+
ws_stack_info_t stack_info = {0};
490+
491+
if (ws_stack_info_get(get_interface_id(), &stack_info)) {
492+
return MESH_ERROR_UNKNOWN;
493+
}
494+
495+
*device_min_sens = stack_info.device_min_sens;
496+
497+
return MESH_ERROR_NONE;
498+
}
499+
500+
mesh_error_t WisunInterface::validate_device_min_sens(uint8_t device_min_sens)
501+
{
502+
if (device_min_sens == 0xFF) {
503+
return MESH_ERROR_UNKNOWN;
504+
}
505+
506+
return MESH_ERROR_NONE;
507+
}
508+
473509
mesh_error_t WisunInterface::set_own_certificate(uint8_t *cert, uint16_t cert_len, uint8_t *cert_key, uint16_t cert_key_len)
474510
{
475511
mesh_error_t ret_val = MESH_ERROR_NONE;
@@ -627,13 +663,21 @@ mesh_error_t WisunInterface::stack_info_get(ws_stack_state_t *stack_info_ptr)
627663
stack_info_ptr->pan_id = stack_info.pan_id;
628664
stack_info_ptr->rsl_in = stack_info.rsl_in;
629665
stack_info_ptr->rsl_out = stack_info.rsl_out;
666+
stack_info_ptr->device_min_sens = stack_info.device_min_sens;
630667
memcpy(stack_info_ptr->parent_addr, stack_info.parent, 16);
631668
memcpy(stack_info_ptr->global_addr, global_address, 16);
632669
memcpy(stack_info_ptr->link_local_addr, link_local_address, 16);
633670

634671
return MESH_ERROR_NONE;
635672
}
636673

674+
const ws_cca_threshold_table_t *WisunInterface::cca_threshold_table_get(void)
675+
{
676+
const cca_threshold_table_s *cca_threshold_table = arm_nwk_get_cca_threshold_table(get_interface_id());
677+
678+
return (const ws_cca_threshold_table_t *)cca_threshold_table;
679+
}
680+
637681
#define WISUN 0x2345
638682
#if MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == WISUN && DEVICE_802_15_4_PHY
639683
MBED_WEAK MeshInterface *MeshInterface::get_target_default_instance()

0 commit comments

Comments
 (0)