1 /** @file
2  *  @brief Bluetooth MICP Microphone Controller shell.
3  *
4  * Copyright (c) 2020 Bose Corporation
5  * Copyright (c) 2020-2022 Nordic Semiconductor ASA
6  *
7  * SPDX-License-Identifier: Apache-2.0
8  */
9 
10 #include <errno.h>
11 #include <stdbool.h>
12 #include <stddef.h>
13 #include <stdint.h>
14 #include <stdio.h>
15 
16 #include <zephyr/autoconf.h>
17 #include <zephyr/bluetooth/audio/aics.h>
18 #include <zephyr/bluetooth/audio/micp.h>
19 #include <zephyr/bluetooth/conn.h>
20 #include <zephyr/shell/shell.h>
21 #include <zephyr/shell/shell_string_conv.h>
22 #include <zephyr/types.h>
23 
24 #include "host/shell/bt.h"
25 #include "common/bt_shell_private.h"
26 
27 static struct bt_micp_mic_ctlr *micp_mic_ctlr;
28 #if defined(CONFIG_BT_MICP_MIC_CTLR_AICS)
29 static struct bt_micp_included micp_included;
30 #endif /* CONFIG_BT_MICP_MIC_CTLR_AICS */
31 
micp_mic_ctlr_discover_cb(struct bt_micp_mic_ctlr * mic_ctlr,int err,uint8_t aics_count)32 static void micp_mic_ctlr_discover_cb(struct bt_micp_mic_ctlr *mic_ctlr,
33 				      int err, uint8_t aics_count)
34 {
35 	if (err != 0) {
36 		bt_shell_error("Discovery failed (%d)", err);
37 	} else {
38 		bt_shell_print("Discovery done with %u AICS", aics_count);
39 
40 #if defined(CONFIG_BT_MICP_MIC_CTLR_AICS)
41 		if (bt_micp_mic_ctlr_included_get(mic_ctlr,
42 						  &micp_included) != 0) {
43 			bt_shell_error("Could not get included services");
44 		}
45 #endif /* CONFIG_BT_MICP_MIC_CTLR_AICS */
46 	}
47 }
48 
micp_mic_ctlr_mute_written_cb(struct bt_micp_mic_ctlr * mic_ctlr,int err)49 static void micp_mic_ctlr_mute_written_cb(struct bt_micp_mic_ctlr *mic_ctlr,
50 					  int err)
51 {
52 	if (err != 0) {
53 		bt_shell_error("Mute write failed (%d)", err);
54 	} else {
55 		bt_shell_print("Mute write completed");
56 	}
57 }
58 
micp_mic_ctlr_unmute_written_cb(struct bt_micp_mic_ctlr * mic_ctlr,int err)59 static void micp_mic_ctlr_unmute_written_cb(struct bt_micp_mic_ctlr *mic_ctlr,
60 					    int err)
61 {
62 	if (err != 0) {
63 		bt_shell_error("Unmute write failed (%d)", err);
64 	} else {
65 		bt_shell_print("Unmute write completed");
66 	}
67 }
68 
micp_mic_ctlr_mute_cb(struct bt_micp_mic_ctlr * mic_ctlr,int err,uint8_t mute)69 static void micp_mic_ctlr_mute_cb(struct bt_micp_mic_ctlr *mic_ctlr, int err,
70 				  uint8_t mute)
71 {
72 	if (err != 0) {
73 		bt_shell_error("Mute get failed (%d)", err);
74 	} else {
75 		bt_shell_print("Mute value %u", mute);
76 	}
77 }
78 
79 #if defined(CONFIG_BT_MICP_MIC_CTLR_AICS)
80 static struct bt_micp_included micp_included;
81 
micp_mic_ctlr_aics_set_gain_cb(struct bt_aics * inst,int err)82 static void micp_mic_ctlr_aics_set_gain_cb(struct bt_aics *inst, int err)
83 {
84 	if (err != 0) {
85 		bt_shell_error("Set gain failed (%d) for inst %p", err, inst);
86 	} else {
87 		bt_shell_print("Gain set for inst %p", inst);
88 	}
89 }
90 
micp_mic_ctlr_aics_unmute_cb(struct bt_aics * inst,int err)91 static void micp_mic_ctlr_aics_unmute_cb(struct bt_aics *inst, int err)
92 {
93 	if (err != 0) {
94 		bt_shell_error("Unmute failed (%d) for inst %p", err, inst);
95 	} else {
96 		bt_shell_print("Unmuted inst %p", inst);
97 	}
98 }
99 
micp_mic_ctlr_aics_mute_cb(struct bt_aics * inst,int err)100 static void micp_mic_ctlr_aics_mute_cb(struct bt_aics *inst, int err)
101 {
102 	if (err != 0) {
103 		bt_shell_error("Mute failed (%d) for inst %p", err, inst);
104 	} else {
105 		bt_shell_print("Muted inst %p", inst);
106 	}
107 }
108 
micp_mic_ctlr_aics_set_manual_mode_cb(struct bt_aics * inst,int err)109 static void micp_mic_ctlr_aics_set_manual_mode_cb(struct bt_aics *inst, int err)
110 {
111 	if (err != 0) {
112 		bt_shell_error("Set manual mode failed (%d) for inst %p", err, inst);
113 	} else {
114 		bt_shell_print("Manual mode set for inst %p", inst);
115 	}
116 }
117 
micp_mic_ctlr_aics_automatic_mode_cb(struct bt_aics * inst,int err)118 static void micp_mic_ctlr_aics_automatic_mode_cb(struct bt_aics *inst, int err)
119 {
120 	if (err != 0) {
121 		bt_shell_error("Set automatic mode failed (%d) for inst %p", err, inst);
122 	} else {
123 		bt_shell_print("Automatic mode set for inst %p", inst);
124 	}
125 }
126 
micp_mic_ctlr_aics_state_cb(struct bt_aics * inst,int err,int8_t gain,uint8_t mute,uint8_t mode)127 static void micp_mic_ctlr_aics_state_cb(struct bt_aics *inst, int err,
128 					int8_t gain, uint8_t mute, uint8_t mode)
129 {
130 	if (err != 0) {
131 		bt_shell_error("AICS state get failed (%d) for inst %p",
132 			       err, inst);
133 	} else {
134 		bt_shell_print("AICS inst %p state gain %d, mute %u, mode %u",
135 			       inst, gain, mute, mode);
136 	}
137 }
138 
micp_mic_ctlr_aics_gain_setting_cb(struct bt_aics * inst,int err,uint8_t units,int8_t minimum,int8_t maximum)139 static void micp_mic_ctlr_aics_gain_setting_cb(struct bt_aics *inst, int err,
140 					       uint8_t units, int8_t minimum,
141 					       int8_t maximum)
142 {
143 	if (err != 0) {
144 		bt_shell_error("AICS gain settings get failed (%d) for inst %p",
145 			       err, inst);
146 	} else {
147 		bt_shell_print("AICS inst %p gain settings units %u, min %d, max %d",
148 			       inst, units, minimum, maximum);
149 	}
150 }
151 
micp_mic_ctlr_aics_input_type_cb(struct bt_aics * inst,int err,uint8_t input_type)152 static void micp_mic_ctlr_aics_input_type_cb(struct bt_aics *inst, int err,
153 					     uint8_t input_type)
154 {
155 	if (err != 0) {
156 		bt_shell_error("AICS input type get failed (%d) for inst %p", err, inst);
157 	} else {
158 		bt_shell_print("AICS inst %p input type %u", inst, input_type);
159 	}
160 }
161 
micp_mic_ctlr_aics_status_cb(struct bt_aics * inst,int err,bool active)162 static void micp_mic_ctlr_aics_status_cb(struct bt_aics *inst, int err,
163 					 bool active)
164 {
165 	if (err != 0) {
166 		bt_shell_error("AICS status get failed (%d) for inst %p", err, inst);
167 	} else {
168 		bt_shell_print("AICS inst %p status %s",
169 			       inst, active ? "active" : "inactive");
170 	}
171 }
172 
micp_mic_ctlr_aics_description_cb(struct bt_aics * inst,int err,char * description)173 static void micp_mic_ctlr_aics_description_cb(struct bt_aics *inst, int err,
174 					      char *description)
175 {
176 	if (err != 0) {
177 		bt_shell_error("AICS description get failed (%d) for inst %p", err, inst);
178 	} else {
179 		bt_shell_print("AICS inst %p description %s", inst, description);
180 	}
181 }
182 #endif /* CONFIG_BT_MICP_MIC_CTLR_AICS */
183 
184 static struct bt_micp_mic_ctlr_cb micp_cbs = {
185 	.discover = micp_mic_ctlr_discover_cb,
186 	.mute_written = micp_mic_ctlr_mute_written_cb,
187 	.unmute_written = micp_mic_ctlr_unmute_written_cb,
188 	.mute = micp_mic_ctlr_mute_cb,
189 
190 #if defined(CONFIG_BT_MICP_MIC_CTLR_AICS)
191 	/* Audio Input Control Service */
192 	.aics_cb = {
193 		.state = micp_mic_ctlr_aics_state_cb,
194 		.gain_setting = micp_mic_ctlr_aics_gain_setting_cb,
195 		.type = micp_mic_ctlr_aics_input_type_cb,
196 		.status = micp_mic_ctlr_aics_status_cb,
197 		.description = micp_mic_ctlr_aics_description_cb,
198 		.set_gain = micp_mic_ctlr_aics_set_gain_cb,
199 		.unmute = micp_mic_ctlr_aics_unmute_cb,
200 		.mute = micp_mic_ctlr_aics_mute_cb,
201 		.set_manual_mode = micp_mic_ctlr_aics_set_manual_mode_cb,
202 		.set_auto_mode = micp_mic_ctlr_aics_automatic_mode_cb,
203 	}
204 #endif /* CONFIG_BT_MICP_MIC_CTLR_AICS */
205 };
206 
cmd_micp_mic_ctlr_discover(const struct shell * sh,size_t argc,char ** argv)207 static int cmd_micp_mic_ctlr_discover(const struct shell *sh, size_t argc,
208 				    char **argv)
209 {
210 	int result;
211 
212 	result = bt_micp_mic_ctlr_cb_register(&micp_cbs);
213 	if (result != 0) {
214 		shell_print(sh, "Failed to register callbacks: %d", result);
215 	}
216 
217 	if (default_conn == NULL) {
218 		return -ENOTCONN;
219 	}
220 
221 	result = bt_micp_mic_ctlr_discover(default_conn, &micp_mic_ctlr);
222 	if (result != 0) {
223 		shell_print(sh, "Fail: %d", result);
224 	}
225 
226 	return result;
227 }
228 
cmd_micp_mic_ctlr_mute_get(const struct shell * sh,size_t argc,char ** argv)229 static int cmd_micp_mic_ctlr_mute_get(const struct shell *sh, size_t argc,
230 				    char **argv)
231 {
232 	int result;
233 
234 	if (micp_mic_ctlr == NULL) {
235 		return -ENOENT;
236 	}
237 
238 	result = bt_micp_mic_ctlr_mute_get(micp_mic_ctlr);
239 
240 	if (result != 0) {
241 		shell_print(sh, "Fail: %d", result);
242 	}
243 
244 	return result;
245 }
246 
cmd_micp_mic_ctlr_mute(const struct shell * sh,size_t argc,char ** argv)247 static int cmd_micp_mic_ctlr_mute(const struct shell *sh, size_t argc,
248 				char **argv)
249 {
250 	int result;
251 
252 	if (micp_mic_ctlr == NULL) {
253 		return -ENOENT;
254 	}
255 
256 	result = bt_micp_mic_ctlr_mute(micp_mic_ctlr);
257 
258 	if (result != 0) {
259 		shell_print(sh, "Fail: %d", result);
260 	}
261 
262 	return result;
263 }
264 
cmd_micp_mic_ctlr_unmute(const struct shell * sh,size_t argc,char ** argv)265 static int cmd_micp_mic_ctlr_unmute(const struct shell *sh, size_t argc,
266 				  char **argv)
267 {
268 	int result;
269 
270 	if (micp_mic_ctlr == NULL) {
271 		return -ENOENT;
272 	}
273 
274 	result = bt_micp_mic_ctlr_unmute(micp_mic_ctlr);
275 
276 	if (result != 0) {
277 		shell_print(sh, "Fail: %d", result);
278 	}
279 
280 	return result;
281 }
282 
283 #if defined(CONFIG_BT_MICP_MIC_CTLR_AICS)
cmd_micp_mic_ctlr_aics_input_state_get(const struct shell * sh,size_t argc,char ** argv)284 static int cmd_micp_mic_ctlr_aics_input_state_get(const struct shell *sh,
285 						size_t argc, char **argv)
286 {
287 	unsigned long index;
288 	int result = 0;
289 
290 	index = shell_strtoul(argv[1], 0, &result);
291 	if (result != 0) {
292 		shell_error(sh, "Could not parse index: %d", result);
293 
294 		return -ENOEXEC;
295 	}
296 
297 	if (index >= micp_included.aics_cnt) {
298 		shell_error(sh, "Index shall be less than %u, was %lu",
299 			    micp_included.aics_cnt, index);
300 
301 		return -ENOEXEC;
302 	}
303 
304 	if (micp_mic_ctlr == NULL) {
305 		return -ENOENT;
306 	}
307 
308 	result = bt_aics_state_get(micp_included.aics[index]);
309 	if (result != 0) {
310 		shell_print(sh, "Fail: %d", result);
311 	}
312 
313 	return result;
314 }
315 
cmd_micp_mic_ctlr_aics_gain_setting_get(const struct shell * sh,size_t argc,char ** argv)316 static int cmd_micp_mic_ctlr_aics_gain_setting_get(const struct shell *sh,
317 						 size_t argc, char **argv)
318 {
319 	unsigned long index;
320 	int result = 0;
321 
322 	index = shell_strtoul(argv[1], 0, &result);
323 	if (result != 0) {
324 		shell_error(sh, "Could not parse index: %d", result);
325 
326 		return -ENOEXEC;
327 	}
328 
329 	if (index >= micp_included.aics_cnt) {
330 		shell_error(sh, "Index shall be less than %u, was %lu",
331 			    micp_included.aics_cnt, index);
332 
333 		return -ENOEXEC;
334 	}
335 
336 	if (micp_mic_ctlr == NULL) {
337 		return -ENOENT;
338 	}
339 
340 	result = bt_aics_gain_setting_get(micp_included.aics[index]);
341 	if (result != 0) {
342 		shell_print(sh, "Fail: %d", result);
343 	}
344 
345 	return result;
346 }
347 
cmd_micp_mic_ctlr_aics_input_type_get(const struct shell * sh,size_t argc,char ** argv)348 static int cmd_micp_mic_ctlr_aics_input_type_get(const struct shell *sh,
349 					       size_t argc, char **argv)
350 {
351 	unsigned long index;
352 	int result = 0;
353 
354 	index = shell_strtoul(argv[1], 0, &result);
355 	if (result != 0) {
356 		shell_error(sh, "Could not parse index: %d", result);
357 
358 		return -ENOEXEC;
359 	}
360 
361 	if (index >= micp_included.aics_cnt) {
362 		shell_error(sh, "Index shall be less than %u, was %lu",
363 			    micp_included.aics_cnt, index);
364 
365 		return -ENOEXEC;
366 	}
367 
368 	if (micp_mic_ctlr == NULL) {
369 		return -ENOENT;
370 	}
371 
372 	result = bt_aics_type_get(micp_included.aics[index]);
373 	if (result != 0) {
374 		shell_print(sh, "Fail: %d", result);
375 	}
376 
377 	return result;
378 }
379 
cmd_micp_mic_ctlr_aics_input_status_get(const struct shell * sh,size_t argc,char ** argv)380 static int cmd_micp_mic_ctlr_aics_input_status_get(const struct shell *sh,
381 						 size_t argc, char **argv)
382 {
383 	unsigned long index;
384 	int result = 0;
385 
386 	index = shell_strtoul(argv[1], 0, &result);
387 	if (result != 0) {
388 		shell_error(sh, "Could not parse index: %d", result);
389 
390 		return -ENOEXEC;
391 	}
392 
393 	if (index >= micp_included.aics_cnt) {
394 		shell_error(sh, "Index shall be less than %u, was %lu",
395 			    micp_included.aics_cnt, index);
396 
397 		return -ENOEXEC;
398 	}
399 
400 	if (micp_mic_ctlr == NULL) {
401 		return -ENOENT;
402 	}
403 
404 	result = bt_aics_status_get(micp_included.aics[index]);
405 	if (result != 0) {
406 		shell_print(sh, "Fail: %d", result);
407 	}
408 
409 	return result;
410 }
411 
cmd_micp_mic_ctlr_aics_input_unmute(const struct shell * sh,size_t argc,char ** argv)412 static int cmd_micp_mic_ctlr_aics_input_unmute(const struct shell *sh,
413 					     size_t argc, char **argv)
414 {
415 	unsigned long index;
416 	int result = 0;
417 
418 	index = shell_strtoul(argv[1], 0, &result);
419 	if (result != 0) {
420 		shell_error(sh, "Could not parse index: %d", result);
421 
422 		return -ENOEXEC;
423 	}
424 
425 	if (index >= micp_included.aics_cnt) {
426 		shell_error(sh, "Index shall be less than %u, was %lu",
427 			    micp_included.aics_cnt, index);
428 
429 		return -ENOEXEC;
430 	}
431 
432 	result = bt_aics_unmute(micp_included.aics[index]);
433 	if (result != 0) {
434 		shell_print(sh, "Fail: %d", result);
435 	}
436 
437 	return result;
438 }
439 
cmd_micp_mic_ctlr_aics_input_mute(const struct shell * sh,size_t argc,char ** argv)440 static int cmd_micp_mic_ctlr_aics_input_mute(const struct shell *sh,
441 					   size_t argc, char **argv)
442 {
443 	unsigned long index;
444 	int result = 0;
445 
446 	index = shell_strtoul(argv[1], 0, &result);
447 	if (result != 0) {
448 		shell_error(sh, "Could not parse index: %d", result);
449 
450 		return -ENOEXEC;
451 	}
452 
453 	if (index >= micp_included.aics_cnt) {
454 		shell_error(sh, "Index shall be less than %u, was %lu",
455 			    micp_included.aics_cnt, index);
456 
457 		return -ENOEXEC;
458 	}
459 
460 	if (micp_mic_ctlr == NULL) {
461 		return -ENOENT;
462 	}
463 
464 	result = bt_aics_mute(micp_included.aics[index]);
465 	if (result != 0) {
466 		shell_print(sh, "Fail: %d", result);
467 	}
468 
469 	return result;
470 }
471 
cmd_micp_mic_ctlr_aics_manual_input_gain_set(const struct shell * sh,size_t argc,char ** argv)472 static int cmd_micp_mic_ctlr_aics_manual_input_gain_set(const struct shell *sh,
473 						      size_t argc, char **argv)
474 {
475 	unsigned long index;
476 	int result = 0;
477 
478 	index = shell_strtoul(argv[1], 0, &result);
479 	if (result != 0) {
480 		shell_error(sh, "Could not parse index: %d", result);
481 
482 		return -ENOEXEC;
483 	}
484 
485 	if (index >= micp_included.aics_cnt) {
486 		shell_error(sh, "Index shall be less than %u, was %lu",
487 			    micp_included.aics_cnt, index);
488 
489 		return -ENOEXEC;
490 	}
491 
492 	if (micp_mic_ctlr == NULL) {
493 		return -ENOENT;
494 	}
495 
496 	result = bt_aics_manual_gain_set(micp_included.aics[index]);
497 	if (result != 0) {
498 		shell_print(sh, "Fail: %d", result);
499 	}
500 
501 	return result;
502 }
503 
cmd_micp_mic_ctlr_aics_automatic_input_gain_set(const struct shell * sh,size_t argc,char ** argv)504 static int cmd_micp_mic_ctlr_aics_automatic_input_gain_set(const struct shell *sh,
505 							 size_t argc,
506 							 char **argv)
507 {
508 	unsigned long index;
509 	int result = 0;
510 
511 	index = shell_strtoul(argv[1], 0, &result);
512 	if (result != 0) {
513 		shell_error(sh, "Could not parse index: %d", result);
514 
515 		return -ENOEXEC;
516 	}
517 
518 	if (index >= micp_included.aics_cnt) {
519 		shell_error(sh, "Index shall be less than %u, was %lu",
520 			    micp_included.aics_cnt, index);
521 
522 		return -ENOEXEC;
523 	}
524 
525 	if (micp_mic_ctlr == NULL) {
526 		return -ENOENT;
527 	}
528 
529 	result = bt_aics_automatic_gain_set(micp_included.aics[index]);
530 	if (result != 0) {
531 		shell_print(sh, "Fail: %d", result);
532 	}
533 
534 	return result;
535 }
536 
cmd_micp_mic_ctlr_aics_gain_set(const struct shell * sh,size_t argc,char ** argv)537 static int cmd_micp_mic_ctlr_aics_gain_set(const struct shell *sh, size_t argc,
538 					 char **argv)
539 {
540 	unsigned long index;
541 	int result = 0;
542 	long gain;
543 
544 	index = shell_strtoul(argv[1], 0, &result);
545 	if (result != 0) {
546 		shell_error(sh, "Could not parse index: %d", result);
547 
548 		return -ENOEXEC;
549 	}
550 
551 	if (index >= micp_included.aics_cnt) {
552 		shell_error(sh, "Index shall be less than %u, was %lu",
553 			    micp_included.aics_cnt, index);
554 
555 		return -ENOEXEC;
556 	}
557 
558 	gain = shell_strtol(argv[2], 0, &result);
559 	if (result != 0) {
560 		shell_error(sh, "Could not parse gain: %d", result);
561 
562 		return -ENOEXEC;
563 	}
564 
565 	if (gain > INT8_MAX || gain < INT8_MIN) {
566 		shell_error(sh, "Gain shall be %d-%d, was %ld",
567 			    INT8_MIN, INT8_MAX, gain);
568 
569 		return -ENOEXEC;
570 	}
571 
572 	if (micp_mic_ctlr == NULL) {
573 		return -ENOENT;
574 	}
575 
576 	result = bt_aics_gain_set(micp_included.aics[index], gain);
577 	if (result != 0) {
578 		shell_print(sh, "Fail: %d", result);
579 	}
580 
581 	return result;
582 }
583 
cmd_micp_mic_ctlr_aics_input_description_get(const struct shell * sh,size_t argc,char ** argv)584 static int cmd_micp_mic_ctlr_aics_input_description_get(const struct shell *sh,
585 						      size_t argc, char **argv)
586 {
587 	unsigned long index;
588 	int result = 0;
589 
590 	index = shell_strtoul(argv[1], 0, &result);
591 	if (result != 0) {
592 		shell_error(sh, "Could not parse index: %d", result);
593 
594 		return -ENOEXEC;
595 	}
596 
597 	if (index >= micp_included.aics_cnt) {
598 		shell_error(sh, "Index shall be less than %u, was %lu",
599 			    micp_included.aics_cnt, index);
600 
601 		return -ENOEXEC;
602 	}
603 
604 	if (micp_mic_ctlr == NULL) {
605 		return -ENOENT;
606 	}
607 
608 	result = bt_aics_description_get(micp_included.aics[index]);
609 	if (result != 0) {
610 		shell_print(sh, "Fail: %d", result);
611 	}
612 
613 	return result;
614 }
615 
cmd_micp_mic_ctlr_aics_input_description_set(const struct shell * sh,size_t argc,char ** argv)616 static int cmd_micp_mic_ctlr_aics_input_description_set(const struct shell *sh,
617 						      size_t argc, char **argv)
618 {
619 	unsigned long index;
620 	int result = 0;
621 
622 	index = shell_strtoul(argv[1], 0, &result);
623 	if (result != 0) {
624 		shell_error(sh, "Could not parse index: %d", result);
625 
626 		return -ENOEXEC;
627 	}
628 
629 	if (index >= micp_included.aics_cnt) {
630 		shell_error(sh, "Index shall be less than %u, was %lu",
631 			    micp_included.aics_cnt, index);
632 
633 		return -ENOEXEC;
634 	}
635 
636 	if (micp_mic_ctlr == NULL) {
637 		return -ENOENT;
638 	}
639 
640 	result = bt_aics_description_set(micp_included.aics[index], argv[2]);
641 	if (result != 0) {
642 		shell_print(sh, "Fail: %d", result);
643 	}
644 
645 	return result;
646 }
647 #endif /* CONFIG_BT_MICP_MIC_CTLR_AICS */
648 
cmd_micp_mic_ctlr(const struct shell * sh,size_t argc,char ** argv)649 static int cmd_micp_mic_ctlr(const struct shell *sh, size_t argc, char **argv)
650 {
651 	if (argc > 1) {
652 		shell_error(sh, "%s unknown parameter: %s",
653 			    argv[0], argv[1]);
654 	} else {
655 		shell_error(sh, "%s Missing subcommand", argv[0]);
656 	}
657 
658 	return -ENOEXEC;
659 }
660 
661 SHELL_STATIC_SUBCMD_SET_CREATE(micp_mic_ctlr_cmds,
662 	SHELL_CMD_ARG(discover, NULL,
663 		      "Discover MICS on remote device",
664 		      cmd_micp_mic_ctlr_discover, 1, 0),
665 	SHELL_CMD_ARG(mute_get, NULL,
666 		      "Read the mute state of the Microphone Device server.",
667 		      cmd_micp_mic_ctlr_mute_get, 1, 0),
668 	SHELL_CMD_ARG(mute, NULL,
669 		      "Mute the Microphone Device server",
670 		      cmd_micp_mic_ctlr_mute, 1, 0),
671 	SHELL_CMD_ARG(unmute, NULL,
672 		      "Unmute the Microphone Device server",
673 		      cmd_micp_mic_ctlr_unmute, 1, 0),
674 #if defined(CONFIG_BT_MICP_MIC_CTLR_AICS)
675 	SHELL_CMD_ARG(aics_input_state_get, NULL,
676 		      "Read the input state of a AICS instance <inst_index>",
677 		      cmd_micp_mic_ctlr_aics_input_state_get, 2, 0),
678 	SHELL_CMD_ARG(aics_gain_setting_get, NULL,
679 		      "Read the gain settings of a AICS instance <inst_index>",
680 		      cmd_micp_mic_ctlr_aics_gain_setting_get, 2, 0),
681 	SHELL_CMD_ARG(aics_input_type_get, NULL,
682 		      "Read the input type of a AICS instance <inst_index>",
683 		      cmd_micp_mic_ctlr_aics_input_type_get, 2, 0),
684 	SHELL_CMD_ARG(aics_input_status_get, NULL,
685 		      "Read the input status of a AICS instance <inst_index>",
686 		      cmd_micp_mic_ctlr_aics_input_status_get, 2, 0),
687 	SHELL_CMD_ARG(aics_input_unmute, NULL,
688 		      "Unmute the input of a AICS instance <inst_index>",
689 		      cmd_micp_mic_ctlr_aics_input_unmute, 2, 0),
690 	SHELL_CMD_ARG(aics_input_mute, NULL,
691 		      "Mute the input of a AICS instance <inst_index>",
692 		      cmd_micp_mic_ctlr_aics_input_mute, 2, 0),
693 	SHELL_CMD_ARG(aics_manual_input_gain_set, NULL,
694 		      "Set the gain mode of a AICS instance to manual "
695 		      "<inst_index>",
696 		      cmd_micp_mic_ctlr_aics_manual_input_gain_set, 2, 0),
697 	SHELL_CMD_ARG(aics_automatic_input_gain_set, NULL,
698 		      "Set the gain mode of a AICS instance to automatic "
699 		      "<inst_index>",
700 		      cmd_micp_mic_ctlr_aics_automatic_input_gain_set, 2, 0),
701 	SHELL_CMD_ARG(aics_gain_set, NULL,
702 		      "Set the gain of a AICS instance <inst_index> <gain>",
703 		      cmd_micp_mic_ctlr_aics_gain_set, 3, 0),
704 	SHELL_CMD_ARG(aics_input_description_get, NULL,
705 		      "Read the input description of a AICS instance "
706 		      "<inst_index>",
707 		      cmd_micp_mic_ctlr_aics_input_description_get, 2, 0),
708 	SHELL_CMD_ARG(aics_input_description_set, NULL,
709 		      "Set the input description of a AICS instance "
710 		      "<inst_index> <description>",
711 		      cmd_micp_mic_ctlr_aics_input_description_set, 3, 0),
712 #endif /* CONFIG_BT_MICP_MIC_CTLR_AICS */
713 	SHELL_SUBCMD_SET_END
714 );
715 
716 SHELL_CMD_ARG_REGISTER(micp_mic_ctlr, &micp_mic_ctlr_cmds,
717 		       "Bluetooth Microphone Controller shell commands",
718 		       cmd_micp_mic_ctlr, 1, 1);
719