Minor temporary patch to allow DFU packet callback

Fork of BLE_API by Bluetooth Low Energy

Committer:
bogdanm
Date:
Tue Apr 01 11:04:56 2014 +0100
Revision:
31:2c94f0501807
Parent:
30:9614522cf932
Child:
34:da2ea8cd6216
Synchronized with git revision fdcc1e387426ce216bc17175b73bcd5f4aececff

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 29:011e95ce78b8 1 /* mbed Microcontroller Library
ktownsend 29:011e95ce78b8 2 * Copyright (c) 2006-2013 ARM Limited
ktownsend 29:011e95ce78b8 3 *
ktownsend 29:011e95ce78b8 4 * Licensed under the Apache License, Version 2.0 (the "License");
ktownsend 29:011e95ce78b8 5 * you may not use this file except in compliance with the License.
ktownsend 29:011e95ce78b8 6 * You may obtain a copy of the License at
ktownsend 29:011e95ce78b8 7 *
ktownsend 29:011e95ce78b8 8 * http://www.apache.org/licenses/LICENSE-2.0
ktownsend 29:011e95ce78b8 9 *
ktownsend 29:011e95ce78b8 10 * Unless required by applicable law or agreed to in writing, software
ktownsend 29:011e95ce78b8 11 * distributed under the License is distributed on an "AS IS" BASIS,
ktownsend 29:011e95ce78b8 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ktownsend 29:011e95ce78b8 13 * See the License for the specific language governing permissions and
ktownsend 29:011e95ce78b8 14 * limitations under the License.
ktownsend 29:011e95ce78b8 15 */
ktownsend 29:011e95ce78b8 16
ktownsend 29:011e95ce78b8 17 #ifndef __GATT_SERVER_H__
ktownsend 29:011e95ce78b8 18 #define __GATT_SERVER_H__
ktownsend 29:011e95ce78b8 19
bogdanm 31:2c94f0501807 20 #include "mbed.h"
ktownsend 29:011e95ce78b8 21 #include "blecommon.h"
ktownsend 29:011e95ce78b8 22 #include "GattService.h"
bogdanm 31:2c94f0501807 23 #include "GattServerEvents.h"
ktownsend 29:011e95ce78b8 24
ktownsend 29:011e95ce78b8 25 /**************************************************************************/
ktownsend 29:011e95ce78b8 26 /*!
ktownsend 29:011e95ce78b8 27 \brief
ktownsend 29:011e95ce78b8 28 The base class used to abstract GATT Server functionality to a specific
ktownsend 29:011e95ce78b8 29 radio transceiver, SOC or BLE Stack.
ktownsend 29:011e95ce78b8 30 */
ktownsend 29:011e95ce78b8 31 /**************************************************************************/
ktownsend 29:011e95ce78b8 32 class GattServer
ktownsend 29:011e95ce78b8 33 {
bogdanm 31:2c94f0501807 34 private:
bogdanm 31:2c94f0501807 35 GattServerEvents *m_pEventHandler;
ktownsend 29:011e95ce78b8 36
ktownsend 29:011e95ce78b8 37 public:
ktownsend 29:011e95ce78b8 38 /* These functions must be defined in the sub-class */
ktownsend 29:011e95ce78b8 39 virtual ble_error_t addService(GattService &) = 0;
bogdanm 31:2c94f0501807 40 virtual ble_error_t readValue(uint16_t, uint8_t[], uint16_t) = 0;
bogdanm 31:2c94f0501807 41 virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t, bool localOnly = false) = 0;
bogdanm 31:2c94f0501807 42
ktownsend 30:9614522cf932 43 // ToDo: For updateValue, check the CCCD to see if the value we are
ktownsend 30:9614522cf932 44 // updating has the notify or indicate bits sent, and if BOTH are set
ktownsend 30:9614522cf932 45 // be sure to call sd_ble_gatts_hvx() twice with notify then indicate!
ktownsend 30:9614522cf932 46 // Strange use case, but valid and must be covered!
ktownsend 29:011e95ce78b8 47
bogdanm 31:2c94f0501807 48 /* Event callback handlers */
bogdanm 31:2c94f0501807 49 void setEventHandler(GattServerEvents *pEventHandler) {m_pEventHandler = pEventHandler;}
bogdanm 31:2c94f0501807 50 void handleEvent(GattServerEvents::gattEvent_e type, uint16_t charHandle) {
bogdanm 31:2c94f0501807 51 if (NULL == m_pEventHandler)
bogdanm 31:2c94f0501807 52 return;
bogdanm 31:2c94f0501807 53 switch(type) {
bogdanm 31:2c94f0501807 54 case GattServerEvents::GATT_EVENT_DATA_SENT:
bogdanm 31:2c94f0501807 55 m_pEventHandler->onDataSent(charHandle);
bogdanm 31:2c94f0501807 56 break;
bogdanm 31:2c94f0501807 57 case GattServerEvents::GATT_EVENT_DATA_WRITTEN:
bogdanm 31:2c94f0501807 58 m_pEventHandler->onDataWritten(charHandle);
bogdanm 31:2c94f0501807 59 break;
bogdanm 31:2c94f0501807 60 case GattServerEvents::GATT_EVENT_UPDATES_ENABLED:
bogdanm 31:2c94f0501807 61 m_pEventHandler->onUpdatesEnabled(charHandle);
bogdanm 31:2c94f0501807 62 break;
bogdanm 31:2c94f0501807 63 case GattServerEvents::GATT_EVENT_UPDATES_DISABLED:
bogdanm 31:2c94f0501807 64 m_pEventHandler->onUpdatesDisabled(charHandle);
bogdanm 31:2c94f0501807 65 break;
bogdanm 31:2c94f0501807 66 case GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED:
bogdanm 31:2c94f0501807 67 m_pEventHandler->onConfirmationReceived(charHandle);
bogdanm 31:2c94f0501807 68 break;
bogdanm 31:2c94f0501807 69 }
bogdanm 31:2c94f0501807 70 }
bogdanm 31:2c94f0501807 71
ktownsend 29:011e95ce78b8 72 uint8_t serviceCount;
ktownsend 29:011e95ce78b8 73 uint8_t characteristicCount;
ktownsend 29:011e95ce78b8 74 };
ktownsend 29:011e95ce78b8 75
ktownsend 29:011e95ce78b8 76 #endif