xref: /btstack/example/sco_demo_util.c (revision 8b29cfc66f1c956c3ace60bbb9a982228656eb75)
1f7c85330SMatthias Ringwald /*
2f7c85330SMatthias Ringwald  * Copyright (C) 2016 BlueKitchen GmbH
3f7c85330SMatthias Ringwald  *
4f7c85330SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5f7c85330SMatthias Ringwald  * modification, are permitted provided that the following conditions
6f7c85330SMatthias Ringwald  * are met:
7f7c85330SMatthias Ringwald  *
8f7c85330SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9f7c85330SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10f7c85330SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11f7c85330SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12f7c85330SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13f7c85330SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14f7c85330SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15f7c85330SMatthias Ringwald  *    from this software without specific prior written permission.
16f7c85330SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17f7c85330SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18f7c85330SMatthias Ringwald  *    monetary gain.
19f7c85330SMatthias Ringwald  *
20f7c85330SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21f7c85330SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22f7c85330SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23f7c85330SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24f7c85330SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25f7c85330SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26f7c85330SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27f7c85330SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28f7c85330SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29f7c85330SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30f7c85330SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31f7c85330SMatthias Ringwald  * SUCH DAMAGE.
32f7c85330SMatthias Ringwald  *
33f7c85330SMatthias Ringwald  * Please inquire about commercial licensing options at
34f7c85330SMatthias Ringwald  * [email protected]
35f7c85330SMatthias Ringwald  *
36f7c85330SMatthias Ringwald  */
37f7c85330SMatthias Ringwald 
38f7c85330SMatthias Ringwald /*
39f7c85330SMatthias Ringwald  * sco_demo_util.c - send/receive test data via SCO, used by hfp_*_demo and hsp_*_demo
40f7c85330SMatthias Ringwald  */
41f7c85330SMatthias Ringwald 
42f7c85330SMatthias Ringwald #include "sco_demo_util.h"
43f7c85330SMatthias Ringwald #include <stdio.h>
44f7c85330SMatthias Ringwald 
45f7c85330SMatthias Ringwald // configure test mode
46f7c85330SMatthias Ringwald #define SCO_DEMO_MODE_SINE		0
47f7c85330SMatthias Ringwald #define SCO_DEMO_MODE_ASCII		1
48f7c85330SMatthias Ringwald #define SCO_DEMO_MODE_COUNTER	2
49f7c85330SMatthias Ringwald 
50*8b29cfc6SMatthias Ringwald 
51f7c85330SMatthias Ringwald // SCO demo configuration
52f7c85330SMatthias Ringwald #define SCO_DEMO_MODE SCO_DEMO_MODE_SINE
53f7c85330SMatthias Ringwald #define SCO_REPORT_PERIOD 100
54f7c85330SMatthias Ringwald 
55*8b29cfc6SMatthias Ringwald #ifdef HAVE_POSIX_FILE_IO
56*8b29cfc6SMatthias Ringwald #define SCO_WAV_FILENAME "sco_input.wav"
57*8b29cfc6SMatthias Ringwald #define SCO_WAV_DURATION_IN_SECONDS 30
58*8b29cfc6SMatthias Ringwald #endif
59*8b29cfc6SMatthias Ringwald 
60f7c85330SMatthias Ringwald 
61f7c85330SMatthias Ringwald #if defined(HAVE_PORTAUDIO) && (SCO_DEMO_MODE == SCO_DEMO_MODE_SINE)
62f7c85330SMatthias Ringwald #define USE_PORTAUDIO
63f7c85330SMatthias Ringwald #endif
64f7c85330SMatthias Ringwald 
65f7c85330SMatthias Ringwald #ifdef USE_PORTAUDIO
66f7c85330SMatthias Ringwald #include <portaudio.h>
67*8b29cfc6SMatthias Ringwald // portaudio config
68*8b29cfc6SMatthias Ringwald #define NUM_CHANNELS 1
69*8b29cfc6SMatthias Ringwald #define SAMPLE_RATE 8000
70*8b29cfc6SMatthias Ringwald #define FRAMES_PER_BUFFER 24
71*8b29cfc6SMatthias Ringwald #define PA_SAMPLE_TYPE paInt8
72f7c85330SMatthias Ringwald // portaudio globals
73f7c85330SMatthias Ringwald static  PaStream * stream;
74f7c85330SMatthias Ringwald #endif
75f7c85330SMatthias Ringwald 
76f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE
77f7c85330SMatthias Ringwald // input signal: pre-computed sine wave, 160 Hz
78f7c85330SMatthias Ringwald static const uint8_t sine[] = {
79f7c85330SMatthias Ringwald       0,  15,  31,  46,  61,  74,  86,  97, 107, 114,
80f7c85330SMatthias Ringwald     120, 124, 126, 126, 124, 120, 114, 107,  97,  86,
81f7c85330SMatthias Ringwald      74,  61,  46,  31,  15,   0, 241, 225, 210, 195,
82f7c85330SMatthias Ringwald     182, 170, 159, 149, 142, 136, 132, 130, 130, 132,
83f7c85330SMatthias Ringwald     136, 142, 149, 159, 170, 182, 195, 210, 225, 241,
84f7c85330SMatthias Ringwald };
85f7c85330SMatthias Ringwald #endif
86f7c85330SMatthias Ringwald 
87f7c85330SMatthias Ringwald static int phase;
88f7c85330SMatthias Ringwald 
89*8b29cfc6SMatthias Ringwald #ifdef SCO_WAV_FILENAME
90*8b29cfc6SMatthias Ringwald 
91*8b29cfc6SMatthias Ringwald static FILE * wav_file;
92*8b29cfc6SMatthias Ringwald static int num_samples_to_write;
93*8b29cfc6SMatthias Ringwald 
94*8b29cfc6SMatthias Ringwald 
95*8b29cfc6SMatthias Ringwald static void little_endian_fstore_16(FILE * file, uint16_t value){
96*8b29cfc6SMatthias Ringwald     uint8_t buf[2];
97*8b29cfc6SMatthias Ringwald     little_endian_store_32(buf, 0, value);
98*8b29cfc6SMatthias Ringwald     fwrite(&buf, 1, 2, file);
99*8b29cfc6SMatthias Ringwald }
100*8b29cfc6SMatthias Ringwald 
101*8b29cfc6SMatthias Ringwald static void little_endian_fstore_32(FILE * file, uint32_t value){
102*8b29cfc6SMatthias Ringwald     uint8_t buf[4];
103*8b29cfc6SMatthias Ringwald     little_endian_store_32(buf, 0, value);
104*8b29cfc6SMatthias Ringwald     fwrite(&buf, 1, 4, file);
105*8b29cfc6SMatthias Ringwald }
106*8b29cfc6SMatthias Ringwald 
107*8b29cfc6SMatthias Ringwald static FILE * wav_init(const char * filename){
108*8b29cfc6SMatthias Ringwald     printf("SCO Demo: creating wav file %s\n", filename);
109*8b29cfc6SMatthias Ringwald     return fopen(filename, "wb");
110*8b29cfc6SMatthias Ringwald }
111*8b29cfc6SMatthias Ringwald 
112*8b29cfc6SMatthias Ringwald static void write_wav_header(FILE * file, int sample_rate, int num_channels, int num_samples, int bytes_per_sample){
113*8b29cfc6SMatthias Ringwald     printf("SCO Demo: writing wav header: sample rate %u, num channels %u, duration %u s, bytes per sample %u\n",
114*8b29cfc6SMatthias Ringwald         sample_rate, num_channels, num_samples / sample_rate / num_channels, bytes_per_sample);
115*8b29cfc6SMatthias Ringwald 
116*8b29cfc6SMatthias Ringwald     /* write RIFF header */
117*8b29cfc6SMatthias Ringwald     fwrite("RIFF", 1, 4, file);
118*8b29cfc6SMatthias Ringwald     // num_samples = blocks * subbands
119*8b29cfc6SMatthias Ringwald     uint32_t data_bytes = (uint32_t) (bytes_per_sample * num_samples * num_channels);
120*8b29cfc6SMatthias Ringwald     little_endian_fstore_32(file, data_bytes + 36);
121*8b29cfc6SMatthias Ringwald     fwrite("WAVE", 1, 4, file);
122*8b29cfc6SMatthias Ringwald 
123*8b29cfc6SMatthias Ringwald     int byte_rate = sample_rate * num_channels * bytes_per_sample;
124*8b29cfc6SMatthias Ringwald     int bits_per_sample = 8 * bytes_per_sample;
125*8b29cfc6SMatthias Ringwald     int block_align = num_channels * bits_per_sample;
126*8b29cfc6SMatthias Ringwald     int fmt_length = 16;
127*8b29cfc6SMatthias Ringwald     int fmt_format_tag = 1; // PCM
128*8b29cfc6SMatthias Ringwald 
129*8b29cfc6SMatthias Ringwald     /* write fmt chunk */
130*8b29cfc6SMatthias Ringwald     fwrite("fmt ", 1, 4, file);
131*8b29cfc6SMatthias Ringwald     little_endian_fstore_32(file, fmt_length);
132*8b29cfc6SMatthias Ringwald     little_endian_fstore_16(file, fmt_format_tag);
133*8b29cfc6SMatthias Ringwald     little_endian_fstore_16(file, num_channels);
134*8b29cfc6SMatthias Ringwald     little_endian_fstore_32(file, sample_rate);
135*8b29cfc6SMatthias Ringwald     little_endian_fstore_32(file, byte_rate);
136*8b29cfc6SMatthias Ringwald     little_endian_fstore_16(file, block_align);
137*8b29cfc6SMatthias Ringwald     little_endian_fstore_16(file, bits_per_sample);
138*8b29cfc6SMatthias Ringwald 
139*8b29cfc6SMatthias Ringwald     /* write data chunk */
140*8b29cfc6SMatthias Ringwald     fwrite("data", 1, 4, file);
141*8b29cfc6SMatthias Ringwald     little_endian_fstore_32(file, data_bytes);
142*8b29cfc6SMatthias Ringwald }
143*8b29cfc6SMatthias Ringwald 
144*8b29cfc6SMatthias Ringwald static void write_wav_data_uint8(FILE * file, unsigned long num_samples, uint8_t * data){
145*8b29cfc6SMatthias Ringwald     fwrite(data, num_samples, 1, file);
146*8b29cfc6SMatthias Ringwald }
147*8b29cfc6SMatthias Ringwald 
148*8b29cfc6SMatthias Ringwald #endif
149*8b29cfc6SMatthias Ringwald 
150*8b29cfc6SMatthias Ringwald 
151f7c85330SMatthias Ringwald void sco_demo_init(void){
152f7c85330SMatthias Ringwald 
153f7c85330SMatthias Ringwald 	// status
154f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE
155f7c85330SMatthias Ringwald #ifdef HAVE_PORTAUDIO
156f7c85330SMatthias Ringwald 	printf("SCO Demo: Sending sine wave, audio output via portaudio.\n");
157f7c85330SMatthias Ringwald #else
158f7c85330SMatthias Ringwald 	printf("SCO Demo: Sending sine wave, hexdump received data.\n");
159f7c85330SMatthias Ringwald #endif
160f7c85330SMatthias Ringwald #endif
161f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_ASCII
162f7c85330SMatthias Ringwald 	printf("SCO Demo: Sending ASCII blocks, print received data.\n");
163f7c85330SMatthias Ringwald #endif
164f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_COUNTER
165f7c85330SMatthias Ringwald 	printf("SCO Demo: Sending counter value, hexdump received data.\n");
166f7c85330SMatthias Ringwald #endif
167f7c85330SMatthias Ringwald 
168*8b29cfc6SMatthias Ringwald #ifdef SCO_WAV_FILENAME
169*8b29cfc6SMatthias Ringwald     wav_file = wav_init(SCO_WAV_FILENAME);
170*8b29cfc6SMatthias Ringwald     const int sample_rate = 8000;
171*8b29cfc6SMatthias Ringwald     const int num_samples = sample_rate * SCO_WAV_DURATION_IN_SECONDS;
172*8b29cfc6SMatthias Ringwald     const int num_channels = 1;
173*8b29cfc6SMatthias Ringwald     const int bytes_per_sample = 1;
174*8b29cfc6SMatthias Ringwald     write_wav_header(wav_file, sample_rate, num_channels, num_samples, bytes_per_sample);
175*8b29cfc6SMatthias Ringwald     num_samples_to_write = num_samples;
176*8b29cfc6SMatthias Ringwald #endif
177*8b29cfc6SMatthias Ringwald 
178f7c85330SMatthias Ringwald #ifdef USE_PORTAUDIO
179f7c85330SMatthias Ringwald     int err;
180f7c85330SMatthias Ringwald     PaStreamParameters outputParameters;
181f7c85330SMatthias Ringwald 
182f7c85330SMatthias Ringwald     /* -- initialize PortAudio -- */
183f7c85330SMatthias Ringwald     err = Pa_Initialize();
184f7c85330SMatthias Ringwald     if( err != paNoError ) return;
185f7c85330SMatthias Ringwald     /* -- setup input and output -- */
186f7c85330SMatthias Ringwald     outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
187f7c85330SMatthias Ringwald     outputParameters.channelCount = NUM_CHANNELS;
188f7c85330SMatthias Ringwald     outputParameters.sampleFormat = PA_SAMPLE_TYPE;
189f7c85330SMatthias Ringwald     outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultHighOutputLatency;
190f7c85330SMatthias Ringwald     outputParameters.hostApiSpecificStreamInfo = NULL;
191f7c85330SMatthias Ringwald     /* -- setup stream -- */
192f7c85330SMatthias Ringwald     err = Pa_OpenStream(
193f7c85330SMatthias Ringwald            &stream,
194f7c85330SMatthias Ringwald            NULL, // &inputParameters,
195f7c85330SMatthias Ringwald            &outputParameters,
196f7c85330SMatthias Ringwald            SAMPLE_RATE,
197f7c85330SMatthias Ringwald            FRAMES_PER_BUFFER,
198f7c85330SMatthias Ringwald            paClipOff, /* we won't output out of range samples so don't bother clipping them */
199f7c85330SMatthias Ringwald            NULL, 	  /* no callback, use blocking API */
200f7c85330SMatthias Ringwald            NULL ); 	  /* no callback, so no callback userData */
201f7c85330SMatthias Ringwald     if( err != paNoError ) return;
202f7c85330SMatthias Ringwald     /* -- start stream -- */
203f7c85330SMatthias Ringwald     err = Pa_StartStream( stream );
204f7c85330SMatthias Ringwald     if( err != paNoError ) return;
205f7c85330SMatthias Ringwald #endif
206f7c85330SMatthias Ringwald 
207f7c85330SMatthias Ringwald #if SCO_DEMO_MODE != SCO_DEMO_MODE_SINE
208f7c85330SMatthias Ringwald     hci_set_sco_voice_setting(0x03);    // linear, unsigned, 8-bit, transparent
209f7c85330SMatthias Ringwald #endif
210f7c85330SMatthias Ringwald 
211f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_ASCII
212f7c85330SMatthias Ringwald     phase = 'a';
213f7c85330SMatthias Ringwald #endif
214f7c85330SMatthias Ringwald }
215f7c85330SMatthias Ringwald 
216f7c85330SMatthias Ringwald 
217f7c85330SMatthias Ringwald void sco_demo_send(hci_con_handle_t sco_handle){
218f7c85330SMatthias Ringwald 
219f7c85330SMatthias Ringwald     if (!sco_handle) return;
220f7c85330SMatthias Ringwald 
221f7c85330SMatthias Ringwald     const int sco_packet_length = 24 + 3; // hci_get_sco_packet_length();
222f7c85330SMatthias Ringwald     const int sco_payload_length = sco_packet_length - 3;
223f7c85330SMatthias Ringwald 
224f7c85330SMatthias Ringwald     hci_reserve_packet_buffer();
225f7c85330SMatthias Ringwald     uint8_t * sco_packet = hci_get_outgoing_packet_buffer();
226f7c85330SMatthias Ringwald     // set handle + flags
227f7c85330SMatthias Ringwald     little_endian_store_16(sco_packet, 0, sco_handle);
228f7c85330SMatthias Ringwald     // set len
229f7c85330SMatthias Ringwald     sco_packet[2] = sco_payload_length;
230f7c85330SMatthias Ringwald     const int frames_per_packet = sco_payload_length;    // for 8-bit data. for 16-bit data it's /2
231f7c85330SMatthias Ringwald 
232f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE
233f7c85330SMatthias Ringwald     int i;
234f7c85330SMatthias Ringwald     for (i=0;i<frames_per_packet;i++){
235f7c85330SMatthias Ringwald         sco_packet[3+i] = sine[phase];
236f7c85330SMatthias Ringwald         phase++;
237f7c85330SMatthias Ringwald         if (phase >= sizeof(sine)) phase = 0;
238f7c85330SMatthias Ringwald     }
239f7c85330SMatthias Ringwald #else
240f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_ASCII
241f7c85330SMatthias Ringwald     memset(&sco_packet[3], phase++, frames_per_packet);
242f7c85330SMatthias Ringwald     if (phase > 'z') phase = 'a';
243f7c85330SMatthias Ringwald #else
244f7c85330SMatthias Ringwald     for (i=0;i<frames_per_packet;i++){
245f7c85330SMatthias Ringwald         sco_packet[3+i] = phase++;
246f7c85330SMatthias Ringwald     }
247f7c85330SMatthias Ringwald #endif
248f7c85330SMatthias Ringwald #endif
249f7c85330SMatthias Ringwald     hci_send_sco_packet_buffer(sco_packet_length);
250f7c85330SMatthias Ringwald 
251f7c85330SMatthias Ringwald     // request another send event
252f7c85330SMatthias Ringwald     hci_request_sco_can_send_now_event();
253f7c85330SMatthias Ringwald 
254f7c85330SMatthias Ringwald     static int count = 0;
255f7c85330SMatthias Ringwald     count++;
256f7c85330SMatthias Ringwald     if ((count % SCO_REPORT_PERIOD) == 0) printf("SCO: sent %u\n", count);
257f7c85330SMatthias Ringwald }
258f7c85330SMatthias Ringwald 
259f7c85330SMatthias Ringwald /**
260f7c85330SMatthias Ringwald  * @brief Process received data
261f7c85330SMatthias Ringwald  */
262f7c85330SMatthias Ringwald void sco_demo_receive(uint8_t * packet, uint16_t size){
263f7c85330SMatthias Ringwald 
264*8b29cfc6SMatthias Ringwald 
265*8b29cfc6SMatthias Ringwald     int dump_data = 1;
266*8b29cfc6SMatthias Ringwald 
267*8b29cfc6SMatthias Ringwald #ifdef SCO_WAV_FILENAME
268*8b29cfc6SMatthias Ringwald     if (num_samples_to_write){
269*8b29cfc6SMatthias Ringwald         const int num_samples = size - 3;
270*8b29cfc6SMatthias Ringwald         const int samples_to_write = btstack_min(num_samples, num_samples_to_write);
271*8b29cfc6SMatthias Ringwald         // convert 8 bit signed to 8 bit unsigned
272*8b29cfc6SMatthias Ringwald         int i;
273*8b29cfc6SMatthias Ringwald         for (i=0;i<samples_to_write;i++){
274*8b29cfc6SMatthias Ringwald             packet[3+i] += 128;
275*8b29cfc6SMatthias Ringwald         }
276*8b29cfc6SMatthias Ringwald         write_wav_data_uint8(wav_file, samples_to_write, &packet[3]);
277*8b29cfc6SMatthias Ringwald         num_samples_to_write -= samples_to_write;
278*8b29cfc6SMatthias Ringwald         if (num_samples_to_write == 0){
279*8b29cfc6SMatthias Ringwald             printf("SCO Demo: closing wav file\n");
280*8b29cfc6SMatthias Ringwald             fclose(wav_file);
281*8b29cfc6SMatthias Ringwald         }
282*8b29cfc6SMatthias Ringwald         dump_data = 0;
283*8b29cfc6SMatthias Ringwald     }
284*8b29cfc6SMatthias Ringwald #endif
285*8b29cfc6SMatthias Ringwald 
286f7c85330SMatthias Ringwald     if (packet[1] & 0xf0){
287f7c85330SMatthias Ringwald         printf("SCO CRC Error: %x - data: ", packet[1] >> 4);
288f7c85330SMatthias Ringwald         printf_hexdump(&packet[3], size-3);
289f7c85330SMatthias Ringwald         return;
290f7c85330SMatthias Ringwald     }
291f7c85330SMatthias Ringwald 
292f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE
293f7c85330SMatthias Ringwald #ifdef USE_PORTAUDIO
294f7c85330SMatthias Ringwald     uint32_t start = btstack_run_loop_get_time_ms();
295f7c85330SMatthias Ringwald     Pa_WriteStream( stream, &packet[3], size -3);
296f7c85330SMatthias Ringwald     uint32_t end   = btstack_run_loop_get_time_ms();
297f7c85330SMatthias Ringwald     if (end - start > 5){
298f7c85330SMatthias Ringwald         printf("Portaudio: write stream took %u ms\n", end - start);
299f7c85330SMatthias Ringwald     }
300*8b29cfc6SMatthias Ringwald     dump_data = 0;
301f7c85330SMatthias Ringwald #endif
302*8b29cfc6SMatthias Ringwald #endif
303*8b29cfc6SMatthias Ringwald 
304*8b29cfc6SMatthias Ringwald     if (dump_data){
305f7c85330SMatthias Ringwald         printf("data: ");
306f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_ASCII
307f7c85330SMatthias Ringwald         int i;
308f7c85330SMatthias Ringwald         for (i=3;i<size;i++){
309f7c85330SMatthias Ringwald             printf("%c", packet[i]);
310f7c85330SMatthias Ringwald         }
311f7c85330SMatthias Ringwald         printf("\n");
312*8b29cfc6SMatthias Ringwald         dump_data = 0;
313*8b29cfc6SMatthias Ringwald #else
314f7c85330SMatthias Ringwald         printf_hexdump(&packet[3], size-3);
315f7c85330SMatthias Ringwald #endif
316*8b29cfc6SMatthias Ringwald     }
317f7c85330SMatthias Ringwald 
318f7c85330SMatthias Ringwald     static int count = 0;
319f7c85330SMatthias Ringwald     count++;
320f7c85330SMatthias Ringwald     if ((count % SCO_REPORT_PERIOD) == 0) printf("SCO: received %u\n", count);
321f7c85330SMatthias Ringwald }
322