Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API BLE_HeartRate mbed nRF51822
Fork of BLE_HeartRate by
Diff: MicroBitAccelerometerService.h
- Revision:
- 77:d0c01a3d966f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MicroBitAccelerometerService.h Mon Nov 30 13:37:37 2015 +0000 @@ -0,0 +1,48 @@ +#ifndef MICROBIT_ACCELEROMETER_SERVICE_H +#define MICROBIT_ACCELEROMETER_SERVICE_H + +extern GattAttribute::Handle_t accelerometerDataCharacteristicHandleGlobal; + +// UUIDs for our service and characteristics +extern const uint8_t MicroBitAccelerometerServiceUUID[]; +extern const uint8_t MicroBitAccelerometerServiceDataUUID[]; +extern const uint8_t MicroBitAccelerometerServicePeriodUUID[]; + + +/** + * Class definition for a MicroBit BLE Accelerometer Service. + * Provides access to live accelerometer data via BLE, and provides basic configuration options. + */ +class MicroBitAccelerometerService +{ + public: + + /** + * Constructor. + * Create a representation of the AccelerometerService + * @param _ble The instance of a BLE device that we're running on. + */ + MicroBitAccelerometerService(BLEDevice &_ble); + + + private: + + /** + * Callback. Invoked when any of our attributes are written via BLE. + */ + void onDataWritten(const GattWriteCallbackParams *params); + + // Bluetooth stack we're running on. + BLEDevice &ble; + + // memory for our 8 bit control characteristics. + uint16_t accelerometerDataCharacteristicBuffer[3]; + uint16_t accelerometerPeriodCharacteristicBuffer; + + // Handles to access each characteristic when they are held by Soft Device. + GattAttribute::Handle_t accelerometerDataCharacteristicHandle; + GattAttribute::Handle_t accelerometerPeriodCharacteristicHandle; +}; + + +#endif