MCUXpresso SDK Documentation

Localization scenarios#

Application configuration#

This section describes configuration options available for the applications. The configuration can be done either at compile time, by using macros added in the app_preinclude.h file of the respective sample, or at runtime, via shell commands. The available configurations are:

  • The Channel Sounding role can be set through the role shell command at runtime only if there are no active connections. The default role is set through the gCsDefaultRole_c define in app_preinclude.h. In the default configuration, the Anchor is in the CS Initiator role (gCsRoleInitiator_c) and the Device is in the CS Reflector role (gCsRoleReflector_c).

  • The number of Channel Sounding procedures to be run via the CS Procedure Repeat mechanism, for each triggered distance measurement. The default value can be set through the gCsProcRepeatMaxNumProcedures_c define. At runtime, the value can be changed using the setnumprocs command.

  • The ranging algorithm to run once the local and remote measurement data is available. Each of the two supported algorithms can be disabled at compile time for code size reasons. By default, both are enabled. To disable an algorithm at compile time, define its respective macro with the value 0 inside app_preinclude.h. The macros are gAppUseCDEAlgorithm_d, gAppUseRADEAlgorithm_d. At runtime, the setalgo shell command can be used to configure the algorithm that runs upon completion of the CS procedure and data transfer. Any combination of algorithms can be selected. By default, RADE is selected.

  • The timing information display feature can be activated by setting the gAppCsTimeInfo_d macro to value 1 inside app_preinclude.h. Additional timing information such as the duration of the CS config phase, CS procedure, BTCS transfer, and running of the algorithms is displayed on the console.

  • The BTCS L2CAP transfer watchdog is an NXP proprietary extension (the CCC BTCS specification does not define any timeout for the L2CAP measurement transfer). When the CS procedure auto-restart loop is enabled on the BTCS client, this watchdog ensures the loop does not stall if a BTCS L2CAP transfer is lost or never completes. The feature is client-side only and is always enabled. The watchdog timeout duration in seconds can be tuned through the gBtcsTimeoutSeconds_c macro (default 3). If a transfer does not complete before the timeout expires, the watchdog only restarts the CS procedure loop when the full procedure sequence (maxNumProcedures) has been reached; otherwise it simply returns to waiting for the next procedure’s measurement data.

For better performance and user experience, the optional LE Coded PHY advertising should be disabled by setting gAppLeCodedAdvEnable_d to 0 inside app_preinclude.h on the Anchor.

  • Maximum concurrent Channel Sounding procedures**: Configure the maximum number of Channel Sounding procedures that can run simultaneously across all connections using the gChannelSoundingMaxConcurrentProcedures_c define in app_preinclude.h.

The sample applications also include an optional non-CCC configuration used to exercise connection handover with a Channel Sounding GAP central. In this configuration the GAP roles are reversed: the Car Anchor acts as a GAP central (gAppScanNonCCC_d) and the Device acts as a GAP peripheral (gAppAdvNonCCC_d). A separate private service UUID (gNonCccDkUUID_d) is used so that non-CCC advertisements stay distinct from the regular CCC applications.

Parent topic:Localization scenarios

Localization after passive entry#

The localization process starts automatically after the Passive Entry scenario is completed. The CS Initiator performs the CS setup and starts a number of gCsProcRepeatMaxNumProcedures_c procedures. After each procedure, the Device’s local data is transmitted through BTCS to the Anchor. After the Anchor collects the data, it runs the selected algorithm(s) and displays the measured distance (meters) in the console.

The below figure shows the output of the localization process after each of the five measurements completed successfully and the distance is displayed.

Output of the localization process

Parent topic:Localization scenarios

Localization on demand and other shell commands#

Localization can also be performed on demand via the tdm shell command. The command can be used in two ways:

  • tdm - Triggers distance measurement on all connected devices

  • tdm <peerId> - Triggers distance measurement on the specified peer device (where peerId is the device ID of the peer)

As shown in the figure below, the Device triggers the localization process, and the default 5 measurements complete successfully.

Triggering the localization process

