Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples: Extract DTM api in sample #11789

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

dchat-nordic
Copy link
Contributor

Extract DTM radio part from transport interface in DTM sample.

Jira: NCSDK-22497

@github-actions github-actions bot added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Jul 12, 2023
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Jul 12, 2023

Test specification

CI/Jenkins/NRF

  • Integration Platforms

CI/Jenkins/integration

Test Module File based changes Manually selected West overwrite
test-fw-nrfconnect-ble X
test-fw-nrfconnect-ble_samples X

Detailed information of selected test modules

Note: This message is automatically posted and updated by the CI

@dchat-nordic dchat-nordic force-pushed the hci_dtm branch 2 times, most recently from 026a2e9 to 7d5265a Compare July 13, 2023 07:13
@dchat-nordic dchat-nordic marked this pull request as draft July 17, 2023 11:58
@dchat-nordic dchat-nordic marked this pull request as ready for review July 19, 2023 11:24
@github-actions github-actions bot added doc-required PR must not be merged without tech writer approval. and removed changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Jul 19, 2023
@NordicBuilder
Copy link
Contributor

You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds.

Note: This comment is automatically posted by the Documentation Publishing GitHub Action.

@dchat-nordic dchat-nordic force-pushed the hci_dtm branch 2 times, most recently from c4beb97 to 28a52dd Compare July 20, 2023 07:38
@@ -228,6 +228,10 @@ Bluetooth samples

* Support for the nRF52840 DK.

* Updated:

* Extracted the DTM radio API from transport layer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Extracted the DTM radio API from transport layer.
* Extracted the DTM radio API from the transport layer.

Comment on lines 74 to 89
* Initialization function:
* ``dtm_init``
* Setup functions:
* ``dtm_setup_reset``
* ``dtm_setup_set_phy``
* ``dtm_setup_set_modulation``
* ``dtm_setup_read_features``
* ``dtm_setup_read_max_supported_value``
* ``dtm_setup_set_cte_mode``
* ``dtm_setup_set_cte_slot``
* ``dtm_setup_set_antenna_params``
* ``dtm_setup_set_transmit_power``
* Test functions:
* ``dtm_test_receive``
* ``dtm_test_transmit``
* ``dtm_test_end``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Initialization function:
* ``dtm_init``
* Setup functions:
* ``dtm_setup_reset``
* ``dtm_setup_set_phy``
* ``dtm_setup_set_modulation``
* ``dtm_setup_read_features``
* ``dtm_setup_read_max_supported_value``
* ``dtm_setup_set_cte_mode``
* ``dtm_setup_set_cte_slot``
* ``dtm_setup_set_antenna_params``
* ``dtm_setup_set_transmit_power``
* Test functions:
* ``dtm_test_receive``
* ``dtm_test_transmit``
* ``dtm_test_end``
* The ``dtm_init`` initialization function
* Setup functions:
* ``dtm_setup_reset``
* ``dtm_setup_set_phy``
* ``dtm_setup_set_modulation``
* ``dtm_setup_read_features``
* ``dtm_setup_read_max_supported_value``
* ``dtm_setup_set_cte_mode``
* ``dtm_setup_set_cte_slot``
* ``dtm_setup_set_antenna_params``
* ``dtm_setup_set_transmit_power``
* Test functions:
* ``dtm_test_receive``
* ``dtm_test_transmit``
* ``dtm_test_end``

Copy link
Contributor

@annakielar annakielar Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add missing empty lines before and after sub-lists, and remember to use :c:func:.


In the ``dtm_cmd_put`` interface, DTM commands are accepted in the 2-byte format.
Parameters such as ``CMD code``, ``Frequency``, ``Length``, or ``Packet Type`` are encoded within this command.
The setup functions implement all the DTM setup required by the Bluetooth Low Energy standard.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The setup functions implement all the DTM setup required by the Bluetooth Low Energy standard.
The setup functions implement the DTM setup required by the Bluetooth Low Energy standard.

@@ -69,20 +69,32 @@ For this reason, a coaxial connection between the DUT and the Lower Tester is em
DTM module interface
====================

The DTM function ``dtm_cmd_put`` implements the four commands defined by the Bluetooth Low Energy standard:
The DTM module interface can be divided into three parts:
Copy link
Contributor

@annakielar annakielar Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The DTM module interface can be divided into three parts:
The DTM module interface can be divided into the following three parts:

Comment on lines 95 to 97
The sample is required to parse the encoding format of the command (ie. UART, HCI, etc.) and use the DTM module interface accordingly.

The sample is also required to interpret the return values of DTM module interface functions and respond to the tester in the correct format.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The sample is required to parse the encoding format of the command (ie. UART, HCI, etc.) and use the DTM module interface accordingly.
The sample is also required to interpret the return values of DTM module interface functions and respond to the tester in the correct format.
The sample is required to perform the following tasks:
* To parse the relevant encoding format - UART or HCI - for the command, and to use the DTM module interface accordingly.
* To interpret the return values of interface functions used in the DTM module, and to respond to the tester in the correct format.

Please check if rephrased correctly.

