Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
DiscoveredCharacteristic.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "ble/DiscoveredCharacteristic.h" 00018 #include "ble/GattClient.h" 00019 00020 ble_error_t 00021 DiscoveredCharacteristic::read(uint16_t offset) const 00022 { 00023 if (!props.read()) { 00024 return BLE_ERROR_OPERATION_NOT_PERMITTED; 00025 } 00026 00027 if (!gattc) { 00028 return BLE_ERROR_INVALID_STATE; 00029 } 00030 00031 return gattc->read(connHandle, valueHandle, offset); 00032 } 00033 00034 ble_error_t 00035 DiscoveredCharacteristic::write(uint16_t length, const uint8_t *value) const 00036 { 00037 if (!props.write()) { 00038 return BLE_ERROR_OPERATION_NOT_PERMITTED; 00039 } 00040 00041 if (!gattc) { 00042 return BLE_ERROR_INVALID_STATE; 00043 } 00044 00045 return gattc->write(GattClient::GATT_OP_WRITE_REQ, connHandle, valueHandle, length, value); 00046 } 00047 00048 ble_error_t 00049 DiscoveredCharacteristic::writeWoResponse(uint16_t length, const uint8_t *value) const 00050 { 00051 if (!props.writeWoResp()) { 00052 return BLE_ERROR_OPERATION_NOT_PERMITTED; 00053 } 00054 00055 if (!gattc) { 00056 return BLE_ERROR_INVALID_STATE; 00057 } 00058 00059 return gattc->write(GattClient::GATT_OP_WRITE_CMD, connHandle, valueHandle, length, value); 00060 } 00061 00062 ble_error_t 00063 DiscoveredCharacteristic::discoverDescriptors(DescriptorCallback_t callback, const UUID &matchingUUID) const 00064 { 00065 return BLE_ERROR_NOT_IMPLEMENTED; /* TODO: this needs to be filled in. */ 00066 }
Generated on Sat Jul 16 2022 17:07:02 by
