mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:5b88d5760320 1 /* mbed Microcontroller Library
kenjiArai 0:5b88d5760320 2 * Copyright (c) 2017-2017 ARM Limited
kenjiArai 0:5b88d5760320 3 *
kenjiArai 0:5b88d5760320 4 * Licensed under the Apache License, Version 2.0 (the "License");
kenjiArai 0:5b88d5760320 5 * you may not use this file except in compliance with the License.
kenjiArai 0:5b88d5760320 6 * You may obtain a copy of the License at
kenjiArai 0:5b88d5760320 7 *
kenjiArai 0:5b88d5760320 8 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 0:5b88d5760320 9 *
kenjiArai 0:5b88d5760320 10 * Unless required by applicable law or agreed to in writing, software
kenjiArai 0:5b88d5760320 11 * distributed under the License is distributed on an "AS IS" BASIS,
kenjiArai 0:5b88d5760320 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 0:5b88d5760320 13 * See the License for the specific language governing permissions and
kenjiArai 0:5b88d5760320 14 * limitations under the License.
kenjiArai 0:5b88d5760320 15 */
kenjiArai 0:5b88d5760320 16
kenjiArai 0:5b88d5760320 17 #ifndef BLE_PAL_GENERIC_ACCESS_SERVICE_H_
kenjiArai 0:5b88d5760320 18 #define BLE_PAL_GENERIC_ACCESS_SERVICE_H_
kenjiArai 0:5b88d5760320 19
kenjiArai 0:5b88d5760320 20 #include "GapTypes.h"
kenjiArai 0:5b88d5760320 21 #include "ble/BLETypes.h"
kenjiArai 0:5b88d5760320 22 #include "ble/blecommon.h"
kenjiArai 0:5b88d5760320 23 #include "ble/GapAdvertisingData.h"
kenjiArai 0:5b88d5760320 24 #include "ble/Gap.h"
kenjiArai 0:5b88d5760320 25
kenjiArai 0:5b88d5760320 26 namespace ble {
kenjiArai 0:5b88d5760320 27 namespace pal {
kenjiArai 0:5b88d5760320 28
kenjiArai 0:5b88d5760320 29 /**
kenjiArai 0:5b88d5760320 30 * Manage state of the GAP service exposed by the GATT server.
kenjiArai 0:5b88d5760320 31 *
kenjiArai 0:5b88d5760320 32 * @see Bluetooth 4.2 Vol 3 PartC: 12 - GAP service and characteristics for GATT
kenjiArai 0:5b88d5760320 33 * server.
kenjiArai 0:5b88d5760320 34 */
kenjiArai 0:5b88d5760320 35 struct GenericAccessService {
kenjiArai 0:5b88d5760320 36
kenjiArai 0:5b88d5760320 37 /**
kenjiArai 0:5b88d5760320 38 * Empty, default, constructor
kenjiArai 0:5b88d5760320 39 */
kenjiArai 0:5b88d5760320 40 GenericAccessService() { }
kenjiArai 0:5b88d5760320 41
kenjiArai 0:5b88d5760320 42 /**
kenjiArai 0:5b88d5760320 43 * Virtual destructor
kenjiArai 0:5b88d5760320 44 */
kenjiArai 0:5b88d5760320 45 virtual ~GenericAccessService() { }
kenjiArai 0:5b88d5760320 46
kenjiArai 0:5b88d5760320 47 /**
kenjiArai 0:5b88d5760320 48 * Acquire the length of the device name.
kenjiArai 0:5b88d5760320 49 * The length can range from 0 (no device name) to 248 octets
kenjiArai 0:5b88d5760320 50 *
kenjiArai 0:5b88d5760320 51 * @param length The length of the device name currently stored in the GAP
kenjiArai 0:5b88d5760320 52 * service.
kenjiArai 0:5b88d5760320 53 *
kenjiArai 0:5b88d5760320 54 * @return BLE_ERROR_NONE in case of success or the appropriate error code
kenjiArai 0:5b88d5760320 55 * otherwise.
kenjiArai 0:5b88d5760320 56 *
kenjiArai 0:5b88d5760320 57 * @see Bluetooth 4.2 Vol 3 PartC: 12.1 - Device Name Characteristic
kenjiArai 0:5b88d5760320 58 */
kenjiArai 0:5b88d5760320 59 virtual ble_error_t get_device_name_length(uint8_t& length) = 0;
kenjiArai 0:5b88d5760320 60
kenjiArai 0:5b88d5760320 61 /**
kenjiArai 0:5b88d5760320 62 * Get the current device name.
kenjiArai 0:5b88d5760320 63 * The result is stored in the array pass in input if the operation
kenjiArai 0:5b88d5760320 64 * succeed. Prior to this call the length of the device name can be acquired
kenjiArai 0:5b88d5760320 65 * with a call to get_device_name_length.
kenjiArai 0:5b88d5760320 66 *
kenjiArai 0:5b88d5760320 67 * @param The array which will host the device name
kenjiArai 0:5b88d5760320 68 *
kenjiArai 0:5b88d5760320 69 * @return BLE_ERROR_NONE in case of success or the appropriate error code
kenjiArai 0:5b88d5760320 70 * otherwise.
kenjiArai 0:5b88d5760320 71 *
kenjiArai 0:5b88d5760320 72 * @see Bluetooth 4.2 Vol 3 PartC: 12.1 - Device Name Characteristic
kenjiArai 0:5b88d5760320 73 */
kenjiArai 0:5b88d5760320 74 virtual ble_error_t get_device_name(Span<uint8_t>& array) = 0;
kenjiArai 0:5b88d5760320 75
kenjiArai 0:5b88d5760320 76 /**
kenjiArai 0:5b88d5760320 77 * Set the value of the device name characteristic exposed by the GAP GATT
kenjiArai 0:5b88d5760320 78 * service.
kenjiArai 0:5b88d5760320 79 *
kenjiArai 0:5b88d5760320 80 * @param device_name The name of the device. If NULL the device name
kenjiArai 0:5b88d5760320 81 * value has a length of 0.
kenjiArai 0:5b88d5760320 82 *
kenjiArai 0:5b88d5760320 83 * @return BLE_ERROR_NONE in case of success or the appropriate error code
kenjiArai 0:5b88d5760320 84 * otherwise.
kenjiArai 0:5b88d5760320 85 *
kenjiArai 0:5b88d5760320 86 * @see Bluetooth 4.2 Vol 3 PartC: 12.1 - Device Name Characteristic
kenjiArai 0:5b88d5760320 87 */
kenjiArai 0:5b88d5760320 88 virtual ble_error_t set_device_name(const uint8_t* device_name) = 0;
kenjiArai 0:5b88d5760320 89
kenjiArai 0:5b88d5760320 90 /**
kenjiArai 0:5b88d5760320 91 * Acquire the appearance stored in the appearance characteristic of the GAP
kenjiArai 0:5b88d5760320 92 * GATT service.
kenjiArai 0:5b88d5760320 93 *
kenjiArai 0:5b88d5760320 94 * @param appearance: If the call succeed will contain the value of the
kenjiArai 0:5b88d5760320 95 * appearance characteristic.
kenjiArai 0:5b88d5760320 96 *
kenjiArai 0:5b88d5760320 97 * @return BLE_ERROR_NONE in case of success or the appropriate error code
kenjiArai 0:5b88d5760320 98 * otherwise.
kenjiArai 0:5b88d5760320 99 *
kenjiArai 0:5b88d5760320 100 * @see Bluetooth 4.2 Vol 3 PartC: 12.2 - Appearance Characteristic
kenjiArai 0:5b88d5760320 101 */
kenjiArai 0:5b88d5760320 102 virtual ble_error_t get_appearance(
kenjiArai 0:5b88d5760320 103 GapAdvertisingData::Appearance& appearance
kenjiArai 0:5b88d5760320 104 ) = 0;
kenjiArai 0:5b88d5760320 105
kenjiArai 0:5b88d5760320 106 /**
kenjiArai 0:5b88d5760320 107 * Set the value of the appearance characteristic of the GAP GATT service.
kenjiArai 0:5b88d5760320 108 *
kenjiArai 0:5b88d5760320 109 * @param appearance: The appearance to set.
kenjiArai 0:5b88d5760320 110 *
kenjiArai 0:5b88d5760320 111 * @return BLE_ERROR_NONE in case of success or the appropriate error code
kenjiArai 0:5b88d5760320 112 * otherwise.
kenjiArai 0:5b88d5760320 113 *
kenjiArai 0:5b88d5760320 114 * @see Bluetooth 4.2 Vol 3 PartC: 12.2 - Appearance Characteristic
kenjiArai 0:5b88d5760320 115 */
kenjiArai 0:5b88d5760320 116 virtual ble_error_t set_appearance(
kenjiArai 0:5b88d5760320 117 GapAdvertisingData::Appearance appearance
kenjiArai 0:5b88d5760320 118 ) = 0;
kenjiArai 0:5b88d5760320 119
kenjiArai 0:5b88d5760320 120 /**
kenjiArai 0:5b88d5760320 121 * Acquire the peripheral prefered connection parameters stored in the GAP
kenjiArai 0:5b88d5760320 122 * GATT service.
kenjiArai 0:5b88d5760320 123 *
kenjiArai 0:5b88d5760320 124 * @param parameters: If the call succeed will contain the value of
kenjiArai 0:5b88d5760320 125 * the peripheral prefered connection parameters characteristic.
kenjiArai 0:5b88d5760320 126 *
kenjiArai 0:5b88d5760320 127 * @return BLE_ERROR_NONE in case of success or the appropriate error code
kenjiArai 0:5b88d5760320 128 * otherwise.
kenjiArai 0:5b88d5760320 129 *
kenjiArai 0:5b88d5760320 130 * @see Bluetooth 4.2 Vol 3 PartC: 12.3 - Peripheral Preferred Connection
kenjiArai 0:5b88d5760320 131 * Parameters Characteristic
kenjiArai 0:5b88d5760320 132 */
kenjiArai 0:5b88d5760320 133 virtual ble_error_t get_peripheral_prefered_connection_parameters(
kenjiArai 0:5b88d5760320 134 ::Gap::ConnectionParams_t& parameters
kenjiArai 0:5b88d5760320 135 ) = 0;
kenjiArai 0:5b88d5760320 136
kenjiArai 0:5b88d5760320 137 /**
kenjiArai 0:5b88d5760320 138 * set the value of the peripheral prefered connection parameters stored in
kenjiArai 0:5b88d5760320 139 * the GAP GATT service.
kenjiArai 0:5b88d5760320 140 *
kenjiArai 0:5b88d5760320 141 * @param parameters: If the peripheral prefered connection parameters
kenjiArai 0:5b88d5760320 142 * to set.
kenjiArai 0:5b88d5760320 143 *
kenjiArai 0:5b88d5760320 144 * @return BLE_ERROR_NONE in case of success or the appropriate error code
kenjiArai 0:5b88d5760320 145 * otherwise.
kenjiArai 0:5b88d5760320 146 *
kenjiArai 0:5b88d5760320 147 * @see Bluetooth 4.2 Vol 3 PartC: 12.3 - Peripheral Preferred Connection
kenjiArai 0:5b88d5760320 148 * Parameters Characteristic
kenjiArai 0:5b88d5760320 149 */
kenjiArai 0:5b88d5760320 150 virtual ble_error_t set_peripheral_prefered_connection_parameters(
kenjiArai 0:5b88d5760320 151 const ::Gap::ConnectionParams_t& parameters
kenjiArai 0:5b88d5760320 152 ) = 0;
kenjiArai 0:5b88d5760320 153
kenjiArai 0:5b88d5760320 154 private:
kenjiArai 0:5b88d5760320 155 GenericAccessService(const GenericAccessService&);
kenjiArai 0:5b88d5760320 156 GenericAccessService& operator=(const GenericAccessService&);
kenjiArai 0:5b88d5760320 157 };
kenjiArai 0:5b88d5760320 158
kenjiArai 0:5b88d5760320 159 } // namespace pal
kenjiArai 0:5b88d5760320 160 } // namespace ble
kenjiArai 0:5b88d5760320 161
kenjiArai 0:5b88d5760320 162 #endif /* BLE_PAL_GENERIC_ACCESS_SERVICE_H_ */