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

Scan only one nrf52832 peripheral

HI

I am using nrf52832 modules with SDK 11.0.0, s132.

I am able to advertise and scan the devices and display RSSI and peer address.

For my project i want to display the RSSI of the advertising nrf module , but the central device is scanning all the surrounding peripheral devices.So how do i implement to scan only one particular peripheral device and there by display that device address and RSSI only??

central: ble_app_uart_c example

peripheral: ble_beacon example

Thanks,

Uma

Parents
  • Hi Uma,

    You have a few options in this case:

    1. Scan with whitelisting provided that you know the MAC address or IRK (if the peripheral uses privacy). If you are not bonded with the device, you can do something similar to this.
    2. Just filter in the handling of the BLE_GAP_EVT_ADV_REPORT event. Then you can filter on anything you want (MAC address, name or whatever), and only print the RSSI of the device(s) you are interested in.
  • Hi,

    these are the lines i added in the gap_params_init

    int8_t tx_power = 3;

    err_code = sd_ble_gap_tx_power_set(tx_power);
    APP_ERROR_CHECK(err_code);

    after successful build when i load the board, the module is not advertising.

    But when the change the power level to 4 it advertises.

    I did not enable the Soft Device(not aware).How do i check for error.?

Reply Children
  • Hi,

    guma said:
    after successful build when i load the board, the module is not advertising.

    Most likely it does not advertise because APP_ERROR_CHECK() has been called with an error code (something not NRF_SUCCESS). The proper approach, in this case, is to find out what the error code is. Have you tried that?

    guma said:
    I did not enable the Soft Device(not aware).How do i check for error.?

    If you did not enable the SoftDevice, then any call to SoftDevice API's (such as sd_ble_gap_tx_power_set()) is illegal. So if the SoftDevice really is not enabled it is expected to fail, in this case with error code is probably NRF_ERROR_SOFTDEVICE_NOT_ENABLED. To fix this you need to make sure that you enable the SoftDevice before you call sd_ble_gap_tx_power_set(). However, you write that you do this in gap_params_init(), and in the SDK examples, this function is called after the SoftDevice is enabled. Therefore, I suspect the error code is something else.

    So, to move forward in a fast and efficient way you should find the error code returned by sd_ble_gap_tx_power_set(), as this will probably tell us what went wrong.

    Update: I just checked the old SDK 11 SoftDevice API (S132 2.0.0), and it turns out that back then +3 dBm was not supported by the SoftDevice. So the error code you get is probably NRF_ERROR_INVALID_PARAM. You have to choose between -40, -30, -20, -16, -12, -8, -4, 0, or 4 dBm using that old SoftDevice. You need a newer SoftDevice to be able to set +3 dBm (at least S132 version 3.0.0).

Related