don/BluetoothSerial — pull request #23 by RhinoLance (2013-11-19 10:13:15+00:00)
Title: Pushe multiple messages to a subscriber

Pushes multiple messages to a subscriber where more than one delimiter exists in a message.

As an example, let's assume that in our app, we've called
bluetoothSerial.subscribe('\n', success, failure);

If MEGBluetoothSerial::bleDidReceiveData gets sent a string of "1\n2\n" our success callback above gets called with "1". "2\n" remains in the buffer.

If MEGBluetoothSerial::bleDidReceiveData then gets sent a string of "3\n", our success callback above gets called with "2", as it's now next in the buffer

As you can see, as soon as MEGBluetoothSerial::bleDidReceiveData gets sent data with more than one delimiter, our callback will be out of phase with the message received.

This pull request ensures that MEGBluetoothSerial::bleDidReceiveData will fire our success callback for each delimited message.

P.S. This is my first pull request, so apologies in advance if I've mucked it up or done something wrong. Let me know if I need to change it somehow.