Example Puck (BLE)

Dependencies:   Puck mbed

The example puck will give your smartphone context about its whereabouts, as well as set up a simple Gatt characteristic. You can later set up rules for what should happen at different locations in the smartphone companion application (Puck Central).

Tutorials for the different Pucks (location, cube, IR) and in-depth documentation for the Puck platform is available at the project's GitHub page

Committer:
aleksanb
Date:
Tue Mar 03 23:55:24 2015 +0000
Revision:
3:76ff01e97555
Parent:
0:8d7583961274
Child:
4:552bda03c07a
Update puck lib version

Who changed what in which revision?

UserRevisionLine numberNew 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 3:76ff01e97555 42 // Let the puck do its thing
aleksanb 0:8d7583961274 43 while(puck->drive());
aleksanb 0:8d7583961274 44 }