TI BLE-Stack for Bluetooth 4.2 API Documentation  3.01.00.07
SNP API: GATT

SNP GATT API Summary

Commands Acronyms Origin Type TL Cmd0 TL Cmd1 Parameter structure
SNP_ADD_SERVICE_REQ AP Sync Req SNP_NPI_SYNC_REQ_TYPE (0x35) SNP_ADD_SERVICE_REQ (0x81) snpAddServiceReq_t
SNP_ADD_SERVICE_RSP NP Sync Rsp SNP_NPI_SYNC_RSP_TYPE (0x75) SNP_ADD_SERVICE_RSP (0x81) snpAddServiceRsp_t
SNP_ADD_CHAR_VAL_DECL_REQ AP Sync Req SNP_NPI_SYNC_REQ_TYPE (0x35) SNP_ADD_CHAR_VAL_DECL_REQ (0x82) snpAddCharValueDeclReq_t
SNP_ADD_CHAR_VAL_DECL_RSP NP Sync Rsp SNP_NPI_SYNC_RSP_TYPE (0x75) SNP_ADD_CHAR_VAL_DECL_RSP (0x82) snpAddCharValueDeclRsp_t
SNP_ADD_CHAR_DESC_DECL_REQ AP Sync Req SNP_NPI_SYNC_REQ_TYPE (0x35) SNP_ADD_CHAR_DESC_DECL_REQ (0x83)
SNP_ADD_CHAR_DESC_DECL_RSP NP Sync Rsp SNP_NPI_SYNC_RSP_TYPE (0x75) SNP_ADD_CHAR_DESC_DECL_RSP (0x83)
SNP_REGISTER_SERVICE_REQ AP Sync Req SNP_NPI_SYNC_REQ_TYPE (0x35) SNP_REGISTER_SERVICE_REQ (0x84)
SNP_REGISTER_SERVICE_RSP NP Sync Rsp SNP_NPI_SYNC_RSP_TYPE (0x75) SNP_REGISTER_SERVICE_RSP (0x84) snpRegisterServiceRsp_t
SNP_GET_ATTR_VALUE_REQ AP Sync Req SNP_NPI_SYNC_REQ_TYPE (0x35) SNP_GET_ATTR_VALUE_REQ (0x85) snpGetAttrValueReq_t
SNP_GET_ATTR_VALUE_RSP NP Sync Rsp SNP_NPI_SYNC_RSP_TYPE (0x75) SNP_GET_ATTR_VALUE_RSP (0x85) snpGetAttrValueRsp_t
SNP_SET_ATTR_VALUE_REQ AP Sync Req SNP_NPI_SYNC_REQ_TYPE (0x35) SNP_SET_ATTR_VALUE_REQ (0x86) snpSetAttrValueReq_t
SNP_SET_ATTR_VALUE_RSP NP Sync Rsp SNP_NPI_SYNC_RSP_TYPE (0x75) SNP_SET_ATTR_VALUE_RSP (0x86) snpSetAttrValueRsp_t
SNP_CHAR_READ_IND NP Async SNP_NPI_ASYNC_CMD_TYPE (0x55) SNP_CHAR_READ_IND (0x87) snpCharReadInd_t
SNP_CHAR_READ_CNF AP Async SNP_NPI_ASYNC_CMD_TYPE (0x55) SNP_CHAR_READ_CNF (0x87) snpCharReadCnf_t
SNP_CHAR_WRITE_IND NP Async SNP_NPI_ASYNC_CMD_TYPE (0x55) SNP_CHAR_WRITE_IND (0x88) snpCharWriteInd_t
SNP_CHAR_WRITE_CNF AP Async SNP_NPI_ASYNC_CMD_TYPE (0x55) SNP_CHAR_WRITE_CNF (0x88) snpCharWriteCnf_t
SNP_SEND_NOTIF_IND_REQ AP Async SNP_NPI_ASYNC_CMD_TYPE (0x55) SNP_SEND_NOTIF_IND_REQ (0x89) snpNotifIndReq_t
SNP_SEND_NOTIF_IND_CNF NP Async SNP_NPI_ASYNC_CMD_TYPE (0x55) SNP_SEND_NOTIF_IND_CNF (0x89) snpNotifIndCnf_t
SNP_CCCD_UPDATED_IND NP Async SNP_NPI_ASYNC_CMD_TYPE (0x55) SNP_CCCD_UPDATED_IND (0x8B) snpCharCfgUpdatedInd_t
SNP_CCCD_UPDATED_CNF AP Async SNP_NPI_ASYNC_CMD_TYPE (0x55) SNP_CCCD_UPDATED_CNF (0x8B) snpCharCfgUpdatedRsp_t
SNP_SET_GATT_PARAM_REQ AP Sync Req SNP_NPI_SYNC_REQ_TYPE (0x35) SNP_SET_GATT_PARAM_REQ (0x8C) snpSetGattParamReq_t
SNP_SET_GATT_PARAM_RSP NP Sync Rsp SNP_NPI_SYNC_RSP_TYPE (0x75) SNP_SET_GATT_PARAM_RSP (0x8C) snpSetGattParamRsp_t
SNP_GET_GATT_PARAM_REQ AP Sync Req SNP_NPI_SYNC_REQ_TYPE (0x35) SNP_GET_GATT_PARAM_REQ (0x8D) snpGetGattParamReq_t
SNP_GET_GATT_PARAM_RSP NP Sync Rsp SNP_NPI_SYNC_RSP_TYPE (0x75) SNP_GET_GATT_PARAM_RSP (0x8D) snpGetGattParamRsp_t

