Functions

GATT Server API Functions

Functions

bStatus_t GATT_InitServer (void)
 Initialize the Generic Attribute Profile Server.
bStatus_t GATT_RegisterService (gattService_t *pService)
 Register a service attribute list with the GATT Server. A service is composed of characteristics or references to other services. Each characteristic contains a value and may contain optional information about the value. There are two types of services: primary service and secondary service.
bStatus_t GATT_DeregisterService (uint16 handle, gattService_t *pService)
 Deregister a service attribute list with the GATT Server.
void GATT_RegisterForReq (uint8 taskId)
 Register to receive incoming ATT Requests.
bStatus_t GATT_VerifyReadPermissions (uint16 connHandle, uint8 permissions)
 Verify the permissions of an attribute for reading.
bStatus_t GATT_VerifyWritePermissions (uint16 connHandle, uint8 permissions, attWriteReq_t *pReq)
 Verify the permissions of an attribute for writing.
uint8 GATT_ServiceChangedInd (uint16 connHandle, uint8 taskId)
 Send out a Service Changed Indication.
gattAttribute_tGATT_FindHandleUUID (uint16 startHandle, uint16 endHandle, const uint8 *pUUID, uint16 len, uint16 *pHandle)
 Find the attribute record for a given handle and UUID.
gattAttribute_tGATT_FindHandle (uint16 handle, uint16 *pHandle)
 Find the attribute record for a given handle.
gattAttribute_tGATT_FindNextAttr (gattAttribute_t *pAttr, uint16 endHandle, uint16 service, uint16 *pLastHandle)
 Find the next attribute of the same type for a given attribute.
uint16 GATT_ServiceNumAttrs (uint16 handle)
 Get the number of attributes for a given service.

Function Documentation

bStatus_t GATT_DeregisterService ( uint16  handle,
gattService_t pService 
)

Deregister a service attribute list with the GATT Server.

NOTE: It's the caller's responsibility to free the service attribute list returned from this API.

Parameters:
handle - handle of service to be deregistered
pService - pointer to deregistered service (to be returned)
Returns:
SUCCESS: Service deregistered successfully.
FAILURE: Service not found.
gattAttribute_t* GATT_FindHandle ( uint16  handle,
uint16 pHandle 
)

Find the attribute record for a given handle.

Parameters:
handle - handle to look for
pHandle - handle of owner of attribute (to be returned)
Returns:
Pointer to attribute record. NULL, otherwise.
gattAttribute_t* GATT_FindHandleUUID ( uint16  startHandle,
uint16  endHandle,
const uint8 pUUID,
uint16  len,
uint16 pHandle 
)

Find the attribute record for a given handle and UUID.

Parameters:
startHandle - first handle to look for
endHandle - last handle to look for
pUUID - pointer to UUID to look for
len - length of UUID
pHandle - handle of owner of attribute (to be returned)
Returns:
Pointer to attribute record. NULL, otherwise.
gattAttribute_t* GATT_FindNextAttr ( gattAttribute_t pAttr,
uint16  endHandle,
uint16  service,
uint16 pLastHandle 
)

Find the next attribute of the same type for a given attribute.

Parameters:
pAttr - pointer to attribute to find a next for
endHandle - last handle to look for
service - handle of owner service
pLastHandle - handle of last attribute (to be returned)
Returns:
Pointer to next attribute record. NULL, otherwise.
bStatus_t GATT_InitServer ( void   ) 

Initialize the Generic Attribute Profile Server.

Returns:
SUCCESS
void GATT_RegisterForReq ( uint8  taskId  ) 

Register to receive incoming ATT Requests.

Parameters:
taskId – task to forward requests to
Returns:
void
bStatus_t GATT_RegisterService ( gattService_t pService  ) 

Register a service attribute list with the GATT Server. A service is composed of characteristics or references to other services. Each characteristic contains a value and may contain optional information about the value. There are two types of services: primary service and secondary service.

A service definition begins with a service declaration and ends before the next service declaration or the maximum Attribute Handle.

A characteristic definition begins with a characteristic declaration and ends before the next characteristic or service declaration or maximum Attribute Handle.

The attribute server will only keep a pointer to the attribute list, so the calling application will have to maintain the code and RAM associated with this list.

Parameters:
pService - pointer to service attribute list to be registered
Returns:
SUCCESS: Service registered successfully.
INVALIDPARAMETER: Invalid service field.
FAILURE: Not enough attribute handles available.
bleMemAllocError: Memory allocation error occurred.
uint8 GATT_ServiceChangedInd ( uint16  connHandle,
uint8  taskId 
)

Send out a Service Changed Indication.

Parameters:
connHandle - connection to use
taskId - task to be notified of confirmation
Returns:
SUCCESS: Indication was sent successfully.
FAILURE: Service Changed attribute not found.
INVALIDPARAMETER: Invalid connection handle or request field.
MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.
bleNotConnected: Connection is down.
blePending: A confirmation is pending with this client.
uint16 GATT_ServiceNumAttrs ( uint16  handle  ) 

Get the number of attributes for a given service.

Parameters:
handle - service handle to look for
Returns:
Number of attributes. 0, otherwise.
bStatus_t GATT_VerifyReadPermissions ( uint16  connHandle,
uint8  permissions 
)

Verify the permissions of an attribute for reading.

Parameters:
connHandle - connection to use
permissions - attribute permissions
Returns:
SUCCESS: Attribute can be read.
ATT_ERR_READ_NOT_PERMITTED: Attribute cannot be read.
ATT_ERR_INSUFFICIENT_AUTHEN: Attribute requires authentication.
ATT_ERR_INSUFFICIENT_KEY_SIZE: Key Size used for encrypting is insufficient.
ATT_ERR_INSUFFICIENT_ENCRYPT: Attribute requires encryption.
bStatus_t GATT_VerifyWritePermissions ( uint16  connHandle,
uint8  permissions,
attWriteReq_t pReq 
)

Verify the permissions of an attribute for writing.

Parameters:
connHandle - connection to use
permissions - attribute permissions
pReq - pointer to write request
Returns:
SUCCESS: Attribute can be written.
ATT_ERR_READ_NOT_PERMITTED: Attribute cannot be written.
ATT_ERR_INSUFFICIENT_AUTHEN: Attribute requires authentication.
ATT_ERR_INSUFFICIENT_KEY_SIZE: Key Size used for encrypting is insufficient.
ATT_ERR_INSUFFICIENT_ENCRYPT: Attribute requires encryption.