Some developers may wish to not include MetroEEG directly but include lower-level code. In this sample we'll endeavor to show a standalone example of getting information from a Mindwave Mobile headset into WP8.
Using the new Bluetooth support in WP8, it's possible to iterate over all paired Bluetooth devices and open a BT-SPP socket to them.
First, we get the list of all connected Bluetooth paired devices.
Next we iterate over that collection attempting to find one with the word "Mindwave" in it. If we don't find one, that could be for multiple reasons: Phone Bluetooth is off, mindwave is off, both devices aren't paired, etc.
And finally we open up a socket that'll be used later to retrieve information from.
Mindwave tends to be very chatty and has over 500+ messages every seconds. Those messages are received over as Bytes by C#. We can see the message format at
We'll use socket.InputStream.ReadAsync to read the data sent over by Mindwave.
We'll have to continuously read that data in a while (true) loop.
Mindwave sends back A LOT of data. It's quite easy to see a pattern of using 2 bytes of
and has an overall length of 36 bytes. for example:
header in it.
If our code has those values then we found the one packet out of 500 packets every second that interested us. Otherwise if that header doesn't exist we can just ignore all 512 bytes.
One unfortunate thing that might happen is that we get 512 bytes that have the header for our 36 bytes packet, but only a part of it. And we might need to read another 512 bytes to get the full 36 byte packet. Once we have that we'll take the length of the data packet (and 2 more bytes to see the next header).
When we run this code snippet we can see the following print out with useful data packets.