BLE GATT-service implementation for high quantity sensor data from a MPU6050-accelerator/gyroscope
Dependencies: BLE_API mbed nRF51822 MPU6050_lib
Diff: MPU6050Service.h
- Revision:
- 12:dc46aa2edccd
- Parent:
- 10:b305e261e7d1
--- a/MPU6050Service.h Tue Sep 08 13:47:25 2015 +0000 +++ b/MPU6050Service.h Tue Sep 22 10:49:59 2015 +0000 @@ -77,18 +77,20 @@ ( BLE &ble, MPU6050 &mpu6050, - PinName interruptPin, + InterruptIn *interruptIn = NULL, const SensorData *initialData = NULL, const MeasuringRange measuringRange = ACCEL_RANGE_2G | GYRO_RANGE_250, const uint32_t masterClock_us = 0 ) : gattServer(ble.gattServer()), mpu(mpu6050), - intIn(interruptPin), + intIn(interruptIn), timer(), _isRunning(false), updateSensorDataCharacteristicTrigger(false), + updateMotionIndicatorCharacteristicTrigger(false), + updateMeasuringRangeTrigger(false), timerOffset_us(masterClock_us), @@ -136,7 +138,8 @@ gattServer.onDataSent(this, &MPU6050Service::dataSentCallback); gattServer.onDataWritten(this, &MPU6050Service::dataWrittenCallback); - intIn.rise(this, &MPU6050Service::interruptRiseCallback); + if (intIn != NULL) + intIn->rise(this, &MPU6050Service::interruptRiseCallback); serviceAdded = true; } @@ -186,11 +189,11 @@ } private: - static const int MAX_SENSOR_POLLS_PER_UPDATE = 15; + static const int MAX_SENSOR_POLLS_PER_UPDATE = 10; GattServer &gattServer; MPU6050 &mpu; - InterruptIn intIn; + InterruptIn *intIn; Timer timer; volatile bool _isRunning;