nordic

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Fri Sep 25 15:26:39 2015 +0100
Revision:
430:bff56e081b6e
Parent:
425:28ea27dcba79
Child:
431:db7edc9ad0bc
Synchronized with git rev 2294f555
Author: Rohit Grover
Release 0.4.5
=============

Enhancements
~~~~~~~~~~~~

* Renamed to GapAdvertisementParams::getIntervalInADVUnits() based on change in BLE API.
* Fix Gap::getAppearance() to checks for correct success code from sd_ble_gap_appearance_get().

Bugfixes
~~~~~~~~

none.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 388:b13ab9a7ddb9 1 /* mbed Microcontroller Library
rgrover1 388:b13ab9a7ddb9 2 * Copyright (c) 2006-2013 ARM Limited
rgrover1 388:b13ab9a7ddb9 3 *
rgrover1 388:b13ab9a7ddb9 4 * Licensed under the Apache License, Version 2.0 (the "License");
rgrover1 388:b13ab9a7ddb9 5 * you may not use this file except in compliance with the License.
rgrover1 388:b13ab9a7ddb9 6 * You may obtain a copy of the License at
rgrover1 388:b13ab9a7ddb9 7 *
rgrover1 388:b13ab9a7ddb9 8 * http://www.apache.org/licenses/LICENSE-2.0
rgrover1 388:b13ab9a7ddb9 9 *
rgrover1 388:b13ab9a7ddb9 10 * Unless required by applicable law or agreed to in writing, software
rgrover1 388:b13ab9a7ddb9 11 * distributed under the License is distributed on an "AS IS" BASIS,
rgrover1 388:b13ab9a7ddb9 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rgrover1 388:b13ab9a7ddb9 13 * See the License for the specific language governing permissions and
rgrover1 388:b13ab9a7ddb9 14 * limitations under the License.
rgrover1 388:b13ab9a7ddb9 15 */
rgrover1 388:b13ab9a7ddb9 16
rgrover1 394:0f7c5048efb3 17 #include "nRF5xServiceDiscovery.h"
rgrover1 394:0f7c5048efb3 18 #include "nRF5xGattClient.h"
rgrover1 388:b13ab9a7ddb9 19
rgrover1 388:b13ab9a7ddb9 20 void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
rgrover1 388:b13ab9a7ddb9 21 {
rgrover1 394:0f7c5048efb3 22 nRF5xServiceDiscovery &sdSingleton = nRF5xGattClient::getInstance().discovery;
rgrover1 388:b13ab9a7ddb9 23
rgrover1 388:b13ab9a7ddb9 24 switch (p_ble_evt->header.evt_id) {
rgrover1 388:b13ab9a7ddb9 25 case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
rgrover1 388:b13ab9a7ddb9 26 switch (p_ble_evt->evt.gattc_evt.gatt_status) {
rgrover1 388:b13ab9a7ddb9 27 case BLE_GATT_STATUS_SUCCESS:
rgrover1 388:b13ab9a7ddb9 28 sdSingleton.setupDiscoveredServices(&p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp);
rgrover1 388:b13ab9a7ddb9 29 break;
rgrover1 388:b13ab9a7ddb9 30
rgrover1 388:b13ab9a7ddb9 31 case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
rgrover1 388:b13ab9a7ddb9 32 default:
rgrover1 388:b13ab9a7ddb9 33 sdSingleton.terminate();
rgrover1 388:b13ab9a7ddb9 34 break;
rgrover1 388:b13ab9a7ddb9 35 }
rgrover1 388:b13ab9a7ddb9 36 break;
rgrover1 388:b13ab9a7ddb9 37
rgrover1 388:b13ab9a7ddb9 38 case BLE_GATTC_EVT_CHAR_DISC_RSP:
rgrover1 388:b13ab9a7ddb9 39 switch (p_ble_evt->evt.gattc_evt.gatt_status) {
rgrover1 388:b13ab9a7ddb9 40 case BLE_GATT_STATUS_SUCCESS:
rgrover1 388:b13ab9a7ddb9 41 sdSingleton.setupDiscoveredCharacteristics(&p_ble_evt->evt.gattc_evt.params.char_disc_rsp);
rgrover1 388:b13ab9a7ddb9 42 break;
rgrover1 388:b13ab9a7ddb9 43
rgrover1 388:b13ab9a7ddb9 44 case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
rgrover1 388:b13ab9a7ddb9 45 default:
rgrover1 388:b13ab9a7ddb9 46 sdSingleton.terminateCharacteristicDiscovery();
rgrover1 388:b13ab9a7ddb9 47 break;
rgrover1 388:b13ab9a7ddb9 48 }
rgrover1 388:b13ab9a7ddb9 49 break;
rgrover1 388:b13ab9a7ddb9 50
rgrover1 388:b13ab9a7ddb9 51 case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP:
rgrover1 388:b13ab9a7ddb9 52 if (sdSingleton.isActive()) {
rgrover1 388:b13ab9a7ddb9 53 sdSingleton.processDiscoverUUIDResponse(&p_ble_evt->evt.gattc_evt.params.char_val_by_uuid_read_rsp);
rgrover1 388:b13ab9a7ddb9 54 }
rgrover1 388:b13ab9a7ddb9 55 break;
rgrover1 388:b13ab9a7ddb9 56
rgrover1 388:b13ab9a7ddb9 57 case BLE_GATTC_EVT_READ_RSP: {
rgrover1 388:b13ab9a7ddb9 58 GattReadCallbackParams response = {
rgrover1 430:bff56e081b6e 59 .handle = p_ble_evt->evt.gattc_evt.params.read_rsp.handle,
rgrover1 430:bff56e081b6e 60 .offset = p_ble_evt->evt.gattc_evt.params.read_rsp.offset,
rgrover1 430:bff56e081b6e 61 .len = p_ble_evt->evt.gattc_evt.params.read_rsp.len,
rgrover1 430:bff56e081b6e 62 .data = p_ble_evt->evt.gattc_evt.params.read_rsp.data,
rgrover1 388:b13ab9a7ddb9 63 };
rgrover1 394:0f7c5048efb3 64 nRF5xGattClient::getInstance().processReadResponse(&response);
rgrover1 388:b13ab9a7ddb9 65 }
rgrover1 388:b13ab9a7ddb9 66 break;
rgrover1 388:b13ab9a7ddb9 67
rgrover1 388:b13ab9a7ddb9 68 case BLE_GATTC_EVT_WRITE_RSP: {
rgrover1 388:b13ab9a7ddb9 69 GattWriteCallbackParams response = {
rgrover1 430:bff56e081b6e 70 .handle = p_ble_evt->evt.gattc_evt.params.write_rsp.handle,
rgrover1 430:bff56e081b6e 71 .writeOp = (GattWriteCallbackParams::WriteOp_t)(p_ble_evt->evt.gattc_evt.params.write_rsp.write_op),
rgrover1 430:bff56e081b6e 72 .offset = p_ble_evt->evt.gattc_evt.params.write_rsp.offset,
rgrover1 430:bff56e081b6e 73 .len = p_ble_evt->evt.gattc_evt.params.write_rsp.len,
rgrover1 430:bff56e081b6e 74 .data = p_ble_evt->evt.gattc_evt.params.write_rsp.data,
rgrover1 388:b13ab9a7ddb9 75 };
rgrover1 394:0f7c5048efb3 76 nRF5xGattClient::getInstance().processWriteResponse(&response);
rgrover1 388:b13ab9a7ddb9 77 }
rgrover1 388:b13ab9a7ddb9 78 break;
rgrover1 388:b13ab9a7ddb9 79
rgrover1 388:b13ab9a7ddb9 80 case BLE_GATTC_EVT_HVX: {
rgrover1 388:b13ab9a7ddb9 81 GattHVXCallbackParams params;
rgrover1 430:bff56e081b6e 82 params.handle = p_ble_evt->evt.gattc_evt.params.hvx.handle;
rgrover1 430:bff56e081b6e 83 params.type = static_cast<HVXType_t>(p_ble_evt->evt.gattc_evt.params.hvx.type);
rgrover1 430:bff56e081b6e 84 params.len = p_ble_evt->evt.gattc_evt.params.hvx.len;
rgrover1 430:bff56e081b6e 85 params.data = p_ble_evt->evt.gattc_evt.params.hvx.data;
rgrover1 388:b13ab9a7ddb9 86
rgrover1 394:0f7c5048efb3 87 nRF5xGattClient::getInstance().processHVXEvent(&params);
rgrover1 388:b13ab9a7ddb9 88 }
rgrover1 388:b13ab9a7ddb9 89 break;
rgrover1 388:b13ab9a7ddb9 90 }
rgrover1 388:b13ab9a7ddb9 91
rgrover1 388:b13ab9a7ddb9 92 sdSingleton.progressCharacteristicDiscovery();
rgrover1 388:b13ab9a7ddb9 93 sdSingleton.progressServiceDiscovery();
rgrover1 388:b13ab9a7ddb9 94 }