Other available shell commands are:

  • setcsconfig: This command overwrites the default parameters for the Channel Sounding Create Config command. It updates only the parameters that are explicitly specified; any parameter that is not provided retains its current value. The syntax is:

    setcsconfig <peerId> <paramName> <value> [<paramName> <value> ...]

    where <peerId> is the device ID of the peer, followed by one or more <paramName> <value> pairs. The supported parameter names and their accepted values are:

    • mainmodetype: CS mode to be used as main mode during the CS procedure for this configuration. Possible values:

      • 1 (CS mode-1)

      • 2 (CS mode-2)

      • 3 (CS mode-3)

    • submodetype: CS mode to be used as submode during the CS procedure for this configuration. Possible values:

      • 1 (CS mode-1)

      • 2 (CS mode-2)

      • 3 (CS mode-3)

      • 255 (no submode used)

    • mainmodeminsteps: Lower bound of the range of main mode CS steps to be executed before a submode CS step is executed during the CS procedure. Range:

      • 1 to 255

    • mainmodemaxsteps: Higher bound of the range of main mode CS steps to be executed before a submode CS step is executed during the CS procedure. Range:

      • 1 to 255

    • mainmoderepetition: Number of main mode CS steps repeated from the previous CS subevent at the beginning of the current CS subevent. Range:

      • 0 to 3

    • mode0steps: Number of CS mode-0 steps to be included at the beginning of each CS subevent. Range:\

      • 1 to 3

    • role: CS role. Possible values:

      • 0 (initiator)

      • 1 (reflector)

    • rtttype: RTT variant to be used during the CS procedure. Possible values:

      • 0 (RTT AA only)

      • 1 (RTT with 32-bit sounding sequence)

      • 2 (RTT with 96-bit sounding sequence)

      • 3 (RTT with 32-bit random sequence)

      • 4 (RTT with 64-bit random sequence)

      • 5 (RTT with 96-bit random sequence)

      • 6 (RTT with 128-bit random sequence)

    • channelmap: 80-bit map in big endian order indicating channels to be used for the CS procedure. The default value is fcff7ffcffffffffff1f (all channels used except 0, 1, 23-25 and 77-78). Bit 79 is reserved for future use. At least 15 channels must be enabled.

    • channelmaprepetition: Number of times the channel map will be cyled through for non-mode-0 steps within a CS procedure. Range:

      • 1 to 255.

    • channelselectiontype: Channel selection type. Possible values:

      • 0 (Channel Selection Algorithm #3b)

      • 1 (Channel Selection Algorithm #3c)

    • cssyncphy: PHY to be used for CS_SYNC exchanges during the CS procedure for the specified CS configuration. Possible values:

      • 1 (LE 1M PHY)

      • 2 (LE 2M PHY)

      • 3 (LE 2M 2BT PHY) - if supported at Link Layer level

    Example: setcsconfig 0 mode0steps 3 cssyncphy 2 updates only the mode-0 steps and the CS_SYNC PHY, leaving all other parameters unchanged.

  • setcsproc: This command overwrites the default parameters for the Channel Sounding Set Procedure Parameters command. It updates only the parameters that are explicitly specified; any parameter that is not provided retains its current value. The syntax is:

    setcsproc <peerId> <paramName> <value> [<paramName> <value> ...]

    where <peerId> is the device ID of the peer, followed by one or more <paramName> <value> pairs. The supported parameter names and their accepted values are:

    • maxprocedureduration: Maximum duration for each CS procedure. Range:

      • 1 to 65535 (units of 0.625ms)

    • minperiodbetweenprocedures: Minimum number of connection events between consecutive CS procedures. Range:

      • 1 to 65535

    • maxperiodbetweenprocedures: Maximum number of connection events between consecutive CS procedures. Range:

      • 1 to 65535

    • maxnumprocedures: Maximum number of CS procedures to be scheduled. Possible values:

      • 0 (CS procedures to continue until disabled)

      • 1 to 65535

    • minsubeventlen: Minimum suggested duration for each CS subevent in microseconds. Range:

      • 1250 microseconds to 3.999999 seconds

    • maxsubeventlen: Maximum suggested duration for each CS subevent in microseconds. Range:

      • 1250 microseconds to 3.999999 seconds

    • antcfgindex: Antenna Configuration Index as described in the Core specification. Range:

      • 0 to 7

    • snrcontrolinit: SNR Control to be applied to the Initiator in the CS procedure (if supported at Link Layer level). Possible values:

      • 0 (SNR control adjustment of 18 dB)

      • 1 (SNR control adjustment of 21 dB)

      • 2 (SNR control adjustment of 24 dB)

      • 3 (SNR control adjustment of 27 dB)

      • 4 (SNR control adjustment of 30 dB)

      • 255 (SNR control is not to be applied)

    • snrcontrolrefl: SNR Control to be applied to the Reflector in the CS procedure (if supported at Link Layer level). Possible values:

      • 0 (SNR control adjustment of 18 dB)

      • 1 (SNR control adjustment of 21 dB)

      • 2 (SNR control adjustment of 24 dB)

      • 3 (SNR control adjustment of 27 dB)

      • 4 (SNR control adjustment of 30 dB)

      • 255 (SNR control is not to be applied)

    Example: setcsproc 0 minsubeventlen 2500 antcfgindex 1 updates only the minimum subevent length and the antenna configuration index, leaving all other parameters unchanged.

  • verbosity: Sets the verbosity level during the CS procedure.

  • setnumprocs: This command overwrites the default value gCsProcRepeatMaxNumProcedures_c parameter for the CS Procedure Repeat. It takes the following parameters, in the order below:

    • peerId

    • maxnumprocedures: Number of procedures in hex format. Example: setnumprocs 0 0x0005. Value 0x0000 means infinite repeats.

  • loop: This command toggles the automatic restart of the CS procedure (whether with CS Procedure Repeat enabled or not) upon its end. By default, the CS procedure will not restart automatically. Parent topic:Localization scenarios

BTCS L2CAP data transfer#

The CCC introduced the Bluetooth LE Channel Sounding (BTCS) measurement transfer feature. BTCS procedures are configured and executed using the Bluetooth Low Energy connection established for the Digital Key Service. The results of the BTCS procedures are transferred to the vehicle and used to estimate the distance. The data transfer is done through the L2CAP channel created during the passive entry scenario. The format of the data transferred through BTCS is defined by the CCC. The algorithms used on the receiver to estimate the distance are (RADE and CDE).

The default transfer direction enabled in the digital_key_car_anchor_cs and digital_key_device_cs is from Device to the Anchor. To reverse the transfer direction in BTCS, the following defines must be set in the app_preinclude.h file:

  • digital_key_car_anchor_cs: gAppBtcsClient_d set to 0 and gAppBtcsServer_d set to 1

  • digital_key_device_cs: gAppBtcsServer_d set to 0 and gAppBtcsClient_d set to 1

The figure below shows the car Anchor output after BTCS transfer direction is reversed.

BTCS transfer - car Anchor output

The figure below shows the Device output after BTCS is enabled.

BTCS transfer - Device output

Both digital_key_car_anchor_cs and digital_key_device_cs applications support gAppBtcsClient_d and gAppBtcsServer_d configuration options at the same time. Also, the algorithm can be run on both (gAppRunAlgo_d can be set on both applicaitons at the same time). Here is a picture showing both applications running the algorithm.

BTCS L2CAP transfer watchdog (NXP proprietary extension)

The CCC BTCS specification does not define any timeout for the L2CAP measurement transfer. As an NXP proprietary extension, the BTCS client provides a watchdog timer that prevents the CS procedure auto-restart loop from stalling when a BTCS L2CAP transfer is lost or never completes. The watchdog is client-side only and is always enabled. Its duration in seconds is configured through gBtcsTimeoutSeconds_c (default 3). The timer is armed when the client starts waiting for the peer transfer and is stopped as soon as the transfer completes. If it expires, the loop is only restarted once the full procedure sequence (maxNumProcedures) has been reached; otherwise the client just returns to waiting for the next procedure’s measurement data.

Parent topic:Localization scenarios