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

How can I get rssi before I make a connection?

Hello ,

I can read the rssi value after the connection is established.

case BLE_GAP_EVT_CONNECTED:
            APPL_LOG("Connected to target\r\n");
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
            APP_ERROR_CHECK(err_code);
            
            m_ble_nus_c.conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
						
            // start discovery of services. The NUS Client waits for a discovery result
            err_code = ble_db_discovery_start(&m_ble_db_discovery, p_ble_evt->evt.gap_evt.conn_handle);
            APP_ERROR_CHECK(err_code);	

			sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle, 0 , 0);

            break;

Then I toggle LEDs according rssi value;

case BLE_GAP_EVT_RSSI_CHANGED:						 
						rssi_value = p_ble_evt->evt.gap_evt.params.rssi_changed.rssi;
						nrf_gpio_pin_clear(LED1);
						nrf_gpio_pin_clear(LED0);
				
						if(rssi_value<-64)
							nrf_gpio_pin_toggle(LED1);
						else if(rssi_value<-48)
							nrf_gpio_pin_toggle(LED0);
						
					break;

But I want to read the rssi value as in the NRFToolbox application before establishing a connection.

nrf_rssi.jpg

Parents
  • Hi,

    The exact RSSI value is not shown in the scanner in nRF Toolbox, but the RSSI is calculated into percentage and a representative image is used to indicate the strength. You can modify the code of the app to show the RSSI value instead of, or in addition to, the image.

    Best regards,

    Jørgen

  • Firstly, thank you for your information. I do not fully understand the codes, but I work on it. The point I try to reach is actually a very common example. The keys of the newly produced cars have the keylessgo feature, and the car opens automatically when the key approaches. So I think that they make use of rssi measurement. In order to be able to evolve faster, I want to learn how to generate a rssi percentage or a number or image(as you said) with c code instead of Android? (IIf such a study had been done before.) As I said, I am examining the Toolbox example, but if there is an example written in C code, it will speed me up a lot.

Reply
  • Firstly, thank you for your information. I do not fully understand the codes, but I work on it. The point I try to reach is actually a very common example. The keys of the newly produced cars have the keylessgo feature, and the car opens automatically when the key approaches. So I think that they make use of rssi measurement. In order to be able to evolve faster, I want to learn how to generate a rssi percentage or a number or image(as you said) with c code instead of Android? (IIf such a study had been done before.) As I said, I am examining the Toolbox example, but if there is an example written in C code, it will speed me up a lot.

Children
No Data
Related