Test code for a generic nrf51822

Dependencies:   mbed AES BLE_API nRF51822 smallAES

Committer:
f3d
Date:
Tue Feb 18 11:41:19 2020 +0000
Revision:
0:df3f7838f957
Generic NRF51822 example

Who changed what in which revision?

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