Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / ble / BlePlatformDelegate.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2014-2017 Nest Labs, Inc.
5  *
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
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18
19 /**
20  *    @file
21  *      This file defines the interface for downcalls from BleLayer
22  *      to a platform's BLE framework.
23  */
24
25 #pragma once
26
27 #include <ble/BleConfig.h>
28
29 #include <ble/BleUUID.h>
30
31 #include <support/DLLUtil.h>
32 #include <system/SystemPacketBuffer.h>
33
34 namespace chip {
35 namespace Ble {
36
37 using ::chip::System::PacketBufferHandle;
38
39 // Platform-agnostic BLE interface
40 class DLL_EXPORT BlePlatformDelegate
41 {
42 public:
43     virtual ~BlePlatformDelegate() {}
44
45     // Following APIs must be implemented by platform:
46
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;
49
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;
53
54     // Close the underlying BLE connection.
55     virtual bool CloseConnection(BLE_CONNECTION_OBJECT connObj) = 0;
56
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;
59
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.
64
65     // Send GATT characteristic indication request
66     virtual bool SendIndication(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId,
67                                 PacketBufferHandle pBuf) = 0;
68
69     // Send GATT characteristic write request
70     virtual bool SendWriteRequest(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId,
71                                   PacketBufferHandle pBuf) = 0;
72
73     // Send GATT characteristic read request
74     virtual bool SendReadRequest(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId,
75                                  PacketBufferHandle pBuf) = 0;
76
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;
80 };
81
82 } /* namespace Ble */
83 } /* namespace chip */