Skip to content

Commit 082d55a

Browse files
authored
Merge pull request #599 from google/gbg/hfp-19
add super wide band constants
2 parents 4c3fd56 + b3869f2 commit 082d55a

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

bumble/hfp.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class HfFeature(enum.IntFlag):
141141
"""
142142
HF supported features (AT+BRSF=) (normative).
143143
144-
Hands-Free Profile v1.8, 4.34.2, AT Capabilities Re-Used from GSM 07.07 and 3GPP 27.007.
144+
Hands-Free Profile v1.9, 4.34.2, AT Capabilities Re-Used from GSM 07.07 and 3GPP 27.007.
145145
"""
146146

147147
EC_NR = 0x001 # Echo Cancel & Noise reduction
@@ -155,14 +155,14 @@ class HfFeature(enum.IntFlag):
155155
HF_INDICATORS = 0x100
156156
ESCO_S4_SETTINGS_SUPPORTED = 0x200
157157
ENHANCED_VOICE_RECOGNITION_STATUS = 0x400
158-
VOICE_RECOGNITION_TEST = 0x800
158+
VOICE_RECOGNITION_TEXT = 0x800
159159

160160

161161
class AgFeature(enum.IntFlag):
162162
"""
163163
AG supported features (+BRSF:) (normative).
164164
165-
Hands-Free Profile v1.8, 4.34.2, AT Capabilities Re-Used from GSM 07.07 and 3GPP 27.007.
165+
Hands-Free Profile v1.9, 4.34.2, AT Capabilities Re-Used from GSM 07.07 and 3GPP 27.007.
166166
"""
167167

168168
THREE_WAY_CALLING = 0x001
@@ -178,7 +178,7 @@ class AgFeature(enum.IntFlag):
178178
HF_INDICATORS = 0x400
179179
ESCO_S4_SETTINGS_SUPPORTED = 0x800
180180
ENHANCED_VOICE_RECOGNITION_STATUS = 0x1000
181-
VOICE_RECOGNITION_TEST = 0x2000
181+
VOICE_RECOGNITION_TEXT = 0x2000
182182

183183

184184
class AudioCodec(enum.IntEnum):
@@ -1390,6 +1390,7 @@ def _on_brsf(self, hf_features: bytes) -> None:
13901390

13911391
def _on_bac(self, *args) -> None:
13921392
self.supported_audio_codecs = [AudioCodec(int(value)) for value in args]
1393+
self.emit('supported_audio_codecs', self.supported_audio_codecs)
13931394
self.send_ok()
13941395

13951396
def _on_bcs(self, codec: bytes) -> None:
@@ -1618,7 +1619,7 @@ class ProfileVersion(enum.IntEnum):
16181619
"""
16191620
Profile version (normative).
16201621
1621-
Hands-Free Profile v1.8, 5.3 SDP Interoperability Requirements.
1622+
Hands-Free Profile v1.8, 6.3 SDP Interoperability Requirements.
16221623
"""
16231624

16241625
V1_5 = 0x0105
@@ -1632,34 +1633,36 @@ class HfSdpFeature(enum.IntFlag):
16321633
"""
16331634
HF supported features (normative).
16341635
1635-
Hands-Free Profile v1.8, 5.3 SDP Interoperability Requirements.
1636+
Hands-Free Profile v1.9, 6.3 SDP Interoperability Requirements.
16361637
"""
16371638

16381639
EC_NR = 0x01 # Echo Cancel & Noise reduction
16391640
THREE_WAY_CALLING = 0x02
16401641
CLI_PRESENTATION_CAPABILITY = 0x04
16411642
VOICE_RECOGNITION_ACTIVATION = 0x08
16421643
REMOTE_VOLUME_CONTROL = 0x10
1643-
WIDE_BAND = 0x20 # Wide band speech
1644+
WIDE_BAND_SPEECH = 0x20
16441645
ENHANCED_VOICE_RECOGNITION_STATUS = 0x40
1645-
VOICE_RECOGNITION_TEST = 0x80
1646+
VOICE_RECOGNITION_TEXT = 0x80
1647+
SUPER_WIDE_BAND = 0x100
16461648

16471649

16481650
class AgSdpFeature(enum.IntFlag):
16491651
"""
16501652
AG supported features (normative).
16511653
1652-
Hands-Free Profile v1.8, 5.3 SDP Interoperability Requirements.
1654+
Hands-Free Profile v1.9, 6.3 SDP Interoperability Requirements.
16531655
"""
16541656

16551657
THREE_WAY_CALLING = 0x01
16561658
EC_NR = 0x02 # Echo Cancel & Noise reduction
16571659
VOICE_RECOGNITION_FUNCTION = 0x04
16581660
IN_BAND_RING_TONE_CAPABILITY = 0x08
16591661
VOICE_TAG = 0x10 # Attach a number to voice tag
1660-
WIDE_BAND = 0x20 # Wide band speech
1662+
WIDE_BAND_SPEECH = 0x20
16611663
ENHANCED_VOICE_RECOGNITION_STATUS = 0x40
1662-
VOICE_RECOGNITION_TEST = 0x80
1664+
VOICE_RECOGNITION_TEXT = 0x80
1665+
SUPER_WIDE_BAND_SPEED_SPEECH = 0x100
16631666

16641667

