Bluetooth Brilliance!

Well, today has certainly been a productive day! I recieved my new HC-06 bluetooth module (I stupidly ripped up the RX trace on the other one trying to unsolder it from the backboard) and have managed to implement the “harris protocol” system! I’ve gone for a really simple protocol as the module itself only sends and recieves USART data as of now, until I learn all the AT commands of course! So the protocol is really easy, you send a packet start character (I’ve chosen ‘#’), send your data before the timeout and end the transaction with the packet terminator character, for which I’ve chosen ‘*’.

Obviously, there are places where this could fall, for example if the bluetooth sending device overruns the internal buffer and writes data to the wrong place. I’ve prevented this from happening by exiting the data receive loop and flagging that the data overrun but not actually allowing the data to write to the wrong location. I’ve also included a time out of 10s/character, its going to be less in the future, its just 10s as I’m using BlueTerm (http://goo.gl/Fy6CRJ) on my phone to communicate! The current structure of a packet is:

#[Packet start]X[Packet descriptor (single character)]D…[Up to 9 pieces of data]*[Transaction terminator]

Its really simple and does the job just fine!

Image
Sending data from my phone to the bluetooth enabled STM32F0 through BlueTerm, this will be the packet format for the date, packet transfer start character ‘#’, packet descriptor ‘d’, the 8 characters of the date and the packet terminator ‘*’.

Image
The whole setup! I love my good ol’ STM32F0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s