BLE_API v2.1.3

Functions
BLE Based Functions
BLE Services » BLE Service Based Definitions

## Functions
BleStackStatus | queryIndexByHostIdGattRole (uint8_t hostId, BleGattRole gattRole, uint8_t maxCount, Service_Basic_Info *info, uint8_t *index)
BleStackStatus | setBLE_ServiceBasicInit (uint8_t hostId, BleGattRole gattRole, uint8_t maxCount, Service_Basic_Info *info, uint8_t *serviceIndex, uint8_t *serviceCount)
BleStackStatus | setBLEGATT_HandleCCCDWriteRequest (uint8_t *wqData, uint16_t wqDataLength, uint16_t *cccd)
BleStackStatus | setBLEGATT_HandleCCCDReadRequest (uint8_t hostId, uint16_t cccdHandleNum, uint16_t cccdValue)
BleStackStatus | setBLEGATT_HandleCCCDReadByTypeRequest (uint8_t hostId, uint16_t cccdHandleNum, uint16_t cccdValue)
BleStackStatus | setBLEGATT_HandleCCCDGeneralReadRequest (uint8_t hostId, uint8_t opcode, uint16_t cccdHandleNum, uint16_t cccdValue)
BleStackStatus | setBLEGATT_HandleReadBlobRequest (BLE_Event_AttParam *attParam, uint8_t *readData, uint8_t reaDataLength)

## Detailed Description

Here shows the definitions of functions.

## Function Documentation

## ◆ queryIndexByHostIdGattRole()

BleStackStatus queryIndexByHostIdGattRole | ( | uint8_t | hostId,
|  | BleGattRole | gattRole,
|  | uint8_t | maxCount,
|  | Service_Basic_Info * | info,
|  | uint8_t * | index
| ) |  |

Query Index from Service Registered Index Mapping Array

Parameters

  [in] | hostId | : the link's host id.
  [in] | gattRole | : BLE GATT role.
  [in] | maxCount | : maximum number of this registered service.
  [in] | info | : a pointer to basic service information.
  [out] | index | : a pointer to the index.

Return values

  BLESTACK_STATUS_ERR_INVALID_HOSTID | : error host id.
  BLESTACK_STATUS_SUCCESS | : setting success.

## ◆ setBLE_ServiceBasicInit()

BleStackStatus setBLE_ServiceBasicInit | ( | uint8_t | hostId,
|  | BleGattRole | gattRole,
|  | uint8_t | maxCount,
|  | Service_Basic_Info * | info,
|  | uint8_t * | serviceIndex,
|  | uint8_t * | serviceCount
| ) |  |

BLE Service Basic Initialization

Parameters

  [in] | hostId | : the link's host id.
  [in] | gattRole | : BLE GATT role.
  [in] | maxCount | : maximum number of this registered service.
  [out] | info | : a pointer to service basic information.
  [out] | serviceIndex | : a pointer to the index.
  [out] | serviceCount | : a pointer to the total count of this registered service.

Return values

  BLESTACK_STATUS_ERR_INVALID_HOSTID | : error host id.
  BLESTACK_STATUS_SUCCESS | : setting success.

## ◆ setBLEGATT_HandleCCCDGeneralReadRequest()

BleStackStatus setBLEGATT_HandleCCCDGeneralReadRequest | ( | uint8_t | hostId,
|  | uint8_t | opcode,
|  | uint16_t | cccdHandleNum,
|  | uint16_t | cccdValue
| ) |  |

BLE Set Automatically Handle CCCD Read Request or Read By Type Request From the Client

Note
  This function will automatically send Read Response or Read By Type Response to the client.
  This function supports for GATT role BLE_GATT_ROLE_SERVER only.

Parameters

  [in] | hostId | : the link's host id.
  [in] | opcode | : OPCODE_ATT_READ_REQUEST or OPCODE_ATT_FIND_BY_TYPE_VALUE_REQUEST
  [in] | cccdHandleNum | : cccd attribute handle number.
  [in] | cccdValue | : cccd attribute data.

Return values

  BLESTACK_STATUS_ERR_INVALID_HOSTID | : Invalid host id.
  BLESTACK_STATUS_ERR_NOT_SUPPORTED | : Invalid GATT role, only supports for server.
  BLESTACK_STATUS_ERR_INVALID_STATE | : Invalid BLE state, usually happens in there is no connection established with the host id.
  BLESTACK_STATUS_ERR_DB_PARSING_IN_PROGRESS | : Services and characteristics discovering have not completed.
  BLESTACK_STATUS_ERR_INVALID_HANDLE | : Invalid handle.
  BLESTACK_STATUS_ERR_INVALID_PARAM | : Invalid parameter, please check the input opcode.
  BLESTACK_STATUS_ERR_BUSY | : Message queue buffer full.
  BLESTACK_STATUS_SUCCESS | : Setting success.