samples/bluetooth/direct_test_mode/CMakeLists.txt Outdated Show resolved Hide resolved
samples/bluetooth/direct_test_mode/README.rst Outdated Show resolved Hide resolved
samples/bluetooth/direct_test_mode/src/dtm.h Show resolved Hide resolved
samples/bluetooth/direct_test_mode/src/dtm.h Outdated Show resolved Hide resolved
samples/bluetooth/direct_test_mode/src/dtm.h Outdated Show resolved Hide resolved
samples/bluetooth/direct_test_mode/src/dtm.c Outdated Show resolved Hide resolved
samples/bluetooth/direct_test_mode/src/dtm.h Outdated Show resolved Hide resolved
samples/bluetooth/direct_test_mode/src/dtm.c Outdated Show resolved Hide resolved
samples/bluetooth/direct_test_mode/src/dtm.c Outdated Show resolved Hide resolved
dtm_inst.event = LE_TEST_STATUS_EVENT_ERROR;
return DTM_ERROR_ILLEGAL_CONFIGURATION;
if (count > dtm_hw_radio_antenna_number_get()) {
return -EINVAL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked this with HCI cammand specification against different return codes?

Copy link
Contributor Author

@dchat-nordic dchat-nordic Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will change this instance to another code, but the transport part of the sample is responsible for translation of error codes. So the return codes of dtm.c don't need to be exact same as Bluetooth specification, but just need to be precise to translate later in transport module.

* ``RECEIVER_TEST``
* ``TRANSMITTER_TEST``
* ``TEST_END``
* The :c:func:`dtm_init`` Initialization function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The :c:func:`dtm_init`` Initialization function
* The :c:func:`dtm_init` initialization function

*
* This function polls for Two Wire UART command.
*
* @return 16 bit command.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return 16 bit command.
* @return 16-bit command.


The :file:`main.c` file may be replaced with other interface implementations, such as an HCI interface, USB, or another interface required by the Upper Tester.
The :file:`mai.c` file may be extended with other interface implementations, such as an HCI interface, USB, or another interface required by the Upper Tester.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The :file:`mai.c` file may be extended with other interface implementations, such as an HCI interface, USB, or another interface required by the Upper Tester.
The :file:`main.c` file may be extended with other interface implementations, such as an HCI interface, USB, or another interface required by the Upper Tester.

@@ -1,101 +1,33 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
* Copyright (c) 2023 Nordic Semiconductor ASA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary - typically this header contains the original year of creation of the file.

Copy link
Contributor

@grochu grochu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a few comments, nothing major.

/* Set front-end module (FEM) gain value. */
FEM_GAIN_SET = 4,

/* Set radio ramp-up time. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be FEM ramp-up time that this command sets.


#define DTM_UART DT_CHOSEN(ncs_dtm_uart)

/* The DTM maximum wait time for the UART command second byte. */
Copy link
Contributor

@grochu grochu Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you specify the unit? I know it is probably moved directly from the original code, but it would be nice to make it precise.


case LE_PHY_LE_CODED_S2_MIN_RANGE ... LE_PHY_LE_CODED_S2_MAX_RANGE:
return dtm_setup_set_phy(DTM_PHY_CODED_S2);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the default case (per coding style). Also in other places in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return -EINVAL;
}

return -EINVAL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be no needed. Maybe __ASSERT_NO)MSG(false) instead of since it should go outside switch case.
The same in other cases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary returns.


The :file:`main.c` file may be replaced with other interface implementations, such as an HCI interface, USB, or another interface required by the Upper Tester.
The :file:`main.c` file may be extended with other interface implementations, such as an HCI interface, USB, or another interface required by the Upper Tester.
The extension should be done by adding appropriate interface implementation in the `transport` directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The extension should be done by adding appropriate interface implementation in the `transport` directory.
The extension should be done by adding an appropriate interface implementation in the :file:`transport` directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dchat-nordic, could you please also fix a TYPO in line 300 in this file ("Anritsu MT885" -> "Anritsu MT8852")? Just spotted it when reading the docs and don't want to open a separate PR for that :)

samples/bluetooth/direct_test_mode/Kconfig Show resolved Hide resolved
.data_len_ext = true,
.phy_2m = true,
.stable_mod = false,
#if (RADIO_MODE_MODE_Ble_LR125Kbit || RADIO_MODE_MODE_Ble_LR500Kbit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if (RADIO_MODE_MODE_Ble_LR125Kbit || RADIO_MODE_MODE_Ble_LR500Kbit)
#if (defined(RADIO_MODE_MODE_Ble_LR125Kbit || defined(RADIO_MODE_MODE_Ble_LR500Kbit))

Some radio mode values could be 0 then the #if will evaluate to false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe even better:

Suggested change
#if (RADIO_MODE_MODE_Ble_LR125Kbit || RADIO_MODE_MODE_Ble_LR500Kbit)
#if CONFIG_HAS_HW_NRF_RADIO_BLE_CODED

#include "dtm_uart_twowire.h"
#include "dtm.h"

