Shuta Nakamae / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Fri Jun 19 15:55:21 2015 +0100
Revision:
239:693a1f145b5a
Parent:
238:6e85a2484de7
Child:
240:75b69581d1dd
Synchronized with git rev 50a110cd
Author: Rohit Grover
partial separation of code related to discovery into files.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 194:c99fc3160091 1 /* mbed Microcontroller Library
rgrover1 194:c99fc3160091 2 * Copyright (c) 2006-2013 ARM Limited
rgrover1 194:c99fc3160091 3 *
rgrover1 194:c99fc3160091 4 * Licensed under the Apache License, Version 2.0 (the "License");
rgrover1 194:c99fc3160091 5 * you may not use this file except in compliance with the License.
rgrover1 194:c99fc3160091 6 * You may obtain a copy of the License at
rgrover1 194:c99fc3160091 7 *
rgrover1 194:c99fc3160091 8 * http://www.apache.org/licenses/LICENSE-2.0
rgrover1 194:c99fc3160091 9 *
rgrover1 194:c99fc3160091 10 * Unless required by applicable law or agreed to in writing, software
rgrover1 194:c99fc3160091 11 * distributed under the License is distributed on an "AS IS" BASIS,
rgrover1 194:c99fc3160091 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rgrover1 194:c99fc3160091 13 * See the License for the specific language governing permissions and
rgrover1 194:c99fc3160091 14 * limitations under the License.
rgrover1 194:c99fc3160091 15 */
rgrover1 194:c99fc3160091 16
rgrover1 194:c99fc3160091 17 #include "btle_gattc.h"
rgrover1 195:061ed80ffbcf 18 #include "UUID.h"
rgrover1 239:693a1f145b5a 19 #include "btle_discovery.h"
rgrover1 202:3ce954ce3eb8 20
rgrover1 194:c99fc3160091 21 void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
rgrover1 194:c99fc3160091 22 {
rgrover1 239:693a1f145b5a 23 ServiceDiscovery *singleton = ServiceDiscovery::getSingleton();
rgrover1 239:693a1f145b5a 24
rgrover1 194:c99fc3160091 25 switch (p_ble_evt->header.evt_id) {
rgrover1 194:c99fc3160091 26 case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
rgrover1 194:c99fc3160091 27 switch (p_ble_evt->evt.gattc_evt.gatt_status) {
rgrover1 235:10bb73f9d15d 28 case BLE_GATT_STATUS_SUCCESS:
rgrover1 239:693a1f145b5a 29 singleton->setupDiscoveredServices(&p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp);
rgrover1 195:061ed80ffbcf 30 break;
rgrover1 195:061ed80ffbcf 31
rgrover1 229:6394db9a71ba 32 case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
rgrover1 229:6394db9a71ba 33 default:
rgrover1 239:693a1f145b5a 34 singleton->terminate();
rgrover1 194:c99fc3160091 35 break;
rgrover1 194:c99fc3160091 36 }
rgrover1 194:c99fc3160091 37 break;
rgrover1 194:c99fc3160091 38
rgrover1 235:10bb73f9d15d 39 case BLE_GATTC_EVT_CHAR_DISC_RSP:
rgrover1 194:c99fc3160091 40 switch (p_ble_evt->evt.gattc_evt.gatt_status) {
rgrover1 235:10bb73f9d15d 41 case BLE_GATT_STATUS_SUCCESS:
rgrover1 239:693a1f145b5a 42 singleton->setupDiscoveredCharacteristics(&p_ble_evt->evt.gattc_evt.params.char_disc_rsp);
rgrover1 219:681be3608738 43 break;
rgrover1 212:f2316b17d8be 44
rgrover1 229:6394db9a71ba 45 case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
rgrover1 229:6394db9a71ba 46 default:
rgrover1 239:693a1f145b5a 47 singleton->terminateCharacteristicDiscovery();
rgrover1 212:f2316b17d8be 48 break;
rgrover1 194:c99fc3160091 49 }
rgrover1 194:c99fc3160091 50 break;
rgrover1 194:c99fc3160091 51 }
rgrover1 195:061ed80ffbcf 52
rgrover1 239:693a1f145b5a 53 singleton->progressCharacteristicDiscovery();
rgrover1 239:693a1f145b5a 54 singleton->progressServiceDiscovery();
rgrover1 194:c99fc3160091 55 }