Solution for Bluetooth SIG hands-on training course

Dependencies:   BLE_API mbed-dev-bin nRF51822-bluetooth-mdw

Dependents:   microbit

Fork of microbit-dal-bluetooth-mdw_starter by Martin Woolley

Committer:
bluetooth_mdw
Date:
Mon Feb 06 09:41:10 2017 +0000
Revision:
80:74afcabdc9a1
Parent:
79:ab48b2043312
Child:
82:91e085d6ad72
Button B displays name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bluetooth_mdw 74:9771cd712730 1 #ifndef MICROBIT_ANIMATION_SERVICE_H
bluetooth_mdw 74:9771cd712730 2 #define MICROBIT_ANIMATION_SERVICE_H
bluetooth_mdw 74:9771cd712730 3
bluetooth_mdw 74:9771cd712730 4 #include "MicroBitConfig.h"
bluetooth_mdw 74:9771cd712730 5 #include "Animator.h"
bluetooth_mdw 74:9771cd712730 6 #include "ble/BLE.h"
bluetooth_mdw 74:9771cd712730 7
bluetooth_mdw 79:ab48b2043312 8 // UUIDs for our service and characteristics
bluetooth_mdw 79:ab48b2043312 9 extern const uint8_t MicroBitAnimationServiceUUID[];
bluetooth_mdw 79:ab48b2043312 10 // animation type: indicates the type of animation that should be executed by the microbit : R|W
bluetooth_mdw 79:ab48b2043312 11 extern const uint8_t MicroBitAnimationServiceAnimationTypeCharacteristicUUID[];
bluetooth_mdw 79:ab48b2043312 12 // animation status: indicates whether or not an animation is currently in progress : R|N
bluetooth_mdw 79:ab48b2043312 13 extern const uint8_t MicroBitAnimationServiceAnimationStatusCharacteristicUUID[];
bluetooth_mdw 79:ab48b2043312 14 // animation control: allows various types of control to be exercised (start|stop|faster|slower) : W
bluetooth_mdw 79:ab48b2043312 15 extern const uint8_t MicroBitAnimationServiceAnimationControlCharacteristicUUID[];
bluetooth_mdw 74:9771cd712730 16
bluetooth_mdw 74:9771cd712730 17 /**
bluetooth_mdw 74:9771cd712730 18 * Class definition for a MicroBit BLE Animation Service.
bluetooth_mdw 74:9771cd712730 19 */
bluetooth_mdw 74:9771cd712730 20 class MicroBitAnimationService
bluetooth_mdw 74:9771cd712730 21 {
bluetooth_mdw 74:9771cd712730 22 public:
bluetooth_mdw 74:9771cd712730 23
bluetooth_mdw 74:9771cd712730 24 /**
bluetooth_mdw 74:9771cd712730 25 * Constructor.
bluetooth_mdw 74:9771cd712730 26 * Create a representation of the AnimationService
bluetooth_mdw 74:9771cd712730 27 * @param _ble The instance of a BLE device that we're running on.
bluetooth_mdw 74:9771cd712730 28 */
bluetooth_mdw 74:9771cd712730 29 MicroBitAnimationService(BLEDevice &_ble);
bluetooth_mdw 74:9771cd712730 30
bluetooth_mdw 74:9771cd712730 31 /**
bluetooth_mdw 74:9771cd712730 32 * Callback. Invoked when a characteristic is written to
bluetooth_mdw 74:9771cd712730 33 */
bluetooth_mdw 74:9771cd712730 34 void onDataWritten(const GattWriteCallbackParams *params);
bluetooth_mdw 74:9771cd712730 35
bluetooth_mdw 74:9771cd712730 36 private:
bluetooth_mdw 74:9771cd712730 37
bluetooth_mdw 74:9771cd712730 38 // Bluetooth stack we're running on.
bluetooth_mdw 74:9771cd712730 39 BLEDevice &ble;
bluetooth_mdw 74:9771cd712730 40
bluetooth_mdw 80:74afcabdc9a1 41 // memory for our Animation characteristics.
bluetooth_mdw 80:74afcabdc9a1 42 uint8_t animation_type_buffer[1];
bluetooth_mdw 80:74afcabdc9a1 43 uint8_t animation_status_buffer[1];
bluetooth_mdw 80:74afcabdc9a1 44 uint8_t animation_control_buffer[1];
bluetooth_mdw 74:9771cd712730 45
bluetooth_mdw 80:74afcabdc9a1 46 // handles on this service's characterisitics.
bluetooth_mdw 80:74afcabdc9a1 47 GattAttribute::Handle_t animationTypeCharacteristicHandle;
bluetooth_mdw 80:74afcabdc9a1 48 GattAttribute::Handle_t animationStatusCharacteristicHandle;
bluetooth_mdw 80:74afcabdc9a1 49 GattAttribute::Handle_t animationControlCharacteristicHandle;
bluetooth_mdw 74:9771cd712730 50
bluetooth_mdw 74:9771cd712730 51 void animationStatusUpdate(MicroBitEvent e);
bluetooth_mdw 74:9771cd712730 52
bluetooth_mdw 74:9771cd712730 53 };
bluetooth_mdw 74:9771cd712730 54
bluetooth_mdw 80:74afcabdc9a1 55 #endif