ble-UartService

Fork of mbed-os-example-ble-UartService by Mathias Giacomuzzi

BLE UART Service - USB Serial Relay

Revision:
27:e5e381e33cd2
Parent:
26:dd9d7eaee2f5
--- 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();