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 508b29cfc6SMatthias Ringwald 51f7c85330SMatthias Ringwald // SCO demo configuration 5238b2eaafSMatthias Ringwald #define SCO_DEMO_MODE SCO_DEMO_MODE_ASCII 53f7c85330SMatthias Ringwald #define SCO_REPORT_PERIOD 100 54f7c85330SMatthias Ringwald 558b29cfc6SMatthias Ringwald #ifdef HAVE_POSIX_FILE_IO 568b29cfc6SMatthias Ringwald #define SCO_WAV_FILENAME "sco_input.wav" 578b29cfc6SMatthias Ringwald #define SCO_WAV_DURATION_IN_SECONDS 30 588b29cfc6SMatthias Ringwald #endif 598b29cfc6SMatthias 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> 678b29cfc6SMatthias Ringwald // portaudio config 688b29cfc6SMatthias Ringwald #define NUM_CHANNELS 1 698b29cfc6SMatthias Ringwald #define SAMPLE_RATE 8000 708b29cfc6SMatthias Ringwald #define FRAMES_PER_BUFFER 24 718b29cfc6SMatthias 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; 88*4a96141eSMatthias Ringwald static int count_sent = 0; 89*4a96141eSMatthias Ringwald static int count_received = 0; 90f7c85330SMatthias Ringwald 91*4a96141eSMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE 928b29cfc6SMatthias Ringwald #ifdef SCO_WAV_FILENAME 938b29cfc6SMatthias Ringwald 948b29cfc6SMatthias Ringwald static FILE * wav_file; 958b29cfc6SMatthias Ringwald static int num_samples_to_write; 968b29cfc6SMatthias Ringwald 978b29cfc6SMatthias Ringwald 988b29cfc6SMatthias Ringwald static void little_endian_fstore_16(FILE * file, uint16_t value){ 998b29cfc6SMatthias Ringwald uint8_t buf[2]; 1008b29cfc6SMatthias Ringwald little_endian_store_32(buf, 0, value); 1018b29cfc6SMatthias Ringwald fwrite(&buf, 1, 2, file); 1028b29cfc6SMatthias Ringwald } 1038b29cfc6SMatthias Ringwald 1048b29cfc6SMatthias Ringwald static void little_endian_fstore_32(FILE * file, uint32_t value){ 1058b29cfc6SMatthias Ringwald uint8_t buf[4]; 1068b29cfc6SMatthias Ringwald little_endian_store_32(buf, 0, value); 1078b29cfc6SMatthias Ringwald fwrite(&buf, 1, 4, file); 1088b29cfc6SMatthias Ringwald } 1098b29cfc6SMatthias Ringwald 1108b29cfc6SMatthias Ringwald static FILE * wav_init(const char * filename){ 1118b29cfc6SMatthias Ringwald printf("SCO Demo: creating wav file %s\n", filename); 1128b29cfc6SMatthias Ringwald return fopen(filename, "wb"); 1138b29cfc6SMatthias Ringwald } 1148b29cfc6SMatthias Ringwald 1158b29cfc6SMatthias Ringwald static void write_wav_header(FILE * file, int sample_rate, int num_channels, int num_samples, int bytes_per_sample){ 1168b29cfc6SMatthias Ringwald printf("SCO Demo: writing wav header: sample rate %u, num channels %u, duration %u s, bytes per sample %u\n", 1178b29cfc6SMatthias Ringwald sample_rate, num_channels, num_samples / sample_rate / num_channels, bytes_per_sample); 1188b29cfc6SMatthias Ringwald 1198b29cfc6SMatthias Ringwald /* write RIFF header */ 1208b29cfc6SMatthias Ringwald fwrite("RIFF", 1, 4, file); 1218b29cfc6SMatthias Ringwald // num_samples = blocks * subbands 1228b29cfc6SMatthias Ringwald uint32_t data_bytes = (uint32_t) (bytes_per_sample * num_samples * num_channels); 1238b29cfc6SMatthias Ringwald little_endian_fstore_32(file, data_bytes + 36); 1248b29cfc6SMatthias Ringwald fwrite("WAVE", 1, 4, file); 1258b29cfc6SMatthias Ringwald 1268b29cfc6SMatthias Ringwald int byte_rate = sample_rate * num_channels * bytes_per_sample; 1278b29cfc6SMatthias Ringwald int bits_per_sample = 8 * bytes_per_sample; 1288b29cfc6SMatthias Ringwald int block_align = num_channels * bits_per_sample; 1298b29cfc6SMatthias Ringwald int fmt_length = 16; 1308b29cfc6SMatthias Ringwald int fmt_format_tag = 1; // PCM 1318b29cfc6SMatthias Ringwald 1328b29cfc6SMatthias Ringwald /* write fmt chunk */ 1338b29cfc6SMatthias Ringwald fwrite("fmt ", 1, 4, file); 1348b29cfc6SMatthias Ringwald little_endian_fstore_32(file, fmt_length); 1358b29cfc6SMatthias Ringwald little_endian_fstore_16(file, fmt_format_tag); 1368b29cfc6SMatthias Ringwald little_endian_fstore_16(file, num_channels); 1378b29cfc6SMatthias Ringwald little_endian_fstore_32(file, sample_rate); 1388b29cfc6SMatthias Ringwald little_endian_fstore_32(file, byte_rate); 1398b29cfc6SMatthias Ringwald little_endian_fstore_16(file, block_align); 1408b29cfc6SMatthias Ringwald little_endian_fstore_16(file, bits_per_sample); 1418b29cfc6SMatthias Ringwald 1428b29cfc6SMatthias Ringwald /* write data chunk */ 1438b29cfc6SMatthias Ringwald fwrite("data", 1, 4, file); 1448b29cfc6SMatthias Ringwald little_endian_fstore_32(file, data_bytes); 1458b29cfc6SMatthias Ringwald } 1468b29cfc6SMatthias Ringwald 1478b29cfc6SMatthias Ringwald static void write_wav_data_uint8(FILE * file, unsigned long num_samples, uint8_t * data){ 1488b29cfc6SMatthias Ringwald fwrite(data, num_samples, 1, file); 1498b29cfc6SMatthias Ringwald } 1508b29cfc6SMatthias Ringwald 1518b29cfc6SMatthias Ringwald #endif 152*4a96141eSMatthias Ringwald #endif 1538b29cfc6SMatthias Ringwald 154f7c85330SMatthias Ringwald void sco_demo_init(void){ 155f7c85330SMatthias Ringwald 156f7c85330SMatthias Ringwald // status 157f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE 158f7c85330SMatthias Ringwald #ifdef HAVE_PORTAUDIO 159f7c85330SMatthias Ringwald printf("SCO Demo: Sending sine wave, audio output via portaudio.\n"); 160f7c85330SMatthias Ringwald #else 161f7c85330SMatthias Ringwald printf("SCO Demo: Sending sine wave, hexdump received data.\n"); 162f7c85330SMatthias Ringwald #endif 163f7c85330SMatthias Ringwald #endif 164f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_ASCII 165f7c85330SMatthias Ringwald printf("SCO Demo: Sending ASCII blocks, print received data.\n"); 166f7c85330SMatthias Ringwald #endif 167f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_COUNTER 168f7c85330SMatthias Ringwald printf("SCO Demo: Sending counter value, hexdump received data.\n"); 169f7c85330SMatthias Ringwald #endif 170f7c85330SMatthias Ringwald 171*4a96141eSMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE 1728b29cfc6SMatthias Ringwald #ifdef SCO_WAV_FILENAME 1738b29cfc6SMatthias Ringwald wav_file = wav_init(SCO_WAV_FILENAME); 1748b29cfc6SMatthias Ringwald const int sample_rate = 8000; 1758b29cfc6SMatthias Ringwald const int num_samples = sample_rate * SCO_WAV_DURATION_IN_SECONDS; 1768b29cfc6SMatthias Ringwald const int num_channels = 1; 1778b29cfc6SMatthias Ringwald const int bytes_per_sample = 1; 1788b29cfc6SMatthias Ringwald write_wav_header(wav_file, sample_rate, num_channels, num_samples, bytes_per_sample); 1798b29cfc6SMatthias Ringwald num_samples_to_write = num_samples; 1808b29cfc6SMatthias Ringwald #endif 181*4a96141eSMatthias Ringwald #endif 1828b29cfc6SMatthias Ringwald 183f7c85330SMatthias Ringwald #ifdef USE_PORTAUDIO 184f7c85330SMatthias Ringwald int err; 185f7c85330SMatthias Ringwald PaStreamParameters outputParameters; 186f7c85330SMatthias Ringwald 187f7c85330SMatthias Ringwald /* -- initialize PortAudio -- */ 188f7c85330SMatthias Ringwald err = Pa_Initialize(); 189f7c85330SMatthias Ringwald if( err != paNoError ) return; 190f7c85330SMatthias Ringwald /* -- setup input and output -- */ 191f7c85330SMatthias Ringwald outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ 192f7c85330SMatthias Ringwald outputParameters.channelCount = NUM_CHANNELS; 193f7c85330SMatthias Ringwald outputParameters.sampleFormat = PA_SAMPLE_TYPE; 194f7c85330SMatthias Ringwald outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultHighOutputLatency; 195f7c85330SMatthias Ringwald outputParameters.hostApiSpecificStreamInfo = NULL; 196f7c85330SMatthias Ringwald /* -- setup stream -- */ 197f7c85330SMatthias Ringwald err = Pa_OpenStream( 198f7c85330SMatthias Ringwald &stream, 199f7c85330SMatthias Ringwald NULL, // &inputParameters, 200f7c85330SMatthias Ringwald &outputParameters, 201f7c85330SMatthias Ringwald SAMPLE_RATE, 202f7c85330SMatthias Ringwald FRAMES_PER_BUFFER, 203f7c85330SMatthias Ringwald paClipOff, /* we won't output out of range samples so don't bother clipping them */ 204f7c85330SMatthias Ringwald NULL, /* no callback, use blocking API */ 205f7c85330SMatthias Ringwald NULL ); /* no callback, so no callback userData */ 206f7c85330SMatthias Ringwald if( err != paNoError ) return; 207f7c85330SMatthias Ringwald /* -- start stream -- */ 208f7c85330SMatthias Ringwald err = Pa_StartStream( stream ); 209f7c85330SMatthias Ringwald if( err != paNoError ) return; 210f7c85330SMatthias Ringwald #endif 211f7c85330SMatthias Ringwald 212f7c85330SMatthias Ringwald #if SCO_DEMO_MODE != SCO_DEMO_MODE_SINE 213f7c85330SMatthias Ringwald hci_set_sco_voice_setting(0x03); // linear, unsigned, 8-bit, transparent 214f7c85330SMatthias Ringwald #endif 215f7c85330SMatthias Ringwald 216f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_ASCII 217f7c85330SMatthias Ringwald phase = 'a'; 218f7c85330SMatthias Ringwald #endif 219f7c85330SMatthias Ringwald } 220f7c85330SMatthias Ringwald 221*4a96141eSMatthias Ringwald static void sco_report(void){ 222*4a96141eSMatthias Ringwald printf("SCO: sent %u, received %u\n", count_sent, count_received); 223*4a96141eSMatthias Ringwald } 224f7c85330SMatthias Ringwald 225f7c85330SMatthias Ringwald void sco_demo_send(hci_con_handle_t sco_handle){ 226f7c85330SMatthias Ringwald 227f7c85330SMatthias Ringwald if (!sco_handle) return; 228f7c85330SMatthias Ringwald 229f7c85330SMatthias Ringwald const int sco_packet_length = 24 + 3; // hci_get_sco_packet_length(); 230f7c85330SMatthias Ringwald const int sco_payload_length = sco_packet_length - 3; 231f7c85330SMatthias Ringwald 232f7c85330SMatthias Ringwald hci_reserve_packet_buffer(); 233f7c85330SMatthias Ringwald uint8_t * sco_packet = hci_get_outgoing_packet_buffer(); 234f7c85330SMatthias Ringwald // set handle + flags 235f7c85330SMatthias Ringwald little_endian_store_16(sco_packet, 0, sco_handle); 236f7c85330SMatthias Ringwald // set len 237f7c85330SMatthias Ringwald sco_packet[2] = sco_payload_length; 238f7c85330SMatthias Ringwald const int frames_per_packet = sco_payload_length; // for 8-bit data. for 16-bit data it's /2 239f7c85330SMatthias Ringwald 240f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE 241f7c85330SMatthias Ringwald int i; 242f7c85330SMatthias Ringwald for (i=0;i<frames_per_packet;i++){ 243f7c85330SMatthias Ringwald sco_packet[3+i] = sine[phase]; 244f7c85330SMatthias Ringwald phase++; 245f7c85330SMatthias Ringwald if (phase >= sizeof(sine)) phase = 0; 246f7c85330SMatthias Ringwald } 247f7c85330SMatthias Ringwald #else 248f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_ASCII 249f7c85330SMatthias Ringwald memset(&sco_packet[3], phase++, frames_per_packet); 250f7c85330SMatthias Ringwald if (phase > 'z') phase = 'a'; 251f7c85330SMatthias Ringwald #else 25238b2eaafSMatthias Ringwald int j; 25338b2eaafSMatthias Ringwald for (j=0;j<frames_per_packet;j++){ 25438b2eaafSMatthias Ringwald sco_packet[3+j] = phase++; 255f7c85330SMatthias Ringwald } 256f7c85330SMatthias Ringwald #endif 257f7c85330SMatthias Ringwald #endif 258f7c85330SMatthias Ringwald hci_send_sco_packet_buffer(sco_packet_length); 259f7c85330SMatthias Ringwald 260f7c85330SMatthias Ringwald // request another send event 261f7c85330SMatthias Ringwald hci_request_sco_can_send_now_event(); 262f7c85330SMatthias Ringwald 263*4a96141eSMatthias Ringwald count_sent++; 264*4a96141eSMatthias Ringwald if ((count_sent % SCO_REPORT_PERIOD) == 0) sco_report(); 265f7c85330SMatthias Ringwald } 266f7c85330SMatthias Ringwald 267f7c85330SMatthias Ringwald /** 268f7c85330SMatthias Ringwald * @brief Process received data 269f7c85330SMatthias Ringwald */ 270f7c85330SMatthias Ringwald void sco_demo_receive(uint8_t * packet, uint16_t size){ 271f7c85330SMatthias Ringwald 2728b29cfc6SMatthias Ringwald 2738b29cfc6SMatthias Ringwald int dump_data = 1; 2748b29cfc6SMatthias Ringwald 275*4a96141eSMatthias Ringwald count_received++; 276*4a96141eSMatthias Ringwald // if ((count_received % SCO_REPORT_PERIOD) == 0) sco_report(); 277*4a96141eSMatthias Ringwald 278*4a96141eSMatthias Ringwald 279*4a96141eSMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE 2808b29cfc6SMatthias Ringwald #ifdef SCO_WAV_FILENAME 2818b29cfc6SMatthias Ringwald if (num_samples_to_write){ 2828b29cfc6SMatthias Ringwald const int num_samples = size - 3; 2838b29cfc6SMatthias Ringwald const int samples_to_write = btstack_min(num_samples, num_samples_to_write); 2848b29cfc6SMatthias Ringwald // convert 8 bit signed to 8 bit unsigned 2858b29cfc6SMatthias Ringwald int i; 2868b29cfc6SMatthias Ringwald for (i=0;i<samples_to_write;i++){ 2878b29cfc6SMatthias Ringwald packet[3+i] += 128; 2888b29cfc6SMatthias Ringwald } 2898b29cfc6SMatthias Ringwald write_wav_data_uint8(wav_file, samples_to_write, &packet[3]); 2908b29cfc6SMatthias Ringwald num_samples_to_write -= samples_to_write; 2918b29cfc6SMatthias Ringwald if (num_samples_to_write == 0){ 2928b29cfc6SMatthias Ringwald printf("SCO Demo: closing wav file\n"); 2938b29cfc6SMatthias Ringwald fclose(wav_file); 2948b29cfc6SMatthias Ringwald } 2958b29cfc6SMatthias Ringwald dump_data = 0; 2968b29cfc6SMatthias Ringwald } 2978b29cfc6SMatthias Ringwald #endif 298*4a96141eSMatthias Ringwald #endif 2998b29cfc6SMatthias Ringwald 300f7c85330SMatthias Ringwald if (packet[1] & 0xf0){ 301f7c85330SMatthias Ringwald printf("SCO CRC Error: %x - data: ", packet[1] >> 4); 302f7c85330SMatthias Ringwald printf_hexdump(&packet[3], size-3); 303f7c85330SMatthias Ringwald return; 304f7c85330SMatthias Ringwald } 305f7c85330SMatthias Ringwald 306f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_SINE 307f7c85330SMatthias Ringwald #ifdef USE_PORTAUDIO 308f7c85330SMatthias Ringwald uint32_t start = btstack_run_loop_get_time_ms(); 309f7c85330SMatthias Ringwald Pa_WriteStream( stream, &packet[3], size -3); 310f7c85330SMatthias Ringwald uint32_t end = btstack_run_loop_get_time_ms(); 311f7c85330SMatthias Ringwald if (end - start > 5){ 312f7c85330SMatthias Ringwald printf("Portaudio: write stream took %u ms\n", end - start); 313f7c85330SMatthias Ringwald } 3148b29cfc6SMatthias Ringwald dump_data = 0; 315f7c85330SMatthias Ringwald #endif 3168b29cfc6SMatthias Ringwald #endif 3178b29cfc6SMatthias Ringwald 3188b29cfc6SMatthias Ringwald if (dump_data){ 319f7c85330SMatthias Ringwald printf("data: "); 320f7c85330SMatthias Ringwald #if SCO_DEMO_MODE == SCO_DEMO_MODE_ASCII 321f7c85330SMatthias Ringwald int i; 322f7c85330SMatthias Ringwald for (i=3;i<size;i++){ 323f7c85330SMatthias Ringwald printf("%c", packet[i]); 324f7c85330SMatthias Ringwald } 325f7c85330SMatthias Ringwald printf("\n"); 3268b29cfc6SMatthias Ringwald dump_data = 0; 3278b29cfc6SMatthias Ringwald #else 328f7c85330SMatthias Ringwald printf_hexdump(&packet[3], size-3); 329f7c85330SMatthias Ringwald #endif 3308b29cfc6SMatthias Ringwald } 331f7c85330SMatthias Ringwald } 332