1 /* 2 * Copyright 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 18 #include "hal/socket_hal.h" 19 20 namespace bluetooth::lpp { 21 22 /** 23 * Interface to low-power processors (LPPs) for supporting LPP offload features. 24 * 25 * This interface allows inheritance from multiple offload HAL interfaces, enabling a unified 26 * offload function management approach through a single interface accessible from the upper layer. 27 */ 28 class LppOffloadInterface { 29 public: 30 LppOffloadInterface() = default; 31 32 virtual ~LppOffloadInterface() = default; 33 34 LppOffloadInterface(const LppOffloadInterface&) = delete; 35 36 LppOffloadInterface& operator=(const LppOffloadInterface&) = delete; 37 38 /** 39 * Registers a socket hal callback function to receive asynchronous events from socket HAL. 40 * 41 * The provided callback function must be executed on the main thread. 42 * 43 * @param callback A pointer to the callback function. Must not be nullptr and must have static 44 * lifetime. 45 * @return True if the callback was successfully registered, false otherwise. 46 */ 47 virtual bool RegisterSocketHalCallback(hal::SocketHalCallback* callbacks) = 0; 48 49 /** 50 * Retrieves the supported offload socket capabilities. 51 * 52 * @return Supported socket capabilities 53 */ 54 virtual hal::SocketCapabilities GetSocketCapabilities() const = 0; 55 56 /** 57 * Notifies the socket HAL that the socket has been opened. 58 * 59 * If this method returns true, SocketHalCallback.SocketOpenedComplete() shall be called to 60 * indicate the result of this operation. 61 * 62 * @param context Socket context including socket ID, channel, hub, and endpoint info 63 * @return True if calling this method was successful, false otherwise 64 */ 65 virtual bool SocketOpened(const hal::SocketContext& context) = 0; 66 67 /** 68 * Notifies the socket HAL that the socket has been closed. 69 * 70 * @param socket_id Identifier assigned to the socket by the host stack 71 */ 72 virtual void SocketClosed(uint64_t socket_id) = 0; 73 }; 74 75 } // namespace bluetooth::lpp 76