16651668
def make_hf_sdp_records(
@@ -1692,11 +1695,11 @@ def make_hf_sdp_records(
16921695
in configuration.supported_hf_features
16931696
):
16941697
hf_supported_features |= HfSdpFeature.ENHANCED_VOICE_RECOGNITION_STATUS
1695-
if HfFeature.VOICE_RECOGNITION_TEST in configuration.supported_hf_features:
1696-
hf_supported_features |= HfSdpFeature.VOICE_RECOGNITION_TEST
1698+
if HfFeature.VOICE_RECOGNITION_TEXT in configuration.supported_hf_features:
1699+
hf_supported_features |= HfSdpFeature.VOICE_RECOGNITION_TEXT
16971700

16981701
if AudioCodec.MSBC in configuration.supported_audio_codecs:
1699-
hf_supported_features |= HfSdpFeature.WIDE_BAND
1702+
hf_supported_features |= HfSdpFeature.WIDE_BAND_SPEECH
17001703

17011704
return [
17021705
sdp.ServiceAttribute(
@@ -1772,14 +1775,14 @@ def make_ag_sdp_records(
17721775
in configuration.supported_ag_features
17731776
):
17741777
ag_supported_features |= AgSdpFeature.ENHANCED_VOICE_RECOGNITION_STATUS
1775-
if AgFeature.VOICE_RECOGNITION_TEST in configuration.supported_ag_features:
1776-
ag_supported_features |= AgSdpFeature.VOICE_RECOGNITION_TEST
1778+
if AgFeature.VOICE_RECOGNITION_TEXT in configuration.supported_ag_features:
1779+
ag_supported_features |= AgSdpFeature.VOICE_RECOGNITION_TEXT
17771780
if AgFeature.IN_BAND_RING_TONE_CAPABILITY in configuration.supported_ag_features:
17781781
ag_supported_features |= AgSdpFeature.IN_BAND_RING_TONE_CAPABILITY
17791782
if AgFeature.VOICE_RECOGNITION_FUNCTION in configuration.supported_ag_features:
17801783
ag_supported_features |= AgSdpFeature.VOICE_RECOGNITION_FUNCTION
17811784
if AudioCodec.MSBC in configuration.supported_audio_codecs:
1782-
ag_supported_features |= AgSdpFeature.WIDE_BAND
1785+
ag_supported_features |= AgSdpFeature.WIDE_BAND_SPEECH
17831786

17841787
return [
17851788
sdp.ServiceAttribute(

examples/run_hfp_gateway.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import os
2222
import io
2323
import logging
24-
import websockets
24+
from typing import Iterable, Optional
2525

26-
from typing import Optional
26+
import websockets
2727

2828
import bumble.core
2929
from bumble.device import Device, ScoLink
@@ -82,6 +82,10 @@ def on_microphone_volume(level: int):
8282
send_message(type='microphone_volume', level=level)
8383

8484

85+
def on_supported_audio_codecs(codecs: Iterable[hfp.AudioCodec]):
86+
send_message(type='supported_audio_codecs', codecs=[codec.name for codec in codecs])
87+
88+
8589
def on_sco_state_change(codec: int):
8690
if codec == hfp.AudioCodec.CVSD:
8791
sample_rate = 8000
@@ -207,6 +211,7 @@ def on_dlc(dlc: rfcomm.DLC):
207211
ag_protocol = hfp.AgProtocol(dlc, configuration)
208212
ag_protocol.on('speaker_volume', on_speaker_volume)
209213
ag_protocol.on('microphone_volume', on_microphone_volume)
214+
ag_protocol.on('supported_audio_codecs', on_supported_audio_codecs)
210215
on_hfp_state_change(True)
211216
dlc.multiplexer.l2cap_channel.on(
212217
'close', lambda: on_hfp_state_change(False)
@@ -241,7 +246,7 @@ def on_sco_connection(sco_link: ScoLink):
241246
# Pick the first one
242247
channel, version, hf_sdp_features = hfp_record
243248
print(f'HF version: {version}')
244-
print(f'HF features: {hf_sdp_features}')
249+
print(f'HF features: {hf_sdp_features.name}')
245250

246251
# Request authentication
247252
print('*** Authenticating...')

tests/hfp_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _default_hf_configuration() -> hfp.HfConfiguration:
6161
# -----------------------------------------------------------------------------
6262
def _default_hf_sdp_features() -> hfp.HfSdpFeature:
6363
return (
64-
hfp.HfSdpFeature.WIDE_BAND
64+
hfp.HfSdpFeature.WIDE_BAND_SPEECH
6565
| hfp.HfSdpFeature.THREE_WAY_CALLING
6666
| hfp.HfSdpFeature.CLI_PRESENTATION_CAPABILITY
6767
)
@@ -108,7 +108,7 @@ def _default_ag_configuration() -> hfp.AgConfiguration:
108108
# -----------------------------------------------------------------------------
109109
def _default_ag_sdp_features() -> hfp.AgSdpFeature:
110110
return (
111-
hfp.AgSdpFeature.WIDE_BAND
111+
hfp.AgSdpFeature.WIDE_BAND_SPEECH
112112
| hfp.AgSdpFeature.IN_BAND_RING_TONE_CAPABILITY
113113
| hfp.AgSdpFeature.THREE_WAY_CALLING
114114
)

0 commit comments

Comments
 (0)