Return-Path: MIME-Version: 1.0 In-Reply-To: <1294185698-1499-3-git-send-email-bgix@codeaurora.org> References: <1294185698-1499-1-git-send-email-bgix@codeaurora.org> <1294185698-1499-3-git-send-email-bgix@codeaurora.org> Date: Thu, 6 Jan 2011 14:31:45 -0300 Message-ID: Subject: Re: [PATCH 2/2] Fix gatt_read_char() to support long Attrib Values From: Claudio Takahasi To: Brian Gix Cc: padovan@profusion.mobi, rshaffer@codeaurora.org, linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: SGkgQnJpYW4sCgpPbiBUdWUsIEphbiA0LCAyMDExIGF0IDk6MDEgUE0sIEJyaWFuIEdpeCA8Ymdp eEBjb2RlYXVyb3JhLm9yZz4gd3JvdGU6Cj4gRml4IGdhdHRfcmVhZF9jaGFyKCkgdG8gc3VwcG9y dCBsb25nIEF0dHJpYnV0ZSBWYWx1ZXMgYnkgcmVjb2duaXppbmcKPiDCoCDCoCDCoCDCoHRoYXQg cmVzdWx0cyBsb25nZXIgdGhhdCAyMSBvY3RldHMgbWF5IGluY2x1ZGUgZGF0YSBiZXlvbmQKPiDC oCDCoCDCoCDCoHdoYXQgaGFzIGJlZW4gcmV0dXJuZWQgd2l0aCB0aGUgZmlyc3QgcmVhZC4gRXh0 cmEgZGF0YSBpcwo+IMKgIMKgIMKgIMKgb2J0YWluZWQgYnkgaXNzdWluZyBSRUFEX0JMT0IgcmVx dWVzdHMgdW50aWwgZWl0aGVyIGEKPiDCoCDCoCDCoCDCoHJlc3VsdCBpcyByZXR1cm5lZCBzaG9y dGVyIHRoYW4gMjIgb2N0ZXRzLCBvciBhbiBlcnJvcgo+IMKgIMKgIMKgIMKgaXMgcmVjaWV2ZWQg aW5kaWNhdGluZyB0aGF0IG5vIGZ1cnRoZXIgZGF0YSBpcyBhdmFpbGFibGUuCj4gwqAgwqAgwqAg wqBUaGUgQVBJIGZvciB0aGlzIGZ1bmN0aW9uIGhhcyBub3Qg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