diff --git a/drivers/nble/gatt.c b/drivers/nble/gatt.c index c1c784bac3b..1c7c3f46a4e 100644 --- a/drivers/nble/gatt.c +++ b/drivers/nble/gatt.c @@ -214,9 +214,9 @@ struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr) return NULL; } -int bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t buf_len, uint16_t offset, - const void *value, uint16_t value_len) +ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len) { uint16_t len; @@ -238,9 +238,9 @@ int bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, return len; } -int bt_gatt_attr_read_service(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_service(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { struct bt_uuid *uuid = attr->user_data; @@ -255,7 +255,7 @@ int bt_gatt_attr_read_service(struct bt_conn *conn, BT_UUID_128(uuid)->val, 16); } -int bt_gatt_attr_read_included(struct bt_conn *conn, +ssize_t bt_gatt_attr_read_included(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { @@ -271,9 +271,9 @@ struct gatt_chrc { }; } __packed; -int bt_gatt_attr_read_chrc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { struct bt_gatt_chrc *chrc = attr->user_data; struct gatt_chrc pdu; @@ -297,16 +297,16 @@ int bt_gatt_attr_read_chrc(struct bt_conn *conn, return bt_gatt_attr_read(conn, attr, buf, len, offset, &pdu, value_len); } -int bt_gatt_attr_read_ccc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { return BT_GATT_ERR(BT_ATT_ERR_NOT_SUPPORTED); } -int bt_gatt_attr_write_ccc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, const void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + const void *buf, uint16_t len, uint16_t offset) { struct _bt_gatt_ccc *ccc = attr->user_data; const uint16_t *data = buf; @@ -331,9 +331,9 @@ int bt_gatt_attr_write_ccc(struct bt_conn *conn, return len; } -int bt_gatt_attr_read_cep(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { struct bt_gatt_cep *value = attr->user_data; uint16_t props = sys_cpu_to_le16(value->properties); @@ -342,16 +342,16 @@ int bt_gatt_attr_read_cep(struct bt_conn *conn, sizeof(props)); } -int bt_gatt_attr_read_cud(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { return BT_GATT_ERR(BT_ATT_ERR_NOT_SUPPORTED); } -int bt_gatt_attr_read_cpf(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { return BT_GATT_ERR(BT_ATT_ERR_NOT_SUPPORTED); } diff --git a/include/bluetooth/gatt.h b/include/bluetooth/gatt.h index e93fbccbca9..542f3d3f784 100644 --- a/include/bluetooth/gatt.h +++ b/include/bluetooth/gatt.h @@ -26,6 +26,7 @@ extern "C" { #if defined(CONFIG_BLUETOOTH_CENTRAL) || defined(CONFIG_BLUETOOTH_PERIPHERAL) #include +#include #include #include #include @@ -115,7 +116,7 @@ struct bt_gatt_attr { * @return Number fo bytes read, or in case of an error * BT_GATT_ERR() with a specific ATT error code. */ - int (*read)(struct bt_conn *conn, + ssize_t (*read)(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset); @@ -131,7 +132,7 @@ struct bt_gatt_attr { * @return Number of bytes written, or in case of an error * BT_GATT_ERR() with a specific ATT error code. */ - int (*write)(struct bt_conn *conn, + ssize_t (*write)(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset); @@ -150,7 +151,7 @@ struct bt_gatt_attr { * @return Number of bytes flushed, or in case of an error * BT_GATT_ERR() with a specific ATT error code. */ - int (*flush)(struct bt_conn *conn, + ssize_t (*flush)(struct bt_conn *conn, const struct bt_gatt_attr *attr, uint8_t flags); @@ -358,9 +359,9 @@ struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr); * @return int number of bytes read in case of success or negative values in * case of error. */ -int bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t buf_len, uint16_t offset, - const void *value, uint16_t value_len); +ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len); /** @brief Read Service Attribute helper. * @@ -377,9 +378,9 @@ int bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, * @return int number of bytes read in case of success or negative values in * case of error. */ -int bt_gatt_attr_read_service(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset); +ssize_t bt_gatt_attr_read_service(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset); /** @def BT_GATT_SERVICE * @brief Generic Service Declaration Macro. @@ -442,9 +443,9 @@ int bt_gatt_attr_read_service(struct bt_conn *conn, * @return int number of bytes read in case of success or negative values in * case of error. */ -int bt_gatt_attr_read_included(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset); +ssize_t bt_gatt_attr_read_included(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset); /** @def BT_GATT_INCLUDE_SERVICE * @brief Include Service Declaration Macro. @@ -476,9 +477,9 @@ int bt_gatt_attr_read_included(struct bt_conn *conn, * @return number of bytes read in case of success or negative values in * case of error. */ -int bt_gatt_attr_read_chrc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset); +ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset); /** @def BT_GATT_CHARACTERISTIC * @brief Characteristic Declaration Macro. @@ -530,9 +531,9 @@ struct _bt_gatt_ccc { * @return number of bytes read in case of success or negative values in * case of error. */ -int bt_gatt_attr_read_ccc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset); +ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset); /** @brief Write Client Characteristic Configuration Attribute helper. * @@ -548,9 +549,9 @@ int bt_gatt_attr_read_ccc(struct bt_conn *conn, * @return number of bytes written in case of success or negative values in * case of error. */ -int bt_gatt_attr_write_ccc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, const void *buf, - uint16_t len, uint16_t offset); +ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, const void *buf, + uint16_t len, uint16_t offset); /** @def BT_GATT_CCC * @brief Client Characteristic Configuration Declaration Macro. @@ -586,9 +587,9 @@ int bt_gatt_attr_write_ccc(struct bt_conn *conn, * @return number of bytes read in case of success or negative values in * case of error. */ -int bt_gatt_attr_read_cep(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset); +ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset); /** @def BT_GATT_CEP * @brief Characteristic Extended Properties Declaration Macro. @@ -620,9 +621,9 @@ int bt_gatt_attr_read_cep(struct bt_conn *conn, * @return number of bytes read in case of success or negative values in * case of error. */ -int bt_gatt_attr_read_cud(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset); +ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset); /** @def BT_GATT_CUD * @brief Characteristic User Format Descriptor Declaration Macro. @@ -655,9 +656,9 @@ int bt_gatt_attr_read_cud(struct bt_conn *conn, * @return number of bytes read in case of success or negative values in * case of error. */ -int bt_gatt_attr_read_cpf(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset); +ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset); /** @def BT_GATT_CPF * @brief Characteristic Presentation Format Descriptor Declaration Macro. diff --git a/net/bluetooth/gatt.c b/net/bluetooth/gatt.c index 9b8bc2a4193..974fa54290f 100644 --- a/net/bluetooth/gatt.c +++ b/net/bluetooth/gatt.c @@ -120,9 +120,9 @@ populate: return 0; } -int bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t buf_len, uint16_t offset, - const void *value, uint16_t value_len) +ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len) { uint16_t len; @@ -140,9 +140,9 @@ int bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, return len; } -int bt_gatt_attr_read_service(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_service(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { struct bt_uuid *uuid = attr->user_data; @@ -163,9 +163,9 @@ struct gatt_incl { uint16_t uuid16; } __packed; -int bt_gatt_attr_read_included(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_included(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { struct bt_gatt_include *incl = attr->user_data; struct gatt_incl pdu; @@ -197,9 +197,9 @@ struct gatt_chrc { }; } __packed; -int bt_gatt_attr_read_chrc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { struct bt_gatt_chrc *chrc = attr->user_data; struct gatt_chrc pdu; @@ -261,9 +261,9 @@ struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr) #endif /* CONFIG_BLUETOOTH_GATT_DYNAMIC_DB */ } -int bt_gatt_attr_read_ccc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { struct _bt_gatt_ccc *ccc = attr->user_data; uint16_t value; @@ -318,9 +318,9 @@ static bool is_bonded(const bt_addr_le_t *addr) #endif /* defined(CONFIG_BLUETOOTH_SMP) */ } -int bt_gatt_attr_write_ccc(struct bt_conn *conn, - const struct bt_gatt_attr *attr, const void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, const void *buf, + uint16_t len, uint16_t offset) { struct _bt_gatt_ccc *ccc = attr->user_data; const uint16_t *data = buf; @@ -370,9 +370,9 @@ int bt_gatt_attr_write_ccc(struct bt_conn *conn, return len; } -int bt_gatt_attr_read_cep(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { struct bt_gatt_cep *value = attr->user_data; uint16_t props = sys_cpu_to_le16(value->properties); @@ -381,18 +381,18 @@ int bt_gatt_attr_read_cep(struct bt_conn *conn, sizeof(props)); } -int bt_gatt_attr_read_cud(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { char *value = attr->user_data; return bt_gatt_attr_read(conn, attr, buf, len, offset, value, strlen(value)); } -int bt_gatt_attr_read_cpf(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { struct bt_gatt_cpf *value = attr->user_data; diff --git a/samples/bluetooth/ipsp/src/ipss.c b/samples/bluetooth/ipsp/src/ipss.c index c1081b14666..eb80cf17112 100644 --- a/samples/bluetooth/ipsp/src/ipss.c +++ b/samples/bluetooth/ipsp/src/ipss.c @@ -48,8 +48,8 @@ #define UDP_PORT 4242 -static int read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *name = attr->user_data; @@ -57,9 +57,9 @@ static int read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(name)); } -static int read_appearance(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_appearance(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t appearance = sys_cpu_to_le16(UNKNOWN_APPEARANCE); @@ -67,8 +67,8 @@ static int read_appearance(struct bt_conn *conn, sizeof(appearance)); } -static int read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -76,8 +76,8 @@ static int read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(value)); } -static int read_manuf(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_manuf(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; diff --git a/samples/bluetooth/peripheral/src/main.c b/samples/bluetooth/peripheral/src/main.c index 08ab9a494d9..558db4efd80 100644 --- a/samples/bluetooth/peripheral/src/main.c +++ b/samples/bluetooth/peripheral/src/main.c @@ -34,8 +34,8 @@ #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define HEART_RATE_APPEARANCE 0x0341 -static int read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *name = attr->user_data; @@ -43,9 +43,9 @@ static int read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(name)); } -static int read_appearance(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_appearance(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t appearance = sys_cpu_to_le16(HEART_RATE_APPEARANCE); @@ -61,8 +61,8 @@ static void hrmc_ccc_cfg_changed(uint16_t value) simulate_hrm = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; } -static int read_blsc(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_blsc(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { uint8_t value = 0x01; @@ -80,8 +80,8 @@ static void blvl_ccc_cfg_changed(uint16_t value) simulate_blvl = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; } -static int read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -126,8 +126,8 @@ static void ct_ccc_cfg_changed(uint16_t value) static uint8_t ct[10]; static uint8_t ct_update = 0; -static int read_ct(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_ct(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -135,8 +135,8 @@ static int read_ct(struct bt_conn *conn, const struct bt_gatt_attr *attr, sizeof(ct)); } -static int write_ct(struct bt_conn *conn, const struct bt_gatt_attr *attr, - const void *buf, uint16_t len, uint16_t offset) +static ssize_t write_ct(struct bt_conn *conn, const struct bt_gatt_attr *attr, + const void *buf, uint16_t len, uint16_t offset) { uint8_t *value = attr->user_data; @@ -150,8 +150,8 @@ static int write_ct(struct bt_conn *conn, const struct bt_gatt_attr *attr, return len; } -static int read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -159,8 +159,8 @@ static int read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(value)); } -static int read_manuf(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_manuf(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -183,8 +183,8 @@ static struct bt_uuid_128 vnd_auth_uuid = BT_UUID_INIT_128( static uint8_t vnd_value[] = { 'V', 'e', 'n', 'd', 'o', 'r' }; -static int read_vnd(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_vnd(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -192,8 +192,8 @@ static int read_vnd(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(value)); } -static int write_vnd(struct bt_conn *conn, const struct bt_gatt_attr *attr, - const void *buf, uint16_t len, uint16_t offset) +static ssize_t write_vnd(struct bt_conn *conn, const struct bt_gatt_attr *attr, + const void *buf, uint16_t len, uint16_t offset) { uint8_t *value = attr->user_data; @@ -216,9 +216,9 @@ static struct vnd_long_value { .data = { 'V', 'e', 'n', 'd', 'o', 'r' }, }; -static int read_long_vnd(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_long_vnd(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { struct vnd_long_value *value = attr->user_data; @@ -226,9 +226,9 @@ static int read_long_vnd(struct bt_conn *conn, sizeof(value->data)); } -static int write_long_vnd(struct bt_conn *conn, - const struct bt_gatt_attr *attr, const void *buf, - uint16_t len, uint16_t offset) +static ssize_t write_long_vnd(struct bt_conn *conn, + const struct bt_gatt_attr *attr, const void *buf, + uint16_t len, uint16_t offset) { struct vnd_long_value *value = attr->user_data; @@ -242,8 +242,8 @@ static int write_long_vnd(struct bt_conn *conn, return len; } -static int flush_long_vnd(struct bt_conn *conn, - const struct bt_gatt_attr *attr, uint8_t flags) +static ssize_t flush_long_vnd(struct bt_conn *conn, + const struct bt_gatt_attr *attr, uint8_t flags) { struct vnd_long_value *value = attr->user_data; @@ -271,8 +271,8 @@ static struct bt_gatt_cep vnd_long_cep = { static int signed_value; -static int read_signed(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_signed(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -280,8 +280,8 @@ static int read_signed(struct bt_conn *conn, const struct bt_gatt_attr *attr, sizeof(signed_value)); } -static int write_signed(struct bt_conn *conn, const struct bt_gatt_attr *attr, - const void *buf, uint16_t len, uint16_t offset) +static ssize_t write_signed(struct bt_conn *conn, const struct bt_gatt_attr *attr, + const void *buf, uint16_t len, uint16_t offset) { uint8_t *value = attr->user_data; diff --git a/samples/bluetooth/peripheral_csc/src/main.c b/samples/bluetooth/peripheral_csc/src/main.c index 1bdb8035a23..a7c48bf5d32 100644 --- a/samples/bluetooth/peripheral_csc/src/main.c +++ b/samples/bluetooth/peripheral_csc/src/main.c @@ -88,9 +88,9 @@ /* Generic Access Profile Service declaration */ -static int read_device_name(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_device_name(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *name = attr->user_data; @@ -98,9 +98,9 @@ static int read_device_name(struct bt_conn *conn, strlen(name)); } -static int read_appearance(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_appearance(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t appearance = sys_cpu_to_le16(CSC_APPEARANCE); @@ -120,7 +120,7 @@ static struct bt_gatt_attr gap_attrs[] = { /* Device Information Service declaration */ -static int read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, +static ssize_t read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -129,7 +129,7 @@ static int read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(value)); } -static int read_manuf(struct bt_conn *conn, const struct bt_gatt_attr *attr, +static ssize_t read_manuf(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -160,8 +160,8 @@ static void blvl_ccc_cfg_changed(uint16_t value) bas_simulate = value == BT_GATT_CCC_NOTIFY; } -static int read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -198,7 +198,7 @@ static void ctrl_point_ccc_cfg_changed(uint16_t value) ctrl_point_configured = value == BT_GATT_CCC_INDICATE; } -static int read_location(struct bt_conn *conn, +static ssize_t read_location(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { @@ -208,9 +208,9 @@ static int read_location(struct bt_conn *conn, sizeof(*value)); } -static int read_csc_feature(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_csc_feature(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t csc_feature = CSC_FEATURE; @@ -229,9 +229,9 @@ struct write_sc_ctrl_point_req { }; } __packed; -static int write_ctrl_point(struct bt_conn *conn, - const struct bt_gatt_attr *attr, const void *buf, - uint16_t len, uint16_t offset) +static ssize_t write_ctrl_point(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + const void *buf, uint16_t len, uint16_t offset) { const struct write_sc_ctrl_point_req *req = buf; uint8_t status; diff --git a/samples/bluetooth/peripheral_dis/src/main.c b/samples/bluetooth/peripheral_dis/src/main.c index b5bc3e6fae3..e1821531069 100644 --- a/samples/bluetooth/peripheral_dis/src/main.c +++ b/samples/bluetooth/peripheral_dis/src/main.c @@ -34,9 +34,9 @@ #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define APPEARANCE 0x0000 -static int read_appearance(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_appearance(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t appearance = sys_cpu_to_le16(APPEARANCE); @@ -44,8 +44,9 @@ static int read_appearance(struct bt_conn *conn, sizeof(appearance)); } -static int read_string(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_string(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { const char *value = attr->user_data; diff --git a/samples/bluetooth/peripheral_esp/src/main.c b/samples/bluetooth/peripheral_esp/src/main.c index a557410603c..b9bbb62bc2c 100644 --- a/samples/bluetooth/peripheral_esp/src/main.c +++ b/samples/bluetooth/peripheral_esp/src/main.c @@ -73,8 +73,9 @@ static inline uint32_t le24_to_int(const uint8_t *u24) (uint32_t)u24[2] << 16); } -static int read_string(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_string(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { const char *string = attr->user_data; @@ -82,8 +83,8 @@ static int read_string(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(string)); } -static int read_u16(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_u16(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const uint16_t *u16 = attr->user_data; uint16_t value = sys_cpu_to_le16(*u16); @@ -94,9 +95,9 @@ static int read_u16(struct bt_conn *conn, const struct bt_gatt_attr *attr, /* Generic Access Profile Service Declaration */ -static int read_appearance(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_appearance(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t value = sys_cpu_to_le16(APPEARANCE_THERMOMETER); @@ -126,8 +127,8 @@ static void blvl_ccc_cfg_changed(uint16_t value) simulate_blvl = value == BT_GATT_CCC_NOTIFY; } -static int read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const uint8_t *value = attr->user_data; @@ -238,9 +239,9 @@ struct read_es_measurement_rp { uint8_t measurement_uncertainty; } __packed; -static int read_es_measurement(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_es_measurement(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { const struct es_measurement *value = attr->user_data; struct read_es_measurement_rp rsp; @@ -256,9 +257,9 @@ static int read_es_measurement(struct bt_conn *conn, sizeof(rsp)); } -static int read_temp_valid_range(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_temp_valid_range(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { const struct temperature_sensor *sensor = attr->user_data; uint16_t tmp[] = {sys_cpu_to_le16(sensor->lower_limit), @@ -278,9 +279,10 @@ struct es_trigger_setting_reference { int16_t ref_val; } __packed; -static int read_temp_trigger_setting(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_temp_trigger_setting(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, + uint16_t offset) { const struct temperature_sensor *sensor = attr->user_data; @@ -322,10 +324,10 @@ struct write_es_trigger_setting_req { uint8_t operand[]; } __packed; -static int write_temp_trigger_setting(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - const void *buf, uint16_t len, - uint16_t offset) +static ssize_t write_temp_trigger_setting(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + const void *buf, uint16_t len, + uint16_t offset) { const struct write_es_trigger_setting_req *req = buf; const struct es_trigger_setting_reference *ref; diff --git a/samples/bluetooth/peripheral_hr/src/main.c b/samples/bluetooth/peripheral_hr/src/main.c index 87243007f1e..f5164f302c1 100644 --- a/samples/bluetooth/peripheral_hr/src/main.c +++ b/samples/bluetooth/peripheral_hr/src/main.c @@ -36,8 +36,8 @@ struct bt_conn *default_conn; -static int read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *name = attr->user_data; @@ -45,9 +45,9 @@ static int read_name(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(name)); } -static int read_appearance(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_appearance(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t appearance = sys_cpu_to_le16(HEART_RATE_APPEARANCE); @@ -63,8 +63,8 @@ static void hrmc_ccc_cfg_changed(uint16_t value) simulate_hrm = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; } -static int read_blsc(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_blsc(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { uint8_t value = 0x01; @@ -82,8 +82,8 @@ static void blvl_ccc_cfg_changed(uint16_t value) simulate_blvl = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; } -static int read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -91,8 +91,8 @@ static int read_blvl(struct bt_conn *conn, const struct bt_gatt_attr *attr, sizeof(*value)); } -static int read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; @@ -100,8 +100,8 @@ static int read_model(struct bt_conn *conn, const struct bt_gatt_attr *attr, strlen(value)); } -static int read_manuf(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_manuf(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const char *value = attr->user_data; diff --git a/samples/bluetooth/peripheral_sc_only/src/main.c b/samples/bluetooth/peripheral_sc_only/src/main.c index 59fd7422e5a..a5b218b4982 100644 --- a/samples/bluetooth/peripheral_sc_only/src/main.c +++ b/samples/bluetooth/peripheral_sc_only/src/main.c @@ -34,9 +34,9 @@ #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define APPEARANCE 0x0000 -static int read_appearance(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_appearance(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t appearance = sys_cpu_to_le16(APPEARANCE); @@ -44,8 +44,9 @@ static int read_appearance(struct bt_conn *conn, sizeof(appearance)); } -static int read_string(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_string(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { const char *value = attr->user_data; diff --git a/tests/bluetooth/shell/src/main.c b/tests/bluetooth/shell/src/main.c index e8f41bd6fe2..31489bb5024 100644 --- a/tests/bluetooth/shell/src/main.c +++ b/tests/bluetooth/shell/src/main.c @@ -206,8 +206,9 @@ static struct bt_conn_cb conn_callbacks = { .security_changed = security_changed, }; -static int read_string(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_string(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { const char *str = attr->user_data; @@ -217,9 +218,9 @@ static int read_string(struct bt_conn *conn, const struct bt_gatt_attr *attr, static uint16_t appearance_value = 0x0001; -static int read_appearance(struct bt_conn *conn, - const struct bt_gatt_attr *attr, void *buf, - uint16_t len, uint16_t offset) +static ssize_t read_appearance(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { uint16_t appearance = sys_cpu_to_le16(appearance_value); diff --git a/tests/bluetooth/tester/src/gatt.c b/tests/bluetooth/tester/src/gatt.c index 566c4eb537d..ae2610f797c 100644 --- a/tests/bluetooth/tester/src/gatt.c +++ b/tests/bluetooth/tester/src/gatt.c @@ -224,8 +224,8 @@ struct gatt_value { bool has_ccc; }; -static int read_value(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_value(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) { const struct gatt_value *value = attr->user_data; @@ -238,8 +238,9 @@ static int read_value(struct bt_conn *conn, const struct bt_gatt_attr *attr, value->len); } -static int write_value(struct bt_conn *conn, const struct bt_gatt_attr *attr, - const void *buf, uint16_t len, uint16_t offset) +static ssize_t write_value(struct bt_conn *conn, + const struct bt_gatt_attr *attr, const void *buf, + uint16_t len, uint16_t offset) { struct gatt_value *value = attr->user_data; @@ -266,8 +267,8 @@ static int write_value(struct bt_conn *conn, const struct bt_gatt_attr *attr, return len; } -static int flush_value(struct bt_conn *conn, - const struct bt_gatt_attr *attr, uint8_t flags) +static ssize_t flush_value(struct bt_conn *conn, + const struct bt_gatt_attr *attr, uint8_t flags) { struct gatt_value *value = attr->user_data;