Using the MBED BLE library and Nordic Puck library this is a simple scoring application using Bluetooth LE. It monitors three analog inputs and triggers on reception of a pulse on any one recording data for a short period on all three. This is then published via BLE characteristics. It's a demonstrator for a new UI dev toolkit that is under development.
Fork of Example_Puck_BLE by
main.cpp@0:8d7583961274, 2014-08-11 (annotated)
- Committer:
- aleksanb
- Date:
- Mon Aug 11 11:17:56 2014 +0000
- Revision:
- 0:8d7583961274
- Child:
- 1:1a59b4810261
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aleksanb | 0:8d7583961274 | 1 | /** |
aleksanb | 0:8d7583961274 | 2 | * Copyright 2014 Nordic Semiconductor |
aleksanb | 0:8d7583961274 | 3 | * |
aleksanb | 0:8d7583961274 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
aleksanb | 0:8d7583961274 | 5 | * you may not use this file except in compliance with the License. |
aleksanb | 0:8d7583961274 | 6 | * You may obtain a copy of the License at |
aleksanb | 0:8d7583961274 | 7 | * |
aleksanb | 0:8d7583961274 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
aleksanb | 0:8d7583961274 | 9 | * |
aleksanb | 0:8d7583961274 | 10 | * Unless required by applicable law or agreed to in writing, software |
aleksanb | 0:8d7583961274 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
aleksanb | 0:8d7583961274 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
aleksanb | 0:8d7583961274 | 13 | * See the License for the specific language governing permissions and |
aleksanb | 0:8d7583961274 | 14 | * limitations under the License |
aleksanb | 0:8d7583961274 | 15 | */ |
aleksanb | 0:8d7583961274 | 16 | |
aleksanb | 0:8d7583961274 | 17 | #define LOG_LEVEL_INFO |
aleksanb | 0:8d7583961274 | 18 | #include "Puck.h" |
aleksanb | 0:8d7583961274 | 19 | |
aleksanb | 0:8d7583961274 | 20 | Puck* puck = &Puck::getPuck(); |
aleksanb | 0:8d7583961274 | 21 | |
aleksanb | 0:8d7583961274 | 22 | // Sample Gatt characteristic and service UUIDs |
aleksanb | 0:8d7583961274 | 23 | const UUID SAMPLE_GATT_SERVICE = stringToUUID("bftj sample "); |
aleksanb | 0:8d7583961274 | 24 | const UUID SAMPLE_GATT_CHARACTERISTIC = stringToUUID("bftj sample char"); |
aleksanb | 0:8d7583961274 | 25 | |
aleksanb | 0:8d7583961274 | 26 | int main(void) { |
aleksanb | 0:8d7583961274 | 27 | // Add the Gatt characteristic |
aleksanb | 0:8d7583961274 | 28 | int characteristicValueLength = 1; |
aleksanb | 0:8d7583961274 | 29 | puck->addCharacteristic( |
aleksanb | 0:8d7583961274 | 30 | SAMPLE_GATT_SERVICE, |
aleksanb | 0:8d7583961274 | 31 | SAMPLE_GATT_CHARACTERISTIC, |
aleksanb | 0:8d7583961274 | 32 | characteristicValueLength, |
aleksanb | 0:8d7583961274 | 33 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); |
aleksanb | 0:8d7583961274 | 34 | |
aleksanb | 0:8d7583961274 | 35 | // Initialize the puck |
aleksanb | 0:8d7583961274 | 36 | puck->init(0xFEED); |
aleksanb | 0:8d7583961274 | 37 | |
aleksanb | 0:8d7583961274 | 38 | // Set the initial value of the characteristic |
aleksanb | 0:8d7583961274 | 39 | uint8_t new_value = 42; |
aleksanb | 0:8d7583961274 | 40 | puck->updateCharacteristicValue(SAMPLE_GATT_CHARACTERISTIC, &new_value, characteristicValueLength); |
aleksanb | 0:8d7583961274 | 41 | |
aleksanb | 0:8d7583961274 | 42 | // Let the puck do it's thing |
aleksanb | 0:8d7583961274 | 43 | while(puck->drive()); |
aleksanb | 0:8d7583961274 | 44 | } |