In this episode of my Bluetooth in Action series, we’ll finally be creating our first program. In the previous episode, we had a look at BGScript, and how to write, compile and flash BGScript applications. Today, we’ll be creating a real-world application.
So, what can we write? I can think of one application that might be useful. I used to travel quite a bit before, and while I love to travel, there was one part that I hated – the thought of luggage being stolen. Your precious laptop and tablet gone, not the kind of thing you want before a trans-Atlantic flight, where you’ve already seen all the films on your previous trip, leaving you 8 hours to think about what happened.
Let’s think of an application that could help us out, using Bluetooth Smart. What if we created an application that allowed a mobile telephone to connect, but triggered an alarm once the link was broken? If your suitcase is out of range of your mobile telephone, then a buzzer starts beeping, or something to attract the attention of people around. Well, this is easy enough to do in BGScript, so let’s try that out. We’ll be creating a new application, not one based on the examples delivered with the SDK. That being said, I will copy an existing BGPROJ file from an example.
To write this application, we are going to need two things. First of all, the BGM111 API Reference Manual that we saw earlier on in this series. We’ll need this to know what functions are available, and how to use them. We will also need the BGM111 Wireless Starter Kit User Guide. We only need one piece of information from here; the GPIO for the LED. The BGM111 API Reference Manual will be used extensively to know what BGScript functions are available, and how to call them. We'll be creating functions to handle connections, disconnections, and advertising.
You can compile this and flash it to test it out if you want, or you can wait until the next episode where I’ll show you how to compile and flash our application, and give it a spin. In the meantime, feel free to drop me a comment, I’ll answer it as soon as I can.