Flying Silicon Sensor
|
#include <ptvBleInterface.h>
Classes | |
struct | SensorData |
Sensor data structure. More... | |
Public Member Functions | |
PtvBleInterface () | |
Default c-tor. | |
void | sendMetaMsg (const String &mna, const String &mmo, const String &msn) |
void | sendShortMsg (const SensorData &data) |
void | sendLongMsg (const SensorData &data) |
void | sendChunked (String &msg) |
int | getReceived (String &cmd) |
void | clrReceived () |
Clear anything received so far. | |
![]() | |
void | init (const char *deviceName) |
void | startAdv (void) |
void | sendData (const char *buf, int len) |
void | poll (void) |
void | shutdown (void) |
int | isConnected (void) |
Protected Member Functions | |
void | poll () |
void | clrBuffer () |
Clear internal receive buffer. | |
Protected Attributes | |
String | command |
Holds last received text line / command. | |
char | rcvBuffer [FIFO_SZ] |
Receive data buffer, same size as UART FIFO. | |
unsigned int | pos |
Write position for next byte. | |
![]() | |
FsUart | bleuart |
Customized UART service. | |
Additional Inherited Members | |
![]() | |
static const int | MtuSize = BLE_ATT_LEN + 3 |
BLE MTU size. | |
![]() | |
static void | cbDisconnect (uint16_t conn_handle, uint8_t reason) |
static void | cbConnect (uint16_t conn_handle) |
Interface for communication via BLE UART
Definition at line 31 of file ptvBleInterface.h.
|
inline |
|
inlineprotected |
Clear internal receive buffer.
Definition at line 72 of file ptvBleInterface.h.
References pos, and rcvBuffer.
Referenced by clrReceived(), poll(), and PtvBleInterface().
|
inline |
Clear anything received so far.
Definition at line 65 of file ptvBleInterface.h.
References clrBuffer(), and command.
Referenced by enable().
int PtvBleInterface::getReceived | ( | String & | cmd | ) |
Must be called periodically to check for received commands
cmd |
Definition at line 45 of file ptvBleInterface.cpp.
References command, and poll().
Referenced by loopConnected().
|
protected |
Periodically called to poll BLE connection for received data chunks / commands. Commands / data chunks must be
terminated. Chunk length is limited by buffer size.
Definition at line 62 of file ptvBleInterface.cpp.
References BleInterface::bleuart, clrBuffer(), command, BleInterface::isConnected(), pos, and rcvBuffer.
Referenced by getReceived().
void PtvBleInterface::sendChunked | ( | String & | msg | ) |
Transmit one message as multiple chunks via BLE
msg | String with message ready to send including line end |
Definition at line 99 of file ptvBleInterface.cpp.
References CHUNK_DELAY_MS, CHUNK_SZ, LOGL, and BleInterface::sendData().
Referenced by sendLongMsg(), sendMetaMsg(), and sendShortMsg().
void PtvBleInterface::sendLongMsg | ( | const SensorData & | data | ) |
Send a message using the long PTVSOAR message format
NOTE: For devices with BLE speed limitations this format is not useful
data | sensor data record to be sent |
Definition at line 163 of file ptvBleInterface.cpp.
References PtvBleInterface::SensorData::absHpa, PtvBleInterface::SensorData::batPct, PtvBleInterface::SensorData::batVolt, PtvBleInterface::SensorData::diffPa, PtvBleInterface::SensorData::humPct, PtvBleInterface::SensorData::isCharging, LOGL, SEND_VOLT, sendChunked(), and PtvBleInterface::SensorData::tempC.
Referenced by loopConnected().
void PtvBleInterface::sendMetaMsg | ( | const String & | mna, |
const String & | mmo, | ||
const String & | msn | ||
) |
Send a PTVSOAR meta data message
mna | Manufacturer name |
mmo | Device model |
msn | Sevice serial number |
Definition at line 147 of file ptvBleInterface.cpp.
References sendChunked().
Referenced by loopConnected().
void PtvBleInterface::sendShortMsg | ( | const SensorData & | data | ) |
Send a message using the short PTV format
Length tailored to 2x20 bytes for BLE 4.1 and earlier
data | sensor data record to be sent |
Definition at line 233 of file ptvBleInterface.cpp.
References PtvBleInterface::SensorData::absHpa, PtvBleInterface::SensorData::batPct, PtvBleInterface::SensorData::batVolt, PtvBleInterface::SensorData::diffPa, PtvBleInterface::SensorData::humPct, PtvBleInterface::SensorData::isCharging, SEND_VOLT, sendChunked(), and PtvBleInterface::SensorData::tempC.
Referenced by loopConnected().
|
protected |
Holds last received text line / command.
Definition at line 74 of file ptvBleInterface.h.
Referenced by clrReceived(), getReceived(), and poll().
|
protected |
Write position for next byte.
Definition at line 78 of file ptvBleInterface.h.
Referenced by clrBuffer(), and poll().
|
protected |
Receive data buffer, same size as UART FIFO.
Definition at line 76 of file ptvBleInterface.h.
Referenced by clrBuffer(), and poll().