1fffdd288SMatthias Ringwald /* 2fffdd288SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 3fffdd288SMatthias Ringwald * 4fffdd288SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5fffdd288SMatthias Ringwald * modification, are permitted provided that the following conditions 6fffdd288SMatthias Ringwald * are met: 7fffdd288SMatthias Ringwald * 8fffdd288SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9fffdd288SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10fffdd288SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11fffdd288SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12fffdd288SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13fffdd288SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14fffdd288SMatthias Ringwald * contributors may be used to endorse or promote products derived 15fffdd288SMatthias Ringwald * from this software without specific prior written permission. 16fffdd288SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17fffdd288SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18fffdd288SMatthias Ringwald * monetary gain. 19fffdd288SMatthias Ringwald * 20fffdd288SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21fffdd288SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22fffdd288SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23fffdd288SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24fffdd288SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25fffdd288SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26fffdd288SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27fffdd288SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28fffdd288SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29fffdd288SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30fffdd288SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31fffdd288SMatthias Ringwald * SUCH DAMAGE. 32fffdd288SMatthias Ringwald * 33fffdd288SMatthias Ringwald * Please inquire about commercial licensing options at 34fffdd288SMatthias Ringwald * [email protected] 35fffdd288SMatthias Ringwald * 36fffdd288SMatthias Ringwald */ 37fffdd288SMatthias Ringwald 38e501bae0SMatthias Ringwald #define BTSTACK_FILE__ "hsp_ag_demo.c" 39ab2c6ae4SMatthias Ringwald 40fffdd288SMatthias Ringwald /* 41fffdd288SMatthias Ringwald * hsp_ag_demo.c 42fffdd288SMatthias Ringwald */ 43fffdd288SMatthias Ringwald 44fffdd288SMatthias Ringwald // ***************************************************************************** 45ec8ae085SMilanka Ringwald /* EXAMPLE_START(hsp_ag_demo): HSP AG - Audio Gateway 46fffdd288SMatthias Ringwald * 47fffdd288SMatthias Ringwald * @text This example implements a HSP Audio Gateway device that sends and receives 48fffdd288SMatthias Ringwald * audio signal over HCI SCO. It demonstrates how to receive 49fffdd288SMatthias Ringwald * an output from a remote headset (HS), and, 507ea7688aSMatthias Ringwald * if HAVE_BTSTACK_STDIN is defined, how to control the HS. 51fffdd288SMatthias Ringwald */ 52fffdd288SMatthias Ringwald // ***************************************************************************** 53fffdd288SMatthias Ringwald 54fffdd288SMatthias Ringwald 55fffdd288SMatthias Ringwald 56fffdd288SMatthias Ringwald #include <stdint.h> 57fffdd288SMatthias Ringwald #include <stdio.h> 58fffdd288SMatthias Ringwald #include <stdlib.h> 59fffdd288SMatthias Ringwald #include <string.h> 60fffdd288SMatthias Ringwald 61fffdd288SMatthias Ringwald #include "btstack.h" 62185c8cd4SMatthias Ringwald #include "sco_demo_util.h" 637ea7688aSMatthias Ringwald #ifdef HAVE_BTSTACK_STDIN 647ea7688aSMatthias Ringwald #include "btstack_stdin.h" 654af4141bSMatthias Ringwald #endif 66fffdd288SMatthias Ringwald 67fffdd288SMatthias Ringwald static uint8_t hsp_service_buffer[150]; 68fffdd288SMatthias Ringwald static const uint8_t rfcomm_channel_nr = 1; 69fffdd288SMatthias Ringwald static const char hsp_ag_service_name[] = "Audio Gateway Test"; 7080b0ebb6SMatthias Ringwald static uint16_t sco_handle = HCI_CON_HANDLE_INVALID; 71fffdd288SMatthias Ringwald 72fffdd288SMatthias Ringwald static char hs_cmd_buffer[100]; 73fffdd288SMatthias Ringwald 7405d93378SMilanka Ringwald static const char * device_name = "HSP AG Demo 00:00:00:00:00:00"; 7505d93378SMilanka Ringwald static const char * device_addr_string = "00:1b:dc:07:32:ef"; 7605d93378SMilanka Ringwald static bd_addr_t device_addr; 77fffdd288SMatthias Ringwald 78fffdd288SMatthias Ringwald /* @section Audio Transfer Setup 79fffdd288SMatthias Ringwald * 80fffdd288SMatthias Ringwald * @text A pre-computed sine wave (160Hz) is used as the input audio signal. 160 Hz. 816a7f493aSMatthias Ringwald * To send and receive an audio signal, ENABLE_SCO_OVER_HCI has to be defined. 82fffdd288SMatthias Ringwald * 83fffdd288SMatthias Ringwald * Tested working setups: 84fffdd288SMatthias Ringwald * - Ubuntu 14 64-bit, CC2564B connected via FTDI USB-2-UART adapter, 921600 baud 85fffdd288SMatthias Ringwald * - Ubuntu 14 64-bit, CSR USB dongle 86fffdd288SMatthias Ringwald * - OS X 10.11, CSR USB dongle 87fffdd288SMatthias Ringwald * 88fffdd288SMatthias Ringwald * Broken setups: 89fffdd288SMatthias Ringwald * - OS X 10.11, CC2564B connected via FDTI USB-2-UART adapter, 921600 baud 90fffdd288SMatthias Ringwald * - select(..) blocks > 400 ms -> num completed is received to late -> gaps between audio 91fffdd288SMatthias Ringwald * - looks like bug in select->FTDI driver as it works correct on Linux 92fffdd288SMatthias Ringwald * 93fffdd288SMatthias Ringwald * SCO not routed over HCI yet: 94fffdd288SMatthias Ringwald * - CSR UART dongle 95fffdd288SMatthias Ringwald * - Broadcom USB dongle 96fffdd288SMatthias Ringwald * - Broadcom UART chipset 97fffdd288SMatthias Ringwald * - .. 98fffdd288SMatthias Ringwald * 99fffdd288SMatthias Ringwald */ 100fffdd288SMatthias Ringwald 101fffdd288SMatthias Ringwald 10205d93378SMilanka Ringwald 10305d93378SMilanka Ringwald #ifdef HAVE_BTSTACK_STDIN 104fffdd288SMatthias Ringwald static void show_usage(void){ 105fffdd288SMatthias Ringwald bd_addr_t iut_address; 106fffdd288SMatthias Ringwald gap_local_bd_addr(iut_address); 107fffdd288SMatthias Ringwald 108fffdd288SMatthias Ringwald printf("\n--- Bluetooth HSP Audio Gateway Test Console %s ---\n", bd_addr_to_str(iut_address)); 109fffdd288SMatthias Ringwald 110fffdd288SMatthias Ringwald printf("---\n"); 11105d93378SMilanka Ringwald printf("c - Connect to %s\n", device_addr_string); 112fffdd288SMatthias Ringwald printf("C - Disconnect\n"); 113fffdd288SMatthias Ringwald printf("a - establish audio connection\n"); 114fffdd288SMatthias Ringwald printf("A - release audio connection\n"); 115584803f1SMatthias Ringwald printf("D - delete all link keys\n"); 116fffdd288SMatthias Ringwald printf("m - set microphone gain 8\n"); 117fffdd288SMatthias Ringwald printf("M - set microphone gain 15\n"); 118fffdd288SMatthias Ringwald printf("o - set speaker gain 0\n"); 119fffdd288SMatthias Ringwald printf("s - set speaker gain 8\n"); 120fffdd288SMatthias Ringwald printf("S - set speaker gain 15\n"); 121fffdd288SMatthias Ringwald printf("r - start ringing\n"); 122fffdd288SMatthias Ringwald printf("t - stop ringing\n"); 1238c0f3635SMilanka Ringwald printf("\n"); 124fffdd288SMatthias Ringwald } 125fffdd288SMatthias Ringwald 12695a8ee01SMatthias Ringwald static void stdin_process(char c){ 12795a8ee01SMatthias Ringwald switch (c){ 128584803f1SMatthias Ringwald case 'a': 129584803f1SMatthias Ringwald printf("Establish audio connection\n"); 130584803f1SMatthias Ringwald hsp_ag_establish_audio_connection(); 131584803f1SMatthias Ringwald break; 132584803f1SMatthias Ringwald case 'A': 133584803f1SMatthias Ringwald printf("Release audio connection\n"); 134584803f1SMatthias Ringwald hsp_ag_release_audio_connection(); 135584803f1SMatthias Ringwald break; 136fffdd288SMatthias Ringwald case 'c': 13705d93378SMilanka Ringwald printf("Connect to %s\n", device_addr_string); 138fffdd288SMatthias Ringwald hsp_ag_connect(device_addr); 139fffdd288SMatthias Ringwald break; 140fffdd288SMatthias Ringwald case 'C': 141fffdd288SMatthias Ringwald printf("Disconnect.\n"); 142fffdd288SMatthias Ringwald hsp_ag_disconnect(); 143fffdd288SMatthias Ringwald break; 144584803f1SMatthias Ringwald case 'D': 145584803f1SMatthias Ringwald printf("Deleting all link keys\n"); 146584803f1SMatthias Ringwald gap_delete_all_link_keys(); 147fffdd288SMatthias Ringwald break; 148fffdd288SMatthias Ringwald case 'm': 149fffdd288SMatthias Ringwald printf("Setting microphone gain 8\n"); 150fffdd288SMatthias Ringwald hsp_ag_set_microphone_gain(8); 151fffdd288SMatthias Ringwald break; 152fffdd288SMatthias Ringwald case 'M': 153fffdd288SMatthias Ringwald printf("Setting microphone gain 15\n"); 154fffdd288SMatthias Ringwald hsp_ag_set_microphone_gain(15); 155fffdd288SMatthias Ringwald break; 156fffdd288SMatthias Ringwald case 'o': 157fffdd288SMatthias Ringwald printf("Setting speaker gain 0\n"); 158fffdd288SMatthias Ringwald hsp_ag_set_speaker_gain(0); 159fffdd288SMatthias Ringwald break; 160fffdd288SMatthias Ringwald case 's': 161fffdd288SMatthias Ringwald printf("Setting speaker gain 8\n"); 162fffdd288SMatthias Ringwald hsp_ag_set_speaker_gain(8); 163fffdd288SMatthias Ringwald break; 164fffdd288SMatthias Ringwald case 'S': 165fffdd288SMatthias Ringwald printf("Setting speaker gain 15\n"); 166fffdd288SMatthias Ringwald hsp_ag_set_speaker_gain(15); 167fffdd288SMatthias Ringwald break; 168fffdd288SMatthias Ringwald case 'r': 169fffdd288SMatthias Ringwald printf("Start ringing\n"); 170fffdd288SMatthias Ringwald hsp_ag_start_ringing(); 171fffdd288SMatthias Ringwald break; 172fffdd288SMatthias Ringwald case 't': 173fffdd288SMatthias Ringwald printf("Stop ringing\n"); 174fffdd288SMatthias Ringwald hsp_ag_stop_ringing(); 175fffdd288SMatthias Ringwald break; 176fffdd288SMatthias Ringwald default: 177fffdd288SMatthias Ringwald show_usage(); 178fffdd288SMatthias Ringwald break; 179fffdd288SMatthias Ringwald } 180fffdd288SMatthias Ringwald } 181fffdd288SMatthias Ringwald #endif 182fffdd288SMatthias Ringwald 18313839019SMatthias Ringwald static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * event, uint16_t event_size){ 1849ec2630cSMatthias Ringwald UNUSED(channel); 18513839019SMatthias Ringwald 1863d50b4baSMatthias Ringwald switch (packet_type){ 1873d50b4baSMatthias Ringwald case HCI_SCO_DATA_PACKET: 18880b0ebb6SMatthias Ringwald if (READ_SCO_CONNECTION_HANDLE(event) != sco_handle) break; 189185c8cd4SMatthias Ringwald sco_demo_receive(event, event_size); 1903d50b4baSMatthias Ringwald break; 191fffdd288SMatthias Ringwald 19213839019SMatthias Ringwald case HCI_EVENT_PACKET: 19305d93378SMilanka Ringwald switch (hci_event_packet_get_type(event)) { 19405d93378SMilanka Ringwald #ifndef HAVE_BTSTACK_STDIN 195fffdd288SMatthias Ringwald case BTSTACK_EVENT_STATE: 19605d93378SMilanka Ringwald if (btstack_event_state_get_state(event) != HCI_STATE_WORKING) break; 19705d93378SMilanka Ringwald printf("Establish HSP AG service to %s...\n", device_addr_string); 19805d93378SMilanka Ringwald hsp_ag_connect(device_addr); 199fffdd288SMatthias Ringwald break; 20005d93378SMilanka Ringwald #endif 20113839019SMatthias Ringwald case HCI_EVENT_SCO_CAN_SEND_NOW: 202185c8cd4SMatthias Ringwald sco_demo_send(sco_handle); 20313839019SMatthias Ringwald break; 204fffdd288SMatthias Ringwald case HCI_EVENT_HSP_META: 205fffdd288SMatthias Ringwald switch (event[2]) { 206fffdd288SMatthias Ringwald case HSP_SUBEVENT_RFCOMM_CONNECTION_COMPLETE: 207206531d8SMilanka Ringwald if (hsp_subevent_rfcomm_connection_complete_get_status(event)){ 208d9ec3f99SMatthias Ringwald printf("RFCOMM connection establishement failed with status %u\n", hsp_subevent_rfcomm_connection_complete_get_status(event)); 20905d93378SMilanka Ringwald break; 210fffdd288SMatthias Ringwald } 21105d93378SMilanka Ringwald printf("RFCOMM connection established.\n"); 21205d93378SMilanka Ringwald #ifndef HAVE_BTSTACK_STDIN 21305d93378SMilanka Ringwald printf("Establish Audio connection to %s...\n", device_addr_string); 21405d93378SMilanka Ringwald hsp_ag_establish_audio_connection(); 21505d93378SMilanka Ringwald #endif 216fffdd288SMatthias Ringwald break; 217fffdd288SMatthias Ringwald case HSP_SUBEVENT_RFCOMM_DISCONNECTION_COMPLETE: 218206531d8SMilanka Ringwald if (hsp_subevent_rfcomm_disconnection_complete_get_status(event)){ 219206531d8SMilanka Ringwald printf("RFCOMM disconnection failed with status %u.\n", hsp_subevent_rfcomm_disconnection_complete_get_status(event)); 220fffdd288SMatthias Ringwald } else { 221206531d8SMilanka Ringwald printf("RFCOMM disconnected.\n"); 222fffdd288SMatthias Ringwald } 223fffdd288SMatthias Ringwald break; 224fffdd288SMatthias Ringwald case HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE: 225206531d8SMilanka Ringwald if (hsp_subevent_audio_connection_complete_get_status(event)){ 226206531d8SMilanka Ringwald printf("Audio connection establishment failed with status %u\n", hsp_subevent_audio_connection_complete_get_status(event)); 227206531d8SMilanka Ringwald } else { 228206531d8SMilanka Ringwald sco_handle = hsp_subevent_audio_connection_complete_get_handle(event); 229fffdd288SMatthias Ringwald printf("Audio connection established with SCO handle 0x%04x.\n", sco_handle); 230d057580eSMatthias Ringwald hci_request_sco_can_send_now_event(); 231fffdd288SMatthias Ringwald } 232fffdd288SMatthias Ringwald break; 233fffdd288SMatthias Ringwald case HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE: 234fffdd288SMatthias Ringwald printf("Audio connection released.\n\n"); 23580b0ebb6SMatthias Ringwald sco_handle = HCI_CON_HANDLE_INVALID; 236fffdd288SMatthias Ringwald break; 237fffdd288SMatthias Ringwald case HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED: 238206531d8SMilanka Ringwald printf("Received microphone gain change %d\n", hsp_subevent_microphone_gain_changed_get_gain(event)); 239fffdd288SMatthias Ringwald break; 240fffdd288SMatthias Ringwald case HSP_SUBEVENT_SPEAKER_GAIN_CHANGED: 241206531d8SMilanka Ringwald printf("Received speaker gain change %d\n", hsp_subevent_speaker_gain_changed_get_gain(event)); 242fffdd288SMatthias Ringwald break; 243fffdd288SMatthias Ringwald case HSP_SUBEVENT_HS_COMMAND:{ 244fffdd288SMatthias Ringwald memset(hs_cmd_buffer, 0, sizeof(hs_cmd_buffer)); 245249d94cfSMatthias Ringwald unsigned int cmd_length = hsp_subevent_hs_command_get_value_length(event); 246249d94cfSMatthias Ringwald unsigned int size = cmd_length <= sizeof(hs_cmd_buffer)? cmd_length : sizeof(hs_cmd_buffer); 247206531d8SMilanka Ringwald memcpy(hs_cmd_buffer, hsp_subevent_hs_command_get_value(event), size - 1); 248fffdd288SMatthias Ringwald printf("Received custom command: \"%s\". \nExit code or call hsp_ag_send_result.\n", hs_cmd_buffer); 249fffdd288SMatthias Ringwald break; 250fffdd288SMatthias Ringwald } 251*d04d6ac3SMatthias Ringwald case HSP_SUBEVENT_BUTTON_PRESSED: 252*d04d6ac3SMatthias Ringwald if (sco_handle == HCI_CON_HANDLE_INVALID){ 253*d04d6ac3SMatthias Ringwald printf("Button event -> establish audio\n"); 254*d04d6ac3SMatthias Ringwald hsp_ag_establish_audio_connection(); 255*d04d6ac3SMatthias Ringwald } else { 256*d04d6ac3SMatthias Ringwald printf("Button event -> release audio\n"); 257*d04d6ac3SMatthias Ringwald hsp_ag_release_audio_connection(); 258*d04d6ac3SMatthias Ringwald } 259*d04d6ac3SMatthias Ringwald break; 260fffdd288SMatthias Ringwald default: 261fffdd288SMatthias Ringwald printf("event not handled %u\n", event[2]); 262fffdd288SMatthias Ringwald break; 263fffdd288SMatthias Ringwald } 264fffdd288SMatthias Ringwald break; 265fffdd288SMatthias Ringwald default: 266fffdd288SMatthias Ringwald break; 267fffdd288SMatthias Ringwald } 26813839019SMatthias Ringwald break; 26913839019SMatthias Ringwald default: 27013839019SMatthias Ringwald break; 27113839019SMatthias Ringwald } 272fffdd288SMatthias Ringwald } 273fffdd288SMatthias Ringwald 274fffdd288SMatthias Ringwald /* @section Main Application Setup 275fffdd288SMatthias Ringwald * 276fffdd288SMatthias Ringwald * @text Listing MainConfiguration shows main application code. 277fffdd288SMatthias Ringwald * To run a HSP Audio Gateway service you need to initialize the SDP, and to create and register HSP AG record with it. 278fffdd288SMatthias Ringwald * In this example, the SCO over HCI is used to receive and send an audio signal. 279fffdd288SMatthias Ringwald * 280fffdd288SMatthias Ringwald * Two packet handlers are registered: 281fffdd288SMatthias Ringwald * - The HCI SCO packet handler receives audio data. 282fffdd288SMatthias Ringwald * - The HSP AG packet handler is used to trigger sending of audio data and commands to the HS. It also receives the AG's answers. 283fffdd288SMatthias Ringwald * 284fffdd288SMatthias Ringwald * The stdin_process callback allows for sending commands to the AG. 285fffdd288SMatthias Ringwald * At the end the Bluetooth stack is started. 286fffdd288SMatthias Ringwald */ 287fffdd288SMatthias Ringwald 288fffdd288SMatthias Ringwald /* LISTING_START(MainConfiguration): Setup HSP Audio Gateway */ 289fffdd288SMatthias Ringwald int btstack_main(int argc, const char * argv[]); 290fffdd288SMatthias Ringwald int btstack_main(int argc, const char * argv[]){ 2919ec2630cSMatthias Ringwald (void)argc; 2929ec2630cSMatthias Ringwald (void)argv; 293fffdd288SMatthias Ringwald 294185c8cd4SMatthias Ringwald sco_demo_init(); 295031381f9SMatthias Ringwald sco_demo_set_codec(HFP_CODEC_CVSD); 296185c8cd4SMatthias Ringwald 297fffdd288SMatthias Ringwald l2cap_init(); 298fffdd288SMatthias Ringwald 299fffdd288SMatthias Ringwald sdp_init(); 300fffdd288SMatthias Ringwald 301fffdd288SMatthias Ringwald memset((uint8_t *)hsp_service_buffer, 0, sizeof(hsp_service_buffer)); 302fffdd288SMatthias Ringwald hsp_ag_create_sdp_record(hsp_service_buffer, 0x10001, rfcomm_channel_nr, hsp_ag_service_name); 303fffdd288SMatthias Ringwald printf("SDP service record size: %u\n", de_get_len(hsp_service_buffer)); 304fffdd288SMatthias Ringwald sdp_register_service(hsp_service_buffer); 305fffdd288SMatthias Ringwald 306fffdd288SMatthias Ringwald rfcomm_init(); 307fffdd288SMatthias Ringwald 308fffdd288SMatthias Ringwald hsp_ag_init(rfcomm_channel_nr); 30913839019SMatthias Ringwald hsp_ag_register_packet_handler(&packet_handler); 310a4fe6467SMatthias Ringwald 311a4fe6467SMatthias Ringwald // register for SCO packets 31213839019SMatthias Ringwald hci_register_sco_packet_handler(&packet_handler); 313fffdd288SMatthias Ringwald 31405d93378SMilanka Ringwald // parse human readable Bluetooth address 31505d93378SMilanka Ringwald sscanf_bd_addr(device_addr_string, device_addr); 31605d93378SMilanka Ringwald 3177ea7688aSMatthias Ringwald #ifdef HAVE_BTSTACK_STDIN 318fffdd288SMatthias Ringwald btstack_stdin_setup(stdin_process); 319fffdd288SMatthias Ringwald #endif 320fffdd288SMatthias Ringwald 32105d93378SMilanka Ringwald gap_set_local_name(device_name); 322fffdd288SMatthias Ringwald gap_discoverable_control(1); 323fffdd288SMatthias Ringwald gap_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO); 32460b9e82fSMatthias Ringwald gap_set_class_of_device(0x400204); 325fffdd288SMatthias Ringwald 326fffdd288SMatthias Ringwald // turn on! 327fffdd288SMatthias Ringwald hci_power_control(HCI_POWER_ON); 328fffdd288SMatthias Ringwald return 0; 329fffdd288SMatthias Ringwald } 330fffdd288SMatthias Ringwald /* LISTING_END */ 3312b6b8c15SMilanka Ringwald /* EXAMPLE_END */ 332