What is the correct syntax for using the AT+GCFA command to query for the handle of a characteristic or descriptor in the remote Server's GATT table?

Answer

The AT+GCFA command is used in conjunction with AT+UUID to locate the handle of a Characteristic or Descriptor in the server’s GATT table. To correctly use the command you must first be connected to the GATT Server device. Then, issue the AT+UUID command on the GATT Client for the Service UUID for each of the Characteristic and/or Descriptor UUIDs you want to access.

The AT+UUID command stores each UUID locally in a UUID index (uS, uC, or uD), which acts as a reference. The AT+GCFA command then uses these stored UUID indices to search the remote GATT table and return the correct attribute handle.

Example: Ezurio vSP Service

Suppose you are connected to a device exposing Ezurio’s vSP service. To search for the RX Characteristic handle or its CCCD descriptor, you must first store the UUIDs locally:

// vSP Service (569a1101b87f490c92cb11ba5ea5167c)

at+uuid 1, 569a1101b87f490c92cb11ba5ea5167c

// RX Characteristic (569a2001b87f490c92cb11ba5ea5167c)

at+uuid 2, 569a2001b87f490c92cb11ba5ea5167c

// TX Characteristic (569a2000b87f490c92cb11ba5ea5167c)

at+uuid 3, 569a2000b87f490c92cb11ba5ea5167c

// CCCD Descriptor (0x2902 = decimal 10498)

at+uuid 4, 10498

Searching with AT+GCFA

Now use the UUID indices to find the handles in the remote GATT table:

// Find RX Characteristic (service index 1, instance 0; characteristic index 2, instance 0)
at+gcfa 1,1,0,2,0
OK

// Example response with handle found:
FC:1, 32, 12   

// Find TX Characteristic
at+gcfa 1,1,0,3,0OKFC:1, 34, 16

// Find CCCD Descriptor under TX Characteristic
at+gcfa 1,1,0,3,0,4,0OKFD:1, 35

In the above examples:

  • The first parameter (1) is the connection handle.

  • The second parameter (1) is the Service UUID index.

  • The third parameter (0) is the service instance index (usually 0 unless multiple instances exist).

  • The fourth and fifth parameters (2,0 or 3,0) identify the Characteristic and its instance.

  • If included, the sixth and seventh parameters (4,0) specify the Descriptor and its instance.

Cross-check with GATT Table Map

You can verify these results against the full GATT Table Map obtained with AT+GCTM which will confirm that:

  • Service handle 30 corresponds to vSP Service.

  • Characteristic handles 32 and 34 correspond to RX and TX.

  • Descriptor handle 35 is the CCCD.