- RFCOMM socket: http://people.csail.mit.edu/albert/bluez-intro/x502.html
- Service Registering: http://people.csail.mit.edu/albert/bluez-intro/x604.html
- WiringPi: https://nicohood.wordpress.com/2014/04/18/arduino-raspberry-pi-serial-communication-protocol-via-usb-and-cc/
- I/O multiplexing: http://beej.us/guide/bgnet/output/html/multipage/advanced.html
- Multithreading and mutex: https://computing.llnl.gov/tutorials/pthreads/#Mutexes
Refer to rpi_final/rpi.c
Pay attention to comments in the beginning of the file for how to compile and run the code...