Today I will show you how to compile an app for the inPulse Smartwatch. For those of you that ask themselves what is an inPulse, head for these websites:
Once you’re done, let’s have some fun.
Or not. You probably noticed that compiling an app to send to your watch is no straightforward, no? So here I’m going to show you how. In a second part I’ll show you how to handle resources, such as fonts or images.
I’m going to make the demo on my Mac, but it’s not really important.
Step 1: grab the SDK, unpack it. You should get something like this:
Let’s see what we got:
- build folder contains your compiled files. Don’t bother with this one.
- compileandload.py is a python script that compiles your app and load it through Bluetooth to your watch
- doc contains SDK’s help files
- examples contains demo apps
- include contains include files necessary for your apps to be compiled
- libs contains apps libraries
- makefile is a file that tells the compiler what to compile and how
- resources will contain your app’s images and fonts
- src will contain your app’s source files
- tools contains tools among which the resource packer and the L2CAP server. Both will be used soon.
Before we begin compiling stuff, let me clarify one important point: an app is composed of two parts: compiled code and resources. Both must be sent separately to the watch. Weird? No. Because resources are loaded onto the watch at a different address in memory. But all you need to know is that it involves a second step.
Now, let’s prepare our files. For this example I’m going to use Trammel Hudson’s watchface called “Flip”. You can grab it here. If you have Mercurial installed on you system, you can grab all his watchfaces by typing “hg clone https://bitbucket.org/hudson/watches”. Else, get files needed. You should have something like this:
Let’s prepare the folders: in the pulse_sdk, delete everything that’s into the “src” and “resource” folders.
Now, move the files:
- “resources” folder should replace the one from pulse_sdk. You can even delete the original one.
- All the other files go into the “src” folder.
For this example, you should have something like this:
You’re done? now let’s compile and load all this stuff.
Launch a terminal, and set yourself to the pulse_sdk folder. One you’re done, let’s start the L2CAP Server. This will be used to send compiled app and resources to the watch. To do so,type “java -d32 -jar ./tools/L2CAPServer/L2CAPServer.jar”. You should obtain no error:
If you have an error at this point, make sure bluetooth is activated. Once you get the “Waiting for a connection…” message, you’re done.
Before we send anything to your watch, you must have it paired to your computer. The method is different whether you use Windows, MacOS or Linux. Anyway, find your watch’s MAC address. On a Mac, you can find it here: Apple menu -> About this Mac -> More info -> System Report -> Bluetooth (click the image below):
Now open another terminal, or a tab to your current one. Here again, set yourself to the pulse_sdk folder. First, pack resources by typing “python ./tools/resource_packer/resource_packer.py”. This will merge all resource in a single binary and generate an include file what will be compiled with our app. You should get something like this:
If not, check “fonts.txt” file in the resource folder, it contains font datas. If one of the line doesn’t begin with a ‘#’, then this line describes the font needed by the project. The font file must be in the resource folder.
Now, let’s send the resource file to the watch. Type “python compileandload.py -d 00:50:C2:E6:D5:52 -f resources/inpulse_resources.bin -r”. This will load the resource file:
This process can take time, depending on your ressources total size. Be patient, watch the number decrease in your terminal 😀
Once done, let’s do the same with the code. Type “python compileandload.py -d 00:50:C2:E6:D5:52”:
Do you see the “compile success!” line? This means “all is ok, now I’m gonna send the binaries to the watch”.
If everything worked fin, your watch should vibrate, reset and display your watchface:
I hope this tutorial has been helpful. For any comment, question, remark, please leave comments.