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.
ConnectionEventMonitor.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_CONNECTION_EVENT_MONITOR 00018 #define MBED_BLE_CONNECTION_EVENT_MONITOR 00019 00020 #include "ble/BLEProtocol.h" 00021 #include "ble/Gap.h" 00022 #include "ble/BLETypes.h" 00023 00024 namespace ble { 00025 namespace pal { 00026 00027 /** 00028 * Implemented by classes that need to be notified of connection changes. 00029 * Notification is done by calling functions in the passed in event handler 00030 */ 00031 class ConnectionEventMonitor { 00032 public: 00033 /** 00034 * Implemented by classes that are reacting to connection changes. 00035 * @see ConnectionEventMonitor 00036 */ 00037 class EventHandler { 00038 public: 00039 /** 00040 * Inform the Security manager of a new connection. This will create 00041 * or retrieve an existing security manager entry for the connected device. 00042 * Called by GAP. 00043 * 00044 * @param[in] connection Handle to identify the connection. 00045 * @param[in] role indicate if the device is central or peripheral. 00046 * @param[in] peer_address_type type of address. 00047 * @param[in] peer_address Address of the connected device. 00048 * @param[in] local_address_type type of address of the local device. 00049 * @param[in] local_address Address of the local device that was used during connection. 00050 * @param[in] connection_params connection parameters like interval, latency and timeout. 00051 * @param[in] resolved_peer_address resolved address of the peer; may 00052 * be NULL. 00053 */ 00054 virtual void on_connected( 00055 connection_handle_t connection, 00056 ::Gap::Role_t role, 00057 ble::peer_address_type_t peer_address_type, 00058 const BLEProtocol::AddressBytes_t peer_address, 00059 BLEProtocol::AddressType_t local_address_type, 00060 const BLEProtocol::AddressBytes_t local_address, 00061 const ::Gap::ConnectionParams_t *connection_params 00062 ) = 0; 00063 00064 /** 00065 * Inform the monitor about a disconnection. 00066 * 00067 * @param[in] connectionHandle Handle to identify the connection. 00068 * @param[in] reason Reason for the disconnection. 00069 */ 00070 virtual void on_disconnected( 00071 connection_handle_t connection, 00072 ::Gap::DisconnectionReason_t reason 00073 ) = 0; 00074 }; 00075 00076 /** 00077 * Register a handler for connection events to be used internally and serviced first. 00078 * 00079 * @param[in] connection_event_handler Event handler being registered. 00080 */ 00081 virtual void set_connection_event_handler(EventHandler *connection_event_handler) = 0; 00082 }; 00083 00084 } // namespace pal 00085 } // namespace ble 00086 00087 #endif /* MBED_BLE_CONNECTION_EVENT_MONITOR */
Generated on Tue Jul 12 2022 12:43:43 by
