xref: /btstack/example/sco_demo_util.h (revision 2fca4dad957cd7b88f4657ed51e89c12615dda72)
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
23*2fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24*2fca4dadSMilanka Ringwald  * GMBH 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.h - send/receive test data via SCO, used by hfp_*_demo and hsp_*_demo
40f7c85330SMatthias Ringwald  */
41f7c85330SMatthias Ringwald 
42f7c85330SMatthias Ringwald 
4380e33422SMatthias Ringwald #ifndef SCO_DEMO_UTIL_H
4480e33422SMatthias Ringwald #define SCO_DEMO_UTIL_H
45f7c85330SMatthias Ringwald 
46f7c85330SMatthias Ringwald #include "hci.h"
47f7c85330SMatthias Ringwald 
48f7c85330SMatthias Ringwald #if defined __cplusplus
49f7c85330SMatthias Ringwald extern "C" {
50f7c85330SMatthias Ringwald #endif
51f7c85330SMatthias Ringwald 
52f7c85330SMatthias Ringwald /**
53f7c85330SMatthias Ringwald  * @brief Init demo SCO data production/consumtion
54f7c85330SMatthias Ringwald  */
55f7c85330SMatthias Ringwald void sco_demo_init(void);
56f7c85330SMatthias Ringwald 
5725234a7eSMilanka Ringwald /**
5825234a7eSMilanka Ringwald  * @brief Set codec (cvsd:0x01, msbc:0x02) and initalize wav writter and portaudio .
5925234a7eSMilanka Ringwald  * @param codec
6025234a7eSMilanka Ringwald  */
61fcb08cdbSMilanka Ringwald  void sco_demo_set_codec(uint8_t codec);
6225234a7eSMilanka Ringwald 
63f7c85330SMatthias Ringwald /**
64f7c85330SMatthias Ringwald  * @brief Send next data on con_handle
65f7c85330SMatthias Ringwald  * @param con_handle
66f7c85330SMatthias Ringwald  */
67f7c85330SMatthias Ringwald void sco_demo_send(hci_con_handle_t con_handle);
68f7c85330SMatthias Ringwald 
69f7c85330SMatthias Ringwald /**
70f7c85330SMatthias Ringwald  * @brief Process received data
71f7c85330SMatthias Ringwald  */
72f7c85330SMatthias Ringwald void sco_demo_receive(uint8_t * packet, uint16_t size);
73f7c85330SMatthias Ringwald 
7425234a7eSMilanka Ringwald /**
7525234a7eSMilanka Ringwald  * @brief Close WAV writer, stop portaudio stream
7625234a7eSMilanka Ringwald  */
77fcb08cdbSMilanka Ringwald void sco_demo_close(void);
78fcb08cdbSMilanka Ringwald 
79f7c85330SMatthias Ringwald #if defined __cplusplus
80f7c85330SMatthias Ringwald }
81f7c85330SMatthias Ringwald #endif
82f7c85330SMatthias Ringwald 
83f7c85330SMatthias Ringwald #endif
84