use UART Service to loopback anything received on the TX characteristic onto the RX.
Dependencies: BLE_API mbed nRF51822
Diff: main.cpp
- Revision:
- 12:33153cf38631
- Parent:
- 10:633cec718bf4
- Child:
- 13:15764cc1f12c
--- a/main.cpp Tue Dec 09 08:55:59 2014 +0000 +++ b/main.cpp Mon Aug 24 12:34:53 2015 +0000 @@ -15,9 +15,9 @@ */ #include "mbed.h" -#include "BLEDevice.h" +#include "ble/BLE.h" -#include "UARTService.h" +#include "ble/services/UARTService.h" #define NEED_CONSOLE_OUTPUT 0 /* Set this if you need debug messages on the console; * it will have an impact on code-size and power consumption. */ @@ -40,9 +40,9 @@ ble.startAdvertising(); } -void onDataWritten(const GattCharacteristicWriteCBParams *params) +void onDataWritten(const GattWriteCallbackParams *params) { - if ((uartServicePtr != NULL) && (params->charHandle == uartServicePtr->getTXCharacteristicHandle())) { + if ((uartServicePtr != NULL) && (params->handle == uartServicePtr->getTXCharacteristicHandle())) { uint16_t bytesRead = params->len; DEBUG("received %u bytes\n\r", bytesRead); ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), params->data, bytesRead); @@ -73,7 +73,7 @@ ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, (const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed)); - ble.setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000)); + ble.setAdvertisingInterval(1000); /* 1000ms; in multiples of 0.625ms. */ ble.startAdvertising(); UARTService uartService(ble);