Pinned to some recent date

Committer:
Simon Cooksey
Date:
Thu Nov 17 16:43:53 2016 +0000
Revision:
0:fb7af294d5d9
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Simon Cooksey 0:fb7af294d5d9 1 /* mbed Microcontroller Library
Simon Cooksey 0:fb7af294d5d9 2 * Copyright (c) 2006-2013 ARM Limited
Simon Cooksey 0:fb7af294d5d9 3 *
Simon Cooksey 0:fb7af294d5d9 4 * Licensed under the Apache License, Version 2.0 (the "License");
Simon Cooksey 0:fb7af294d5d9 5 * you may not use this file except in compliance with the License.
Simon Cooksey 0:fb7af294d5d9 6 * You may obtain a copy of the License at
Simon Cooksey 0:fb7af294d5d9 7 *
Simon Cooksey 0:fb7af294d5d9 8 * http://www.apache.org/licenses/LICENSE-2.0
Simon Cooksey 0:fb7af294d5d9 9 *
Simon Cooksey 0:fb7af294d5d9 10 * Unless required by applicable law or agreed to in writing, software
Simon Cooksey 0:fb7af294d5d9 11 * distributed under the License is distributed on an "AS IS" BASIS,
Simon Cooksey 0:fb7af294d5d9 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Simon Cooksey 0:fb7af294d5d9 13 * See the License for the specific language governing permissions and
Simon Cooksey 0:fb7af294d5d9 14 * limitations under the License.
Simon Cooksey 0:fb7af294d5d9 15 */
Simon Cooksey 0:fb7af294d5d9 16
Simon Cooksey 0:fb7af294d5d9 17 #ifndef __DISCOVERED_SERVICE_H__
Simon Cooksey 0:fb7af294d5d9 18 #define __DISCOVERED_SERVICE_H__
Simon Cooksey 0:fb7af294d5d9 19
Simon Cooksey 0:fb7af294d5d9 20 #include "UUID.h"
Simon Cooksey 0:fb7af294d5d9 21 #include "GattAttribute.h"
Simon Cooksey 0:fb7af294d5d9 22
Simon Cooksey 0:fb7af294d5d9 23 /**@brief Type for holding information about the service and the characteristics found during
Simon Cooksey 0:fb7af294d5d9 24 * the discovery process.
Simon Cooksey 0:fb7af294d5d9 25 */
Simon Cooksey 0:fb7af294d5d9 26 class DiscoveredService {
Simon Cooksey 0:fb7af294d5d9 27 public:
Simon Cooksey 0:fb7af294d5d9 28 /**
Simon Cooksey 0:fb7af294d5d9 29 * Set information about the discovered service.
Simon Cooksey 0:fb7af294d5d9 30 *
Simon Cooksey 0:fb7af294d5d9 31 * @param[in] uuidIn
Simon Cooksey 0:fb7af294d5d9 32 * The UUID of the discovered service.
Simon Cooksey 0:fb7af294d5d9 33 * @param[in] startHandleIn
Simon Cooksey 0:fb7af294d5d9 34 * The start handle of the discovered service in the peer's
Simon Cooksey 0:fb7af294d5d9 35 * ATT table.
Simon Cooksey 0:fb7af294d5d9 36 * @param[in] endHandleIn
Simon Cooksey 0:fb7af294d5d9 37 * The end handle of the discovered service in the peer's
Simon Cooksey 0:fb7af294d5d9 38 * ATT table.
Simon Cooksey 0:fb7af294d5d9 39 */
Simon Cooksey 0:fb7af294d5d9 40 void setup(UUID uuidIn, GattAttribute::Handle_t startHandleIn, GattAttribute::Handle_t endHandleIn) {
Simon Cooksey 0:fb7af294d5d9 41 uuid = uuidIn;
Simon Cooksey 0:fb7af294d5d9 42 startHandle = startHandleIn;
Simon Cooksey 0:fb7af294d5d9 43 endHandle = endHandleIn;
Simon Cooksey 0:fb7af294d5d9 44 }
Simon Cooksey 0:fb7af294d5d9 45
Simon Cooksey 0:fb7af294d5d9 46 /**
Simon Cooksey 0:fb7af294d5d9 47 * Set the start and end handle of the discovered service.
Simon Cooksey 0:fb7af294d5d9 48 * @param[in] startHandleIn
Simon Cooksey 0:fb7af294d5d9 49 * The start handle of the discovered service in the peer's
Simon Cooksey 0:fb7af294d5d9 50 * ATT table.
Simon Cooksey 0:fb7af294d5d9 51 * @param[in] endHandleIn
Simon Cooksey 0:fb7af294d5d9 52 * The end handle of the discovered service in the peer's
Simon Cooksey 0:fb7af294d5d9 53 * ATT table.
Simon Cooksey 0:fb7af294d5d9 54 */
Simon Cooksey 0:fb7af294d5d9 55 void setup(GattAttribute::Handle_t startHandleIn, GattAttribute::Handle_t endHandleIn) {
Simon Cooksey 0:fb7af294d5d9 56 startHandle = startHandleIn;
Simon Cooksey 0:fb7af294d5d9 57 endHandle = endHandleIn;
Simon Cooksey 0:fb7af294d5d9 58 }
Simon Cooksey 0:fb7af294d5d9 59
Simon Cooksey 0:fb7af294d5d9 60 /**
Simon Cooksey 0:fb7af294d5d9 61 * Set the long UUID of the discovered service.
Simon Cooksey 0:fb7af294d5d9 62 *
Simon Cooksey 0:fb7af294d5d9 63 * @param[in] longUUID
Simon Cooksey 0:fb7af294d5d9 64 * The long UUID of the discovered service.
Simon Cooksey 0:fb7af294d5d9 65 * @param[in] order
Simon Cooksey 0:fb7af294d5d9 66 * The byte ordering of @p longUUID.
Simon Cooksey 0:fb7af294d5d9 67 */
Simon Cooksey 0:fb7af294d5d9 68 void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) {
Simon Cooksey 0:fb7af294d5d9 69 uuid.setupLong(longUUID, order);
Simon Cooksey 0:fb7af294d5d9 70 }
Simon Cooksey 0:fb7af294d5d9 71
Simon Cooksey 0:fb7af294d5d9 72 public:
Simon Cooksey 0:fb7af294d5d9 73 /**
Simon Cooksey 0:fb7af294d5d9 74 * Get the UUID of the discovered service.
Simon Cooksey 0:fb7af294d5d9 75 *
Simon Cooksey 0:fb7af294d5d9 76 * @return A reference to the UUID of the discovered service.
Simon Cooksey 0:fb7af294d5d9 77 */
Simon Cooksey 0:fb7af294d5d9 78 const UUID &getUUID(void) const {
Simon Cooksey 0:fb7af294d5d9 79 return uuid;
Simon Cooksey 0:fb7af294d5d9 80 }
Simon Cooksey 0:fb7af294d5d9 81
Simon Cooksey 0:fb7af294d5d9 82 /**
Simon Cooksey 0:fb7af294d5d9 83 * Get the start handle of the discovered service in the peer's ATT table.
Simon Cooksey 0:fb7af294d5d9 84 *
Simon Cooksey 0:fb7af294d5d9 85 * @return A reference to the start handle.
Simon Cooksey 0:fb7af294d5d9 86 */
Simon Cooksey 0:fb7af294d5d9 87 const GattAttribute::Handle_t& getStartHandle(void) const {
Simon Cooksey 0:fb7af294d5d9 88 return startHandle;
Simon Cooksey 0:fb7af294d5d9 89 }
Simon Cooksey 0:fb7af294d5d9 90
Simon Cooksey 0:fb7af294d5d9 91 /**
Simon Cooksey 0:fb7af294d5d9 92 * Get the end handle of the discovered service in the peer's ATT table.
Simon Cooksey 0:fb7af294d5d9 93 *
Simon Cooksey 0:fb7af294d5d9 94 * @return A reference to the end handle.
Simon Cooksey 0:fb7af294d5d9 95 */
Simon Cooksey 0:fb7af294d5d9 96 const GattAttribute::Handle_t& getEndHandle(void) const {
Simon Cooksey 0:fb7af294d5d9 97 return endHandle;
Simon Cooksey 0:fb7af294d5d9 98 }
Simon Cooksey 0:fb7af294d5d9 99
Simon Cooksey 0:fb7af294d5d9 100 public:
Simon Cooksey 0:fb7af294d5d9 101 /**
Simon Cooksey 0:fb7af294d5d9 102 * Construct a DiscoveredService instance.
Simon Cooksey 0:fb7af294d5d9 103 */
Simon Cooksey 0:fb7af294d5d9 104 DiscoveredService() : uuid(UUID::ShortUUIDBytes_t(0)),
Simon Cooksey 0:fb7af294d5d9 105 startHandle(GattAttribute::INVALID_HANDLE),
Simon Cooksey 0:fb7af294d5d9 106 endHandle(GattAttribute::INVALID_HANDLE) {
Simon Cooksey 0:fb7af294d5d9 107 /* empty */
Simon Cooksey 0:fb7af294d5d9 108 }
Simon Cooksey 0:fb7af294d5d9 109
Simon Cooksey 0:fb7af294d5d9 110 private:
Simon Cooksey 0:fb7af294d5d9 111 DiscoveredService(const DiscoveredService &);
Simon Cooksey 0:fb7af294d5d9 112
Simon Cooksey 0:fb7af294d5d9 113 private:
Simon Cooksey 0:fb7af294d5d9 114 UUID uuid; /**< UUID of the service. */
Simon Cooksey 0:fb7af294d5d9 115 GattAttribute::Handle_t startHandle; /**< Service Handle Range. */
Simon Cooksey 0:fb7af294d5d9 116 GattAttribute::Handle_t endHandle; /**< Service Handle Range. */
Simon Cooksey 0:fb7af294d5d9 117 };
Simon Cooksey 0:fb7af294d5d9 118
Simon Cooksey 0:fb7af294d5d9 119 #endif /*__DISCOVERED_SERVICE_H__*/