Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os-example-ble-UartService by
Revision 27:e5e381e33cd2, committed 2018-10-19
- Comitter:
- YJKIYOKAWA
- Date:
- Fri Oct 19 09:26:01 2018 +0000
- Parent:
- 26:dd9d7eaee2f5
- Commit message:
- update receive data buffering
Changed in this revision
| source/MyUARTService.h | Show annotated file Show diff for this revision Revisions of this file |
| source/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/MyUARTService.h Wed Oct 17 00:52:50 2018 +0000
+++ b/source/MyUARTService.h Fri Oct 19 09:26:01 2018 +0000
@@ -68,7 +68,7 @@
GattService uartService(UARTServiceUUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
ble.addService(uartService);
- ble.onDataWritten(this, &MyUARTService::onDataWritten);
+ //ble.onDataWritten(this, &MyUARTService::onDataWritten);
}
/**
--- a/source/main.cpp Wed Oct 17 00:52:50 2018 +0000
+++ b/source/main.cpp Fri Oct 19 09:26:01 2018 +0000
@@ -104,11 +104,11 @@
if (params->handle == uartServicePtr->getTXCharacteristicHandle())
{
- int c;
- while ((c = uartServicePtr->_getc()) != EOF)
+ uint16_t bytesRead = params->len;
+ for (int i = 0; i < bytesRead; i++)
{
led2 = 1;
- buf.putc(c);
+ buf.putc(params->data[i]);
}
}
else
@@ -221,7 +221,7 @@
/* Setup advertising. */
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
+ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME) - 1);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, (uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));
@@ -246,7 +246,7 @@
// printf("Start up...\n\r");
buf.clear();
- serial.baud(115200);
+ serial.baud(19200);
while (1){
mainProc();
