LIS3DH & BLE broadcast example for VTT Node V3 & mbed

Dependencies:   BLE_API TMP_nrf51 mbed nRF51822

Committer:
jejuho
Date:
Mon Jan 25 13:27:15 2016 +0000
Revision:
1:bd7fd35251ab
Parent:
0:de3e4a57ebe0
Initial version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jejuho 0:de3e4a57ebe0 1 /* mbed Microcontroller Library
jejuho 0:de3e4a57ebe0 2 * Copyright (c) 2006-2013 ARM Limited
jejuho 0:de3e4a57ebe0 3 *
jejuho 0:de3e4a57ebe0 4 * Licensed under the Apache License, Version 2.0 (the "License");
jejuho 0:de3e4a57ebe0 5 * you may not use this file except in compliance with the License.
jejuho 0:de3e4a57ebe0 6 * You may obtain a copy of the License at
jejuho 0:de3e4a57ebe0 7 *
jejuho 0:de3e4a57ebe0 8 * http://www.apache.org/licenses/LICENSE-2.0
jejuho 0:de3e4a57ebe0 9 *
jejuho 0:de3e4a57ebe0 10 * Unless required by applicable law or agreed to in writing, software
jejuho 0:de3e4a57ebe0 11 * distributed under the License is distributed on an "AS IS" BASIS,
jejuho 0:de3e4a57ebe0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jejuho 0:de3e4a57ebe0 13 * See the License for the specific language governing permissions and
jejuho 0:de3e4a57ebe0 14 * limitations under the License.
jejuho 0:de3e4a57ebe0 15 */
jejuho 0:de3e4a57ebe0 16
jejuho 0:de3e4a57ebe0 17 #ifndef __BLE_LED_SERVICE_H__
jejuho 0:de3e4a57ebe0 18 #define __BLE_LED_SERVICE_H__
jejuho 0:de3e4a57ebe0 19
jejuho 0:de3e4a57ebe0 20 class LEDService {
jejuho 0:de3e4a57ebe0 21 public:
jejuho 0:de3e4a57ebe0 22 const static uint16_t LED_SERVICE_UUID = 0xA000;
jejuho 0:de3e4a57ebe0 23 const static uint16_t LED_STATE_CHARACTERISTIC_UUID = 0xA001;
jejuho 0:de3e4a57ebe0 24
jejuho 0:de3e4a57ebe0 25 LEDService(BLEDevice &_ble, bool initialValueForLEDCharacteristic) :
jejuho 0:de3e4a57ebe0 26 ble(_ble), ledState(LED_STATE_CHARACTERISTIC_UUID, &initialValueForLEDCharacteristic)
jejuho 0:de3e4a57ebe0 27 {
jejuho 0:de3e4a57ebe0 28 GattCharacteristic *charTable[] = {&ledState};
jejuho 0:de3e4a57ebe0 29 GattService ledService(LED_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
jejuho 0:de3e4a57ebe0 30 ble.addService(ledService);
jejuho 0:de3e4a57ebe0 31 }
jejuho 0:de3e4a57ebe0 32
jejuho 0:de3e4a57ebe0 33 GattAttribute::Handle_t getValueHandle() const {
jejuho 0:de3e4a57ebe0 34 return ledState.getValueHandle();
jejuho 0:de3e4a57ebe0 35 }
jejuho 0:de3e4a57ebe0 36
jejuho 0:de3e4a57ebe0 37 private:
jejuho 0:de3e4a57ebe0 38 BLEDevice &ble;
jejuho 0:de3e4a57ebe0 39 ReadWriteGattCharacteristic<bool> ledState;
jejuho 0:de3e4a57ebe0 40 };
jejuho 0:de3e4a57ebe0 41
jejuho 0:de3e4a57ebe0 42 #endif /* #ifndef __BLE_LED_SERVICE_H__ */