Added state management on YMSCBPeripheral

Added state management on YMSCBPeripheral so that the CBPeripheral state is closely monitored in YMSCBPeripheral, this will prevent errors where we try to write and CBPeripheral is null or not connected.

For some unreliable bluetooth connections and certain IOS versions (7.03) the Bluetooth is a little bit buggy and this can cause the CBPeripheral to get out of state quite easily causing strange behaviour and crashes.

Also fixed crashing bug when writing a null characteristic.