This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Detect Coded PHY transmitting devices

Hi All,

Scanning with a nRF52840 Dongle, Is there a way to know if one of the scanned devices is using Coded PHY modulation to advertise? And if the answer is negative, could I detect this fact scanning with a with a nRF52840 DK board instead?

Thanks in advance

Parents
  • Hi.

    If you look at the API nrf_ble_scan_params_set:

    /**@brief Function for changing the scanning parameters.
     *
     **@details Use this function to change scanning parameters. During the parameter change
     *         the scan is stopped. To resume scanning, use @ref nrf_ble_scan_start.
     *         Scanning parameters can be set to NULL. If so, the default static configuration
     *         is used. For example, use this function when the @ref NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT event is generated.
     *         The generation of this event means that there is a risk that the whitelist is empty. In such case, this function can change
     *         the scanning parameters, so that the whitelist is not used, and you avoid the error caused by scanning with the whitelist
     *         when there are no devices on the whitelist.
     *
     * @param[in,out] p_scan_ctx     Pointer to the Scanning Module instance.
     * @param[in]     p_scan_param   GAP scanning parameters. Can be initialized as NULL.
     *
     * @retval NRF_SUCCESS          If parameters are changed successfully.
     * @retval NRF_ERROR_NULL       If a NULL pointer is passed as input.
     */
    ret_code_t nrf_ble_scan_params_set(nrf_ble_scan_t        * const p_scan_ctx,
                                       ble_gap_scan_params_t const * p_scan_param);

    It takes a pointer to the scanning module instance, p_scan_ctx, and scanning parameters, which is a struct called ble_gap_scan_params_t:

    /**@brief GAP scanning parameters. */
    typedef struct
    {
      uint8_t               extended               : 1; /**< If 1, the scanner will accept extended advertising packets.
                                                             If set to 0, the scanner will not receive advertising packets
                                                             on secondary advertising channels, and will not be able
                                                             to receive long advertising PDUs. */
      uint8_t               report_incomplete_evts : 1; /**< If 1, events of type @ref ble_gap_evt_adv_report_t may have
                                                             @ref ble_gap_adv_report_type_t::status set to
                                                             @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA.
                                                             This parameter is ignored when used with @ref sd_ble_gap_connect
                                                             @note This may be used to abort receiving more packets from an extended
                                                                   advertising event, and is only available for extended
                                                                   scanning, see @ref sd_ble_gap_scan_start.
                                                             @note This feature is not supported by this SoftDevice. */
      uint8_t               active                 : 1; /**< If 1, perform active scanning by sending scan requests.
                                                             This parameter is ignored when used with @ref sd_ble_gap_connect. */
      uint8_t               filter_policy          : 2; /**< Scanning filter policy. @sa BLE_GAP_SCAN_FILTER_POLICIES.
                                                             @note Only @ref BLE_GAP_SCAN_FP_ACCEPT_ALL and
                                                                   @ref BLE_GAP_SCAN_FP_WHITELIST are valid when used with
                                                                   @ref sd_ble_gap_connect */
      uint8_t               scan_phys;                  /**< Bitfield of PHYs to scan on. If set to @ref BLE_GAP_PHY_AUTO,
                                                             scan_phys will default to @ref BLE_GAP_PHY_1MBPS.
                                                             - If @ref ble_gap_scan_params_t::extended is set to 0, the only
                                                               supported PHY is @ref BLE_GAP_PHY_1MBPS.
                                                             - When used with @ref sd_ble_gap_scan_start,
                                                               the bitfield indicates the PHYs the scanner will use for scanning
                                                               on primary advertising channels. The scanner will accept
                                                               @ref BLE_GAP_PHYS_SUPPORTED as secondary advertising channel PHYs.
                                                             - When used with @ref sd_ble_gap_connect, the
                                                               bitfield indicates the PHYs on where a connection may be initiated.
                                                               If scan_phys contains @ref BLE_GAP_PHY_1MBPS and/or @ref BLE_GAP_PHY_2MBPS,
                                                               the primary scan PHY is @ref BLE_GAP_PHY_1MBPS.
                                                               If scan_phys also contains @ref BLE_GAP_PHY_CODED, the primary scan
                                                               PHY will also contain @ref BLE_GAP_PHY_CODED. If the only scan PHY is
                                                               @ref BLE_GAP_PHY_CODED, the primary scan PHY is
                                                               @ref BLE_GAP_PHY_CODED only. */
      uint16_t              interval;                   /**< Scan interval in 625 us units. @sa BLE_GAP_SCAN_INTERVALS. */
      uint16_t              window;                     /**< Scan window in 625 us units. @sa BLE_GAP_SCAN_WINDOW.
                                                             If scan_phys contains both @ref BLE_GAP_PHY_1MBPS and
                                                             @ref BLE_GAP_PHY_CODED interval shall be larger than or
                                                             equal to twice the scan window. */
      uint16_t              timeout;                    /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */
      ble_gap_ch_mask_t     channel_mask;               /**< Channel mask for primary and secondary advertising channels.
                                                             At least one of the primary channels, that is channel index 37-39, must be
                                                             set to 0.
                                                             Masking away secondary channels is not supported. */
    } ble_gap_scan_params_t;

    You can create a struct for the scanning parameters in main.c and set scan_phys = BLE_GAP_CODED_PHY

    Best regards,

    Andreas

