new version for central test two peripherals

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_Nano_Central_Type3 by Francesco Pavoni

Revision:
1:2f1203d70643
Parent:
0:83b5c6efd8d7
Child:
2:4b53d13d9851
diff -r 83b5c6efd8d7 -r 2f1203d70643 main.cpp
--- a/main.cpp	Sat Nov 21 11:13:58 2015 +0000
+++ b/main.cpp	Sun Nov 22 10:28:59 2015 +0000
@@ -4,6 +4,7 @@
 #include "ble/DiscoveredService.h"
 
 BLE ble;
+Serial pc(USBTX, USBRX);
 
 const uint8_t MPU6050_service_uuid[] = {
     0x45,0x35,0x56,0x80,0x0F,0xD8,0x5F,0xB5,0x51,0x48,0x30,0x27,0x06,0x9B,0x3F,0xD9
@@ -19,7 +20,7 @@
 
 
 void scanCallback(const Gap::AdvertisementCallbackParams_t *params) {
-    printf("adv peerAddr[%02x %02x %02x %02x %02x %02x] rssi %d, isScanResponse %u, AdvertisementType %u\r\n",
+    pc.printf("adv peerAddr[%02x %02x %02x %02x %02x %02x] rssi %d, isScanResponse %u, AdvertisementType %u\r\n",
            params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0],
            params->rssi, params->isScanResponse, params->type);
     
@@ -28,38 +29,39 @@
 }
 
 void serviceDiscoveryCallback(const DiscoveredService *service) {
-    printf("service found...\r\n");    
+    pc.printf("service found...\r\n");    
 }
 
 void characteristicDiscoveryCallback(const DiscoveredCharacteristic *characteristicP) {
-    printf("characteristicDiscoveryCallback\r\n");
+    pc.printf("characteristicDiscoveryCallback\r\n");
     ble.gattClient().read(characteristicP->getConnHandle(), characteristicP->getValueHandle(), 0);
 }
 
 void connectionCallback(const Gap::ConnectionCallbackParams_t *params) {
-    printf("GAP_EVT_CONNECTED");
+    pc.printf("GAP_EVT_CONNECTED");
     ble.gattClient().launchServiceDiscovery(params->handle, serviceDiscoveryCallback, characteristicDiscoveryCallback, serviceUUID, accelUUID);
 }
 
 void discoveryTerminationCallback(Gap::Handle_t connectionHandle) {
-    printf("terminated SD for handle %u\r\n", connectionHandle);
+    pc.printf("terminated SD for handle %u\r\n", connectionHandle);
 }
 
 void triggerRead(const GattReadCallbackParams *response) {
     printf("triggerRead.....");
     for(int i=0; i < response->len; i++){
-        printf("data %x", response->data[i]);  
+        pc.printf("data %x", response->data[i]);  
     }
-    printf("\r\n");
+    pc.printf("\r\n");
 }
 
 void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params){//(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) {
-    printf("disconnected\r\n");
+    pc.printf("disconnected\r\n");
 }
 
 int main(void) {
+    pc.baud(9600);
     wait(8.0);
-    printf("start\r\n");
+    pc.printf("start\r\n");
 
     ble.init();
     ble.onConnection(connectionCallback);