OSDN Git Service

shared/att: Use smaller defines
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 9 Nov 2015 16:39:07 +0000 (18:39 +0200)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 13 Nov 2015 12:00:28 +0000 (14:00 +0200)
Not every term of the command needs to be part of the define as it make
them awful long.

src/shared/att-types.h
src/shared/att.c
src/shared/gatt-helpers.c
src/shared/gatt-server.c

index d474495..c3062c0 100644 (file)
@@ -42,8 +42,8 @@
 #define BT_ATT_OP_MTU_RSP                      0x03
 #define BT_ATT_OP_FIND_INFO_REQ                        0x04
 #define BT_ATT_OP_FIND_INFO_RSP                        0x05
-#define BT_ATT_OP_FIND_BY_TYPE_VAL_REQ         0x06
-#define BT_ATT_OP_FIND_BY_TYPE_VAL_RSP         0x07
+#define BT_ATT_OP_FIND_BY_TYPE_REQ             0x06
+#define BT_ATT_OP_FIND_BY_TYPE_RSP             0x07
 #define BT_ATT_OP_READ_BY_TYPE_REQ             0x08
 #define BT_ATT_OP_READ_BY_TYPE_RSP             0x09
 #define BT_ATT_OP_READ_REQ                     0x0a
index faff18f..3a84783 100644 (file)
@@ -112,8 +112,8 @@ static const struct {
        { BT_ATT_OP_MTU_RSP,                    ATT_OP_TYPE_RSP },
        { BT_ATT_OP_FIND_INFO_REQ,              ATT_OP_TYPE_REQ },
        { BT_ATT_OP_FIND_INFO_RSP,              ATT_OP_TYPE_RSP },
-       { BT_ATT_OP_FIND_BY_TYPE_VAL_REQ,       ATT_OP_TYPE_REQ },
-       { BT_ATT_OP_FIND_BY_TYPE_VAL_RSP,       ATT_OP_TYPE_RSP },
+       { BT_ATT_OP_FIND_BY_TYPE_REQ,           ATT_OP_TYPE_REQ },
+       { BT_ATT_OP_FIND_BY_TYPE_RSP,           ATT_OP_TYPE_RSP },
        { BT_ATT_OP_READ_BY_TYPE_REQ,           ATT_OP_TYPE_REQ },
        { BT_ATT_OP_READ_BY_TYPE_RSP,           ATT_OP_TYPE_RSP },
        { BT_ATT_OP_READ_REQ,                   ATT_OP_TYPE_REQ },
@@ -156,7 +156,7 @@ static const struct {
 } att_req_rsp_mapping_table[] = {
        { BT_ATT_OP_MTU_REQ,                    BT_ATT_OP_MTU_RSP },
        { BT_ATT_OP_FIND_INFO_REQ,              BT_ATT_OP_FIND_INFO_RSP},
-       { BT_ATT_OP_FIND_BY_TYPE_VAL_REQ,       BT_ATT_OP_FIND_BY_TYPE_VAL_RSP },
+       { BT_ATT_OP_FIND_BY_TYPE_REQ,           BT_ATT_OP_FIND_BY_TYPE_RSP },
        { BT_ATT_OP_READ_BY_TYPE_REQ,           BT_ATT_OP_READ_BY_TYPE_RSP },
        { BT_ATT_OP_READ_REQ,                   BT_ATT_OP_READ_RSP },
        { BT_ATT_OP_READ_BLOB_REQ,              BT_ATT_OP_READ_BLOB_RSP },
index b1dd38b..a0a5b26 100644 (file)
@@ -107,7 +107,7 @@ unsigned int bt_gatt_result_service_count(struct bt_gatt_result *result)
                return 0;
 
        if (result->opcode != BT_ATT_OP_READ_BY_GRP_TYPE_RSP &&
-                       result->opcode != BT_ATT_OP_FIND_BY_TYPE_VAL_RSP)
+                       result->opcode != BT_ATT_OP_FIND_BY_TYPE_RSP)
                return 0;
 
        return result_element_count(result);
@@ -342,7 +342,7 @@ bool bt_gatt_iter_next_service(struct bt_gatt_iter *iter,
                *end_handle = get_le16(pdu_ptr + 2);
                convert_uuid_le(pdu_ptr + 4, iter->result->data_len - 4, uuid);
                break;
-       case BT_ATT_OP_FIND_BY_TYPE_VAL_RSP:
+       case BT_ATT_OP_FIND_BY_TYPE_RSP:
                *start_handle = get_le16(pdu_ptr);
                *end_handle = get_le16(pdu_ptr + 2);
 
@@ -747,7 +747,7 @@ static void find_by_type_val_cb(uint8_t opcode, const void *pdu,
        /* PDU must contain 4 bytes and it must be a multiple of 4, where each
         * 4 bytes contain the 16-bit attribute and group end handles.
         */
-       if (opcode != BT_ATT_OP_FIND_BY_TYPE_VAL_RSP || !pdu || !length ||
+       if (opcode != BT_ATT_OP_FIND_BY_TYPE_RSP || !pdu || !length ||
                                                                length % 4) {
                success = false;
                goto done;
@@ -785,7 +785,7 @@ static void find_by_type_val_cb(uint8_t opcode, const void *pdu,
                put_le16(op->service_type, pdu + 4);
                bt_uuid_to_le(&op->uuid, pdu + 6);
 
-               op->id = bt_att_send(op->att, BT_ATT_OP_FIND_BY_TYPE_VAL_REQ,
+               op->id = bt_att_send(op->att, BT_ATT_OP_FIND_BY_TYPE_REQ,
                                                pdu, sizeof(pdu),
                                                find_by_type_val_cb,
                                                bt_gatt_request_ref(op),
@@ -855,7 +855,7 @@ static struct bt_gatt_request *discover_services(struct bt_att *att,
                put_le16(op->service_type, pdu + 4);
                bt_uuid_to_le(&op->uuid, pdu + 6);
 
-               op->id = bt_att_send(att, BT_ATT_OP_FIND_BY_TYPE_VAL_REQ,
+               op->id = bt_att_send(att, BT_ATT_OP_FIND_BY_TYPE_REQ,
                                                pdu, sizeof(pdu),
                                                find_by_type_val_cb,
                                                bt_gatt_request_ref(op),
index 4025cd1..ba668e3 100644 (file)
@@ -711,7 +711,7 @@ static void find_by_type_val_cb(uint8_t opcode, const void *pdu,
        if (data.ecode)
                goto error;
 
-       bt_att_send(server->att, BT_ATT_OP_FIND_BY_TYPE_VAL_RSP, data.pdu,
+       bt_att_send(server->att, BT_ATT_OP_FIND_BY_TYPE_RSP, data.pdu,
                                                data.len, NULL, NULL, NULL);
 
        return;
@@ -1316,7 +1316,7 @@ static bool gatt_server_register_att_handlers(struct bt_gatt_server *server)
 
        /* Find By Type Value */
        server->find_by_type_value_id = bt_att_register(server->att,
-                                               BT_ATT_OP_FIND_BY_TYPE_VAL_REQ,
+                                               BT_ATT_OP_FIND_BY_TYPE_REQ,
                                                find_by_type_val_cb,
                                                server, NULL);