Connection Handover messages and records

Connection Handover records and the corresponding messages are used to negotiate and activate an alternative communication carrier. The negotiated communication carrier can then be used to perform certain activities between the two devices, such as Bluetooth® pairing.

Connection Handover records

The Connection Handover library provides functions for creating and encoding the following Connection Handover records:

  • Handover Request record

  • Handover Select record

  • Handover Mediation record

  • Handover Initiate record

  • Handover Carrier record

  • Local records:

    • Alternative Carrier record

    • Collision Resolution record

Connection Handover messages

The Connection Handover message library provides functions for encoding the following messages:

  • Bluetooth LE OOB message

  • Handover Select message

  • Handover Request message

  • Handover Mediation message

  • Handover Initiate message

This library is used in the Bluetooth: NFC pairing sample.

The following code sample demonstrates how to create a Handover Select message with one Alternative Carrier record that has a reference to the Bluetooth LE OOB record:

static int tnep_initial_msg_encode(struct nfc_ndef_msg_desc *msg)
{
	int err;
	struct nfc_ndef_ch_msg_records ch_records;
	static struct nfc_ndef_le_oob_rec_payload_desc rec_payload;

	NFC_NDEF_LE_OOB_RECORD_DESC_DEF(oob_rec, '0', &rec_payload);
	NFC_NDEF_CH_AC_RECORD_DESC_DEF(oob_ac, NFC_AC_CPS_ACTIVE, 1, "0", 0);
	NFC_NDEF_CH_HS_RECORD_DESC_DEF(hs_rec, NFC_NDEF_CH_MSG_MAJOR_VER,
				       NFC_NDEF_CH_MSG_MINOR_VER, 1);

	memset(&rec_payload, 0, sizeof(rec_payload));

	rec_payload.addr = &oob_local.addr;
	rec_payload.le_sc_data = &oob_local.le_sc_data;
	rec_payload.tk_value = tk_value;
	rec_payload.local_name = bt_get_name();
	rec_payload.le_role = NFC_NDEF_LE_OOB_REC_LE_ROLE(
		NFC_NDEF_LE_OOB_REC_LE_ROLE_PERIPH_ONLY);
	rec_payload.appearance = NFC_NDEF_LE_OOB_REC_APPEARANCE(
		CONFIG_BT_DEVICE_APPEARANCE);
	rec_payload.flags = NFC_NDEF_LE_OOB_REC_FLAGS(BT_LE_AD_NO_BREDR);

	ch_records.ac = &NFC_NDEF_CH_AC_RECORD_DESC(oob_ac);
	ch_records.carrier = &NFC_NDEF_LE_OOB_RECORD_DESC(oob_rec);
	ch_records.cnt = 1;

	err =  nfc_ndef_ch_msg_hs_create(msg,
					 &NFC_NDEF_CH_RECORD_DESC(hs_rec),
					 &ch_records);
	if (err) {
		return err;
	}

	return nfc_tnep_initial_msg_encode(msg, NULL, 0);
}

API documentation

Connection Handover records

Header file: include/nfc/ndef/ch.h
Source file: subsys/nfc/ndef/ch.c
Connection Handover records

Connection Handover messages

Header file: include/nfc/ndef/ch_msg.h
Source file: subsys/nfc/ndef/ch_msg.c
NFC Connection Hanover messages