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.
Dependencies: FatFileSystem TB6612FNG2 mbed
Diff: BTstack/att.h
- Revision:
- 0:de03cbbcd0ff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/BTstack/att.h Mon Nov 30 09:32:15 2015 +0000
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2011-2012 by Matthias Ringwald
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * 4. Any redistribution, use, or modification is done solely for
+ * personal benefit and not for any commercial purpose or for
+ * monetary gain.
+ *
+ * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
+ * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Please inquire about commercial licensing options at btstack@ringwald.ch
+ *
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+// MARK: Attribute PDU Opcodes
+#define ATT_ERROR_RESPONSE 0x01
+
+#define ATT_EXCHANGE_MTU_REQUEST 0x02
+#define ATT_EXCHANGE_MTU_RESPONSE 0x03
+
+#define ATT_FIND_INFORMATION_REQUEST 0x04
+#define ATT_FIND_INFORMATION_REPLY 0x05
+#define ATT_FIND_BY_TYPE_VALUE_REQUEST 0x06
+#define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07
+
+#define ATT_READ_BY_TYPE_REQUEST 0x08
+#define ATT_READ_BY_TYPE_RESPONSE 0x09
+#define ATT_READ_REQUEST 0x0a
+#define ATT_READ_RESPONSE 0x0b
+#define ATT_READ_BLOB_REQUEST 0x0c
+#define ATT_READ_BLOB_RESPONSE 0x0d
+#define ATT_READ_MULTIPLE_REQUEST 0x0e
+#define ATT_READ_MULTIPLE_RESPONSE 0x0f
+#define ATT_READ_BY_GROUP_TYPE_REQUEST 0x10
+#define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11
+
+#define ATT_WRITE_REQUEST 0x12
+#define ATT_WRITE_RESPONSE 0x13
+
+#define ATT_PREPARE_WRITE_REQUEST 0x16
+#define ATT_PREPARE_WRITE_RESPONSE 0x17
+#define ATT_EXECUTE_WRITE_REQUEST 0x18
+#define ATT_EXECUTE_WRITE_RESPONSE 0x19
+
+#define ATT_HANDLE_VALUE_NOTIFICATION 0x1b
+#define ATT_HANDLE_VALUE_CONFIRMATION 0x1c
+#define ATT_HANDLE_VALUE_INDICATION 0x1d
+
+
+#define ATT_WRITE_COMMAND 0x52
+#define ATT_SIGNED_WRITE_COMAND 0xD2
+
+// MARK: ATT Error Codes
+#define ATT_ERROR_ATTRIBUTE_INVALID 0x01
+#define ATT_ERROR_INVALID_OFFSET 0x07
+#define ATT_ERROR_ATTRIBUTE_NOT_FOUND 0x0a
+#define ATT_ERROR_UNSUPPORTED_GROUP_TYPE 0x10
+
+// MARK: Attribute Property Flags
+#define ATT_PROPERTY_BROADCAST 0x01
+#define ATT_PROPERTY_READ 0x02
+#define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
+#define ATT_PROPERTY_WRITE 0x08
+#define ATT_PROPERTY_NOTIFY 0x10
+#define ATT_PROPERTY_INDICATE 0x20
+#define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
+#define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
+
+// MARK: Attribute Property Flag, BTstack extension
+// value is asked from client
+#define ATT_PROPERTY_DYNAMIC 0x100
+// 128 bit UUID used
+#define ATT_PROPERTY_UUID128 0x200
+
+// MARK: GATT UUIDs
+#define GATT_PRIMARY_SERVICE_UUID 0x2800
+#define GATT_SECONDARY_SERVICE_UUID 0x2801
+#define GATT_CHARACTERISTICS_UUID 0x2803
+
+#define GAP_SERVICE_UUID 0x1800
+#define GAP_DEVICE_NAME_UUID 0x2a00
+
+#define ATT_TRANSACTION_MODE_NONE 0x0
+#define ATT_TRANSACTION_MODE_ACTIVE 0x1
+#define ATT_TRANSACTION_MODE_EXECUTE 0x2
+#define ATT_TRANSACTION_MODE_CANCEL 0x3
+
+typedef struct att_connection {
+ uint16_t mtu;
+} att_connection_t;
+
+typedef uint8_t signature_t[12];
+
+// ATT Client Read Callback for Dynamic Data
+// - if buffer == NULL, don't copy data, just return size of value
+// - if buffer != NULL, copy data and return number bytes copied
+// @param offset defines start of attribute value
+typedef uint16_t (*att_read_callback_t)(uint16_t handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
+
+// ATT Client Write Callback for Dynamic Data
+// @param handle to be written
+// @param transaction - ATT_TRANSACTION_MODE_NONE for regular writes, ATT_TRANSACTION_MODE_ACTIVE for prepared writes and ATT_TRANSACTION_MODE_EXECUTE
+// @param offset into the value - used for queued writes and long attributes
+// @param buffer
+// @param buffer_size
+// @Param signature used for signed write commmands
+typedef void (*att_write_callback_t)(uint16_t handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size, signature_t * signature);
+
+// MARK: ATT Operations
+
+void att_set_db(uint8_t const * db);
+
+void att_set_read_callback(att_read_callback_t callback);
+
+void att_set_write_callback(att_write_callback_t callback);
+
+void att_dump_attributes(void);
+
+// response buffer size = att_connection->mtu
+uint16_t att_handle_request(att_connection_t * att_connection,
+ uint8_t * request_buffer,
+ uint16_t request_len,
+ uint8_t * response_buffer);
+
+uint16_t att_prepare_handle_value_notification(att_connection_t * att_connection,
+ uint16_t handle,
+ uint8_t *value,
+ uint16_t value_len,
+ uint8_t * response_buffer);
+
+uint16_t att_prepare_handle_value_indication(att_connection_t * att_connection,
+ uint16_t handle,
+ uint8_t *value,
+ uint16_t value_len,
+ uint8_t * response_buffer);
+
+
+
\ No newline at end of file