forked - for export trials ..
Dependencies: BLE_API mbed nRF51822
Fork of BLE_UARTConsole by
Diff: main.cpp
- Revision:
- 9:fa721f82115a
- Parent:
- 8:f9bf6d403cde
diff -r f9bf6d403cde -r fa721f82115a main.cpp --- a/main.cpp Tue Jul 07 06:58:31 2015 +0000 +++ b/main.cpp Tue Aug 18 07:42:10 2015 +0000 @@ -29,8 +29,9 @@ #define DEBUG(...) /* nothing */ #endif /* #if NEED_CONSOLE_OUTPUT */ -BLEDevice ble; -DigitalOut led1(LED1); +Serial pc(USBTX, USBRX); // tx, rx +BLEDevice ble; +DigitalOut led1(LED1); UARTService *uart; void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) @@ -44,12 +45,21 @@ { led1 = !led1; DEBUG("ping\r\n"); + pc.printf("ping\r\n"); } int main(void) { + const char *serviceName = "rob ble"; + led1 = 1; Ticker ticker; + + // usb/serial port initialisation + pc.baud(115200); + pc.printf("Initialising the nRF51822\n\r"); + pc.printf("service %s\n\r", serviceName); + ticker.attach(periodicCallback, 1); DEBUG("Initialising the nRF51822\n\r"); @@ -62,7 +72,7 @@ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, - (const uint8_t *)"BLE UART", sizeof("BLE UART") - 1); + (const uint8_t *)serviceName, strlen(serviceName)); ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, (const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));