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

Wrong IQ value type ?

Hi,

I'm designing my own algorithm for direction finding and for that i need IQ value as input. In NCS v1.6.0, in the locator exemple for aoa, the IQ value are store in a int8_t type in struct bt_df_per_adv_sync_iq_samples_report -> bt_hci_le_iq_sample.

However, in nrf52833 product specification chapter 6.18.12.7, IQ value are 12 bits signed. I don't understand why Nordic decide to cut 4 bit (even if it's LSB) from IQ value. There's more in hci.c, in le_df_connectionless_iq_report function, where we can see 

static void le_df_connectionless_iq_report(struct pdu_data *pdu_rx,
					   struct node_rx_pdu *node_rx,
					   struct net_buf *buf)
{
	struct bt_hci_evt_le_connectionless_iq_report *sep;
	struct node_rx_iq_report *iq_report;

	struct lll_sync *lll;
	uint8_t samples_cnt;
	int16_t iq_tmp;
	int16_t rssi;
	uint8_t idx;

	iq_report =  (struct node_rx_iq_report *)node_rx;

	if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) ||
	    !(le_event_mask & BT_EVT_MASK_LE_CONNECTIONLESS_IQ_REPORT)) {
		return;
	}

	lll = iq_report->hdr.rx_ftr.param;

	/* TX LL thread has higher priority than RX thread. It may happen that
	 * host succefully disables CTE sampling in the meantime.
	 * It should be verified here, to avoid reporint IQ samples after
	 * the functionality was disabled.
	 */
	if (ull_df_sync_cfg_is_disabled_or_requested_to_disable(&lll->df_cfg)) {
		/* Dropp further processing of the event. */
		return;
	}

	/* If there are no IQ samples due to insufficient resources
	 * HCI event should inform about it by store single octet with
	 * special I_sample and Q_sample data.
	 */
	samples_cnt = (!iq_report->sample_count ? 1 : iq_report->sample_count);

	sep = meta_evt(buf, BT_HCI_EVT_LE_CONNECTIONLESS_IQ_REPORT,
		       (sizeof(*sep) +
			(samples_cnt * sizeof(struct bt_hci_le_iq_sample))));

	rssi = RSSI_DBM_TO_DECI_DBM(iq_report->hdr.rx_ftr.rssi);

	sep->sync_handle = sys_cpu_to_le16(iq_report->hdr.handle);
	sep->rssi = sys_cpu_to_le16(rssi);
	sep->rssi_ant_id = iq_report->rssi_ant_id;
	sep->cte_type = iq_report->cte_info.type;

	sep->chan_idx = lll->data_chan_id;
	sep->per_evt_counter = sys_cpu_to_le16(lll->event_counter);

	if (sep->cte_type == BT_HCI_LE_AOA_CTE) {
		sep->slot_durations = iq_report->local_slot_durations;
	} else if (sep->cte_type == BT_HCI_LE_AOD_CTE_1US) {
		sep->slot_durations = BT_HCI_LE_ANTENNA_SWITCHING_SLOT_1US;
	} else {
		sep->slot_durations = BT_HCI_LE_ANTENNA_SWITCHING_SLOT_2US;
	}

	sep->packet_status = iq_report->packet_status;

	if (iq_report->packet_status == BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES) {
		sep->sample[0].i = BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE;
		sep->sample[0].q = BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE;
		sep->sample_count = 0;
	} else {
		for (idx = 0; idx < samples_cnt; ++idx) {
			/*iq_tmp = IQ_SHIFT_12_TO_8_BIT(iq_report->sample[idx].i);
			sep->sample[idx].i = (int8_t)iq_tmp;
			iq_tmp = IQ_SHIFT_12_TO_8_BIT(iq_report->sample[idx].q);
			sep->sample[idx].q = (int8_t)iq_tmp;*/

			sep->sample[idx].i = iq_report->sample[idx].i;
			sep->sample[idx].q = iq_report->sample[idx].q;
		}
		sep->sample_count = samples_cnt;
	}
}

I comment the ligne which shift the value from 12bit to 8bit. Even in III_df_types.h, the IQ sample are define as int16_t.

I would like to understand why, maybe i'm missing something.

Thanks

Parents Reply Children
Related