void IndoorLocalizationService::on_ble_event(ble_evt_t * p_ble_evt) {

	Service::on_ble_event(p_ble_evt);

	switch (p_ble_evt->header.evt_id) {
#if CHAR_RSSI==1
	case BLE_GAP_EVT_CONNECTED: {

#if (NORDIC_SDK_VERSION >= 11) || \
	(SOFTDEVICE_SERIES == 130 && SOFTDEVICE_MAJOR == 1 && SOFTDEVICE_MINOR == 0) || \
	(SOFTDEVICE_SERIES == 110 && SOFTDEVICE_MAJOR == 8)
		sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle, 0, 0);
#else
		sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle);
#endif
		break;
	}
	case BLE_GAP_EVT_DISCONNECTED: {
		sd_ble_gap_rssi_stop(p_ble_evt->evt.gap_evt.conn_handle);
		break;
	}
	case BLE_GAP_EVT_RSSI_CHANGED: {
		onRSSIChanged(p_ble_evt->evt.gap_evt.params.rssi_changed.rssi);
		break;
	}
#endif

	default: {
	}
	}
}
Example #2
0
uint32_t conn_mw_ble_gap_rssi_start(uint8_t const * const p_rx_buf,
                                   uint32_t              rx_buf_len,
                                   uint8_t * const       p_tx_buf,
                                   uint32_t * const      p_tx_buf_len)
{
   SER_ASSERT_NOT_NULL(p_rx_buf);
   SER_ASSERT_NOT_NULL(p_tx_buf);
   SER_ASSERT_NOT_NULL(p_tx_buf_len);

   uint32_t err_code = NRF_SUCCESS;
   uint32_t sd_err_code;

   uint16_t conn_handle;
   uint8_t  threshold_dbm;
   uint8_t  skip_count;

   err_code = ble_gap_rssi_start_req_dec(p_rx_buf, rx_buf_len, &conn_handle, &threshold_dbm, &skip_count);
   SER_ASSERT(err_code == NRF_SUCCESS, err_code);

   sd_err_code = sd_ble_gap_rssi_start(conn_handle, threshold_dbm, skip_count);

   err_code = ble_gap_rssi_start_rsp_enc(sd_err_code, p_tx_buf, p_tx_buf_len);
   SER_ASSERT(err_code == NRF_SUCCESS, err_code);

   return err_code;
}
Example #3
0
void start_Rssi(void)
{
	//sd_ble_gap_rssi_get(m_conn_handle,p_rssi);
	sd_ble_gap_rssi_start(m_conn_handle,2,15);//kevin add
	disp_str_rssi.LCD_disp_Rssi_flag=1;
#if (DEBUG_UART_EN)
		//DbgPrintf("start_Rssi\r\n");
#endif	

}
Example #4
0
void RSSIModule::StartConnectionRSSIMeasurement(Connection* connection)
{
    u32 err = 0;

    if (connection->isConnected)
    {
        //Reset old values
        connection->rssiSamplesNum = 0;
        connection->rssiSamplesSum = 0;

        err = sd_ble_gap_rssi_start(connection->connectionHandle, 0, 0);
        APP_ERROR_CHECK(err);

    }
}
void StatusReporterModule::StartConnectionRSSIMeasurement(Connection* connection){
	u32 err = 0;

	if (connection->isConnected())
	{
		//Reset old values
		connection->rssiSamplesNum = 0;
		connection->rssiSamplesSum = 0;

		err = sd_ble_gap_rssi_start(connection->connectionHandle, 0, 0);
		if(err == NRF_ERROR_INVALID_STATE || err == BLE_ERROR_INVALID_CONN_HANDLE){
			//Both errors are due to a disconnect and we can simply ignore them
		} else {
			APP_ERROR_CHECK(err); //OK
		}

		logt("STATUSMOD", "RSSI measurement started for connection %u with code %u", connection->connectionId, err);
	}
}
void BLETransceiver::startRSSIMeasure(void)
{
	sd_ble_gap_rssi_start(u16_connHandle);
}