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 */ 00052 virtual void on_connected( 00053 connection_handle_t connection, 00054 ::Gap::Role_t role, 00055 BLEProtocol::AddressType_t peer_address_type, 00056 const BLEProtocol::AddressBytes_t peer_address, 00057 BLEProtocol::AddressType_t local_address_type, 00058 const BLEProtocol::AddressBytes_t local_address, 00059 const ::Gap::ConnectionParams_t *connection_params 00060 ) = 0; 00061 00062 /** 00063 * Inform the monitor about a disconnection. 00064 * 00065 * @param[in] connectionHandle Handle to identify the connection. 00066 * @param[in] reason Reason for the disconnection. 00067 */ 00068 virtual void on_disconnected( 00069 connection_handle_t connection, 00070 ::Gap::DisconnectionReason_t reason 00071 ) = 0; 00072 }; 00073 00074 /** 00075 * Register a handler for connection events to be used internally and serviced first. 00076 * 00077 * @param[in] connection_event_handler Event handler being registered. 00078 */ 00079 virtual void set_connection_event_handler(EventHandler *connection_event_handler) = 0; 00080 }; 00081 00082 } // namespace pal 00083 } // namespace ble 00084 00085 #endif /* MBED_BLE_CONNECTION_EVENT_MONITOR */
Generated on Tue Jul 12 2022 14:23:32 by
