Brain-dead Bluetooth on the P1
Let me start by saying two things:
- My customer wants me to incorporate Bluetooth into a Propeller device I make for him, so his customers can see sensor data on their cellphones.
- I don't know anything about Bluetooth.
How even to get started? Well, I lucked out. I ordered one of these from DigiKey, hoping for the best:
I liked it because, theoretically, I could just plug it into a Propeller Activity Board and use it with a Spin program to talk to my phone.
But I knew that was too easy to be true.
I was wrong.
By just powering it up, my phone was able to pair with it. Okay, how about sending and receiving data?
I installed this app on my Android phone:
It connected to the device plugged into the Activity Board. So I connected TX and RX to see if I got an echo. I did.
Next I wrote a little program in Spin:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ ser : "Parallax Serial Terminal" PUB start | x ser.startrxtx(1, 0, 0, 115200) ser.str(string("Enter numbers to square:", 13, 10)) repeat x := ser.decin ser.dec(x) ser.str(string(" squared = ")) ser.dec(x * x) ser.str(string(13, 10))
Here's a photo of the transaction:
What could be easier?
Well, okay. I need an app for the phone to do nice graphs, etc. I'm sure they're out there. I just need to find one and deal with the communication protocol.