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
source/drivers/TimedInterruptIn.cpp@82:91e085d6ad72, 2017-03-24 (annotated)
- Committer:
- bluetooth_mdw
- Date:
- Fri Mar 24 06:20:38 2017 +0000
- Revision:
- 82:91e085d6ad72
- Parent:
- 35:8ce23bc1af38
Removed comment re: writing initial values to the Attribute Table. Added comments to onDataWritten. Removed solution details.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LancasterUniversity | 35:8ce23bc1af38 | 1 | /* |
LancasterUniversity | 35:8ce23bc1af38 | 2 | The MIT License (MIT) |
LancasterUniversity | 35:8ce23bc1af38 | 3 | |
LancasterUniversity | 35:8ce23bc1af38 | 4 | Copyright (c) 2016 Lancaster University, UK. |
LancasterUniversity | 35:8ce23bc1af38 | 5 | |
LancasterUniversity | 35:8ce23bc1af38 | 6 | Permission is hereby granted, free of charge, to any person obtaining a |
LancasterUniversity | 35:8ce23bc1af38 | 7 | copy of this software and associated documentation files (the "Software"), |
LancasterUniversity | 35:8ce23bc1af38 | 8 | to deal in the Software without restriction, including without limitation |
LancasterUniversity | 35:8ce23bc1af38 | 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
LancasterUniversity | 35:8ce23bc1af38 | 10 | and/or sell copies of the Software, and to permit persons to whom the |
LancasterUniversity | 35:8ce23bc1af38 | 11 | Software is furnished to do so, subject to the following conditions: |
LancasterUniversity | 35:8ce23bc1af38 | 12 | |
LancasterUniversity | 35:8ce23bc1af38 | 13 | The above copyright notice and this permission notice shall be included in |
LancasterUniversity | 35:8ce23bc1af38 | 14 | all copies or substantial portions of the Software. |
LancasterUniversity | 35:8ce23bc1af38 | 15 | |
LancasterUniversity | 35:8ce23bc1af38 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
LancasterUniversity | 35:8ce23bc1af38 | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
LancasterUniversity | 35:8ce23bc1af38 | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
LancasterUniversity | 35:8ce23bc1af38 | 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
LancasterUniversity | 35:8ce23bc1af38 | 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
LancasterUniversity | 35:8ce23bc1af38 | 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
LancasterUniversity | 35:8ce23bc1af38 | 22 | DEALINGS IN THE SOFTWARE. |
LancasterUniversity | 35:8ce23bc1af38 | 23 | */ |
LancasterUniversity | 35:8ce23bc1af38 | 24 | |
LancasterUniversity | 35:8ce23bc1af38 | 25 | #include "MicroBitConfig.h" |
LancasterUniversity | 35:8ce23bc1af38 | 26 | #include "TimedInterruptIn.h" |
LancasterUniversity | 35:8ce23bc1af38 | 27 | /** |
LancasterUniversity | 35:8ce23bc1af38 | 28 | * Constructor. |
LancasterUniversity | 35:8ce23bc1af38 | 29 | * |
LancasterUniversity | 35:8ce23bc1af38 | 30 | * Create an instance of TimedInterruptIn that has an additional timestamp field. |
LancasterUniversity | 35:8ce23bc1af38 | 31 | */ |
LancasterUniversity | 35:8ce23bc1af38 | 32 | TimedInterruptIn::TimedInterruptIn(PinName name) : InterruptIn(name) |
LancasterUniversity | 35:8ce23bc1af38 | 33 | { |
LancasterUniversity | 35:8ce23bc1af38 | 34 | timestamp = 0; |
LancasterUniversity | 35:8ce23bc1af38 | 35 | } |
LancasterUniversity | 35:8ce23bc1af38 | 36 | |
LancasterUniversity | 35:8ce23bc1af38 | 37 | /** |
LancasterUniversity | 35:8ce23bc1af38 | 38 | * Stores the given timestamp for this instance of TimedInterruptIn. |
LancasterUniversity | 35:8ce23bc1af38 | 39 | * |
LancasterUniversity | 35:8ce23bc1af38 | 40 | * @param timestamp the timestamp to retain. |
LancasterUniversity | 35:8ce23bc1af38 | 41 | */ |
LancasterUniversity | 35:8ce23bc1af38 | 42 | void TimedInterruptIn::setTimestamp(uint64_t timestamp) |
LancasterUniversity | 35:8ce23bc1af38 | 43 | { |
LancasterUniversity | 35:8ce23bc1af38 | 44 | this->timestamp = timestamp; |
LancasterUniversity | 35:8ce23bc1af38 | 45 | } |
LancasterUniversity | 35:8ce23bc1af38 | 46 | |
LancasterUniversity | 35:8ce23bc1af38 | 47 | /** |
LancasterUniversity | 35:8ce23bc1af38 | 48 | * Retrieves the retained timestamp for this instance of TimedInterruptIn. |
LancasterUniversity | 35:8ce23bc1af38 | 49 | * |
LancasterUniversity | 35:8ce23bc1af38 | 50 | * @return the timestamp held by this instance. |
LancasterUniversity | 35:8ce23bc1af38 | 51 | */ |
LancasterUniversity | 35:8ce23bc1af38 | 52 | uint64_t TimedInterruptIn::getTimestamp() |
LancasterUniversity | 35:8ce23bc1af38 | 53 | { |
LancasterUniversity | 35:8ce23bc1af38 | 54 | return timestamp; |
LancasterUniversity | 35:8ce23bc1af38 | 55 | } |