# smart shades control

1) prerequisites
	1 - a raspberry pi (or a compatible device)
	2 - a bluetooth 4.0+ adapter with bluetooth low energy support (raspberry pi 3 has blue built in)
	3 - a sd card with at least 2 GiB of space and a sd card reader/writer
	4 - a smart shades peripheral that has been previously configured with the app

2) setting up the raspberry pi
	1 - download the lite version of the raspian linux distribution
	2 - format the sd card (quick format is sufficient)
	3 - open the archive and write the raspian image file to the sd card 
			mac osx:
	4 - insert the sd card to the raspberry pi and power the device
	5 - wait for the operating system to load
	6 - attach a keyboard and a screen or ssh to the raspberry pi
		the default login credentials are 
			username: pi
			password: raspberry
	7 - sudo apt-get update
		sudo apt-get upgrade
		sudo apt-get install bluez 
		(	if bluez is not available in the package repository or does not contain all required tools {hcitool, gatttool}, 
			instructions on how to install it can be found at:    )
	8 - enable the bluetooth adapter:	sudo hciconfig hci0 up
	9 - scan for ble devices (smart shades devices are named RISExxx):		sudo hcitool lescan
	10-	use the provided script to execute commands on the peripheral (sudo is required, launch the python script with the --help option to receive usage instructions)

3) services & characteristics

	battery service uuid:				0000180f-0000-1000-8000-00805f9b34fb

	battery value characteristic:		00002a19-0000-1000-8000-00805f9b34fb    [returns battery value in percentage format, 0-100]

	motor service uuid:					00001861-B87F-490C-92CB-11BA5EA5167C

	motor state value characteristic:	00001525-B87F-490C-92CB-11BA5EA5167C    [returns an array, the first value is the motor position in percentage]

	motor control characteristic:		00001530-B87F-490C-92CB-11BA5EA5167C    [write 0x69 to move up, 0x96 to move down]

	motor value characteristic:         00001526-B87F-490C-92CB-11BA5EA5167C    [write 0x00 - 0x69, (0 - 100 represented as % in base10)]

4) Examples

	sudo python -t [device's MAC] -c get_battery					[prints out the device's current battery level]
	sudo python -t [device's MAC] -c get_position				[prints out the device's current position]
	sudo python -t [device's MAC] -c move_up						[moves the device to its highest position]
	sudo python -t [device's MAC] -c move_down					[moves the device to its lowest position]
	sudo python -t [device's MAC] -c move_target -a [position]	[moves the device to the specified position with 0 being the highest and 100 the lowest position]