Solution for Bluetooth SIG hands-on training course
Dependencies: BLE_API mbed-dev-bin nRF51822-bluetooth-mdw
Fork of microbit-dal-bluetooth-mdw_starter by
inc/bluetooth/MicroBitAnimationService.h
- Committer:
- bluetooth_mdw
- Date:
- 2017-02-06
- Revision:
- 80:74afcabdc9a1
- Parent:
- 79:ab48b2043312
- Child:
- 82:91e085d6ad72
File content as of revision 80:74afcabdc9a1:
#ifndef MICROBIT_ANIMATION_SERVICE_H #define MICROBIT_ANIMATION_SERVICE_H #include "MicroBitConfig.h" #include "Animator.h" #include "ble/BLE.h" // UUIDs for our service and characteristics extern const uint8_t MicroBitAnimationServiceUUID[]; // animation type: indicates the type of animation that should be executed by the microbit : R|W extern const uint8_t MicroBitAnimationServiceAnimationTypeCharacteristicUUID[]; // animation status: indicates whether or not an animation is currently in progress : R|N extern const uint8_t MicroBitAnimationServiceAnimationStatusCharacteristicUUID[]; // animation control: allows various types of control to be exercised (start|stop|faster|slower) : W extern const uint8_t MicroBitAnimationServiceAnimationControlCharacteristicUUID[]; /** * Class definition for a MicroBit BLE Animation Service. */ class MicroBitAnimationService { public: /** * Constructor. * Create a representation of the AnimationService * @param _ble The instance of a BLE device that we're running on. */ MicroBitAnimationService(BLEDevice &_ble); /** * Callback. Invoked when a characteristic is written to */ void onDataWritten(const GattWriteCallbackParams *params); private: // Bluetooth stack we're running on. BLEDevice &ble; // memory for our Animation characteristics. uint8_t animation_type_buffer[1]; uint8_t animation_status_buffer[1]; uint8_t animation_control_buffer[1]; // handles on this service's characterisitics. GattAttribute::Handle_t animationTypeCharacteristicHandle; GattAttribute::Handle_t animationStatusCharacteristicHandle; GattAttribute::Handle_t animationControlCharacteristicHandle; void animationStatusUpdate(MicroBitEvent e); }; #endif