Partial implementation of BlueGiga's BGAPI for use with the BLE112/3 modules over UART.

Hi there! I recently started using BLE112 modules with the mbed LPC1768 MCU, and I realized there was no implementation of BlueGiga's BGAPI available for mbed. This library implements only a few commands, but if you're looking to get started, this is a good place to look.

This was developed against BGAPI v1.3.2. I make no guarantees as to how well it will work with newer revisions of the software.

BGLib.cpp

Committer:
dishbreak
Date:
2015-05-17
Revision:
1:3336b2391c80
Child:
2:3ce9a31a6a7e

File content as of revision 1:3336b2391c80:

#include "BGLib.h"

BGLib::BGLib(PinName tx, PinName rx, PinName rts, PinName cts) :
    mSerial(tx, rx) {
    mSerial.set_flow_control(SerialBase::RTSCTS, rts, cts);
    mSerial.baud(57600);
    mSerial.attach(this, &BGLib::parse);
}

void BGLib::set_hello_callback(hello_callback_t pCallback) {
    mHelloCallback = pCallback;
}

void BGLib::send_hello() {
    uint8_t bytes[] = {0x00, 0x00, 0x00, 0x01};
    send_bytes(bytes, 4);
}

void BGLib::parse() {
    mSerial.getc();
    mHelloCallback();
}

void BGLib::send_bytes(uint8_t bytes[], int length) {
    for (int i = 0; i < length; i++) {
        mSerial.putc(bytes[i]);
    }
}