Coverage Report

Created: 2025-06-24 06:17

/src/connectedhomeip/src/ble/BlePlatformDelegate.h
Line
Count
Source (jump to first uncovered line)
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
#ifndef _CHIP_BLE_BLE_H
28
#error "Please include <ble/Ble.h> instead!"
29
#endif
30
31
#include <lib/core/CHIPError.h>
32
#include <lib/support/DLLUtil.h>
33
#include <system/SystemPacketBuffer.h>
34
35
#include "BleConfig.h"
36
#include "BleUUID.h"
37
38
namespace chip {
39
namespace Ble {
40
41
using ::chip::System::PacketBufferHandle;
42
43
// Platform-agnostic BLE interface
44
class DLL_EXPORT BlePlatformDelegate
45
{
46
public:
47
0
    virtual ~BlePlatformDelegate() {}
48
49
    // Following APIs must be implemented by platform:
50
51
    // Subscribe to updates and indications on the specfied characteristic
52
    virtual CHIP_ERROR SubscribeCharacteristic(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId,
53
                                               const ChipBleUUID * charId) = 0;
54
55
    // Unsubscribe from updates and indications on the specified characteristic
56
    virtual CHIP_ERROR UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId,
57
                                                 const ChipBleUUID * charId) = 0;
58
59
    // Close the underlying BLE connection.
60
    virtual CHIP_ERROR CloseConnection(BLE_CONNECTION_OBJECT connObj) = 0;
61
62
    // Get MTU size negotiated for specified BLE connection. Return value of 0 means MTU size could not be determined.
63
    virtual uint16_t GetMTU(BLE_CONNECTION_OBJECT connObj) const = 0;
64
65
    // Send GATT characteristic indication request
66
    virtual CHIP_ERROR SendIndication(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId,
67
                                      PacketBufferHandle pBuf) = 0;
68
69
    // Send GATT characteristic write request
70
    virtual CHIP_ERROR SendWriteRequest(BLE_CONNECTION_OBJECT connObj, const ChipBleUUID * svcId, const ChipBleUUID * charId,
71
                                        PacketBufferHandle pBuf) = 0;
72
};
73
74
} /* namespace Ble */
75
} /* namespace chip */