LOG_MODULE_REGISTER(dtm_tw_tr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider making log level configurable through Kconfig like for other modules

@@ -281,7 +297,7 @@ Vendor-specific commands can be divided into different categories as follows:

.. note::
Front-end module configuration parameters, such as ``antenna output``, ``gain``, and ``active delay``, are not set to their default values after the DTM reset command.
Testers, for example Anritsu MT885, issue a reset command in the beginning of every test.
Testers, for example Anritsu MT8852, issue a reset command in the beginning of every test.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Testers, for example Anritsu MT8852, issue a reset command in the beginning of every test.
Testers, for example Anritsu MT8852, issue a reset command at the beginning of every test.

@@ -69,20 +70,35 @@ For this reason, a coaxial connection between the DUT and the Lower Tester is em
DTM module interface
====================

The DTM function ``dtm_cmd_put`` implements the four commands defined by the Bluetooth Low Energy standard:
The DTM module interface can be divided into following three parts:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The DTM module interface can be divided into following three parts:
The DTM module interface can be divided into the following three parts:

* :c:func:`dtm_test_end`

The setup functions implement the DTM setup required by the Bluetooth Low Energy standard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend removing this empty line to have both similar sentences in one paragraph.

@@ -299,7 +315,7 @@ Vendor-specific commands can be divided into different categories as follows:
The DTM-to-Serial adaptation layer
==================================

The :file:`main.c` file is an implementation of the UART interface specified in the `Bluetooth Core Specification`_: Vol. 6, Part F, Chap. 3.
The :file:`main_uart.c` file is an implementation of the UART interface specified in the `Bluetooth Core Specification`_: Vol. 6, Part F, Chap. 3.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The :file:`main_uart.c` file is an implementation of the UART interface specified in the `Bluetooth Core Specification`_: Vol. 6, Part F, Chap. 3.
The :file:`main_uart.c` file is an implementation of the UART interface specified in the `Bluetooth Core Specification`_, Volume 6, Part F, Chapter 3.

LE_TEST_SUPPORTED_TX_TIME_MIN_RANGE = 0x04,
/** @brief DTM maximum supported values */
enum dtm_max_supported {
/** Max supported TX octets */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Max supported TX octets */
/** Maximum supported TX octets. */

Please use full forms instead of max and min - please correct all occurrences in this file. Please also add periods at the end of all doxygen comments.

/** @brief Read the maximum supported parameter value by DTM.
*
* @param[in] parameter Value to be read.
* @param[out] max_val The pointer to the maximum value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[out] max_val The pointer to the maximum value.
* @param[out] max_val The pointer to the maximum value.

All params' descriptions per function should be aligned to the same vertical line.

Comment on lines 231 to 234
* @param[in] count The antenna count.
* @param[in] pattern The antenna switching pattern.
* @param[in] pattern_len The length of the pattern.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in] count The antenna count.
* @param[in] pattern The antenna switching pattern.
* @param[in] pattern_len The length of the pattern.
* @param[in] count The antenna count.
* @param[in] pattern The antenna switching pattern.
* @param[in] pattern_len The length of the pattern.

Comment on lines 241 to 244
* @param[in] power The transmit power request.
* @param[in] val TX power value (in dBM) in case of DTM_TX_POWER_REQUEST_VAL request.
* @param[in] channel The channel to adjust power (set to 0 if unknown).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in] power The transmit power request.
* @param[in] val TX power value (in dBM) in case of DTM_TX_POWER_REQUEST_VAL request.
* @param[in] channel The channel to adjust power (set to 0 if unknown).
* @param[in] power The transmit power request.
* @param[in] val TX power value (in dBM) in case of DTM_TX_POWER_REQUEST_VAL request.
* @param[in] channel The channel to adjust power (set to 0 if unknown).

Comment on lines 260 to 262
* @param[in] channel The transmission channel.
* @param[in] length The packet length.
* @param[in] pkt The packet type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in] channel The transmission channel.
* @param[in] length The packet length.
* @param[in] pkt The packet type.
* @param[in] channel The transmission channel.
* @param[in] length The packet length.
* @param[in] pkt The packet type.

/** @brief Set the transmit power for DTM.
*
* @param[in] power The transmit power request.
* @param[in] val TX power value (in dBM) in case of DTM_TX_POWER_REQUEST_VAL request.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in] val TX power value (in dBM) in case of DTM_TX_POWER_REQUEST_VAL request.
* @param[in] val TX power value (in dBm) in case of DTM_TX_POWER_REQUEST_VAL request.

Please correct all occurrences.

Copy link
Contributor

@KAGA164 KAGA164 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I added few lats comments

samples/bluetooth/direct_test_mode/src/dtm.c Outdated Show resolved Hide resolved
samples/bluetooth/direct_test_mode/README.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@KAGA164 KAGA164 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Extract DTM radio part from transport interface in DTM sample.

Jira: NCSDK-22497

Signed-off-by: Dominik Chat <dominik.chat@nordicsemi.no>
@nordicjm nordicjm merged commit 2ef2ba0 into nrfconnect:main Aug 9, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-required PR must not be merged without tech writer approval.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants