• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 HIMSA II K/S - www.himsa.com.
3  * Represented by EHIMA - www.ehima.com
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 #include "mock_state_machine.h"
19 
20 using namespace bluetooth::le_audio::broadcaster;
21 
22 IBroadcastStateMachineCallbacks* callbacks;
23 AdvertisingCallbacks* adv_callbacks;
Initialize(IBroadcastStateMachineCallbacks * cb,AdvertisingCallbacks * adv_cb)24 void BroadcastStateMachine::Initialize(IBroadcastStateMachineCallbacks* cb,
25                                        AdvertisingCallbacks* adv_cb) {
26   callbacks = cb;
27   adv_callbacks = adv_cb;
28 }
29 
CreateInstance(BroadcastStateMachineConfig msg)30 std::unique_ptr<BroadcastStateMachine> BroadcastStateMachine::CreateInstance(
31     BroadcastStateMachineConfig msg) {
32   auto instance = std::make_unique<MockBroadcastStateMachine>(
33       std::move(msg), callbacks, adv_callbacks);
34   MockBroadcastStateMachine::last_instance_ = instance.get();
35   return std::move(instance);
36 }
37 
38 namespace bluetooth::le_audio {
39 namespace broadcaster {
40 
operator <<(std::ostream & os,const BroadcastStateMachine::Message & state)41 std::ostream& operator<<(std::ostream& os,
42                          const BroadcastStateMachine::Message& state) {
43   static const char* char_value_[BroadcastStateMachine::MESSAGE_COUNT] = {
44       "START", "SUSPEND", "STOP"};
45   os << char_value_[static_cast<uint8_t>(state)];
46   return os;
47 }
48 
operator <<(std::ostream & os,const BroadcastStateMachine::State & state)49 std::ostream& operator<<(std::ostream& os,
50                          const BroadcastStateMachine::State& state) {
51   static const char* char_value_[BroadcastStateMachine::STATE_COUNT] = {
52       "STOPPED", "CONFIGURING", "CONFIGURED", "STOPPING", "STREAMING"};
53   os << char_value_[static_cast<uint8_t>(state)];
54   return os;
55 }
56 
operator <<(std::ostream & os,const BigConfig & config)57 std::ostream& operator<<(std::ostream& os, const BigConfig& config) {
58   return os;
59 }
60 
operator <<(std::ostream & os,const BroadcastStateMachineConfig & config)61 std::ostream& operator<<(std::ostream& os,
62                          const BroadcastStateMachineConfig& config) {
63   return os;
64 }
65 
operator <<(std::ostream & os,const BroadcastStateMachine & machine)66 std::ostream& operator<<(std::ostream& os,
67                          const BroadcastStateMachine& machine) {
68   return os;
69 }
70 
71 }  // namespace broadcaster
72 }  // namespace bluetooth::le_audio
73 
74 uint8_t MockBroadcastStateMachine::instance_counter_ = 0;
75 MockBroadcastStateMachine* MockBroadcastStateMachine::last_instance_ = nullptr;
76