Updated to latest online libraries (See also mbed Apps: HelloBlue, FOTA4)

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_Default_APP by Yihui Xiong

Committer:
yihui
Date:
Fri Oct 10 03:36:28 2014 +0000
Revision:
1:a607cd9655d7
use NVIC_SystemReset() to run bootloader

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 1:a607cd9655d7 1 /* mbed Microcontroller Library
yihui 1:a607cd9655d7 2 * Copyright (c) 2006-2013 ARM Limited
yihui 1:a607cd9655d7 3 *
yihui 1:a607cd9655d7 4 * Licensed under the Apache License, Version 2.0 (the "License");
yihui 1:a607cd9655d7 5 * you may not use this file except in compliance with the License.
yihui 1:a607cd9655d7 6 * You may obtain a copy of the License at
yihui 1:a607cd9655d7 7 *
yihui 1:a607cd9655d7 8 * http://www.apache.org/licenses/LICENSE-2.0
yihui 1:a607cd9655d7 9 *
yihui 1:a607cd9655d7 10 * Unless required by applicable law or agreed to in writing, software
yihui 1:a607cd9655d7 11 * distributed under the License is distributed on an "AS IS" BASIS,
yihui 1:a607cd9655d7 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
yihui 1:a607cd9655d7 13 * See the License for the specific language governing permissions and
yihui 1:a607cd9655d7 14 * limitations under the License.
yihui 1:a607cd9655d7 15 */
yihui 1:a607cd9655d7 16
yihui 1:a607cd9655d7 17 #ifndef __NRF51822_GATT_SERVER_H__
yihui 1:a607cd9655d7 18 #define __NRF51822_GATT_SERVER_H__
yihui 1:a607cd9655d7 19
yihui 1:a607cd9655d7 20 #include "mbed.h"
yihui 1:a607cd9655d7 21 #include "blecommon.h"
yihui 1:a607cd9655d7 22 #include "ble.h" /* nordic ble */
yihui 1:a607cd9655d7 23 #include "GattService.h"
yihui 1:a607cd9655d7 24 #include "public/GattServer.h"
yihui 1:a607cd9655d7 25
yihui 1:a607cd9655d7 26 #define BLE_TOTAL_CHARACTERISTICS 24
yihui 1:a607cd9655d7 27 #define BLE_TOTAL_DESCRIPTORS 24
yihui 1:a607cd9655d7 28
yihui 1:a607cd9655d7 29 class nRF51GattServer : public GattServer
yihui 1:a607cd9655d7 30 {
yihui 1:a607cd9655d7 31 public:
yihui 1:a607cd9655d7 32 static nRF51GattServer &getInstance() {
yihui 1:a607cd9655d7 33 static nRF51GattServer m_instance;
yihui 1:a607cd9655d7 34 return m_instance;
yihui 1:a607cd9655d7 35 }
yihui 1:a607cd9655d7 36
yihui 1:a607cd9655d7 37 /* Functions that must be implemented from GattServer */
yihui 1:a607cd9655d7 38 virtual ble_error_t addService(GattService &);
yihui 1:a607cd9655d7 39 virtual ble_error_t readValue(uint16_t handle, uint8_t buffer[], uint16_t *const lengthP);
yihui 1:a607cd9655d7 40 virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t, bool localOnly = false);
yihui 1:a607cd9655d7 41
yihui 1:a607cd9655d7 42 /* nRF51 Functions */
yihui 1:a607cd9655d7 43 void eventCallback(void);
yihui 1:a607cd9655d7 44 void hwCallback(ble_evt_t *p_ble_evt);
yihui 1:a607cd9655d7 45
yihui 1:a607cd9655d7 46 private:
yihui 1:a607cd9655d7 47 GattCharacteristic *p_characteristics[BLE_TOTAL_CHARACTERISTICS];
yihui 1:a607cd9655d7 48 ble_gatts_char_handles_t nrfCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS];
yihui 1:a607cd9655d7 49 GattAttribute *p_descriptors[BLE_TOTAL_DESCRIPTORS];
yihui 1:a607cd9655d7 50 uint16_t nrfDescriptorHandles[BLE_TOTAL_DESCRIPTORS];
yihui 1:a607cd9655d7 51
yihui 1:a607cd9655d7 52 nRF51GattServer() {
yihui 1:a607cd9655d7 53 serviceCount = 0;
yihui 1:a607cd9655d7 54 characteristicCount = 0;
yihui 1:a607cd9655d7 55 descriptorCount = 0;
yihui 1:a607cd9655d7 56 };
yihui 1:a607cd9655d7 57
yihui 1:a607cd9655d7 58 nRF51GattServer(nRF51GattServer const &);
yihui 1:a607cd9655d7 59 void operator=(nRF51GattServer const &);
yihui 1:a607cd9655d7 60 };
yihui 1:a607cd9655d7 61
yihui 1:a607cd9655d7 62 #endif