BlueGiga library (BGLib) for BLE112/3

Hi friends,

I have ported the entire BGLib library to Squirrel for use with your Imp.

I have been working with it for a week and its pretty stable and reliable. I haven’t tested all of it so there will be bugs.
A reference design should be forthcoming at some point for those that need a bit of hardware guidance.


Aron nice one and iBeacon as well have you test that feature?
If so could you share Obj C code?
@MakeDeck is this on your radar?

I tested it with various apps such as this one.

iBeacons are stupidly simple. They advertise with a specific payload blindly and frequently until they run out of batteries. Life is simple if you are an iBeacon.

I am working on an iBeacon scanner application using this class at the moment. It’s coming together nicely and I am continuing to test/update/fix the class.

I’m not at my Mac at the moment, @cloudcontrol, but I have an iOS app I wrote for a feature on iBeacons I wrote for The Register last year. Give me a mo and I’ll upload the source to GitHub and share the link here.

The key lines of the code are listed here, if you can’t wait!

Build your OWN Apple iBeacon with a Raspberry Pi

If I say so myself, it’s a handy dissection of the iBeacon ‘protocol’ too.

Tony thanks for the offer I’m not ioser but I’m trying to get a lazy mate to build me a simple app for testing a forthcoming iB proj.

Aron really interested scanner especially for proximity it’s looks like ios supports a crude range immediate,near,far. I was hoping that the iB could use RSSI of phone’s BT to build a smarter iB. I can then control lighting levels/scenes based on uses & proximity.

This looks to be a fantastic library/port Aron. Great work!

It’s disappointing that the code requires >55% of the program storage available on the imp-001/imp-002…

Does this improve with the imp-003? Any chance a soon to be released impOS update compresses compiled bytecode and the amount of “available” program storage increases significantly?

@controlcloud - definitely on the radar. :slight_smile:

I am interested in it as a “beacon bug” that uploads to a webservice a list of ibeacons in range as and when the list changes (for example because a beacon has come in and out of range)

If the clocks were in sync you could even use multiple “bugs” to triangulate beacons

@controlCloud proximity is pretty crude with iBeacon. The iBeacon announces the power it believes it is transmitting at and the BLE112 reports the RSSI of the signal it receives. With a bit of rough calibration you can sort-of work out how far away the two devices are from each other. Of course if there is an object between the two devices it will appear to be further away. I haven’t got round to crunching the numbers yet.

@deldrid1 it started at 90% until I commented out chunks! The simplest approach is to comment out any commands and events you aren’t using but yep, its a big class. With my application code, I am sitting at 87% now. Most of the work for me is in the agent and the UI now, so I am not concerned. We may see some extra flash available to us in imp-003 but we will definitely be seeing bytecode improvements soon. We never expected to run out of storage before RAM but its happening frequently.

@back_ache I am doing basically that with Firebase at the moment as a demo. It’s perfect for asset tracking and Squirrel is MUCH easier to work with than BGScript. A screenshot is here but the link is only temporary. The biggest issue I have is that BLE is very chatty so you have to denoise it in the imp not in the agent. Good luck trying to triangulate :slight_smile:

@smittytone nice article. I broke down the iBeacon protocol yesterday here including an answer to what the 0x02 0x15 is. It took me a while to get it all perfect but my work became clearer in my head when I did.

Well done, @aron. I just ordered a BLE113 breakout board to give this a whirl.

@smittytone can you share the link to BLE113 breakout you’ve ordered?

Here you go, @controlCloud:

Chose this one for the hard I2C connection (in place of USB)

Thanks that’s the only I could find too.

Found this site very useful for all things iBeacon and especially this

@smittytone, look out for the default firmware installed on that BLE113 … it is 38400 with no flow control. Flow control turns out to be a very good idea. I included support for packet-mode but have not tested it.