Protortype

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_LED by Praktyki

Committer:
Gulio
Date:
Mon Mar 07 11:23:36 2016 +0000
Revision:
0:56899988652b
ghj

Who changed what in which revision?

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