xref: /btstack/test/hfp/test_sequences.c (revision 3edc84c5b6b1e23a3d103fe8ce1f6b5ad1df3498)
1 /*
2  * Copyright (C) 2014 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 // *****************************************************************************
39 //
40 // HFP Test Sequences
41 //
42 // *****************************************************************************
43 
44 #include <stdint.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <string.h>
48 
49 #include "test_sequences.h"
50 
51 
52 #define TEST_SEQUENCE(name) { (char**)name, sizeof(name) / sizeof(char *)}
53 
54 /* Service Level Connection (slc) test sequences */
55 
56 const char * slc_test1[] = {
57     "AT+BRSF=438",
58     "+BRSF:1007",
59     "OK",
60     "AT+BAC=1,2",
61     "OK",
62     "AT+CIND=?",
63     "+CIND:(\"service\",(0,1)),(\"call\",(0,1)),(\"callsetup\",(0,3)),(\"battchg\",(0,5)),(\"signal\",(0,5)),(\"roam\",(0,1)),(\"callheld\",(0,2))",
64     "OK",
65     "AT+CIND?",
66     "+CIND:1,0,0,3,5,0,0",
67     "OK",
68     "AT+CMER=3,0,0,1",
69     "OK",
70     "AT+CHLD=?",
71     "+CHLD:(1,1x,2,2x,3)",
72     "OK"
73 };
74 
75 hfp_test_item_t slc_tests[] = {
76     TEST_SEQUENCE(slc_test1)
77 };
78 
79 /* Service Level Connection (slc) common commands */
80 const char * slc_cmds_test1[] = {
81     "AT+BAC=1,3",
82     "OK"
83 };
84 
85 hfp_test_item_t slc_cmds_tests[] = {
86     TEST_SEQUENCE(slc_cmds_test1)
87 };
88 
89 /* Codecs Connection (cc) test sequences */
90 const char * cc_test1[] = {
91     "AT+BCC",
92     "OK",
93     "NOP",
94     "+BCS:1",
95     "AT+BCS=1",
96     "OK"
97 };
98 
99 const char * cc_test2[] = {
100     "AT+BAC=1,2",
101     "OK",
102     "AT+BCC",
103     "OK",
104     "NOP",
105     "BCS:1",
106     "AT+BCS=1",
107     "OK"
108 };
109 
110 
111 const char * cc_test3[] = {
112     "AT+BAC=1,2",
113     "OK",
114     "AT+BCC",
115     "OK",
116     "NOP",
117     "+BCS:1",
118     "AT+BAC=2,3",
119     "OK",
120     "NOP",
121     "+BCS:3",
122     "AT+BCS=3",
123     "OK"
124 };
125 
126 const char * cc_test4[] = {
127     "AT+BCC",
128     "OK",
129     "NOP",
130     "+BCS:1",
131     "AT+BAC=2,3",
132     "OK",
133     "NOP",
134     "+BCS:3",
135     "AT+BCS=3",
136     "OK"
137 };
138 
139 hfp_test_item_t cc_tests[] = {
140     TEST_SEQUENCE(cc_test1),
141     TEST_SEQUENCE(cc_test2),
142     TEST_SEQUENCE(cc_test3),
143     TEST_SEQUENCE(cc_test4)
144 };
145 
146 
147 
148 //////////////
149 
150 static int test_item_size = sizeof(hfp_test_item_t);
151 
152 // SLC
153 hfp_test_item_t * hfp_slc_tests(){ return slc_tests;}
154 int slc_tests_size(){ return sizeof(slc_tests)/test_item_size;}
155 
156 char ** default_slc_setup() { return (char **)slc_test1;}
157 int default_slc_setup_size(){ return sizeof(slc_test1)/sizeof(char*);}
158 
159 // SLC commands
160 hfp_test_item_t * hfp_slc_cmds_tests(){ return slc_cmds_tests;}
161 int slc_cmds_tests_size(){ return sizeof(slc_cmds_tests)/test_item_size;}
162 
163 char ** default_slc_cmds_setup() { return (char **)slc_cmds_test1;}
164 int default_slc_cmds_setup_size(){ return sizeof(slc_cmds_test1)/sizeof(char*);}
165 
166 // CC
167 hfp_test_item_t * hfp_cc_tests(){ return cc_tests;}
168 int cc_tests_size(){ return sizeof(cc_tests) /test_item_size;
169 }
170 char ** default_cc_setup() { return (char **)cc_test1;}
171 int default_cc_setup_size(){ return sizeof(cc_test1)/sizeof(char*);}
172 
173 
174