Pull request for i.a. sensor buffer template

Dependencies:   BLE_API MPU6050 mbed nRF51822

Revision:
1:b529e733ab71
Parent:
0:7c12d0922052
Child:
2:bf1a19d489eb
--- a/main.cpp	Tue Jan 23 09:04:55 2018 +0000
+++ b/main.cpp	Fri Sep 14 19:47:25 2018 +0000
@@ -167,13 +167,29 @@
     ble.init();
     ble.gap().onDisconnection(disconnectionCallback);
     ble.gap().onConnection(connectionCallback);
-
-
+    
+    uint8_t name[] = "iot aabbccddeeff";
+    
+    Gap::AddressType_t addr_type;
+    Gap::Address_t address;
+    ble_error_t error = ble.gap().getAddress(&addr_type, address);
+    if (error == BLE_ERROR_NONE) {
+        for (int i = 5; i >= 0; i--){
+            //sprintf(name[4 + ((5-i)*2)], "%02x", (uint8_t)address[i]);
+            //sprintf(buffer, "%02x", address[i]);
+            char buffer[3];
+            sprintf(buffer, "%02x", address[i]);
+            name[4 + ((5-i)*2)] = buffer[0];
+            name[4 + ((5-i)*2) + 1] = buffer[1];
+        }
+    }
+    LOG("name = %s\n", name);
+    
     /* setup advertising */
     ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
     ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
     ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
-                                     (const uint8_t *)"smurfs", sizeof("smurfs"));
+                                     name, sizeof(name));
     ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,
                                      (const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));
     DFUService dfu(ble);