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.
main.cpp@0:d099a4338c9a, 2015-02-11 (annotated)
- Committer:
- albertoa
- Date:
- Wed Feb 11 01:34:24 2015 +0000
- Revision:
- 0:d099a4338c9a
test1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| albertoa | 0:d099a4338c9a | 1 | /** |
| albertoa | 0:d099a4338c9a | 2 | * Copyright 2014 Nordic Semiconductor |
| albertoa | 0:d099a4338c9a | 3 | * |
| albertoa | 0:d099a4338c9a | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| albertoa | 0:d099a4338c9a | 5 | * you may not use this file except in compliance with the License. |
| albertoa | 0:d099a4338c9a | 6 | * You may obtain a copy of the License at |
| albertoa | 0:d099a4338c9a | 7 | * |
| albertoa | 0:d099a4338c9a | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| albertoa | 0:d099a4338c9a | 9 | * |
| albertoa | 0:d099a4338c9a | 10 | * Unless required by applicable law or agreed to in writing, software |
| albertoa | 0:d099a4338c9a | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| albertoa | 0:d099a4338c9a | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| albertoa | 0:d099a4338c9a | 13 | * See the License for the specific language governing permissions and |
| albertoa | 0:d099a4338c9a | 14 | * limitations under the License |
| albertoa | 0:d099a4338c9a | 15 | */ |
| albertoa | 0:d099a4338c9a | 16 | |
| albertoa | 0:d099a4338c9a | 17 | #define LOG_LEVEL_INFO |
| albertoa | 0:d099a4338c9a | 18 | #include "Puck.h" |
| albertoa | 0:d099a4338c9a | 19 | |
| albertoa | 0:d099a4338c9a | 20 | Puck* puck = &Puck::getPuck(); |
| albertoa | 0:d099a4338c9a | 21 | |
| albertoa | 0:d099a4338c9a | 22 | // Sample Gatt characteristic and service UUIDs |
| albertoa | 0:d099a4338c9a | 23 | const UUID SAMPLE_GATT_SERVICE = stringToUUID("bftj sample "); |
| albertoa | 0:d099a4338c9a | 24 | const UUID SAMPLE_GATT_CHARACTERISTIC = stringToUUID("bftj sample char"); |
| albertoa | 0:d099a4338c9a | 25 | |
| albertoa | 0:d099a4338c9a | 26 | int main(void) { |
| albertoa | 0:d099a4338c9a | 27 | // Add the Gatt characteristic |
| albertoa | 0:d099a4338c9a | 28 | int characteristicValueLength = 1; |
| albertoa | 0:d099a4338c9a | 29 | puck->addCharacteristic( |
| albertoa | 0:d099a4338c9a | 30 | SAMPLE_GATT_SERVICE, |
| albertoa | 0:d099a4338c9a | 31 | SAMPLE_GATT_CHARACTERISTIC, |
| albertoa | 0:d099a4338c9a | 32 | characteristicValueLength, |
| albertoa | 0:d099a4338c9a | 33 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); |
| albertoa | 0:d099a4338c9a | 34 | |
| albertoa | 0:d099a4338c9a | 35 | // Initialize the puck |
| albertoa | 0:d099a4338c9a | 36 | puck->init(0xFEED); |
| albertoa | 0:d099a4338c9a | 37 | |
| albertoa | 0:d099a4338c9a | 38 | // Set the initial value of the characteristic |
| albertoa | 0:d099a4338c9a | 39 | uint8_t new_value = 42; |
| albertoa | 0:d099a4338c9a | 40 | puck->updateCharacteristicValue(SAMPLE_GATT_CHARACTERISTIC, &new_value, characteristicValueLength); |
| albertoa | 0:d099a4338c9a | 41 | |
| albertoa | 0:d099a4338c9a | 42 | // Let the puck do it's thing |
| albertoa | 0:d099a4338c9a | 43 | while(puck->drive()); |
| albertoa | 0:d099a4338c9a | 44 | } |