Skip to content

Commit 2c8676f

Browse files
committed
We now parse ENABLED_SCHEMAS in a loop, allowing for multiple gadget to be enabled
1 parent e137e4c commit 2c8676f

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

recipes-devtools/android-tools/android-tools/arduino-android-gadget-setup

+34-27
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,43 @@ start()
3737

3838
# populate config, optional
3939
mkdir configs/c.1/strings/0x409
40-
CFG_STRING="adb+acm"
41-
if [[ $ENABLED_SCHEMAS =~ "ncm" ]]; then
42-
CFG_STRING="adb+acm+ncm"
43-
fi
40+
CFG_STRING=$(echo $ENABLED_SCHEMAS | tr ' ' '+')
4441
echo $CFG_STRING > configs/c.1/strings/0x409/configuration
4542
echo 900 > configs/c.1/MaxPower
4643

47-
# create a generic ffs for adb
48-
mkdir functions/ffs.adb
49-
50-
# create the acm (serial) function
51-
mkdir functions/acm.GS0
52-
53-
if [[ $ENABLED_SCHEMAS =~ "ncm" ]]; then
54-
# create the ncm function
55-
mkdir functions/ncm.usb0
56-
57-
# assign ncm function to configuration
58-
ln -s functions/ncm.usb0/ configs/c.1
59-
fi
60-
61-
# assign acm function to configuration
62-
ln -s functions/acm.GS0 configs/c.1
63-
64-
# assign generic ffs to configuration
65-
ln -s functions/ffs.adb/ configs/c.1
66-
67-
# create adb ffs device dir and mount it
68-
mkdir -p /dev/usb-ffs/adb
69-
mount -o uid=1000,gid=1000 -t functionfs adb /dev/usb-ffs/adb
44+
# Loop through each element in ENABLED_SCHEMAS
45+
acm_count=0
46+
ncm_count=0
47+
for schema in $ENABLED_SCHEMAS; do
48+
case $schema in
49+
acm)
50+
# create the acm (serial) function with unique name
51+
mkdir -p functions/acm.GS$acm_count
52+
# assign acm function to configuration
53+
ln -s functions/acm.GS$acm_count configs/c.1
54+
acm_count=$((acm_count + 1))
55+
;;
56+
ffs)
57+
# create a generic ffs for adb
58+
mkdir functions/ffs.adb
59+
# assign generic ffs to configuration
60+
ln -s functions/ffs.adb/ configs/c.1
61+
# create adb ffs device dir and mount it
62+
mkdir -p /dev/usb-ffs/adb
63+
mount -o uid=1000,gid=1000 -t functionfs adb /dev/usb-ffs/adb
64+
;;
65+
ncm)
66+
# create the ncm function with unique name
67+
mkdir -p functions/ncm.usb$ncm_count
68+
# assign ncm function to configuration
69+
ln -s functions/ncm.usb$ncm_count configs/c.1
70+
ncm_count=$((ncm_count + 1))
71+
;;
72+
*)
73+
echo "Unknown schema: $schema"
74+
;;
75+
esac
76+
done
7077

7178
# execute adbd
7279
# /usr/bin/adbd

0 commit comments

Comments
 (0)