Example program for mbed Cloud Bluetooth Devicelink

Dependencies:   ChainableLED

Committer:
Jan Jongboom
Date:
Mon May 01 14:04:51 2017 +0200
Revision:
0:cfbdc6a35374
Initial commit

Who changed what in which revision?

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