TI BLE-Stack for Bluetooth 4.2 API Documentation
3.01.00.07
|
Files | |
file | simple_np_gatt.h |
SNP GATT Layer API. | |
Functions | |
uint8_t | SNP_addCharValueDecl (snpAddCharValueDeclReq_t *pReq, uint8_t uuidLen, snpAddCharValueDeclRsp_t *pRsp) |
SNP Add Characteristic Value Declaration. More... | |
uint8_t | SNP_addDescriptionValue (snpAddCharDescDeclReq_t *lDescReq, snpAddCharDescDeclRsp_t *lDescRsp) |
SNP Add Characteristic Descriptor Declaration. More... | |
uint8_t | SNP_addService (snpAddServiceReq_t *pReq, uint8_t uuidLen, snpAddServiceRsp_t *pRsp) |
SNP Add Service. More... | |
uint8_t | SNP_getAttrValue (snpGetAttrValueReq_t *pReq, snpGetAttrValueRsp_t *pRsp, uint16_t *pDataLenght) |
SNP Get Attribute Value. More... | |
uint8_t | SNP_getGATTParam (snpGetGattParamReq_t *pReq, snpGetGattParamRsp_t *pRsp, uint16_t *pDataLen) |
SNP Get GATT Parameter. More... | |
uint8_t | SNP_processCharConfigUpdatedCnf (snpCharCfgUpdatedRsp_t *pReq) |
SNP Characteristic Configuration Update Confirm (0x8B) More... | |
uint8_t | SNP_readCharCnf (snpCharReadCnf_t *pReq, uint16_t dataSize) |
SNP Read Characteristic Confirmation. More... | |
uint8_t | SNP_registerService (snpRegisterServiceRsp_t *pRsp) |
SNP Register Service. More... | |
uint8_t | SNP_sendNotifInd (snpNotifIndReq_t *pCmdStruct, int16_t length) |
SNP Send Notification Indication. More... | |
uint8_t | SNP_setAttrValue (snpSetAttrValueReq_t *pReq, uint16_t dataLenght, snpSetAttrValueRsp_t *pRsp) |
SNP Set Attribute Value. More... | |
uint8_t | SNP_setGATTParam (snpSetGattParamReq_t *pReq, uint16_t reqDataLen, snpSetGattParamRsp_t *pRsp) |
SNP Set GATT Parameter. More... | |
uint8_t | SNP_writeCharCnf (snpCharWriteCnf_t *pReq) |
SNP Write Characteristic Confirmation. More... | |
uint8_t SNP_addCharValueDecl | ( | snpAddCharValueDeclReq_t * | pReq, |
uint8_t | uuidLen, | ||
snpAddCharValueDeclRsp_t * | pRsp | ||
) |
SNP Add Characteristic Value Declaration.
AP -> NP (SNP_addCharValueDecl)
CMD 0 | CMD 1 |
---|---|
0x35 | 0x82 |
SNP_NPI_SYNC_REQ_TYPE | SNP_ADD_CHAR_VAL_DECL_REQ |
NP -> AP (SNP_addCharValueDecl)
CMD 0 | CMD 1 |
---|---|
0x75 | 0x82 |
SNP_NPI_SYNC_RSP_TYPE | SNP_ADD_CHAR_VAL_DECL_RSP |
This command is sent to the SNP to add the two Bluetooth Specification mandatory attributes for a characteristic:
This command should be sent after SNP_addService (0x81) command has been sent to begin service declaration.
It is possible to add optional attributes to the characteristic using SNP_addDescriptionValue (0x83) command.
This command must be called before adding additional attributes with SNP_addDescriptionValue (0x83).
If the GATT Notify or GATT Indicate properties are enabled, a CCCD characteristic must be added with the SNP_addDescriptionValue (0x83) command.
The TI BLE Stack expects the properties to be aligned logically with the permissions. For example, a characteristic with read properties would most likely have read permissions.
AP -> NP
snpAddCharValueDeclReq_t
Size | Description |
---|---|
1 Byte | Permissions of the value attribute GATT Attribute Access Permissions Bit Fields |
2 Byte | Properties of the value attribute GATT Characteristic Properties Bit Fields |
1 Byte | Reserved |
2 Byte | Reserved |
2 Byte | 2 Byte UUID dealing with UUID |
NP -> AP
snpAddCharValueDeclRsp_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
2 Byte | Attribute Handle |
[in] | pReq | : Add Characteristic Value & Declaration Request Structure snpAddCharValueDeclReq_t |
[in] | uuidLen | : 1 Byte UUID Length of Service |
[out] | pRsp | : Add Characteristic Value & Declaration Response Structure snpAddCharValueDeclRsp_t |
uint8_t SNP_addDescriptionValue | ( | snpAddCharDescDeclReq_t * | lDescReq, |
snpAddCharDescDeclRsp_t * | lDescRsp | ||
) |
SNP Add Characteristic Descriptor Declaration.
AP -> NP (SNP_addDescriptionValue)
CMD 0 | CMD 1 |
---|---|
0x35 | 0x83 |
SNP_NPI_SYNC_REQ_TYPE | SNP_ADD_CHAR_DESC_DECL_REQ |
NP -> AP (SNP_addDescriptionValue)
CMD 0 | CMD 1 |
---|---|
0x75 | 0x83 |
SNP_NPI_SYNC_RSP_TYPE | SNP_ADD_CHAR_DESC_DECL_RSP |
This command is used to add one or more of the following attributes to a characteristic:
User Description String CCCD Presentation format Server Characteristic Config (Reserved) Aggregate format Generic Attribute using short UUID Generic Attribute using long UUID
For User Description String, the attribute permissions is forced to be read-only.
All those attributes are optional. At least one needs to be added when using this command.
CCCD, Presentation Format, and User Description String attributes can be added once for each characteristic.
Trying to create a second will lead to a SNP_CMD_REJECTED.
If the NOTIFY and INDICATE properties are enabled by the CCCD attribute, and a GATT Clint writes to this attribute - SNP_writeCharCnf is forwarded to AP. AP must then determine if the write is authorized and send write to the attribute via SNP_setGATTParam.
AP -> NP
snpAddCharDescDeclReq_t
Size | Description |
---|---|
1 Byte | Header of Attributes to add SNP GATT Descriptors Header |
X Byte | Depending on Header, the length can very |
NP -> AP
snpAddCharDescDeclRsp_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
1 Byte | Header of Added Attributes SNP GATT Descriptors Header |
X Byte | Handles of Attributes added, depending on header |
snpAddCharDescDeclReq_t for SNP_ADD_CHAR_DESC_DECL_REQ
snpAddCharDescDeclRsp_t for SNP_ADD_CHAR_DESC_DECL_RSP
snpAddAttrGenShortUUID_t for Short UUID
snpAddAttrGenLongUUID_t for Long UUID
snpAddAttrCccd_t for CCCD
snpAddAttrFormat_t for Presentation Format
snpAddAttrUserDesc_t for User Description
[in] | lDescReq | : Add Descriptor Request Structure, snpAddCharDescDeclReq_t |
[out] | lDescRsp | : Add Descriptor Response Structure, snpAddCharDescDeclRsp_t |
uint8_t SNP_addService | ( | snpAddServiceReq_t * | pReq, |
uint8_t | uuidLen, | ||
snpAddServiceRsp_t * | pRsp | ||
) |
SNP Add Service.
AP -> NP (SNP_addService)
CMD 0 | CMD 1 |
---|---|
0x35 | 0x81 |
SNP_NPI_SYNC_REQ_TYPE | SNP_ADD_SERVICE_REQ |
NP -> AP (SNP_addService)
CMD 0 | CMD 1 |
---|---|
0x75 | 0x81 |
SNP_NPI_SYNC_RSP_TYPE | SNP_ADD_SERVICE_RSP |
The SNP Add Service command is sent to the SNP to start the addition of a new service to the GATT server running on the SNP.
This command should be followed by SNP_addCharValueDecl (0x82) command and optionally SNP_addDescriptionValue (0x83) command to add characteristics to the service.
Lastly, when all characteristics have been added, SNP_registerService (0x84) command should be sent to the device.
Only one service can be added at a time. That is, once this command has been sent, all characteristics must then be added and the service must to be registered before adding another service.
Services and characteristic cannot be added if the Device has started.
Device is started when SNP_startAdv or SNP_setAdvData is send to the SNP.
Once started, the only way to stop the device is to reset it.
When NP is reset, all previously added services and characteristics are lost.
AP -> NP
snpAddServiceReq_t
Size | Description |
---|---|
1 Byte | Type of the service to add Service Type |
2 Byte | 2 Byte UUID dealing with UUID |
NP -> AP
snpAddServiceRsp_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
[in] | pReq | : Add Service Request Structure, snpAddServiceReq_t |
[in] | uuidLen | : 1 Byte UUID Length of Service |
[out] | pRsp | : Add Service Response Structure, snpAddServiceRsp_t |
uint8_t SNP_getAttrValue | ( | snpGetAttrValueReq_t * | pReq, |
snpGetAttrValueRsp_t * | pRsp, | ||
uint16_t * | pDataLenght | ||
) |
SNP Get Attribute Value.
AP -> NP (SNP_getAttrValue)
CMD 0 | CMD 1 |
---|---|
0x35 | 0x85 |
SNP_NPI_SYNC_REQ_TYPE | SNP_GET_ATTR_VALUE_REQ |
NP -> AP (SNP_getAttrValue)
CMD 0 | CMD 1 |
---|---|
0x75 | 0x85 |
SNP_NPI_SYNC_RSP_TYPE | SNP_GET_ATTR_VALUE_RSP |
This command is sent to the SNP to retrieve the value of an attribute on the GATT server. This includes non-user added Services, the Device Information Service and the Generic Access Service.
This command can only be used to get read from User Description and Presentation Format Attributes. These attribute values are stored on SNP. Other attribute values are Reserved for Future Use.
For getting the value of a SNP managed attribute, the command SNP_getAttrValue (0x8D) should be used.
AP -> NP
snpGetAttrValueReq_t
Size | Description |
---|---|
2 Byte | Attribute Handle to get Value from |
NP -> AP
snpGetAttrValueRsp_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
2 Byte | Attribute Handle of where Value is from |
X Byte | Value of the Attribute Handle |
[in] | pReq | : Get Attribute Value Request Structure, snpGetAttrValueReq_t |
[out] | pRsp | : Get Attribute Value Response Structure, snpGetAttrValueRsp_t |
[out] | pDataLenght | : Length in Bytes of snpGetAttrValueRsp_t::pData |
uint8_t SNP_getGATTParam | ( | snpGetGattParamReq_t * | pReq, |
snpGetGattParamRsp_t * | pRsp, | ||
uint16_t * | pDataLen | ||
) |
SNP Get GATT Parameter.
AP -> NP (SNP_getGATTParam)
CMD 0 | CMD 1 |
---|---|
0x35 | 0x8D |
SNP_NPI_SYNC_REQ_TYPE | SNP_GET_GATT_PARAM_REQ |
NP -> AP (SNP_getGATTParam)
CMD 0 | CMD 1 |
---|---|
0x75 | 0x8D |
SNP_NPI_SYNC_RSP_TYPE | SNP_GET_GATT_PARAM_RSP |
This command is used to get the value of a Characteristic Value attribute from a characteristic managed by SNP GATT Server. This includes non-user added Services, the Device Information Service and the Generic Access Service.
For reading other types of Attributes, use SNP_getAttrValue (0x85)
For writing the value of a Characteristic Value Attribute, use SNP_setGATTParam (0x8C)
AP -> NP
snpGetGattParamReq_t
Size | Description |
---|---|
1 Byte | Service ID containing parameter Predefined services |
2 Byte | Parameter ID to get data from |
NP -> AP
snpGetGattParamRsp_t
Size | Description |
---|---|
1 Byte | Service ID containing parameter Predefined services |
2 Byte | Parameter ID to get data from |
X Byte | Parameter Data |
[in] | pReq | : Get GATT Parameter Request Structure, snpGetGattParamReq_t |
[out] | pRsp | : Get GATT Parameter Response Structure, snpGetGattParamRsp_t |
[out] | pDataLen | : Length in Bytes of snpGetGattParamRsp_t::pData |
uint8_t SNP_processCharConfigUpdatedCnf | ( | snpCharCfgUpdatedRsp_t * | pReq | ) |
SNP Characteristic Configuration Update Confirm (0x8B)
NP -> AP (N/A)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x8B |
SNP_NPI_ASYNC_CMD_TYPE | SNP_CCCD_UPDATED_IND |
AP -> NP (SNP_processCharConfigUpdatedCnf)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x8B |
SNP_NPI_ASYNC_CMD_TYPE | SNP_CCCD_UPDATED_CNF |
The SNP_CCCD_UPDATED_IND event is sent from the SNP when the remote GATT Client has requested to update the CCCD value added by the AP.
Upon receiving this event, if snpCharCfgUpdatedRsp_t::rspNeeded is SNP_RESPONSE_NEEDED then within 30 seconds the AP must:
If there is no response within 30 seconds, an ATT timeout will occur and BLE connection will be lost.
AP is responsible for remembering the CCCD value, accept/decline authorize the CCCD, and if associated characteristic value changes, the AP must send out notification or indication of the change.
If snpCharCfgUpdatedRsp_t::rspNeeded is SNP_RESPONSE_NOT_NEEDED then no response is needed.
NP -> AP
snpCharCfgUpdatedInd_t
Size | Description |
---|---|
2 Byte | Connection Handle generating request to write |
2 Byte | Handle to CCCD attribute being written to |
1 Byte | Indicate if Response is Needed from AP Options for Response Needed Field |
2 Byte | Value to write to CCCD |
AP -> NP
snpCharCfgUpdatedRsp_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
2 Byte | Connection Handle generating request to read |
[in] | pReq | : structure of the confirmation, see snpCharCfgUpdatedRsp_t |
uint8_t SNP_readCharCnf | ( | snpCharReadCnf_t * | pReq, |
uint16_t | dataSize | ||
) |
SNP Read Characteristic Confirmation.
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 |
If a GATT client requests a read of a characteristic that was added by the AP, the SNP GATT server will forward an SNP_CHAR_READ_IND (0x87) to the AP.
The AP then has 30 seconds to do the following:
If no response occurs in 30 seconds, an ATT timeout will occur and BLE connection will be lost.
NP -> AP
snpCharReadInd_t
Size | Description |
---|---|
2 Byte | Connection Handle generating request to read |
2 Byte | Attribute Handle of Characteristic Value to read from |
2 Byte | Offset in Bytes |
2 Byte | Max Size of Data to read |
AP -> NP
snpCharReadCnf_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
2 Byte | Connection Handle generating request to read |
2 Byte | Attribute Handle of Characteristic Value to read |
2 Byte | Offset in Bytes |
X Byte | Data to write to characteristic |
[in] | pReq | : Read Characteristic Confirmation Structure, snpCharReadCnf_t |
[in] | dataSize | : Length in Bytes of snpCharReadCnf_t::pData |
uint8_t SNP_registerService | ( | snpRegisterServiceRsp_t * | pRsp | ) |
SNP Register Service.
AP -> NP (SNP_registerService)
CMD 0 | CMD 1 |
---|---|
0x35 | 0x84 |
SNP_NPI_SYNC_REQ_TYPE | SNP_REGISTER_SERVICE_REQ |
NP -> AP (SNP_registerService)
CMD 0 | CMD 1 |
---|---|
0x75 | 0x84 |
SNP_NPI_SYNC_RSP_TYPE | SNP_REGISTER_SERVICE_RSP |
This command should be sent to the device to register the previously added service and characteristics to the devices GATT server.
This command should be sent after SNP_addService and SNP_addCharValueDecl; along with any optional attributes desired from SNP_addDescriptionValue.
When NP is reset, all previously added services and characteristics are lost.
AP -> NP
No Parameter Structure
NP -> AP
snpRegisterServiceRsp_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
2 Byte | Start Handle of the Registered Service |
2 Byte | End Handle of Registered Service |
[out] | pRsp | : Register Service Response Structure, snpRegisterServiceRsp_t |
uint8_t SNP_sendNotifInd | ( | snpNotifIndReq_t * | pCmdStruct, |
int16_t | length | ||
) |
SNP Send Notification Indication.
AP -> NP (SNP_sendNotifInd)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x89 |
SNP_NPI_ASYNC_CMD_TYPE | SNP_SEND_NOTIF_IND_REQ |
NP -> AP (N/A)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x89 |
SNP_NPI_ASYNC_CMD_TYPE | SNP_SEND_NOTIF_IND_CNF |
This command is used to request SNP to send a Notification or Indication to the GATT Client. This is only possible if a CCCD for the characteristic has been created and notifications / indications have been enabled by the GATT Client writing to the CCCD.
If CCCD Attribute of a characteristic is not configured correctly, the GATT server may not send out notification or indication.
Indications require a confirmation from the GATT client. Thus only one indication can be sent at a time. Once confirmation is received, it is then forwarded to AP via SNP_SEND_NOTIF_IND_CNF with a SNP_SUCCESS.
If no confirmation is received from the GATT Client within 30 seconds, SNP_SEND_NOTIF_IND_CNF with a SNP_FAILURE will be sent back to AP. An ATT timeout will also occur, dropping the BLE connection.
Notifications don't require a confirmation from the GATT Client. SNP will produce a SNP_SEND_NOTIF_IND_CNF with a SNP_SUCCESS when command has been forwarded to BLE-Stack Host.
The maximum size possible for a notification or indication value is ATT_MTU_SIZE. If the value sent is larger than ATT_MTU_SIZE bytes, it will be truncated.
AP -> NP
snpNotifIndReq_t
Size | Description |
---|---|
2 Byte | Connection Handle to send Notification/Indication |
2 Byte | Attribute Handle of Characteristic Value to notify/indicate |
1 Byte | Reserved |
1 Byte | Type of the Request SNP indication type |
X Byte | Characteristic Value to Send |
NP -> AP
snpNotifIndCnf_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
2 Byte | Connection Handle Notified/Indicated |
[in] | pCmdStruct | :Parameter Structure for Notification/Indication, snpNotifIndReq_t |
[in] | length | :Length in Bytes of snpNotifIndReq_t::pData |
uint8_t SNP_setAttrValue | ( | snpSetAttrValueReq_t * | pReq, |
uint16_t | dataLenght, | ||
snpSetAttrValueRsp_t * | pRsp | ||
) |
SNP Set Attribute Value.
AP -> NP (SNP_setAttrValue)
CMD 0 | CMD 1 |
---|---|
0x35 | 0x86 |
SNP_NPI_SYNC_REQ_TYPE | SNP_SET_ATTR_VALUE_REQ |
NP -> AP (SNP_setAttrValue)
CMD 0 | CMD 1 |
---|---|
0x75 | 0x86 |
SNP_NPI_SYNC_RSP_TYPE | SNP_SET_ATTR_VALUE_RSP |
This command is sent to the SNP in order to write the value of an attribute on the GATT server. This includes non-user added Services, the Device Information Service and the Generic Access Service.
This command can only be used to write User Description and Presentation Format Attributes.
For writing to Characteristic Value Attributes, use SNP_setGATTParam (0x8C)
For reading the value of a SNP managed attribute, the command SNP_getAttrValue (0x85) should be used.
AP -> NP
snpSetAttrValueReq_t
Size | Description |
---|---|
2 Byte | Attribute Handle to get Value from |
X Byte | Value to Set the Attribute |
NP -> AP
snpSetAttrValueRsp_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
2 Byte | Attribute Handle of where Value is from |
[in] | pReq | : Set Attribute Value Request Structure, snpSetAttrValueReq_t |
[in] | dataLenght | : Length in Bytes of snpSetAttrValueReq_t::pData |
[out] | pRsp | : Set Attribute Value Response Structure, snpSetAttrValueRsp_t |
uint8_t SNP_setGATTParam | ( | snpSetGattParamReq_t * | pReq, |
uint16_t | reqDataLen, | ||
snpSetGattParamRsp_t * | pRsp | ||
) |
SNP Set GATT Parameter.
AP -> NP (SNP_setGATTParam)
CMD 0 | CMD 1 |
---|---|
0x35 | 0x8C |
SNP_NPI_SYNC_REQ_TYPE | SNP_SET_GATT_PARAM_REQ |
NP -> AP (SNP_setGATTParam)
CMD 0 | CMD 1 |
---|---|
0x75 | 0x8C |
SNP_NPI_SYNC_RSP_TYPE | SNP_SET_GATT_PARAM_RSP |
This command is used to write the attribute value of a characteristic managed on the SNP GATT Server. This includes non-user added Services, the Device Information Service and the Generic Access Service.
This command can only write to Characteristic Value attributes.
For other types of Attributes, use SNP_setAttrValue (0x86)
For reading the value of a SNP managed attribute, the command SNP_getAttrValue (0x85) should be used.
The SNP_setGATTParam::reqDataLen should never exceed the maximum length of the attribute value
AP -> NP
snpSetGattParamReq_t
Size | Description |
---|---|
1 Byte | Service ID containing parameter Predefined services |
2 Byte | Parameter ID |
X Byte | Value to Set the Parameter |
NP -> AP
snpSetGattParamRsp_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
[in] | pReq | : Set GATT Parameter Request Structure, snpSetGattParamReq_t |
[in] | reqDataLen | : Length in Bytes of snpSetGattParamReq_t::pData |
[out] | pRsp | : Set GATT Parameter Response Structure, snpSetGattParamRsp_t |
uint8_t SNP_writeCharCnf | ( | snpCharWriteCnf_t * | pReq | ) |
SNP Write Characteristic Confirmation.
NP -> AP (N/A)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x88 |
SNP_NPI_ASYNC_CMD_TYPE | SNP_CHAR_WRITE_IND |
AP -> NP (SNP_writeCharCnf)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x88 |
SNP_NPI_ASYNC_CMD_TYPE | SNP_CHAR_WRITE_CNF |
If a GATT client requests a write of a characteristic that was added by the AP, the SNP GATT server will forward an SNP_CHAR_WRITE_IND (0x88) to the AP.
The AP then has 30 seconds to do the following:
If no response occurs in 30 seconds, an ATT timeout will occur and BLE connection will be lost.
NP -> AP
snpCharWriteInd_t
Size | Description |
---|---|
2 Byte | Connection Handle generating request to write |
2 Byte | Attribute Handle of Characteristic Value to write to |
1 Byte | Indicate if Response is Needed from AP Options for Response Needed Field |
2 Byte | Offset in Bytes |
X Byte | Data to write to characteristic |
AP -> NP
snpCharWriteCnf_t
Size | Description |
---|---|
1 Byte | Status list of status generated by the SNP. |
2 Byte | Connection Handle Confirmation |
[in] | pReq | : Characteristic Write Confirmation Request Structure, snpCharWriteCnf_t |