aa

Dependents:   Peripheral_1_serial_copy Peripheral_1_serial 151006_1st_Scenario_normal

Fork of BLE_API by Bluetooth Low Energy

Committer:
rgrover1
Date:
Fri Jun 19 15:52:00 2015 +0100
Revision:
474:2a8a453ecd7e
Parent:
470:150c2363f776
Child:
476:122bcbdadb56
Synchronized with git rev 9f54d528
Author: Rohit Grover
add some comment headers

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 431:1c8c592430ec 1 /* mbed Microcontroller Library
rgrover1 431:1c8c592430ec 2 * Copyright (c) 2006-2013 ARM Limited
rgrover1 431:1c8c592430ec 3 *
rgrover1 431:1c8c592430ec 4 * Licensed under the Apache License, Version 2.0 (the "License");
rgrover1 431:1c8c592430ec 5 * you may not use this file except in compliance with the License.
rgrover1 431:1c8c592430ec 6 * You may obtain a copy of the License at
rgrover1 431:1c8c592430ec 7 *
rgrover1 431:1c8c592430ec 8 * http://www.apache.org/licenses/LICENSE-2.0
rgrover1 431:1c8c592430ec 9 *
rgrover1 431:1c8c592430ec 10 * Unless required by applicable law or agreed to in writing, software
rgrover1 431:1c8c592430ec 11 * distributed under the License is distributed on an "AS IS" BASIS,
rgrover1 431:1c8c592430ec 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rgrover1 431:1c8c592430ec 13 * See the License for the specific language governing permissions and
rgrover1 431:1c8c592430ec 14 * limitations under the License.
rgrover1 431:1c8c592430ec 15 */
rgrover1 431:1c8c592430ec 16
rgrover1 431:1c8c592430ec 17 #ifndef __SERVICE_DISOVERY_H__
rgrover1 431:1c8c592430ec 18 #define __SERVICE_DISOVERY_H__
rgrover1 431:1c8c592430ec 19
rgrover1 431:1c8c592430ec 20 #include "UUID.h"
rgrover1 431:1c8c592430ec 21 #include "Gap.h"
rgrover1 438:b55ce5f5715d 22 #include "GattAttribute.h"
rgrover1 470:150c2363f776 23 #include "DiscoveredService.h"
rgrover1 470:150c2363f776 24 #include "DiscoveredCharacteristic.h"
rgrover1 431:1c8c592430ec 25
rgrover1 431:1c8c592430ec 26 class ServiceDiscovery {
rgrover1 431:1c8c592430ec 27 public:
rgrover1 431:1c8c592430ec 28 typedef void (*ServiceCallback_t)(const DiscoveredService &);
rgrover1 431:1c8c592430ec 29 typedef void (*CharacteristicCallback_t)(const DiscoveredCharacteristic &);
rgrover1 457:6ebc9bbde90b 30 typedef void (*TerminationCallback_t)(Gap::Handle_t connectionHandle);
rgrover1 431:1c8c592430ec 31
rgrover1 431:1c8c592430ec 32 public:
rgrover1 456:ff4ffb69e19f 33 static ble_error_t launch(Gap::Handle_t connectionHandle,
rgrover1 456:ff4ffb69e19f 34 ServiceCallback_t sc = NULL,
rgrover1 456:ff4ffb69e19f 35 CharacteristicCallback_t cc = NULL,
rgrover1 458:5546ebd25359 36 const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
rgrover1 458:5546ebd25359 37 const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN));
rgrover1 431:1c8c592430ec 38
rgrover1 474:2a8a453ecd7e 39 /**
rgrover1 474:2a8a453ecd7e 40 * Terminate an ongoing service-discovery. This should result in an
rgrover1 474:2a8a453ecd7e 41 * invocation of the TerminationCallback if service-discovery is active.
rgrover1 474:2a8a453ecd7e 42 */
rgrover1 431:1c8c592430ec 43 static void terminate(void);
rgrover1 431:1c8c592430ec 44
rgrover1 474:2a8a453ecd7e 45 /**
rgrover1 474:2a8a453ecd7e 46 * Is service-discovery currently active?
rgrover1 474:2a8a453ecd7e 47 */
rgrover1 457:6ebc9bbde90b 48 static bool isActive(void);
rgrover1 474:2a8a453ecd7e 49
rgrover1 474:2a8a453ecd7e 50 /**
rgrover1 474:2a8a453ecd7e 51 * Setup callback to be invoked when service discovery is terminated.
rgrover1 474:2a8a453ecd7e 52 */
rgrover1 457:6ebc9bbde90b 53 static void onTermination(TerminationCallback_t callback);
rgrover1 457:6ebc9bbde90b 54
rgrover1 431:1c8c592430ec 55 protected:
rgrover1 431:1c8c592430ec 56 Gap::Handle_t connHandle; /**< Connection handle as provided by the SoftDevice. */
rgrover1 431:1c8c592430ec 57 UUID matchingServiceUUID;
rgrover1 431:1c8c592430ec 58 ServiceCallback_t serviceCallback;
rgrover1 431:1c8c592430ec 59 UUID matchingCharacteristicUUID;
rgrover1 431:1c8c592430ec 60 CharacteristicCallback_t characteristicCallback;
rgrover1 431:1c8c592430ec 61 };
rgrover1 431:1c8c592430ec 62
rgrover1 431:1c8c592430ec 63 #endif // ifndef __SERVICE_DISOVERY_H__