     {
       temp = ble_read();
       if ('r' == temp) { // read comand from smartphone)
-//        int length = 4+sizeof(curDistance);
-//        String output = "D:";
-//        output+=curDistance;
-//        output+="\n";
-//        byte length= 8;
-          
-        
-//        char distanceBuf[10];
-//        
-//        ltoa(curDistance,distanceBuf,10);
-//        int length;
-//
-//   for (byte i = 0;i<sizeof(distanceBuf);i++){
-//       if (distanceBuf[i]==NULL) {
-//              length=i+1;
-//              break;
-//            } 
-//         }
-//         char outBuf[length];
-//         for (byte i = 0;i<length;i++){
-//            outBuf[i]=distanceBuf[i];
-//         } 
-//         
-
-
-//         ble_write(length);
-         ble_write('D');
-         ble_write(':');
-//          ble_write_bytes((unsigned char *)outBuf,length);
-          ble_write('\n');
-//          ble_write_bytes();
+          stroller_ble_print();
       } 
       else if ( 'c' == temp ) { // aCcept or commit command from smartphone, later used for resetting
         curDistance=0;
         ble_write('r');
         ble_write('\n');
       }
-      //            temp = ble_read();
-      //            if('o' == temp)
-      //            {
-      //                temp = ble_read();
-      //                if('n' == temp)
-      //                {
-      //
-      //                    ble_write_bytes((unsigned char *)"LED on", 6);
-      //                }
-      //                else if('f' == temp && 'f' == ble_read())
-      //                {
-      //                    ble_write_bytes((unsigned char *)"LED off", 7);
-      //                }
-      //            }
     }
   }
 //  delay(50);

}


volatile int hadRound = 0;
void loop()
{
//      Wire.begin();
////      RTC.begin(); 
      union {
        char data[4];
        long stamp;
      } time;
//        time.stamp = RTC.now().unixtime();
    time.stamp=millis();
//    time.stamp=100L;
      char chrTime[10];
//      ltoa(millis(),chrTime,10);
  if (hadRound== 1) {
    // compare the time of the last logged or the current logged value
    // the actual calculation

      curDistance = curDistance + distance;
//
//      // write to SD card
////
////      // here, we can write the full, readable timestamp:
      dataFile.write(chrTime, 10);
      dataFile.write(';');
      dataFile.write('R');
      dataFile.write('\n');
      dataFile.flush();
//      currentRunFile.seek(0); // always start at the beginning of the file
////      // read the first four bytes of the file, that contain the last written timestamp
////      
//      union{
//        char data[4];
//        long stamp;
//      } lastTime ;
//      //read the last saved timestamp
//       lastTime.data[0]=currentRunFile.read();
//       lastTime.data[1]=currentRunFile.read();
//       lastTime.data[2]=currentRunFile.read();
//       lastTime.data[3]=currentRunFile.read();
//       
//      byte reset= 0;
//      if ((time.stamp-lastTime.stamp)>timeBetweenRounds) {
//        // we have a new file, reset the distance and save to a new file
//
//        char distanceBuf[10];
////        ltoa(curDistance,distanceBuf,10);
//                int length;
//
//   for (byte i = 0;i< sizeof(distanceBuf);i++){
//       if (distanceBuf[i]==NULL) {
//              length=i+1;
//              break;
//            } 
//         }
//         char outBuf[length];
//         for (byte i = 0;i<length;i++){
//            outBuf[i]=distanceBuf[i];
//         } 
//        runs.write(chrTime, 10);
//        runs.write(':');
//        runs.write(outBuf, length);
//        reset=1;
//        currentRunFile.read(); //";"
////        currentRunFile.read();//"Distance" 1
////        currentRunFile.read();//"Distance" 2
////        currentRunFile.read();//"Distance" 3
////        currentRunFile.read();//"Distance" 4
////        currentRunFile.read();//";"
//
//        union{
//          char data[4];
//          long stamp;
//        } startingTime ;
//        
//       startingTime.data[0]=currentRunFile.read();
//       startingTime.data[1]=currentRunFile.read();
//       startingTime.data[2]=currentRunFile.read();
//       startingTime.data[3]=currentRunFile.read();
//        char startingTimeOut[10];
////        ltoa(startingTime.stamp,startingTimeOut,10);
//        runs.write(':');
//        runs.write(startingTimeOut, 10);
//        runs.write('\n');
//        runs.flush();
//        curDistance=distance;
//      } 
//      currentRunFile.seek(0);
//      currentRunFile.write(time.data, 4);
////      currentRunFile.write(':');
////      currentRunFile.write((unsigned char*)&curDistance, 4);      
//      if (reset==1) {
//        currentRunFile.write(':');
//        currentRunFile.write(time.data, 4); // origin time, will not be changed later on
//        currentRunFile.flush();
//      }      
//      
//      
      hadRound=0;

  }
  if (ble_available() )

  attachInterrupt(interupt, BtnDownCB, FALLING );

  // Call the function to enable low power consumption
  #if !DEBUG
    ble_low_power();
  #else 
   Serial.begin(9600);
  #endif

  // If you are using the Blend, uncomment below
  ble_set_pins(6, 7);
