/* mbed Microcontroller Library * Copyright (c) 2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "ble/GattServer.h" namespace ble { namespace interface { template GattServer::GattServer() : serviceCount(0), characteristicCount(0), eventHandler(NULL), dataSentCallChain(), dataWrittenCallChain(), dataReadCallChain(), updatesEnabledCallback(NULL), updatesDisabledCallback(NULL), confirmationReceivedCallback(NULL) { } template ble_error_t GattServer::addService(GattService &service) { return impl()->addService_(service); } template ble_error_t GattServer::read( GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP ) { return impl()->read_(attributeHandle, buffer, lengthP); } template ble_error_t GattServer::read( ble::connection_handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP ) { return impl()->read_(connectionHandle, attributeHandle, buffer, lengthP); } template ble_error_t GattServer::write( GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly ) { return impl()->write_(attributeHandle, value, size, localOnly); } template ble_error_t GattServer::write( ble::connection_handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly ) { return impl()->write_( connectionHandle, attributeHandle, value, size, localOnly ); } template ble_error_t GattServer::areUpdatesEnabled( const GattCharacteristic &characteristic, bool *enabledP ) { return impl()->areUpdatesEnabled_(characteristic, enabledP); } template ble_error_t GattServer::areUpdatesEnabled( ble::connection_handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP ) { return impl()->areUpdatesEnabled_(connectionHandle, characteristic, enabledP); } template bool GattServer::isOnDataReadAvailable() const { return impl()->isOnDataReadAvailable_(); } template ble_error_t GattServer::reset(void) { return impl()->reset_(); } template ble_error_t GattServer::reset_(void) { /* Notify that the instance is about to shutdown */ shutdownCallChain.call(this); shutdownCallChain.clear(); serviceCount = 0; characteristicCount = 0; dataSentCallChain.clear(); dataWrittenCallChain.clear(); dataReadCallChain.clear(); updatesEnabledCallback = NULL; updatesDisabledCallback = NULL; confirmationReceivedCallback = NULL; return BLE_ERROR_NONE; } /* -------------------------- Dummy implementation -------------------------- */ template ble_error_t GattServer::addService_(GattService &service) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t GattServer::read_( GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t GattServer::read_( ble::connection_handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t GattServer::write_( GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t GattServer::write_( ble::connection_handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t *value, uint16_t size, bool localOnly ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t GattServer::areUpdatesEnabled_( const GattCharacteristic &characteristic, bool *enabledP ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t GattServer::areUpdatesEnabled_( ble::connection_handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP ) { return BLE_ERROR_NOT_IMPLEMENTED; } template bool GattServer::isOnDataReadAvailable_() const { return BLE_ERROR_NOT_IMPLEMENTED; } } // interface } // ble