On line 8 change:
- system("bluetooth-agent 0000 & > /dev/ttyGS0");
to:
- system("bluetooth-agent 0000 > /dev/ttyGS0 2> /dev/ttyGS0 &");
I.e., Add "2> /dev/ttyGS0" and move the ampersand to the end.
When you do, you will see the error message: /bin/sh: bluetooth-agent: command not found
bluetooth-agent is not a command in Galileo Linux.
Also, add "2> /dev/ttyGS0" to every "system" string to print out error messages.
I don't know if this will solve your problem. But at least it fix one error. I will look at your script more tommorrow.
Regards,
Bob