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.

Committer:
dishbreak
Date:
Sun May 17 23:24:26 2015 +0000
Revision:
1:3336b2391c80
Child:
2:3ce9a31a6a7e
Completed steel thread--can send hello packet using callbacks.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dishbreak 1:3336b2391c80 1 #include "BGLib.h"
dishbreak 1:3336b2391c80 2
dishbreak 1:3336b2391c80 3 BGLib::BGLib(PinName tx, PinName rx, PinName rts, PinName cts) :
dishbreak 1:3336b2391c80 4 mSerial(tx, rx) {
dishbreak 1:3336b2391c80 5 mSerial.set_flow_control(SerialBase::RTSCTS, rts, cts);
dishbreak 1:3336b2391c80 6 mSerial.baud(57600);
dishbreak 1:3336b2391c80 7 mSerial.attach(this, &BGLib::parse);
dishbreak 1:3336b2391c80 8 }
dishbreak 1:3336b2391c80 9
dishbreak 1:3336b2391c80 10 void BGLib::set_hello_callback(hello_callback_t pCallback) {
dishbreak 1:3336b2391c80 11 mHelloCallback = pCallback;
dishbreak 1:3336b2391c80 12 }
dishbreak 1:3336b2391c80 13
dishbreak 1:3336b2391c80 14 void BGLib::send_hello() {
dishbreak 1:3336b2391c80 15 uint8_t bytes[] = {0x00, 0x00, 0x00, 0x01};
dishbreak 1:3336b2391c80 16 send_bytes(bytes, 4);
dishbreak 1:3336b2391c80 17 }
dishbreak 1:3336b2391c80 18
dishbreak 1:3336b2391c80 19 void BGLib::parse() {
dishbreak 1:3336b2391c80 20 mSerial.getc();
dishbreak 1:3336b2391c80 21 mHelloCallback();
dishbreak 1:3336b2391c80 22 }
dishbreak 1:3336b2391c80 23
dishbreak 1:3336b2391c80 24 void BGLib::send_bytes(uint8_t bytes[], int length) {
dishbreak 1:3336b2391c80 25 for (int i = 0; i < length; i++) {
dishbreak 1:3336b2391c80 26 mSerial.putc(bytes[i]);
dishbreak 1:3336b2391c80 27 }
dishbreak 1:3336b2391c80 28 }