After much searching and trail and error I found out that my code is correct. I just had to remove the devices from the ipad's Setting.
Goto Settings > General > Bluetooth > Devices.
Select the device by clicking the accessory indicator. In the next screen just click on "Forget this Device".
Running the application again solved my problem.