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

Embed: (wiki syntax)

« Back to documentation index

BGLib Class Reference

BGLib Class Reference

A class which can communicate with a BlueGiga BLE112(3) over a UART Connection. More...

#include <BGLib.h>

Public Types

enum  gap_discover_mode { gap_discover_limited = 0, gap_discover_generic = 1, gap_discover_observation = 2 }
 

GAP Discoverable modes.

More...

Public Member Functions

 BGLib (PinName tx, PinName rx, PinName rts, PinName cts)
 Create a BGLib instance.
void ble_cmd_system_hello ()
 Send a Hello command to the device.
void set_ble_rsp_system_hello (hello_callback_t pCallback)
 Set the callback for a Hello command.
void ble_cmd_system_get_info ()
 Send a Get Info command to the device.
void set_ble_rsp_system_get_info (get_info_callback_t pCallback)
 Set the callback for a Get Info command.
void ble_cmd_system_reset (ble_msg_system_reset_t args)
 Send a Reset command to the device.
void set_ble_evt_system_boot (boot_callback_t pCallback)
 Set the callback for a Boot event.
void set_timestamp_callback (timestamp_callback_t pCallback)
 Set a "timestamping" callback.
void ble_cmd_gap_discover (gap_discover_mode mode)
 Send a Discover command to the device.
void set_ble_rsp_gap_discover (discover_callback_t pCallback)
 Set the callback for a Discover command.
void set_ble_evt_gap_scan_result (scan_result_callback_t pCallback)
 Set the callback for Scan Result events.

Detailed Description

A class which can communicate with a BlueGiga BLE112(3) over a UART Connection.

Note that all communication is asynchronous. Your class will have to supply callbacks for each command it intends to use.

Example:

 #include "mbed.h"
 #include "BGLib.h"
 
 BGLib ble112(p9, p10, p7, p8);
 
 void helloCallback() {
    printf("BLE112 said hello!\r\n");
 }
 
 int main() {
     ble112.set_ble_rsp_system_hello(&helloCallback);
     ble112.ble_cmd_system_hello();
 }

Definition at line 24 of file BGLib.h.


Member Enumeration Documentation

GAP Discoverable modes.

Enumerator:
gap_discover_limited 

Discover only limited discoverable devices, that is, Slaves which have the LE Limited Discoverable Mode bit set in the Flags AD type of their advertisement packets.

gap_discover_generic 

Discover limited and generic discoverable devices, that is, Slaves which have the LE Limited Discoverable Mode or the LE General Discoverable Mode bit set in the Flags AD type of their advertisement packets.

gap_discover_observation 

Discover all devices regardless of the Flags AD type, so also devices in non-discoverable mode will be reported to host.

Definition at line 37 of file BGLib.h.


Constructor & Destructor Documentation

BGLib ( PinName  tx,
PinName  rx,
PinName  rts,
PinName  cts 
)

Create a BGLib instance.

Parameters:
txPin to use for UART transmission
rxPin to use for UART reception
rtsFlow control pin used for RTS.
ctsFlow control pin used for CTS.

Definition at line 3 of file BGLib.cpp.


Member Function Documentation

void ble_cmd_gap_discover ( gap_discover_mode  mode )

Send a Discover command to the device.

Parameters:
modeThe mode that the device should do discovery in.

Definition at line 50 of file BGLib.cpp.

void ble_cmd_system_get_info (  )

Send a Get Info command to the device.

Definition at line 19 of file BGLib.cpp.

void ble_cmd_system_hello (  )

Send a Hello command to the device.

Definition at line 14 of file BGLib.cpp.

void ble_cmd_system_reset ( ble_msg_system_reset_t  args )

Send a Reset command to the device.

Parameters:
argsA struct containing the DFU flag.

Definition at line 36 of file BGLib.cpp.

void set_ble_evt_gap_scan_result ( scan_result_callback_t  pCallback )

Set the callback for Scan Result events.

Parameters:
pCallbackFunction pointer to the desired callback.

Definition at line 46 of file BGLib.cpp.

void set_ble_evt_system_boot ( boot_callback_t  pCallback )

Set the callback for a Boot event.

Invoked when the BLE112 is powered on or reset.

Parameters:
pCallbackFunction pointer to the desired callback.

Definition at line 28 of file BGLib.cpp.

void set_ble_rsp_gap_discover ( discover_callback_t  pCallback )

Set the callback for a Discover command.

Parameters:
pCallbackFunction pointer to the desired callback.

Definition at line 32 of file BGLib.cpp.

void set_ble_rsp_system_get_info ( get_info_callback_t  pCallback )

Set the callback for a Get Info command.

Invoked when a response arrives.

Parameters:
pCallbackFunction pointer to the desired callback.

Definition at line 24 of file BGLib.cpp.

void set_ble_rsp_system_hello ( hello_callback_t  pCallback )

Set the callback for a Hello command.

Invoked when a response arrives.

Parameters:
pCallbackFunction pointer to the desired callback.

Definition at line 10 of file BGLib.cpp.

void set_timestamp_callback ( timestamp_callback_t  pCallback )

Set a "timestamping" callback.

This is invoked whenever the mbed receives any data on the UART interface.

Parameters:
pCallbackFunction pointer to the desired callback.

Definition at line 42 of file BGLib.cpp.