You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: applications/matter_bridge/doc/adding_ble_bridged_device_service.rst
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,8 +31,8 @@ The following steps show how to add support for a new Bluetooth LE service calle
31
31
32
32
#. Implement the ``Bridged Device Data Provider`` role.
33
33
34
-
a. Create the :file:`my_bt_service_data_provider.cpp` and :file:`my_bt_service_data_provider.h` files for your Bluetooth LE Data Provider in the :file:`src/ble_providers` directory.
35
-
#. Open the :file:`nrf/samples/matter/common/src/bridge/ble_bridged_device.h` header file and find the :c:struct:`BLEBridgedDeviceProvider` class constructor.
34
+
a. Create the :file:`my_bt_service_data_provider.cpp` and :file:`my_bt_service_data_provider.h` files for your Bluetooth LE Data Provider in the :file:`src/ble/data_providers` directory.
35
+
#. Open the :file:`nrf/applications/matter_bridge/src/ble/data_providers/ble_bridged_device.h` header file and find the :c:struct:`BLEBridgedDeviceProvider` class constructor.
36
36
Note the constructor signature, it will be used in the child class implemented in the next steps.
37
37
#. Add a new :c:struct:`MyBtServiceDataProvider` class inheriting :c:struct:`BLEBridgedDeviceProvider`, and implement its constructor in the :file:`my_bt_service_data_provider.h` file.
38
38
@@ -50,7 +50,7 @@ The following steps show how to add support for a new Bluetooth LE service calle
50
50
51
51
};
52
52
53
-
#. Open the :file:`nrf/samples/matter/common/src/bridge/ble_bridged_device.h` header file again to see which methods of :c:struct:`BLEBridgedDeviceProvider` class are purely virtual (assigned with ``=0``) and have to be overridden by the :c:struct:`MyBtServiceDataProvider` class.
53
+
#. Open the :file:`nrf/applications/matter_bridge/src/ble/data_providers/ble_bridged_device.h` header file again to see which methods of :c:struct:`BLEBridgedDeviceProvider` class are purely virtual (assigned with ``=0``) and have to be overridden by the :c:struct:`MyBtServiceDataProvider` class.
54
54
55
55
Note that :c:struct:`BLEBridgedDeviceProvider` inherits from the :c:struct:`BridgedDeviceDataProvider` class, so the :c:struct:`MyBtServiceDataProvider` class has to implement the purely virtual methods of :c:struct:`BridgedDeviceDataProvider` as well.
56
56
#. Edit the :c:struct:`MyBtServiceDataProvider` class in the :file:`my_bt_service_data_provider.h` header file to declare the required methods as follows:
@@ -247,12 +247,12 @@ The following steps show how to add support for a new Bluetooth LE service calle
#. Provide an allocator for ``MyBtServiceDataProvider`` object creation.
254
254
The Matter Bridge application uses a :c:struct:`BleBridgedDeviceFactory` factory module that creates paired ``Matter Bridged Device`` and ``Bridged Device Data Provider`` objects matching a specific Matter device type ID.
255
-
To add support for creating the ``MyBtServiceDataProvider`` object, edit the :file:`src/ble_providers/ble_bridged_device_factory.h` and :file:`src/ble_providers/ble_bridged_device_factory.cpp` files as follows:
255
+
To add support for creating the ``MyBtServiceDataProvider`` object, edit the :file:`src/ble/ble_bridged_device_factory.h` and :file:`src/ble/ble_bridged_device_factory.cpp` files as follows:
256
256
257
257
- :file:`ble_bridged_device_factory.h`
258
258
@@ -270,7 +270,7 @@ The following steps show how to add support for a new Bluetooth LE service calle
270
270
271
271
#. Provide mapping between the ``My Bt Service`` UUID and corresponding Matter device types in the helper methods.
272
272
273
-
a. Add the ``MyBtService`` UUID in the :c:enum:`ServiceUuid` declaration, in the :file:`src/ble_providers/ble_bridged_device_factory.h` header file.
274
-
#. Perform proper mapping of Bluetooth UUID and Matter device types in the :c:func:`MatterDeviceTypeToBleService` and :c:func:`BleServiceToMatterDeviceType` methods, in the :file:`src/ble_providers/ble_bridged_device_factory.cpp` file.
273
+
a. Add the ``MyBtService`` UUID in the :c:enum:`ServiceUuid` declaration, in the :file:`src/ble/ble_bridged_device_factory.h` header file.
274
+
#. Perform proper mapping of Bluetooth UUID and Matter device types in the :c:func:`MatterDeviceTypeToBleService` and :c:func:`BleServiceToMatterDeviceType` methods, in the :file:`src/ble/ble_bridged_device_factory.cpp` file.
275
275
276
276
#. Compile the target and test it following the steps from the :ref:`Matter Bridge application testing <matter_bridge_testing>` section.
Copy file name to clipboardExpand all lines: applications/matter_bridge/doc/adding_bridged_matter_device.rst
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ The following steps show how to add support for a new Matter device type, using
18
18
#. Implement the ``Matter Bridged Device`` role.
19
19
20
20
a. Create the :file:`pressure_sensor.cpp` and :file:`pressure_sensor.h` files in the :file:`src/bridged_device_types` directory.
21
-
#. Open the :file:`nrf/samples/matter/common/src/bridge/matter_bridged_device.h` header file and find the :c:struct:`MatterBridgedDevice` class constructor.
21
+
#. Open the :file:`nrf/applications/matter_bridge/src/core/matter_bridged_device.h` header file and find the :c:struct:`MatterBridgedDevice` class constructor.
22
22
Note the constructor signature, it will be used in the child class implemented in the next steps.
23
23
#. Add a new :c:struct:`PressureSensorDevice` class inheriting :c:struct:`MatterBridgedDevice`, and implement its constructor in the :file:`pressure_sensor.cpp` and :file:`pressure_sensor.h` files.
24
24
@@ -49,7 +49,7 @@ The following steps show how to add support for a new Matter device type, using
49
49
50
50
#. Declare all clusters that are mandatory for the Pressure Sensor device type, according to the Matter device library specification, and fill the appropriate :c:struct:`MatterBridgedDevice` class fields in the :c:struct:`PressureSensorDevice` class constructor.
51
51
52
-
The Pressure Sensor device requires the ``Descriptor``, ``Bridged Device Basic Information`` and ``Identify`` clusters, which can be declared using helper macros from the :file:`nrf/samples/matter/common/src/bridge/matter_bridged_device.h` header file, and the ``Pressure Measurement`` cluster, which has to be defined in the application.
52
+
The Pressure Sensor device requires the ``Descriptor``, ``Bridged Device Basic Information`` and ``Identify`` clusters, which can be declared using helper macros from the :file:`nrf/applications/matter_bridge/src/core/matter_bridged_device.h` header file, and the ``Pressure Measurement`` cluster, which has to be defined in the application.
53
53
Edit the :file:`pressure_sensor.cpp` file as follows:
54
54
55
55
- Add:
@@ -109,7 +109,7 @@ The following steps show how to add support for a new Matter device type, using
#. Open the :file:`nrf/samples/matter/common/src/bridge/matter_bridged_device.h` header file again to see which methods of the :c:struct:`MatterBridgedDevice` class are purely virtual (assigned with ``=0``) and have to be overridden by the :c:struct:`PressureSensorDevice` class.
112
+
#. Open the :file:`nrf/applications/matter_bridge/src/core/matter_bridged_device.h` header file again to see which methods of the :c:struct:`MatterBridgedDevice` class are purely virtual (assigned with ``=0``) and have to be overridden by the :c:struct:`PressureSensorDevice` class.
113
113
#. Edit the :c:struct:`PressureSensorDevice` class in the :file:`pressure_sensor.h` header file to declare the required methods as follows:
114
114
115
115
.. code-block:: C++
@@ -118,7 +118,8 @@ The following steps show how to add support for a new Matter device type, using
@@ -257,7 +258,7 @@ The following steps show how to add support for a new Matter device type, using
257
258
#. Implement the ``Bridged Device Data Provider`` role.
258
259
259
260
a. Create the :file:`simulated_pressure_sensor_data_provider.cpp` and :file:`simulated_pressure_sensor_data_provider.h` files in the :file:`src/simulated_providers` directory.
260
-
#. Open the :file:`nrf/samples/matter/common/src/bridge/bridged_device_data_provider.h` header file and find the :c:struct:`BridgedDeviceDataProvider` class constructor.
261
+
#. Open the :file:`nrf/applications/matter_bridge/src/core/bridged_device_data_provider.h` header file and find the :c:struct:`BridgedDeviceDataProvider` class constructor.
261
262
Note the constructor signature, it will be used in the child class implemented in the next steps.
262
263
#. Add a new :c:struct:`SimulatedPressureSensorDataProvider` class inheriting :c:struct:`BridgedDeviceDataProvider`, and implement its constructor in the :file:`simulated_pressure_sensor_data_provider.h` header file.
263
264
@@ -275,7 +276,7 @@ The following steps show how to add support for a new Matter device type, using
275
276
~SimulatedPressureSensorDataProvider() {}
276
277
};
277
278
278
-
#. Open the :file:`nrf/samples/matter/common/src/bridge/bridged_device_data_provider.h` header file again to see which methods of the :c:struct:`BridgedDeviceDataProvider` class are purely virtual (assigned with ``=0``) and have to be overridden by the :c:struct:`SimulatedPressureSensorDataProvider` class.
279
+
#. Open the :file:`nrf/applications/matter_bridge/src/core/bridged_device_data_provider.h` header file again to see which methods of the :c:struct:`BridgedDeviceDataProvider` class are purely virtual (assigned with ``=0``) and have to be overridden by the :c:struct:`SimulatedPressureSensorDataProvider` class.
279
280
#. Edit the :c:struct:`SimulatedPressureSensorDataProvider` class in the :file:`simulated_pressure_sensor_data_provider.h` header file to declare the required methods as follows:
280
281
281
282
.. code-block:: C++
@@ -396,7 +397,7 @@ The following steps show how to add support for a new Matter device type, using
Copy file name to clipboardExpand all lines: applications/matter_bridge/doc/adding_bridged_protocol.rst
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,3 +18,43 @@ This allows updating the Matter Data Model state and also enables handling Matte
18
18
The subscription handling can be implemented either by utilizing the implemented protocol's native support for pushing notifications by the end device, or by performing periodic data polling, which is less efficient.
19
19
20
20
If the Matter device can perform write operations or be controlled using Matter invoke command operations, the ``Bridged Device Data Provider`` shall be able to send appropriate information to the physical end device.
21
+
22
+
Complete the following steps to add support for a proprietary protocol:
23
+
24
+
1. Create a ``MyProtocol Data Provider`` class that inherits from the ``Bridged Device Data Provider`` class.
25
+
This class should contain all the data and logic used by all your bridged devices.
26
+
For reference, see the implementation in the :file:`src/ble/data_providers/ble_bridged_device.h` file.
27
+
28
+
#. For each bridged device type, create a ``MyProtocol MyDevice Data Provider`` class that inherits from the ``MyProtocol Data Provider`` class.
29
+
These classes keep the state of the Matter device synchronized with the state of the device, using the following functions:
30
+
* :c:func:`NotifyUpdateState` - Called to notify the bridge when the bridged device changed state.
31
+
* :c:func:`UpdateState` - Called by the bridge when the bridged device should update its state (for example, turning a light on or off).
32
+
33
+
#. Create a ``MyProtocol Connectivity Manager`` class that holds information about all current connections of the bridged device.
34
+
This class must implement the following functions:
This class takes care of any connection-related code that your protocol needs.
43
+
44
+
#. Create a ``MyProtocol Bridged Device Factory`` class that handles device creation, storage, and removal.
45
+
46
+
#. Adapt the main application to use your newly created classes.
47
+
Create a new ``BRIDGED_DEVICE_MY_PROTOCOL`` configuration, go through the application code and find where the :ref:`CONFIG_BRIDGED_DEVICE_BT <CONFIG_BRIDGED_DEVICE_BT>` Kconfig option is used by the preprocessor.
48
+
Add support for your protocol in the found instances.
49
+
50
+
An application with support for ``MyProtocol`` would work like this:
51
+
52
+
1. The application reads the stored devices and creates them using the ``MyProtocol Bridged Device Factory`` class.
53
+
#. To bridge new devices, the application needs to know their ``MyProtocol`` connection details.
54
+
Those details can be provided by the user or obtained through device discovery.
55
+
To enable this, implement the necessary shell commands in the :file:`src/bridge_shell.cpp` file.
56
+
#. Using the ``MyProtocol Bridged Device Factory`` class and knowing the connection details, the application creates and stores new bridged devices.
57
+
You can use the ``MyProtocol Connectivity Manager`` class to map the ``MyProtocol`` device ID to the corresponding ``MyProtocol Device Data Provider`` instance.
58
+
#. Matter traffic is routed through the ``MyProtocol MyDevice Data Provider`` class.
59
+
When data from the device is received, you can use the ``MyProtocol Connectivity Manager`` class to forward the data to the correct ``MyProtocol MyDevice Data Provider`` instance.
60
+
#. If a device must be removed, the ``MyProtocol Bridged Device Factory`` class handles it.
0 commit comments