Abraham Marsen / Mbed 2 deprecated Jazz_Hands_Nordic

Dependencies:   mbed

Committer:
Grimmkey
Date:
Thu Apr 30 20:46:27 2015 +0000
Revision:
0:b8221deeaa87
Georgia Institute of Technology ECE 4180 Spring 2015 Jazz Hands project, Nordic nRF51822 half

Who changed what in which revision?

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