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 #pragma once 16 #include <string> 17 18 #include "pw_bluetooth_sapphire/internal/host/hci-spec/protocol.h" 19 20 namespace bt::hci_spec { 21 22 using AdvertisingEventBits = uint16_t; 23 24 // Helper functions to convert HCI data types to library objects. 25 26 // Returns a user-friendly string representation of |version|. 27 std::string HCIVersionToString( 28 pw::bluetooth::emboss::CoreSpecificationVersion version); 29 30 // Returns a user-friendly string representation of |status|. 31 std::string StatusCodeToString(pw::bluetooth::emboss::StatusCode code); 32 33 // Returns a user-friendly string representation of |link_type|. 34 const char* LinkTypeToString(pw::bluetooth::emboss::LinkType link_type); 35 36 // Returns a user-friendly string representation of |key_type|. 37 const char* LinkKeyTypeToString(hci_spec::LinkKeyType key_type); 38 39 // Returns a user-friendly string representation of |role|. 40 std::string ConnectionRoleToString(pw::bluetooth::emboss::ConnectionRole role); 41 42 // Convert a LEAdvertisingType's properties (e.g. connectable, scannable, 43 // directed, etc) to the appropriate advertising event bits for use in 44 // HCI_LE_Set_Extended_Advertising_Parameters (Core Spec, Volume 4, Part E, 45 // Section 7.8.53) 46 std::optional<AdvertisingEventBits> AdvertisingTypeToEventBits( 47 pw::bluetooth::emboss::LEAdvertisingType type); 48 49 } // namespace bt::hci_spec 50