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.
Reply
  • 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.
Children
  • Hi

    I was able to successfully  filter required device by name, MAC address.

    I do not understand whitelisting??

    I want to do with UUID, i couldnt get past though is_uuid_present function.

    the peripheral  and central configurations are kept as default. What should i change?How can i filter using uuid??

    The default TX power level of the module is 0dBm right??

    according to the documentation Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, 3, and 4 dBm), my device is nrf52832.When i have set to 3dbm im unable to advertise why?

    Thanks

  • Hi,

    guma said:
    I do not understand whitelisting??

    Whitelisting is simply a method that lets the scanner (in this case) ignore advertising packets form non-whitelisted devices. You can whitelist the MAC address (or IRK if the peer is using privacy - random resolvable address - and you have exchanged the IRK when bonding).

    guma said:

    I want to do with UUID, i couldnt get past though is_uuid_present function.

    the peripheral  and central configurations are kept as default. What should i change?How can i filter using uuid??

    Filtering on UUID is essentially similar to any other filtering. Instead of filtering on the Name which is part of the advertising packet, you filter on UUID instead. Note that both name and UUID are optional, so unless you know that it is part of the advertising packet you are not guaranteed to find anything. (That means that a device can support a BLE service without advertising the service UUID. So, in that case, you have to connect and do service discovery to know that the service is supported).

    The is_uuid_present function in the NUS central example in SDK 11 demonstrates how you can search for a specific UUID in the advertising data. If it doe snot find the UUID you are searching for it indicates that it is not part of the advertising packet.

    guma said:
    The default TX power level of the module is 0dBm right??

    Yes, the Tx power is 0 dBm unless you explicitly set it to something else.

    guma said:
    according to the documentation Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, 3, and 4 dBm), my device is nrf52832.When i have set to 3dbm im unable to advertise why?

    Unable to advertise? In what way? How do you set the Tx power? It should be just to call sd_ble_gap_tx_power_set() after enabling the SoftDevice. Do you get an error returned?

  • 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.?

  • 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).

  • Hi,

    Thank you for explaining.

    Regarding the TX power level, the range or distance reduces as power level is set to -4, -8 and so on right?

    At the reception end is there any feature with regards to the LNA/PA control ? or it is already enabled in the module ?How does it work in the nrf52832 module?

    Thanks in advance.

Related