## ◆ setBLEGATT_HandleCCCDReadByTypeRequest()

BleStackStatus setBLEGATT_HandleCCCDReadByTypeRequest | ( | uint8_t | hostId,
|  | uint16_t | cccdHandleNum,
|  | uint16_t | cccdValue
| ) |  |

BLE Set Handle CCCD Read By Type Request From the Client

Note
  This function will send Read By Type Response to the client.
  This function supports for GATT role BLE_GATT_ROLE_SERVER only.

Parameters

  [in] | hostId | : the link's host id.
  [in] | cccdHandleNum | : cccd attribute handle number.
  [in] | cccdValue | : cccd attribute data.

Return values

  BLESTACK_STATUS_ERR_INVALID_HOSTID | : Invalid host id.
  BLESTACK_STATUS_ERR_NOT_SUPPORTED | : Invalid GATT role, only supports for server.
  BLESTACK_STATUS_ERR_INVALID_STATE | : Invalid BLE state, usually happens in there is no connection established with the host id.
  BLESTACK_STATUS_ERR_DB_PARSING_IN_PROGRESS | : Services and characteristics discovering have not completed.
  BLESTACK_STATUS_ERR_INVALID_HANDLE | : Invalid handle.
  BLESTACK_STATUS_ERR_BUSY | : Message queue buffer full.
  BLESTACK_STATUS_SUCCESS | : Setting success.

## ◆ setBLEGATT_HandleCCCDReadRequest()

BleStackStatus setBLEGATT_HandleCCCDReadRequest | ( | uint8_t | hostId,
|  | uint16_t | cccdHandleNum,
|  | uint16_t | cccdValue
| ) |  |

BLE Set Handle CCCD Read Request From the Client

Note
  This function will send Read Response to the client.
  This function supports for GATT role BLE_GATT_ROLE_SERVER only.

Parameters

  [in] | hostId | : the link's host id.
  [in] | cccdHandleNum | : cccd attribute handle number.
  [in] | cccdValue | : cccd attribute data.

Return values

  BLESTACK_STATUS_ERR_INVALID_HOSTID | : Invalid host id.
  BLESTACK_STATUS_ERR_NOT_SUPPORTED | : Invalid GATT role, only supports for server.
  BLESTACK_STATUS_ERR_INVALID_STATE | : Invalid BLE state, usually happens in there is no connection established with the host id.
  BLESTACK_STATUS_ERR_DB_PARSING_IN_PROGRESS | : Services and characteristics discovering have not completed.
  BLESTACK_STATUS_ERR_INVALID_HANDLE | : Invalid handle.
  BLESTACK_STATUS_ERR_BUSY | : Message queue buffer full.
  BLESTACK_STATUS_SUCCESS | : Setting success.

## ◆ setBLEGATT_HandleCCCDWriteRequest()

BleStackStatus setBLEGATT_HandleCCCDWriteRequest | ( | uint8_t * | wqData,
|  | uint16_t | wqDataLength,
|  | uint16_t * | cccd
| ) |  |

BLE Set Handle CCCD Write Request From the Client

Note
  The server defined cccd value will be updated to the attribute data of write request from client.
  This function supports for GATT role BLE_GATT_ROLE_SERVER only.

Parameters

  [in] | wqData | : a pointer to the attribute data of write request.
  [in] | wqDataLength | : the length of the attribute data of write request.
  [out] | cccd | : a pointer to the server defined cccd which will be updated.

Return values

  BLESTACK_STATUS_ERR_INVALID_PARAM | : Invalid length of the attribute data of write request.
  BLESTACK_STATUS_SUCCESS | : Setting success.

## ◆ setBLEGATT_HandleReadBlobRequest()

BleStackStatus setBLEGATT_HandleReadBlobRequest | ( | BLE_Event_AttParam * | attParam,
|  | uint8_t * | readData,
|  | uint8_t | reaDataLength
| ) |  |

Handle BLE Service Read Blob Request

Parameters

  [in] | attParam | : a pointer to attribute parameter.
  [out] | readData | : a pointer to "read" data.
  [out] | reaDataLength | : the length of "read" data.

Return values

  BLESTACK_STATUS_ERR_INVALID_HOSTID | : Error host id.
  BLESTACK_STATUS_ERR_INVALID_STATE | : Invalid BLE state, usually happens in there is no connection established with the host id.
  BLESTACK_STATUS_ERR_INVALID_HANDLE | : Invalid handle.
  BLESTACK_STATUS_ERR_BUSY | : Message queue buffer full.
  BLESTACK_STATUS_SUCCESS | : Setting success.