Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: nRF51_Vdd TextLCD BME280
GenericGattClient.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2017-2017 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef MBED_BLE_GENERIC_GATT_CLIENT 00018 #define MBED_BLE_GENERIC_GATT_CLIENT 00019 00020 #include <algorithm> 00021 #include "ble/GattClient.h" 00022 #include "ble/pal/PalGattClient.h" 00023 #include "ble/pal/SigningEventMonitor.h" 00024 00025 // IMPORTANT: private header. Not part of the public interface. 00026 00027 namespace ble { 00028 namespace generic { 00029 00030 /** 00031 * Generic implementation of the GattClient. 00032 * It requires a pal::GattClient injected at construction site. 00033 * @attention: Not part of the public interface of BLE API. 00034 */ 00035 class GenericGattClient : public GattClient, 00036 public pal::SigningEventMonitor { 00037 public: 00038 /** 00039 * Create a GenericGattClient from a pal::GattClient 00040 */ 00041 GenericGattClient(pal::GattClient* pal_client); 00042 00043 /** 00044 * @see GattClient::launchServiceDiscovery 00045 */ 00046 virtual ble_error_t launchServiceDiscovery ( 00047 Gap::Handle_t connection_handle, 00048 ServiceDiscovery::ServiceCallback_t service_callback, 00049 ServiceDiscovery::CharacteristicCallback_t characteristic_callback, 00050 const UUID& matching_service_uuid, 00051 const UUID& matching_characteristic_uuid 00052 ); 00053 00054 /** 00055 * @see GattClient::isServiceDiscoveryActive 00056 */ 00057 virtual bool isServiceDiscoveryActive () const; 00058 00059 /** 00060 * @see GattClient::terminateServiceDiscovery 00061 */ 00062 virtual void terminateServiceDiscovery (); 00063 00064 /** 00065 * @see GattClient::read 00066 */ 00067 virtual ble_error_t read ( 00068 Gap::Handle_t connection_handle, 00069 GattAttribute::Handle_t attribute_handle, 00070 uint16_t offset 00071 ) const; 00072 00073 /** 00074 * @see GattClient::write 00075 */ 00076 virtual ble_error_t write ( 00077 GattClient::WriteOp_t cmd, 00078 Gap::Handle_t connection_handle, 00079 GattAttribute::Handle_t attribute_handle, 00080 size_t length, 00081 const uint8_t* value 00082 ) const; 00083 00084 /** 00085 * @see GattClient::onServiceDiscoveryTermination 00086 */ 00087 virtual void onServiceDiscoveryTermination ( 00088 ServiceDiscovery::TerminationCallback_t callback 00089 ); 00090 00091 /** 00092 * @see GattClient::discoverCharacteristicDescriptors 00093 */ 00094 virtual ble_error_t discoverCharacteristicDescriptors ( 00095 const DiscoveredCharacteristic& characteristic, 00096 const CharacteristicDescriptorDiscovery::DiscoveryCallback_t & discoveryCallback, 00097 const CharacteristicDescriptorDiscovery::TerminationCallback_t & terminationCallback 00098 ); 00099 00100 /** 00101 * @see GattClient::isCharacteristicDescriptorDiscoveryActive 00102 */ 00103 virtual bool isCharacteristicDescriptorDiscoveryActive ( 00104 const DiscoveredCharacteristic& characteristic 00105 ) const; 00106 00107 /** 00108 * @see GattClient::terminateCharacteristicDescriptorDiscovery 00109 */ 00110 virtual void terminateCharacteristicDescriptorDiscovery ( 00111 const DiscoveredCharacteristic& characteristic 00112 ); 00113 00114 /** 00115 * @see GattClient::reset 00116 */ 00117 virtual ble_error_t reset (void); 00118 00119 /** 00120 * @see ble::pal::SigningEventMonitor::set_signing_event_handler 00121 */ 00122 virtual void set_signing_event_handler (pal::SigningEventMonitor::EventHandler *signing_event_handler); 00123 00124 private: 00125 struct ProcedureControlBlock; 00126 struct DiscoveryControlBlock; 00127 struct ReadControlBlock; 00128 struct WriteControlBlock; 00129 struct DescriptorDiscoveryControlBlock; 00130 00131 ProcedureControlBlock* get_control_block(Gap::Handle_t connection); 00132 const ProcedureControlBlock* get_control_block(Gap::Handle_t connection) const; 00133 void insert_control_block(ProcedureControlBlock* cb) const; 00134 void remove_control_block(ProcedureControlBlock* cb) const; 00135 00136 void on_termination(Gap::Handle_t connection_handle); 00137 void on_server_message_received(connection_handle_t, const pal::AttServerMessage&); 00138 void on_server_response(connection_handle_t, const pal::AttServerMessage&); 00139 void on_server_event(connection_handle_t, const pal::AttServerMessage&); 00140 void on_transaction_timeout(connection_handle_t); 00141 00142 uint16_t get_mtu(Gap::Handle_t connection) const; 00143 00144 pal::GattClient* const _pal_client; 00145 ServiceDiscovery::TerminationCallback_t _termination_callback; 00146 pal::SigningEventMonitor::EventHandler* _signing_event_handler; 00147 mutable ProcedureControlBlock* control_blocks; 00148 bool _is_reseting; 00149 }; 00150 00151 } 00152 } 00153 00154 #endif /* MBED_BLE_GENERIC_GATT_CLIENT */
Generated on Tue Jul 12 2022 15:15:46 by