Reply
  • Hi.

    If you look at the API nrf_ble_scan_params_set:

    /**@brief Function for changing the scanning parameters.
     *
     **@details Use this function to change scanning parameters. During the parameter change
     *         the scan is stopped. To resume scanning, use @ref nrf_ble_scan_start.
     *         Scanning parameters can be set to NULL. If so, the default static configuration
     *         is used. For example, use this function when the @ref NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT event is generated.
     *         The generation of this event means that there is a risk that the whitelist is empty. In such case, this function can change
     *         the scanning parameters, so that the whitelist is not used, and you avoid the error caused by scanning with the whitelist
     *         when there are no devices on the whitelist.
     *
     * @param[in,out] p_scan_ctx     Pointer to the Scanning Module instance.
     * @param[in]     p_scan_param   GAP scanning parameters. Can be initialized as NULL.
     *
     * @retval NRF_SUCCESS          If parameters are changed successfully.
     * @retval NRF_ERROR_NULL       If a NULL pointer is passed as input.
     */
    ret_code_t nrf_ble_scan_params_set(nrf_ble_scan_t        * const p_scan_ctx,
                                       ble_gap_scan_params_t const * p_scan_param);

    It takes a pointer to the scanning module instance, p_scan_ctx, and scanning parameters, which is a struct called ble_gap_scan_params_t:

    /**@brief GAP scanning parameters. */
    typedef struct
    {
      uint8_t               extended               : 1; /**< If 1, the scanner will accept extended advertising packets.
                                                             If set to 0, the scanner will not receive advertising packets
                                                             on secondary advertising channels, and will not be able
                                                             to receive long advertising PDUs. */
      uint8_t               report_incomplete_evts : 1; /**< If 1, events of type @ref ble_gap_evt_adv_report_t may have
                                                             @ref ble_gap_adv_report_type_t::status set to
                                                             @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA.
                                                             This parameter is ignored when used with @ref sd_ble_gap_connect
                                                             @note This may be used to abort receiving more packets from an extended
                                                                   advertising event, and is only available for extended
                                                                   scanning, see @ref sd_ble_gap_scan_start.
                                                             @note This feature is not supported by this SoftDevice. */
      uint8_t               active                 : 1; /**< If 1, perform active scanning by sending scan requests.
                                                             This parameter is ignored when used with @ref sd_ble_gap_connect. */
      uint8_t               filter_policy          : 2; /**< Scanning filter policy. @sa BLE_GAP_SCAN_FILTER_POLICIES.
                                                             @note Only @ref BLE_GAP_SCAN_FP_ACCEPT_ALL and
                                                                   @ref BLE_GAP_SCAN_FP_WHITELIST are valid when used with
                                                                   @ref sd_ble_gap_connect */
      uint8_t               scan_phys;                  /**< Bitfield of PHYs to scan on. If set to @ref BLE_GAP_PHY_AUTO,
                                                             scan_phys will default to @ref BLE_GAP_PHY_1MBPS.
                                                             - If @ref ble_gap_scan_params_t::extended is set to 0, the only
                                                               supported PHY is @ref BLE_GAP_PHY_1MBPS.
                                                             - When used with @ref sd_ble_gap_scan_start,
                                                               the bitfield indicates the PHYs the scanner will use for scanning
                                                               on primary advertising channels. The scanner will accept
                                                               @ref BLE_GAP_PHYS_SUPPORTED as secondary advertising channel PHYs.
                                                             - When used with @ref sd_ble_gap_connect, the
                                                               bitfield indicates the PHYs on where a connection may be initiated.
                                                               If scan_phys contains @ref BLE_GAP_PHY_1MBPS and/or @ref BLE_GAP_PHY_2MBPS,
                                                               the primary scan PHY is @ref BLE_GAP_PHY_1MBPS.
                                                               If scan_phys also contains @ref BLE_GAP_PHY_CODED, the primary scan
                                                               PHY will also contain @ref BLE_GAP_PHY_CODED. If the only scan PHY is
                                                               @ref BLE_GAP_PHY_CODED, the primary scan PHY is
                                                               @ref BLE_GAP_PHY_CODED only. */
      uint16_t              interval;                   /**< Scan interval in 625 us units. @sa BLE_GAP_SCAN_INTERVALS. */
      uint16_t              window;                     /**< Scan window in 625 us units. @sa BLE_GAP_SCAN_WINDOW.
                                                             If scan_phys contains both @ref BLE_GAP_PHY_1MBPS and
                                                             @ref BLE_GAP_PHY_CODED interval shall be larger than or
                                                             equal to twice the scan window. */
      uint16_t              timeout;                    /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */
      ble_gap_ch_mask_t     channel_mask;               /**< Channel mask for primary and secondary advertising channels.
                                                             At least one of the primary channels, that is channel index 37-39, must be
                                                             set to 0.
                                                             Masking away secondary channels is not supported. */
    } ble_gap_scan_params_t;

    You can create a struct for the scanning parameters in main.c and set scan_phys = BLE_GAP_CODED_PHY

    Best regards,

    Andreas

Children
  • Thanks again for your help, Andreas.

    and by the way,

    Is there available in Nordic Semiconductor a reference documentation including a "systematic and comprehensive" description of all the functionalities implemented in an nRF52840 SoC? For instance, one describing each S140 SoftDevice API call/definition/command/macro/function (or whatever you may call it when you are referring to an "instruction to invoke/set" one SD/HW particular functionality), including its options if any? I mean one not only describing the functionality but also comparing it with similar ones, in terms of pros and cons. One not just making a mention in a long list or defining its correct spelling, as I think it could be the case with what I find in Nordic Infocenter? I think it would save tons of time.

    Best regards.

    Juan

  • Hi Juan.

    I do not think there is a place where pros and cons are taken into concideration when API's are described. I think the most thorough information on the SoftDevice API would be in the SoftDevice API documentation (this one is S140 v6.1.1). The Message Sequence Charts could also be a good idea to look at, to get a better understanding on how and when to use the right API.

    Best regards,

    Andreas

Related