nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches
ble_lbs_data_provider.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#pragma once
8
9#include "ble_bridged_device.h"
10#include "ble_connectivity_manager.h"
11#include "bridged_device_data_provider.h"
12
14
15class BleLBSDataProvider : public Nrf::BLEBridgedDeviceProvider {
16public:
17 explicit BleLBSDataProvider(UpdateAttributeCallback updateCallback, InvokeCommandCallback commandCallback)
18 : BLEBridgedDeviceProvider(updateCallback, commandCallback)
19 {
20 }
21
22 void Init() override;
23 void NotifyUpdateState(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data,
24 size_t dataSize) override;
25 CHIP_ERROR UpdateState(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer) override;
26
27 static void NotifyOnOffAttributeChange(intptr_t context);
28#ifdef CONFIG_BRIDGE_GENERIC_SWITCH_BRIDGED_DEVICE
29 static void NotifySwitchCurrentPositionAttributeChange(intptr_t context);
30#endif
31
32 static void GattWriteCallback(bt_conn *conn, uint8_t err, bt_gatt_write_params *params);
33 static uint8_t GattNotifyCallback(bt_conn *conn, bt_gatt_subscribe_params *params, const void *data,
34 uint16_t length);
35
36 const bt_uuid *GetServiceUuid() override;
37 int ParseDiscoveredData(bt_gatt_dm *discoveredData) override;
38
39private:
40 void Subscribe();
41 bool CheckSubscriptionParameters(bt_gatt_subscribe_params *params);
42
43 bool mOnOff = false;
44#ifdef CONFIG_BRIDGE_GENERIC_SWITCH_BRIDGED_DEVICE
45 uint8_t mCurrentSwitchPosition = false;
46#endif
47 uint16_t mLedCharacteristicHandle;
48 bt_gatt_write_params mGattWriteParams{};
49 uint16_t mButtonCharacteristicHandle;
50 uint16_t mCccHandle;
51 bt_gatt_subscribe_params mGattSubscribeParams{};
52
53 uint8_t mGattWriteDataBuffer[sizeof(mOnOff)];
54};
void Init() override
BleLBSDataProvider(UpdateAttributeCallback updateCallback, InvokeCommandCallback commandCallback)
Definition ble_lbs_data_provider.h:17
void NotifyUpdateState(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data, size_t dataSize) override
CHIP_ERROR UpdateState(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer) override
static uint8_t GattNotifyCallback(bt_conn *conn, bt_gatt_subscribe_params *params, const void *data, uint16_t length)
static void GattWriteCallback(bt_conn *conn, uint8_t err, bt_gatt_write_params *params)
int ParseDiscoveredData(bt_gatt_dm *discoveredData) override
const bt_uuid * GetServiceUuid() override
static void NotifyOnOffAttributeChange(intptr_t context)
Definition ble_lbs_data_provider.h:15