2018-10-11 programming

Stars Wars Addiction Too Strong

A long time ago (in a galaxy far, far away...) I planned on writing a post describing how I got an IRC chatbot to work with a Sphero BB8 droid. It's been a long time, but here it is.


For Christmas of 2016, my brother got me one of those Sphero droids. Best Christmas present ever, yes. It came with a "forceband", though I never got around to fiddling with it. From what I could tell, you couldn't control the droid from the forceband. The real driving force was the app.

To get started, you would have to hold your BT-enabled phone up to the droid and wait for it to connect. Then, a list of options would come up to let you interact with the little guy. You could watch The Force Awakens with him, and he would chirp when it got to his scenes, or you could remote-control him to roll around. You could also voice-command him, but that was all the app- the actual droid didn't have voice recognition.

To be honest, I loved figuring all this stuff out for an hour, but my nerdy computer-science-major-college-undergrad-wannabe-hacker self kicked in and I wanted to get my hands on some code.

Hacking BB8

I remember the cursory Google search I made didn't turn up with many results. Someone had made a Java library to program the droid, but I had no interest in learning Java or having it all be blackboxed, like it already was. I was kinda disappointed, until I ran into someone's post about how the droids actually work. I read that they connect to your phone via Bluetooth and there was no authentication. Heck yes.

I looked into BT a bit more and then kicked off some hacking. If you want to connect to the droid from your computer, you just need to know its MAC address and then connect before it connects with anything else. That's it. Oh, and you need to make sure he's powered on.

To find nearby devices and their MAC addresses, in Linux you can run sudo hcitool lescan. My droid's address was EE:67:34:14:C8:E4. You can tell which address is for the droid because it will be prefaced with BB-.

I am forgetting the details (why oh why did I wait two years to write this), but I definitely paired and connected with BB8 from the command line before I moved on. I don't recall the commands I used, but if I ever do, I'll come back and edit this post.

After looking around for a while, I found this library in Python (you know my fave) that handled all the BT connecting and even had some wrappers for controlling the droid. I used it to connect with the droid and make him change colors. It was awesome.

I later added some code to control his driving, and I let my brothers play with him from the command line. This is where the IRC bot comes into play...

This is already long enough, read the next post here.

If you're interested in checking out the code, I have it all on Github.