This is part three of my quest to build BlueTooth Low Energy Peripherals for fun.
The first part showed how to create a rudimentary Peripheral on a Mac. But really, it was to learn about how it’s done on a Mac, and I don’t see much interest in turning your Mac into a Peripheral.
The second part showed how to set up a cross-compilation development environment on a Mac with step-debugging code on the Pi.
This installment is, again, a prep phase, since the method in the second installment does not really work for building a Bluetooth stack on a Mac with cross-compile intentions. This is because the Linux dependencies needed to compile and link the app are not available fot the Mac, and implementing them would basically mean implementing a Linux hci and dbus emulator. That would be fun, but my goal is to build a Peripheral…
Sorry, my #fail
So this installment is about setting up NetBeans to actually compile and step through code on the Pi. Yes, I said it was slow, but what choice does a Bluetoothj n00b dev have?
The goal of this phase in our Sprint zero, is to have a way to hit “build” on the Mac, have the Pi do the actual build and then run the debugger to step through code that’s running on it.
The revised development workflow is:
- Use the Mac to write code on the Pi. This post is about setting up NetBeans to do so.
- Use the Mac to build (compile and link) the code on the Pi (using its native tool-chain, no more cross-compiling).
- Use NetBeans to debug the code running on the Pi (remotely).
Right click on the project’s root node to get to its preferences and go from there:
Set up a new Build Host
Configure the remote build host
Set up the local and remote directory paths
Set up the source folder
Set up the build host
Set up make working directory
Running & debugging remotely
Running the debugger on the Pi
gdbserver :1234 welcome_1
Here you’re telling gdbserer to run the welcome app on port 1234.
Attaching and stepping through the code from the Mac
From the menu, select “Debug”/”Attach debugger” and fill in the form:
- For debugger, select “remote debugger”
- For target, type “remote pi :1234”
‘pi’ is the pi’s host name (I put mine in /etc/hosts)
‘:1234’ is the port with which NetBeans will communicate on your Pi. This has to be the same port number that you selected in the
Here’s bunget in action.
I hope you find the post useful!