BLE Library Reference

Note: This page is currently incomplete (but we're working on it). For more details regarding the functions and constants please see the Quick Summary at the bottom of this page.

Note: This summary will be replaced with detailed descriptions of each function and constant.

Quick Summary

typedef struct BLEPacket {
  uint8_t pipe;
  uint8_t length;
  uint8_t * data;
} BLEPacket;
 
/*************** BLEduino functions ***********************/
void begin();
 
//Reads the head of the receive buffer;
//Returns BLEPacket object (struct, actually)
BLEPacket read();
 
//Reads the first packet in buffer from the specified pipe.
//Returns BLEPacket object with all the data contained
BLEPacket read(uint8_t pipe);
 
//Returns packets available in buffer
uint8_t available();
 
//Returns packets available in buffer (of the specified pipe)
uint8_t available(uint8_t pipe);
 
//Sends a data array (20 bytes max) to the specified pipe.  Specify size too please.
uint8_t sendData(uint8_t pipe, uint8_t* data, uint8_t size);
 
//Sends a single byte of data to the specified pipe.
uint8_t sendData(uint8_t pipe, uint8_t data);
 
//Send a command from the list below.
uint8_t sendCommand(uint8_t command);
 
//Flush everything in the buffer
void flush();
 
//Flush everything in the specified pipe
void flush(uint8_t pipe);
 
//Returns the head of the buffer with out removing it from the buffer.
BLEPacket peek();
 
//Returns the head of the buffer (of the specified pipe) with out removing it from the buffer.
BLEPacket peek(uint8_t pipe);
 
//return true if connected, false if not connected
bool isConnected();
 
//DEBUG
void print_all();
void print_all_list();
uint8_t return_head();
uint8_t return_tail();
 
/*************** BLEduino constants ***********************/
 
#define _SS_MAX_RX_BUFF 21 // RX buffer size
#define _SS_MAX_PACKET_LENGTH 20 // size of each element in buffer
 
#define BLEDUINO_LED 13 //yes, that one.
 
 
// Shield-Shield compatibility
#define BD11 MOSI
#define BD12 MISO
#define BD13 SCK
 
/********************************************************************************/
/* User Pipes */
 
//If a user is doing anything pipe specific, then use these constants.
//Those ending with READ are used to read from the phone.
//Those ending in SEND are used to send data to the phone
 
#define CONTROLLER_READ 4
#define CONTROLLER_SEND 2

#define FIRMATA_READ 9
#define FIRMATA_SEND 7

#define UART_READ 12
#define UART_SEND 14

#define NOTIFICATION_SEND 16

#define BRIDGE_ID_READ 21
#define BRIDGE_ID_SEND 22

#define BRIDGE_READ 24
#define BRIDGE_SEND 26

#define VEHICLE_READ 30
#define VEHICLE_SEND 28

#define PIPE_IS_CONNECTED 0
 
/********************************************************************************/
/* Commands */
 
//Reset the BLEduino antenna
//If bleduino connected, it will disconnect and continue advertising.
//If bleduino is not advertising, it will begin to advertise.
#define COMMAND_RESET 0
 
//Disconnects from phone and stops advertising.
#define COMMAND_DISCONNECT 1
 
//Updates the variable returned by isConnected();
#define COMMAND_IS_CONNECTED 2
 
//Turn BLE_LED on
#define COMMAND_LED_ON 3
 
//Turn BLE_LED off
#define COMMAND_LED_OFF 4
 
//Change µB baud rate to 9600
#define COMMAND_BAUD_RATE_9600 5
 
//etc
#define COMMAND_BAUD_RATE_14400 6
 
#define COMMAND_BAUD_RATE_19200 7
 
#define COMMAND_BAUD_RATE_28800 8
 
#define COMMAND_BAUD_RATE_31250 9
 
#define COMMAND_BAUD_RATE_38400 10
 
#define COMMAND_BAUD_RATE_57600 11
 
//toggle sleep mode in µB.  Danger, this is prone to errors. For the hardcore only.
#define COMMAND_SLEEP_TOGGLE 12
 
//Change the name the BLEduino will advertise. This is currently not used in this part of the code.
#define COMMAND_CHANGE_DEVICE_NAME 13