1 // Copyright 2023 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include "pw_bluetooth_sapphire/internal/host/gatt/mock_server.h"
16
17 #include "pw_bluetooth_sapphire/internal/host/att/att.h"
18 #include "pw_bluetooth_sapphire/internal/host/gatt/gatt_defs.h"
19 #include "pw_unit_test/framework.h"
20
21 namespace bt::gatt::testing {
22
MockServer(PeerId peer_id,LocalServiceManager::WeakPtr local_services)23 MockServer::MockServer(PeerId peer_id,
24 LocalServiceManager::WeakPtr local_services)
25 : peer_id_(peer_id),
26 local_services_(std::move(local_services)),
27 weak_self_(this) {}
28
SendUpdate(IdType service_id,IdType chrc_id,BufferView value,IndicationCallback indicate_cb)29 void MockServer::SendUpdate(IdType service_id,
30 IdType chrc_id,
31 BufferView value,
32 IndicationCallback indicate_cb) {
33 if (update_handler_) {
34 update_handler_(service_id, chrc_id, value, std::move(indicate_cb));
35 } else {
36 ADD_FAILURE() << "notification/indication sent without an update_handler_";
37 }
38 }
39
40 } // namespace bt::gatt::testing
41