Coverage Report

Created: 2026-03-27 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/connectedhomeip/src/ble/BleConnectionDelegate.h
Line
Count
Source
1
/*
2
 *
3
 *    Copyright (c) 2020 Project CHIP Authors
4
 *
5
 *    Licensed under the Apache License, Version 2.0 (the "License");
6
 *    you may not use this file except in compliance with the License.
7
 *    You may obtain a copy of the License at
8
 *
9
 *        http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 *    Unless required by applicable law or agreed to in writing, software
12
 *    distributed under the License is distributed on an "AS IS" BASIS,
13
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 *    See the License for the specific language governing permissions and
15
 *    limitations under the License.
16
 */
17
18
/**
19
 *    @file
20
 *      This file defines the interface for application to delegate Ble connection to
21
 *      to BleLayer.
22
 */
23
24
#pragma once
25
26
#ifndef _CHIP_BLE_BLE_H
27
#error "Please include <ble/Ble.h> instead!"
28
#endif
29
30
#include <lib/support/DLLUtil.h>
31
#include <lib/support/SetupDiscriminator.h>
32
#include <lib/support/Span.h>
33
34
#include "BleConfig.h"
35
#include "BleError.h"
36
37
namespace chip {
38
namespace Ble {
39
class BleLayer;
40
} // namespace Ble
41
} // namespace chip
42
43
namespace chip {
44
namespace Ble {
45
46
// Platform-agnostic BLE interface
47
class DLL_EXPORT BleConnectionDelegate
48
{
49
public:
50
0
    virtual ~BleConnectionDelegate() {}
51
52
    // Public function pointers:
53
    typedef void (*OnConnectionCompleteFunct)(void * appState, BLE_CONNECTION_OBJECT connObj);
54
    OnConnectionCompleteFunct OnConnectionComplete;
55
56
    // A callback indicating that a connection was established to a device with (long) discriminator
57
    // matchedDiscriminator.
58
    typedef void (*OnConnectionByDiscriminatorsCompleteFunct)(void * appState, uint16_t matchedLongDiscriminator,
59
                                                              BLE_CONNECTION_OBJECT connObj);
60
61
    typedef void (*OnConnectionErrorFunct)(void * appState, CHIP_ERROR err);
62
    OnConnectionErrorFunct OnConnectionError;
63
64
    // Call this function to delegate the connection steps required to get a BLE_CONNECTION_OBJECT
65
    // out of a peripheral that matches the given discriminator.
66
    virtual void NewConnection(BleLayer * bleLayer, void * appState, const SetupDiscriminator & connDiscriminator) = 0;
67
68
    // Call this function to delegate the connection steps required to get a connected BLE_CONNECTION_OBJECT
69
    // out of a disconnected BLE_CONNECTION_OBJECT.
70
    virtual void NewConnection(BleLayer * bleLayer, void * appState, BLE_CONNECTION_OBJECT connObj) = 0;
71
72
    // Call this function to stop the connection
73
    virtual CHIP_ERROR CancelConnection() = 0;
74
75
    // Call this function to delegate the connection steps required to get a BLE_CONNECTION_OBJECT
76
    // out of a peripheral that matches any of the given discriminators.
77
    //
78
    // The provided onConnectionComplete callback may be called multiple times, if multiple
79
    // connections are created.
80
    //
81
    // If the onConnectionError callback is called, that indicates that there will be no more
82
    // onConnectionComplete callbacks until the next NewConnection call.
83
    //
84
    // Calling CancelConnection will ensure no more calls to onConnectionComplete or
85
    // onConnectionError until the next NewConnection call.
86
    //
87
    // The implementation must not assume that the memory backing the "discriminators" argument will
88
    // outlive this call returning.
89
    //
90
    virtual CHIP_ERROR NewConnection(BleLayer * bleLayer, void * appState, const Span<const SetupDiscriminator> & discriminators,
91
                                     OnConnectionByDiscriminatorsCompleteFunct onConnectionComplete,
92
                                     OnConnectionErrorFunct onConnectionError)
93
0
    {
94
        // Should this handle the case when "discriminators" has length 1 automatically by
95
        // delegating to the NewConnection overload that takes a single SetupDiscriminator?  It adds
96
        // some unavoidable codesize and storage for the discriminator to do that.  Probably better
97
        // to have the API consumers handle that.
98
0
        return CHIP_ERROR_NOT_IMPLEMENTED;
99
0
    }
Unexecuted instantiation: chip::Ble::BleConnectionDelegate::NewConnection(chip::Ble::BleLayer*, void*, chip::Span<chip::SetupDiscriminator const> const&, void (*)(void*, unsigned short, chip::DeviceLayer::Internal::BluezConnection*), void (*)(void*, chip::ChipError))
Unexecuted instantiation: chip::Ble::BleConnectionDelegate::NewConnection(chip::Ble::BleLayer*, void*, chip::Span<chip::SetupDiscriminator const> const&, void (*)(void*, unsigned short, chip::DeviceLayer::Internal::BluezConnection*), void (*)(void*, chip::ChipError))
100
};
101
102
} /* namespace Ble */
103
} /* namespace chip */