adaptation for book and plug demo
Fork of BLE_API by
UARTService Class Reference
BLE Service to enable UART over BLE. More...
#include <UARTService.h>
Public Member Functions | |
UARTService (BLE &_ble) | |
uint16_t | getTXCharacteristicHandle () |
Note: TX and RX characteristics are to be interpreted from the viewpoint of the GATT client using this service. | |
uint16_t | getRXCharacteristicHandle () |
Note: TX and RX characteristics are to be interpreted from the viewpoint of the GATT client using this service. | |
size_t | write (const void *_buffer, size_t length) |
We attempt to collect bytes before pushing them to the UART RX characteristic; writing to the RX characteristic then generates notifications for the client. | |
size_t | writeString (const char *str) |
Helper function to write out strings. | |
int | _putc (int c) |
Override for Stream::_putc(). | |
int | _getc () |
Override for Stream::_getc(). | |
void | onDataWritten (const GattWriteCallbackParams *params) |
This callback allows the UART service to receive updates to the txCharacteristic. | |
Data Fields | |
uint8_t | receiveBuffer [BLE_UART_SERVICE_MAX_DATA_LEN] |
The local buffer into which we receive inbound data before forwarding it to the application. | |
uint8_t | sendBuffer [BLE_UART_SERVICE_MAX_DATA_LEN] |
The local buffer into which outbound data is accumulated before being pushed to the rxCharacteristic. | |
GattCharacteristic | txCharacteristic |
From the point of view of the external client, this is the characteristic they'd write into in order to communicate with this application. | |
GattCharacteristic | rxCharacteristic |
From the point of view of the external client, this is the characteristic they'd read from in order to receive the bytes transmitted by this application. | |
Static Public Attributes | |
static const unsigned | BLE_UART_SERVICE_MAX_DATA_LEN = (BLE_GATT_MTU_SIZE_DEFAULT - 3) |
< Maximum length of data (in bytes) that the UART service module can transmit to the peer. |
Detailed Description
BLE Service to enable UART over BLE.
Definition at line 46 of file UARTService.h.
Constructor & Destructor Documentation
UARTService | ( | BLE & | _ble ) |
- Parameters:
-
ref] ble BLE object for the underlying controller.
Definition at line 57 of file UARTService.h.
Member Function Documentation
int _getc | ( | ) |
Override for Stream::_getc().
- Returns:
- The character read.
Definition at line 159 of file UARTService.h.
int _putc | ( | int | c ) |
Override for Stream::_putc().
- Parameters:
-
c This function writes the character c, cast to an unsigned char, to stream.
- Returns:
- The character written as an unsigned char cast to an int or EOF on error.
Definition at line 150 of file UARTService.h.
uint16_t getRXCharacteristicHandle | ( | ) |
Note: TX and RX characteristics are to be interpreted from the viewpoint of the GATT client using this service.
Definition at line 84 of file UARTService.h.
uint16_t getTXCharacteristicHandle | ( | ) |
Note: TX and RX characteristics are to be interpreted from the viewpoint of the GATT client using this service.
Definition at line 77 of file UARTService.h.
void onDataWritten | ( | const GattWriteCallbackParams * | params ) |
This callback allows the UART service to receive updates to the txCharacteristic.
The application should forward the call to this function from the global onDataWritten() callback handler; if that's not used, this method can be used as a callback directly.
Definition at line 176 of file UARTService.h.
size_t write | ( | const void * | _buffer, |
size_t | length | ||
) |
We attempt to collect bytes before pushing them to the UART RX characteristic; writing to the RX characteristic then generates notifications for the client.
Updates made in quick succession to a notification-generating characteristic result in data being buffered in the Bluetooth stack as notifications are sent out. The stack has its limits for this buffering - typically a small number under 10. Collecting data into the sendBuffer buffer helps mitigate the rate of updates. But we shouldn't buffer a large amount of data before updating the characteristic, otherwise the client needs to turn around and make a long read request; this is because notifications include only the first 20 bytes of the updated data.
- Parameters:
-
buffer The received update. length Number of characters to be appended.
- Returns:
- Number of characters appended to the rxCharacteristic.
Definition at line 105 of file UARTService.h.
size_t writeString | ( | const char * | str ) |
Helper function to write out strings.
- Parameters:
-
str The received string.
- Returns:
- Number of characters appended to the rxCharacteristic.
Definition at line 139 of file UARTService.h.
Field Documentation
const unsigned BLE_UART_SERVICE_MAX_DATA_LEN = (BLE_GATT_MTU_SIZE_DEFAULT - 3) [static] |
< Maximum length of data (in bytes) that the UART service module can transmit to the peer.
Definition at line 49 of file UARTService.h.
The local buffer into which we receive inbound data before forwarding it to the application.
Definition at line 194 of file UARTService.h.
GattCharacteristic rxCharacteristic |
From the point of view of the external client, this is the characteristic they'd read from in order to receive the bytes transmitted by this application.
Definition at line 207 of file UARTService.h.
uint8_t sendBuffer[BLE_UART_SERVICE_MAX_DATA_LEN] |
The local buffer into which outbound data is accumulated before being pushed to the rxCharacteristic.
Definition at line 198 of file UARTService.h.
GattCharacteristic txCharacteristic |
From the point of view of the external client, this is the characteristic they'd write into in order to communicate with this application.
Definition at line 205 of file UARTService.h.
Generated on Wed Jul 13 2022 09:31:10 by 1.7.2