Flying Silicon Sensor
BleInterface Class Reference

#include <bleInterface.h>

Inheritance diagram for BleInterface:
PtvBleInterface

Public Member Functions

void init (const char *deviceName)
 
void startAdv (void)
 
void sendData (const char *buf, int len)
 
void poll (void)
 
void shutdown (void)
 
int isConnected (void)
 

Static Public Attributes

static const int MtuSize = BLE_ATT_LEN + 3
 BLE MTU size.
 

Static Protected Member Functions

static void cbDisconnect (uint16_t conn_handle, uint8_t reason)
 
static void cbConnect (uint16_t conn_handle)
 

Protected Attributes

FsUart bleuart
 Customized UART service.
 

Detailed Description

Encapsulates BLE connection details

Definition at line 40 of file bleInterface.h.

Member Function Documentation

◆ cbConnect()

void BleInterface::cbConnect ( uint16_t  conn_handle)
staticprotected

Callback invoked when central connects

Definition at line 35 of file bleInterface.cpp.

References MtuSize.

Referenced by init().

◆ cbDisconnect()

void BleInterface::cbDisconnect ( uint16_t  conn_handle,
uint8_t  reason 
)
staticprotected

Callback invoked when central disconnects

Definition at line 66 of file bleInterface.cpp.

Referenced by init().

◆ init()

void BleInterface::init ( const char *  deviceName)

Initialise the Adafruit BLE library

Parameters
deviceNameName of the device visible at BLE central

Definition at line 166 of file bleInterface.cpp.

References bleuart, cbConnect(), cbDisconnect(), and MtuSize.

Referenced by appSetup().

◆ isConnected()

int BleInterface::isConnected ( void  )

BLE connected query

Returns
1 if a BLE connection is active, else 0

Definition at line 87 of file bleInterface.cpp.

Referenced by appLoop(), and PtvBleInterface::poll().

◆ poll()

void BleInterface::poll ( void  )

Should be called periodically to poll BLE UART FIFO (default implementation, does nothing with data)

Definition at line 75 of file bleInterface.cpp.

References bleuart.

◆ sendData()

void BleInterface::sendData ( const char *  buf,
int  len 
)

Transmit a string via BLE

Parameters
bufString / Data
lenLength

Definition at line 119 of file bleInterface.cpp.

References bleuart.

Referenced by PtvBleInterface::sendChunked().

◆ shutdown()

void BleInterface::shutdown ( void  )

Stop BLE advertising and force disconnect

Definition at line 95 of file bleInterface.cpp.

Referenced by disable(), and suspend().

◆ startAdv()

void BleInterface::startAdv ( void  )

Setup and start BLE advertising

Definition at line 127 of file bleInterface.cpp.

References bleuart.

Referenced by enable().

Member Data Documentation

◆ bleuart

FsUart BleInterface::bleuart
protected

Customized UART service.

Definition at line 57 of file bleInterface.h.

Referenced by init(), PtvBleInterface::poll(), poll(), sendData(), and startAdv().

◆ MtuSize

const int BleInterface::MtuSize = BLE_ATT_LEN + 3
static

BLE MTU size.

NOTE: The connection interval must be rather short for constant data flow anyway, so there is no benefit in using a larger MTU size for the messages we send.

Definition at line 53 of file bleInterface.h.

Referenced by cbConnect(), and init().


The documentation for this class was generated from the following files: