3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2014-2017 Nest Labs, Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * This file defines the interface for downcalls from BleLayer
22 * to a platform's BLE framework.
27 #include <ble/BleConfig.h>
29 #include <ble/BleUUID.h>
31 #include <support/DLLUtil.h>
32 #include <system/SystemPacketBuffer.h>
37 using ::chip::System::PacketBufferHandle;
39 // Platform-agnostic BLE interface
40 class DLL_EXPORT BlePlatformDelegate
43 virtual ~BlePlatformDelegate() {}
45 // Following APIs must be implemented by platform:
47 // Subscribe to updates and indications on the specfied characteristic
48 virtual bool SubscribeCharacteristic(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId) = 0;
50 // Unsubscribe from updates and indications on the specified characteristic
51 virtual bool UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId,
52 const ChipBleUUID * charId) = 0;
54 // Close the underlying BLE connection.
55 virtual bool CloseConnection(BLE_CONNECTION_OBJECT connObj) = 0;
57 // Get MTU size negotiated for specified BLE connection. Return value of 0 means MTU size could not be determined.
58 virtual uint16_t GetMTU(BLE_CONNECTION_OBJECT connObj) const = 0;
60 // Data path calling convention:
61 // A 'true' return value from a Send* function indicates that the characteristic was written or updated
62 // successfully. A 'false' value indicates failure, and is used to report this failure to the user via the return
63 // value of chipConnection::SendMessage.
65 // Send GATT characteristic indication request
66 virtual bool SendIndication(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId,
67 PacketBufferHandle pBuf) = 0;
69 // Send GATT characteristic write request
70 virtual bool SendWriteRequest(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId,
71 PacketBufferHandle pBuf) = 0;
73 // Send GATT characteristic read request
74 virtual bool SendReadRequest(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId,
75 PacketBufferHandle pBuf) = 0;
77 // Send response to remote host's GATT chacteristic read response
78 virtual bool SendReadResponse(BLE_CONNECTION_OBJECT connObj, BLE_READ_REQUEST_CONTEXT requestContext, const ChipBleUUID * svcId,
79 const ChipBleUUID * charId) = 0;
83 } /* namespace chip */