bluekitchen / btstack

Dual-mode Bluetooth stack, with small memory footprint.
http://bluekitchen-gmbh.com
Other
1.68k stars 605 forks source link

how to send dtmf tone directly in hfp_ag_demo #508

Closed alisagao123 closed 1 year ago

alisagao123 commented 1 year ago

currently, it is an sine wave which is defined in sco_demo_util.c sine_int16[], after hfp_ag_demo running and connect audio stream successfully with hands free unit, I can hear a continuous sound in hands free unit, can I do some modification to let it send dtmf tone directly in hfp_ag_demo side after the audio stream connection successfully and I can hear the voice like dtmf tone?

mringwal commented 1 year ago

If you have your device configured for SCO-over-HCI, you can send any sounds in either role. The sco_demo_util code also allows to send music (a mod song) next to microphone input or the test sine wave.

Why do you want to send DTMF sounds to the HF unit? There's usually a human with a headset on that side.

You can tell the AG to send DTMF sounds over the telephone network by calling hfp_hf_send_dtmf_code on the HFP HF side. This might be useful to navigate some call center navigation system.

alisagao123 commented 1 year ago

thanks for your quick response. actually, I want to do bluetooth HFP call function automated testing. My target test board works as HFP hands free unit, and I loopback the headset and micphone in hands free unit when hfp_ag_demo is running on one Linux PC, and in hfg_ag_demo side, I will check if the output file 'sco_input.wav' has noise or no voice to verify if hands free unit works well. it is easy for me to check if dtmf tone has voice or no voice, it has mature algorithms to do this. I don't want to change anything in hands free unit as I need to test it.

mringwal commented 1 year ago

Still not sure what you want to do. Could you clarify your feature request? Feel free to discuss general ideas on the mailing list or get in touch with us for engineering support.

HFP calls work by sending a AT command from HF to AG - no sound there. In the HFP AG demo, you should receive an event for the 'initiate call to 12345678' and also events if the user presses buttons on the HF side during the call.

If you just need any sound, you could use our mod player, or play sine tones of different frequencies.

alisagao123 commented 1 year ago
ideas

Hi @mringwal , I uploaded an picture, I am not sure if you can get my idea. thanks. and I just want to do some simple modification in source code.

alisagao123 commented 1 year ago

Is the voice I heared on hands free unit side from the array defined in sco_demo_util.c sine_int16[]? I thought it was. can I just do some modification in this array , and then I can hear the dtmf tone on hands free unit side?

mringwal commented 1 year ago

The picture helped. How do you do the loopback on the HF? In the HF software or I2S?

Anyway, I see why you want to send some kind of test tone, and you can use DTMF if you like. Depending on how you configure sco_demo_util.c it will use the sine_int16[], the mod player, or the microphone.

To generate DTMF on a desktop, could just generate the sample for the two sine waves using regular floating point math and the sin() function and and mix them together life as that's fast enough. You could also store some DTMF tones with an online tool or use Audacity, then load that file with a sound library or BTstack's wav_util.c.

alisagao123 commented 1 year ago

when I modify the SCO_DEMO_MODE to mod player, there are many failures when building. // SCO demo configuration //#define SCO_DEMO_MODE SCO_DEMO_MODE_SINE

define SCO_DEMO_MODE SCO_DEMO_MODE_MODPLAYER

alisagao123 commented 1 year ago

In source code, where I can set the audio card if I define the SCO_DEMO_MODE to microphone? as I insert an external usb audio card into my Linux PC, I don't want to use the default one on this PC,

define SCO_DEMO_MODE SCO_DEMO_MODE_MICROPHONE

I also want to define my record simple rate/channel/format if I use microphone, where I can set these parameters by myself?

mringwal commented 1 year ago

The posix port uses the default configuration of PortAudio. The examples avoid any knowledge of the underlying system.

Sample rate / num channels is fixed for Bluetooth audio.

Feel free to patch sco_util.c and/or platform/posix/btstack_audio_portaudio.c as needed.

alisagao123 commented 1 year ago

thanks @mringwal , is there example for obex file transfer?

mringwal commented 1 year ago

OBEX File Transfer - Object Push Profile - is available to commercial customers.

If you use BTstack as some kind of end-of-line product test in manufacturing, this classifies as commercial use which requires a license.

Please get in touch with us at contact@bluekichen-gmbh.com for details.