this is program how build nRF51822 to get ADXL345 data

Dependencies:   BLE_API mbed nRF51822

Fork of ADXL345_I2C by Peter Swanson

Files at this revision

API Documentation at this revision

Comitter:
asyrofi
Date:
Thu Dec 07 10:21:05 2017 +0000
Parent:
8:a682144e97a8
Child:
10:e5ee9515f4a2
Commit message:
awesome one

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Dec 07 06:08:01 2017 +0000
+++ b/main.cpp	Thu Dec 07 10:21:05 2017 +0000
@@ -189,7 +189,18 @@
              
     
         }
-       */  
+       */
+       
+       char buffer [20];
+       
+       // Test Daata
+       memset(&buffer, 0, sizeof(buffer));
+       int16_t reading_1 = 54;
+       int16_t reading_2 = 42;
+       int16_t reading_3 = 32;
+       
+       snprintf(buffer,20,"data: %d, %d, %d\n", reading_1, reading_2, reading_3);
+         
          
     led1 = 1;
     uart1.baud(9600);
@@ -224,10 +235,11 @@
          wait(0.1);
          accelerometer.getOutput(readings);
          uart1.printf("%i, %i, %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]);
-         ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)readings[0]/*params->data*/, sizeof(readings),false/*bytesRead*/);
-         ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)readings[1]/*params->data*/, sizeof(readings),false/*bytesRead*/);
-         ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)readings[2]/*params->data*/, sizeof(readings),false/*bytesRead*/);         
+     
+         memset(&buffer, 0, sizeof(buffer));
+         snprintf(buffer, 20, "data: %d, %d, %d\n", (int16_t)readings[0],(int16_t)readings[1], (int16_t)readings[2]);
          
+         ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)buffer, sizeof(buffer), false);
     }
  
  }