So I'm not sure why it's doing this. My if statement keeps interpreting the second variable as a literal string instead of a variable. Below is my exact code. lights() { bulb1state=$(gatttool -b D8:6F:4B:09:AC:E6 --char-read -a 0x001b) echo $bulb1state bulb2state=$(gatttool -b DA:5A:4B:09:AC:E6 --char-read -a 0x001b) bulb3state=$(gatttool -b AC:E6:4B:07:39:E9 --char-read -a 0x0018) bulb4state=$(gatttool -b AC:E6:4B:08:40:50 --char-read -a 0x0018) offstate="Characteristic value/descriptor: 00 00 00 00" echo $bulb1state echo $offstate if [ "$offstate" = "$bulb1state" ]; then echo $bulb1state echo "bulb1 state = off" gatttool -b D8:6F:4B:09:AC:E6 --char-write -a 0x001b -n ff000000 gatttool -b DA:5A:4B:09:AC:E6 --char-write -a 0x001b -n ff000000 gatttool -b AC:E6:4B:07:39:E9 --char-write -a 0x0018 -n ff000000 gatttool -b AC:E6:4B:08:40:50 --char-write -a 0x0018 -n ff000000 fi }
My output:
>lights
Characteristic value/descriptor: 00 00 00 00
Characteristic value/descriptor: 00 00 00 00
Characteristic value/descriptor: 00 00 00 00
I don't understand why the last 2 echo statements are not displaying.
Aucun commentaire:
Enregistrer un commentaire