-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcy_ble_custom.c
564 lines (483 loc) · 25 KB
/
cy_ble_custom.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
/***************************************************************************//**
* \file cy_ble_custom.c
* \version 3.60
*
* \brief
* Contains the source code for the Custom service.
*
********************************************************************************
* \copyright
* Copyright 2017-2021, Cypress Semiconductor Corporation. All rights reserved.
* You may use this file only in accordance with the license, terms, conditions,
* disclaimers, and limitations in the end user license agreement accompanying
* the software package with which this file was provided.
*******************************************************************************/
#include "cy_ble_event_handler.h"
#if defined(CY_IP_MXBLESS)
#if CY_BLE_LIB_HOST_CORE
/*******************************************************************************
* Private Function Prototypes
*******************************************************************************/
static void Cy_BLE_CUSTOMC_DiscoverServiceEventHandler(const cy_stc_ble_disc_srv_info_t *discServInfo);
static void Cy_BLE_CUSTOMC_DiscoverCharacteristicsEventHandler(const cy_stc_ble_disc_char_info_t *discCharInfo);
static void Cy_BLE_CUSTOMC_DiscoverCharDescriptorsEventHandler(const cy_stc_ble_disc_descr_info_t *discDescrInfo);
static void Cy_BLE_CUSTOMC_GetCharRange(cy_stc_ble_disc_range_info_t *charRangeInfo);
static cy_en_ble_gatt_err_code_t Cy_BLE_CUSTOM_EventHandler(uint32_t eventCode, void *eventParam);
/*******************************************************************************
* Global Variables
*******************************************************************************/
/* The pointer to a global BLE CUSTOM server config structure */
const cy_stc_ble_customs_config_t *cy_ble_customsConfigPtr = NULL;
/* The pointer to a global BLE CUSTOM client config structure */
const cy_stc_ble_customc_config_t *cy_ble_customcConfigPtr = NULL;
/******************************************************************************
* Function Name: Cy_BLE_CUSTOMS_Init
***************************************************************************//**
*
* This function initializes server of the Custom service.
*
* \param config: The configuration structure for the Custom service.
*
* \return
* \ref cy_en_ble_api_result_t : The return value indicates whether the function succeeded or
* failed. The following are possible error codes.
*
* Error Codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | The function completed successfully.
* CY_BLE_ERROR_INVALID_PARAMETER | On specifying NULL as input parameter.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_CUSTOMS_Init(const cy_stc_ble_customs_config_t *config)
{
cy_en_ble_api_result_t apiResult = CY_BLE_SUCCESS;
if(config == NULL)
{
apiResult = CY_BLE_ERROR_INVALID_PARAMETER;
}
else
{
/* Register the pointer to the config structure */
cy_ble_customsConfigPtr = config;
}
return(apiResult);
}
/******************************************************************************
* Function Name: Cy_BLE_CUSTOMC_Init
***************************************************************************//**
*
* This function initializes client of the Custom service.
*
* \param config: The configuration structure for the Custom service.
*
* \return
* \ref cy_en_ble_api_result_t : The return value indicates whether the function succeeded or
* failed. The following are possible error codes.
*
* Error Codes | Description
* ------------ | -----------
* CY_BLE_SUCCESS | The function completed successfully.
* CY_BLE_ERROR_INVALID_PARAMETER | On specifying NULL as input parameter.
* CY_BLE_ERROR_MEMORY_ALLOCATION_FAILED | Buffer overflow in the registration callback.
*
******************************************************************************/
cy_en_ble_api_result_t Cy_BLE_CUSTOMC_Init(const cy_stc_ble_customc_config_t *config)
{
cy_en_ble_api_result_t apiResult;
if(config == NULL)
{
apiResult = CY_BLE_ERROR_INVALID_PARAMETER;
}
else
{
/* Register the pointer to the config structure */
cy_ble_customcConfigPtr = config;
/* Register an event Handler for the Custom service */
apiResult = Cy_BLE_RegisterServiceEventHandler(&Cy_BLE_CUSTOM_EventHandler);
{
uint32_t discIdx;
uint32_t locCharIdx;
for(discIdx = 0u; discIdx < cy_ble_configPtr->params->maxClientCount; discIdx++)
{
uint32_t locServIdx;
for(locServIdx = 0u; locServIdx < cy_ble_customcConfigPtr->serviceCount; locServIdx++)
{
uint32 servCnt = cy_ble_configPtr->context->discServiCount;
uint32 customServIdx = cy_ble_customcConfigPtr->serviceDiscIdx + locServIdx;
if(cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) + customServIdx].range.startHandle ==
CY_BLE_GATT_INVALID_ATTR_HANDLE_VALUE)
{
for(locCharIdx = 0u; locCharIdx < cy_ble_customcConfigPtr->attrInfo[locServIdx].charCount;
locCharIdx++)
{
uint32_t locDescIdx;
cy_ble_customcConfigPtr->attrInfo[locServIdx].customServChar[locCharIdx].
customServCharHandle[discIdx] = 0u;
for(locDescIdx = 0u; locDescIdx < cy_ble_customcConfigPtr->attrInfo[locServIdx].
customServChar[locCharIdx].descCount; locDescIdx++)
{
cy_ble_customcConfigPtr->attrInfo[locServIdx].customServChar[locCharIdx].
customServCharDesc[locDescIdx].descHandle[discIdx] = 0u;
}
/* Initialize uuid */
cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) + customServIdx].uuid = 0x0000u;
}
}
/* Initialize uuid */
if(cy_ble_customcConfigPtr->attrInfo[locServIdx].uuidFormat == 1u)
{
cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) + customServIdx].uuid =
*(uint16 *)cy_ble_customcConfigPtr->attrInfo[locServIdx].uuid;
}
else
{
cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) + customServIdx].uuid = 0x0000u;
}
}
}
}
}
return(apiResult);
}
/******************************************************************************
* Function Name: Cy_BLE_CUSTOMC_DiscoverServiceEventHandler
***************************************************************************//**
*
* This function is called on receiving a Read By Group Response event or
* Read response with the 128-bit service uuid.
*
* \param discServInfo: The pointer to a service information structure.
*
******************************************************************************/
static void Cy_BLE_CUSTOMC_DiscoverServiceEventHandler(const cy_stc_ble_disc_srv_info_t *discServInfo)
{
uint32_t discIdx = Cy_BLE_GetDiscoveryIdx(discServInfo->connHandle);
uint32_t fFlag = 0u;
uint32_t j;
/* Services with the 128-bit UUID have discServInfo->uuid equal to 0 and the address to
* the 128-uuid is stored in cy_ble_customCServ.uuid128.
*/
for(j = 0u; (j < cy_ble_customcConfigPtr->serviceCount) && (fFlag == 0u); j++)
{
if((memcmp(cy_ble_customcConfigPtr->attrInfo[j].uuid, &discServInfo->srvcInfo->uuid.uuid128,
CY_BLE_GATT_128_BIT_UUID_SIZE) == 0) &&
(cy_ble_customcConfigPtr->attrInfo[j].uuidFormat == CY_BLE_GATT_128_BIT_UUID_FORMAT))
{
uint32 servCnt = cy_ble_configPtr->context->discServiCount;
uint32 customServIdx = cy_ble_customcConfigPtr->serviceDiscIdx + j;
if(cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) + customServIdx].range.startHandle ==
CY_BLE_GATT_INVALID_ATTR_HANDLE_VALUE)
{
cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) + customServIdx].range.startHandle =
discServInfo->srvcInfo->range.startHandle;
cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) + customServIdx].range.endHandle =
discServInfo->srvcInfo->range.endHandle;
cy_ble_customcConfigPtr->attrInfo[j].customServHandle[discIdx] =
discServInfo->srvcInfo->range.startHandle;
cy_ble_configPtr->context->discovery[discIdx].servCount++;
fFlag = 1u;
}
/* Indicate that request was handled */
cy_ble_eventHandlerFlag &= (uint8_t) ~CY_BLE_CALLBACK;
}
}
}
/******************************************************************************
* Function Name: Cy_BLE_CUSTOMC_DiscoverCharacteristicsEventHandler
***************************************************************************//**
*
* This function is called on receiving a #CY_BLE_EVT_GATTC_READ_BY_TYPE_RSP
* event. Based on the service index,the appropriate data structure is populated
* using the data received as part of the callback.
*
* \param discCharInfo: The pointer to the characteristic information structure.
*
******************************************************************************/
static void Cy_BLE_CUSTOMC_DiscoverCharacteristicsEventHandler(const cy_stc_ble_disc_char_info_t *discCharInfo)
{
static cy_ble_gatt_db_attr_handle_t *customsLastEndHandle[CY_BLE_MAX_CONNECTION_INSTANCES] = { 0u };
static uint32_t discoveryLastServ[CY_BLE_MAX_CONNECTION_INSTANCES] = { 0u };
uint32_t discIdx = Cy_BLE_GetDiscoveryIdx(discCharInfo->connHandle);
uint32_t servIdx = cy_ble_configPtr->context->discovery[discIdx].servCount - cy_ble_customcConfigPtr->serviceDiscIdx;
uint32_t customDiscIdx = cy_ble_customcConfigPtr->serviceDiscIdx;
uint32_t locReqHandle = 0u;
uint32_t locCharIndex;
if((cy_ble_configPtr->context->discovery[discIdx].servCount >= customDiscIdx) &&
(cy_ble_configPtr->context->discovery[discIdx].servCount <=
((customDiscIdx + cy_ble_customcConfigPtr->serviceCount) - 1u)))
{
/* Update the last characteristic endHandle to the declaration handle of this characteristic */
if(customsLastEndHandle[discIdx] != NULL)
{
if(discoveryLastServ[discIdx] == servIdx)
{
*customsLastEndHandle[discIdx] = discCharInfo->charDeclHandle - 1u;
}
customsLastEndHandle[discIdx] = NULL;
}
for(locCharIndex = 0u; (locCharIndex < cy_ble_customcConfigPtr->attrInfo[servIdx].charCount) && (locReqHandle == 0u);
locCharIndex++)
{
uint32_t fFlag = 0u;
/* Support the 128-bit uuid */
if((discCharInfo->uuidFormat == CY_BLE_GATT_128_BIT_UUID_FORMAT) &&
(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[locCharIndex].uuidFormat ==
CY_BLE_GATT_128_BIT_UUID_FORMAT))
{
if(memcmp(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[locCharIndex].uuid,
&discCharInfo->uuid.uuid128, CY_BLE_GATT_128_BIT_UUID_SIZE) == 0)
{
fFlag = 1u;
}
}
/* And support the 16-bit uuid */
if((discCharInfo->uuidFormat == CY_BLE_GATT_16_BIT_UUID_FORMAT) &&
(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[locCharIndex].uuidFormat ==
CY_BLE_GATT_16_BIT_UUID_FORMAT))
{
if(memcmp(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[locCharIndex].uuid,
&discCharInfo->uuid.uuid16, CY_BLE_GATT_16_BIT_UUID_SIZE) == 0)
{
fFlag = 1u;
}
}
if((fFlag == 1u) &&
(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[locCharIndex].customServCharHandle[discIdx] ==
CY_BLE_GATT_INVALID_ATTR_HANDLE_VALUE))
{
cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[locCharIndex].customServCharHandle[discIdx] =
discCharInfo->valueHandle;
cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[locCharIndex].properties[discIdx] =
discCharInfo->properties;
/* Init the pointer to the characteristic endHandle */
customsLastEndHandle[discIdx] = &cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[locCharIndex].
customServCharEndHandle[discIdx];
/* Init the service index of the discovered characteristic */
discoveryLastServ[discIdx] = servIdx;
locReqHandle = 1u;
}
}
/* Init the characteristic endHandle to the service endHandle.
* The characteristic endHandle will be updated to the declaration
* Handler of the following characteristic,
* in the following characteristic discovery procedure. */
if(customsLastEndHandle[discIdx] != NULL)
{
uint32 servCnt = cy_ble_configPtr->context->discServiCount;
*customsLastEndHandle[discIdx] = cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) +
cy_ble_configPtr->context->discovery[discIdx].servCount].range.endHandle;
}
/* Indicate that the request was handled */
cy_ble_eventHandlerFlag &= (uint8_t) ~CY_BLE_CALLBACK;
}
}
/******************************************************************************
* Function Name: Cy_BLE_CUSTOMC_GetCharRange
***************************************************************************//**
*
* Returns a possible range of the current characteristic descriptor via
* the input parameter charRangeInfo->range.
*
* \param *charRangeInfo: The pointer to the descriptor range information structure.
*
******************************************************************************/
static void Cy_BLE_CUSTOMC_GetCharRange(cy_stc_ble_disc_range_info_t *charRangeInfo)
{
uint32_t discIdx = Cy_BLE_GetDiscoveryIdx(charRangeInfo->connHandle);
uint32_t customDiscIdx = cy_ble_customcConfigPtr->serviceDiscIdx;
uint32_t exitFlag = 0u;
if((cy_ble_configPtr->context->discovery[discIdx].servCount >= customDiscIdx) &&
(cy_ble_configPtr->context->discovery[discIdx].servCount <= ((customDiscIdx +
cy_ble_customcConfigPtr->serviceCount) - 1u)))
{
uint32_t servIdx = cy_ble_configPtr->context->discovery[discIdx].servCount - customDiscIdx;
if(charRangeInfo->srviIncIdx != CY_BLE_DISCOVERY_INIT)
{
cy_ble_configPtr->context->discovery[discIdx].charCount++;
}
while((cy_ble_configPtr->context->discovery[discIdx].charCount <
cy_ble_customcConfigPtr->attrInfo[servIdx].charCount) && (exitFlag == 0u))
{
uint32_t charIdx = cy_ble_configPtr->context->discovery[discIdx].charCount;
if((cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].descCount > 0u) &&
(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].customServCharEndHandle[discIdx] != 0u))
{
/* Read the characteristic range */
charRangeInfo->range.startHandle = cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].
customServCharHandle[discIdx] + 1u;
charRangeInfo->range.endHandle = cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].
customServCharEndHandle[discIdx];
exitFlag = 1u;
}
else
{
cy_ble_configPtr->context->discovery[discIdx].charCount++;
}
}
/* Indicate that the request was handled */
cy_ble_eventHandlerFlag &= (uint8_t) ~CY_BLE_CALLBACK;
}
}
/******************************************************************************
* Function Name: Cy_BLE_CUSTOMC_DiscoverCharDescriptorsEventHandler
***************************************************************************//**
*
* This function is called on receiving a #CY_BLE_EVT_GATTC_FIND_INFO_RSP event.
* Based on the descriptor UUID, the appropriate data structure is populated using
* the data received as part of the callback.
*
* \param discDescrInfo: The pointer to the descriptor information structure.
*
******************************************************************************/
static void Cy_BLE_CUSTOMC_DiscoverCharDescriptorsEventHandler(const cy_stc_ble_disc_descr_info_t *discDescrInfo)
{
uint32_t locDescIndex;
uint32_t locReqHandle = 0u;
uint32_t discIdx = Cy_BLE_GetDiscoveryIdx(discDescrInfo->connHandle);
uint32_t customDiscIdx = cy_ble_customcConfigPtr->serviceDiscIdx;
if((cy_ble_configPtr->context->discovery[discIdx].servCount >= customDiscIdx) &&
(cy_ble_configPtr->context->discovery[discIdx].servCount <= ((customDiscIdx +
cy_ble_customcConfigPtr->serviceCount) - 1u)))
{
uint32_t servIdx = cy_ble_configPtr->context->discovery[discIdx].servCount - customDiscIdx;
uint32_t charIdx = cy_ble_configPtr->context->discovery[discIdx].charCount;
for(locDescIndex = 0u; (locDescIndex < cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].descCount) &&
(locReqHandle == 0u); locDescIndex++)
{
uint32_t fFlag = 0u;
if((discDescrInfo->uuidFormat == CY_BLE_GATT_128_BIT_UUID_FORMAT) &&
(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].customServCharDesc[locDescIndex].
uuidFormat == CY_BLE_GATT_128_BIT_UUID_FORMAT))
{
if(memcmp(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].
customServCharDesc[locDescIndex].uuid, &discDescrInfo->uuid.uuid128,
CY_BLE_GATT_128_BIT_UUID_SIZE) == 0)
{
fFlag = 1u;
}
}
if((discDescrInfo->uuidFormat == CY_BLE_GATT_16_BIT_UUID_FORMAT) &&
(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].customServCharDesc[locDescIndex].
uuidFormat == CY_BLE_GATT_16_BIT_UUID_FORMAT))
{
if(memcmp(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].
customServCharDesc[locDescIndex].uuid, &discDescrInfo->uuid.uuid16,
CY_BLE_GATT_16_BIT_UUID_SIZE) == 0)
{
fFlag = 1u;
}
}
if((fFlag == 1u) &&
(cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].customServCharDesc[locDescIndex].
descHandle[discIdx] == CY_BLE_GATT_INVALID_ATTR_HANDLE_VALUE))
{
cy_ble_customcConfigPtr->attrInfo[servIdx].customServChar[charIdx].customServCharDesc[locDescIndex].
descHandle[discIdx] = discDescrInfo->descrHandle;
locReqHandle = 1u;
}
}
}
}
/******************************************************************************
* Function Name: Cy_BLE_CUSTOM_EventHandler
***************************************************************************//**
*
* Handles events from the BLE Stack for the Custom service.
*
* \param eventCode: The event code.
* \param eventParam: The event parameters.
*
* \return
* The return value is of the type cy_en_ble_gatt_err_code_t.
*
******************************************************************************/
static cy_en_ble_gatt_err_code_t Cy_BLE_CUSTOM_EventHandler(uint32_t eventCode,
void *eventParam)
{
if(eventCode > (uint32_t)CY_BLE_EVT_MAX)
{
/* Handling service-specific events */
switch((cy_en_ble_evt_t)eventCode)
{
/* Discovery events */
case CY_BLE_EVT_GATTC_DISC_SERVICE:
Cy_BLE_CUSTOMC_DiscoverServiceEventHandler((cy_stc_ble_disc_srv_info_t*)eventParam);
break;
case CY_BLE_EVT_GATTC_DISC_CHAR:
Cy_BLE_CUSTOMC_DiscoverCharacteristicsEventHandler((cy_stc_ble_disc_char_info_t*)eventParam);
break;
case CY_BLE_EVT_GATTC_DISC_DESCR:
Cy_BLE_CUSTOMC_DiscoverCharDescriptorsEventHandler((cy_stc_ble_disc_descr_info_t*)eventParam);
break;
case CY_BLE_EVT_GATTC_DISC_DESCR_GET_RANGE:
Cy_BLE_CUSTOMC_GetCharRange((cy_stc_ble_disc_range_info_t*)eventParam);
break;
default:
break;
}
}
else
{
/* Handling GATT Client events */
switch((cy_en_ble_event_t)eventCode)
{
case CY_BLE_EVT_GATTC_READ_RSP:
case CY_BLE_EVT_GATTC_READ_MULTI_RSP:
{
cy_stc_ble_gattc_read_rsp_param_t *eventParamCast = (cy_stc_ble_gattc_read_rsp_param_t*)eventParam;
cy_stc_ble_conn_handle_t locConnHandle = eventParamCast->connHandle;
uint32_t discIdx = Cy_BLE_GetDiscoveryIdx(locConnHandle);
/* Read the response with the 128-bit included service uuid */
if((Cy_BLE_GetConnectionState(locConnHandle) == CY_BLE_CONN_STATE_CLIENT_INCL_DISCOVERING) &&
(discIdx < cy_ble_configPtr->params->maxClientCount) &&
(cy_ble_configPtr->context->discovery[discIdx].inclInfo.inclDefHandle != 0u))
{
cy_stc_ble_disc_srvc128_info_t discServ128Info;
cy_stc_ble_disc_srv_info_t locDiscServInfo;
uint32_t servCnt = cy_ble_configPtr->context->discServiCount;
/* Store the service range */
discServ128Info.range = cy_ble_configPtr->context->discovery[discIdx].inclInfo.inclHandleRange;
(void)memcpy((void*)discServ128Info.uuid.uuid128.value, (void*)eventParamCast->value.val,
(uint32_t)eventParamCast->value.len);
locDiscServInfo.srvcInfo = &discServ128Info;
locDiscServInfo.connHandle = locConnHandle;
Cy_BLE_CUSTOMC_DiscoverServiceEventHandler(&locDiscServInfo);
/* Re-initiate the function, setting the start
* handle to the attribute handle which is placed next to the one used in
* the above step.
*/
discServ128Info.range.startHandle =
cy_ble_configPtr->context->discovery[discIdx].inclInfo.inclDefHandle + 1u;
discServ128Info.range.endHandle =
cy_ble_configPtr->context->serverInfo[(discIdx * servCnt) +
cy_ble_configPtr->context->discovery[discIdx].servCount].range.endHandle;
if(discServ128Info.range.startHandle <= discServ128Info.range.endHandle)
{
cy_stc_ble_gattc_read_by_type_req_t requestParam;
requestParam.range = discServ128Info.range;
requestParam.connHandle = eventParamCast->connHandle;
if(Cy_BLE_GATTC_FindIncludedServices(&requestParam) != CY_BLE_SUCCESS)
{
Cy_BLE_ApplCallback((uint32_t)CY_BLE_EVT_GATTC_INCL_DISCOVERY_FAILED,
&eventParamCast->connHandle);
cy_ble_configPtr->context->discovery[discIdx].autoDiscoveryFlag = 0u;
}
}
else /* Continue discovery of the following service */
{
Cy_BLE_NextInclDiscovery(eventParamCast->connHandle, CY_BLE_DISCOVERY_CONTINUE);
}
cy_ble_eventHandlerFlag &= (uint8_t) ~CY_BLE_CALLBACK;
cy_ble_configPtr->context->discovery[discIdx].inclInfo.inclDefHandle = 0u;
}
}
break;
default:
break;
}
}
return(CY_BLE_GATT_ERR_NONE);
}
#endif /* CY_BLE_LIB_HOST_CORE */
#endif /* CY_IP_MXBLESS */
/* [] END OF FILE */