All these command have some parameters. The parameters can be found/set using the indicated Parameter structure. All Parameter/Structures should be little-endian format (LSB first). For UUID parameters, dealing with UUID

SNP Characteristic Read Indication (0x87)

NP -> AP (N/A)

CMD 0 CMD 1
0x55 0x87
SNP_NPI_ASYNC_CMD_TYPE SNP_CHAR_READ_IND

AP -> NP (SNP_readCharCnf)

CMD 0 CMD 1
0x55 0x87
SNP_NPI_ASYNC_CMD_TYPE SNP_CHAR_READ_CNF

The SNP_CHAR_READ_IND Event is sent by the SNP when a remote GATT client wants to read a characteristic value managed by the AP.

The AP must answer with SNP_readCharCnf / SNP_CHAR_READ_CNF within 30 seconds. If there's no response, an ATT Timeout will occur and the BLE connection will be lost.

A characteristic value can be up to 512 Bytes long. However, not more than ATT_MTU_SIZE can be read at once by a ATT operation.

If the characteristic size is bigger than ATT_MTU_SIZE, the remote GATT client will send several SNP_CHAR_READ_IND, until it reads the complete value. There is several different ways for the GATT client to fully read a characteristic; one way is that each read request sent by the GATT client is translated in a SNP_CHAR_READ_IND with snpCharReadInd_t.

The snpCharReadInd_t::offset represents the start of the data to read, the snpCharReadInd_t::maxSize represents maximum size of the characteristic.

The AP needs to reply with the SNP_readCharCnf command which contains the data payload. The AP will indicate the offset the data were read from, the size of the data, and the data with snpCharReadCnf_t.

The default ATT_MTU_SIZE is set to 27. If MTU Size is changed (negotiated between GATT server and GATT client), then a SNP_EVENT_IND with SNP_ATT_MTU_EVT event will be send by the NP to the AP The AP cannot initiate this change.

Corresponding Events/Commands

SNP_CHAR_READ_IND (from SNP) | SNP_CHAR_READ_CNF (from AP)

NP -> AP
snpCharReadInd_t

Size Description
2 Byte Connection Handle
2 Byte Attribute Handle
2 Byte Offset in Bytes
2 Byte Max Size
Related Structures

snpCharReadInd_t for SNP_CHAR_READ_IND
snpCharReadCnf_t for SNP_CHAR_READ_CNF

SNP Characteristic Write Indication (0x88)

NP -> AP (N/A)

CMD 0 CMD 1
0x55 0x88
SNP_NPI_ASYNC_CMD_TYPE SNP_CHAR_WRITE_IND

AP -> NP (SNP_readCharCnf)

CMD 0 CMD 1
0x55 0x88
SNP_NPI_ASYNC_CMD_TYPE SNP_CHAR_WRITE_CNF

The SNP_CHAR_WRITE_IND Event is sent by the SNP when a remote GATT client wants to write a characteristic value managed by the AP.

The AP needs to answer with a SNP_CHAR_WRITE_CNF / SNP_writeCharCnf within 30 seconds.

The GATT client may request a partial write, hence the usage of the offset where the write should begin relative to the beginning of the characteristic value (the offset is a number of Bytes). The characteristic value length is application specific. Neither the SNP or the AP SNP library know the length of the characteristic value.

If the GATT client starts to write a characteristic value with offset 0, the entire value will be written. If the GATT client starts to write a characteristic value with an offset different than 0, a partial write will occur.

It is the responsibility of the application to know the length of each characteristic value.

The snpCharWriteInd_t::rspNeeded field set to 1 indicates that the AP must send SNP_CHAR_WRITE_CNF / SNP_writeCharCnf within 30 seconds. If this field is set to 0, the SNP_charWrite_rsp is not needed. This can happen if a ATT_WRITE_CMD operation has been used by the remote GATT client. If a confirmation is send anyway, it will be ignored by the NP.

The application can also have their own permission mechanism and rules. In this case it is the responsibility of the application to deny the writing of the value by return a error status with SNP_CHAR_WRITE_CNF / SNP_writeCharCnf.

Corresponding Events/Commands

SNP_CHAR_WRITE_IND (from SNP) | SNP_CHAR_WRITE_CNF (from AP)

NP -> AP
snpCharWriteInd_t

Size Description
2 Byte Connection Handle
2 Byte Attribute Handle
1 Byte Response Needed? Options for Response Needed Field
2 Byte Offset in Bytes
X Byte Data to be Written
Related Structures

snpCharWriteInd_t for SNP_CHAR_WRITE_IND
snpCharWriteCnf_t for SNP_CHAR_WRITE_CNF

Copyright 2017, Texas Instruments Incorporated