[
https://issues.apache.org/jira/browse/MYNEWT-291?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Christopher Collins updated MYNEWT-291:
---
Description:
Nimble notifies the app that a characteristic or descriptor is being accessed
via an access callback. The access callback takes a context parameter which
points to an instance of the following union:
{noformat}
union ble_gatt_access_ctxt {
struct {
const struct ble_gatt_chr_def *chr;
void *data;
int len;
} chr_access;
struct {
const struct ble_gatt_dsc_def *dsc;
void *data;
int len;
} dsc_access;
};
{noformat}
This is problematic because the user may wish to point the _data_ fields to
read-only data, requiring them to "cast away const." This looks questionable
in code, and is difficult to document in the user guide with a straight face.
Instead, we should change the union to the following:
{noformat}
union ble_gatt_access_ctxt {
struct {
const struct ble_gatt_chr_def *chr;
const void *data;
int len;
} chr_read;
struct {
const struct ble_gatt_chr_def *chr;
void *data;
int len;
} chr_write;
struct {
const struct ble_gatt_dsc_def *dsc;
const void *data;
int len;
} dsc_read;
struct {
const struct ble_gatt_dsc_def *dsc;
void *data;
int len;
} dsc_write;
};
{noformat}
was:
Nimble notifies the app that a characteristic or descriptor is being accessed
via an access callback. The access callback takes a context parameter which
points to an instance of the following union:
{noformat}
union ble_gatt_access_ctxt {
struct {
const struct ble_gatt_chr_def *chr;
void *data;
int len;
} chr_access;
struct {
const struct ble_gatt_dsc_def *dsc;
void *data;
int len;
} dsc_access;
};
{noformat}
This is problematic because the user may wish to point the _data_ fields to
read-only data, requiring them to "cast away const." This looks questionable
in code, and is difficult to document in the user guide with a straight face.
Instead, we should change the union to the following:
union ble_gatt_access_ctxt {
struct {
const struct ble_gatt_chr_def *chr;
const void *data;
int len;
} chr_read;
struct {
const struct ble_gatt_chr_def *chr;
void *data;
int len;
} chr_write;
struct {
const struct ble_gatt_dsc_def *dsc;
const void *data;
int len;
} dsc_read;
struct {
const struct ble_gatt_dsc_def *dsc;
void *data;
int len;
} dsc_write;
};
> BLE Host - Split GATT attribute access function into more specific events
> -
>
> Key: MYNEWT-291
> URL: https://issues.apache.org/jira/browse/MYNEWT-291
> Project: Mynewt
> Issue Type: Bug
> Components: Nimble
>Reporter: Christopher Collins
>Assignee: Christopher Collins
> Fix For: 0.9.0
>
>
> Nimble notifies the app that a characteristic or descriptor is being accessed
> via an access callback. The access callback takes a context parameter which
> points to an instance of the following union:
> {noformat}
> union ble_gatt_access_ctxt {
> struct {
> const struct ble_gatt_chr_def *chr;
> void *data;
> int len;
> } chr_access;
> struct {
> const struct ble_gatt_dsc_def *dsc;
> void *data;
> int len;
> } dsc_access;
> };
> {noformat}
> This is problematic because the user may wish to point the _data_ fields to
> read-only data, requiring them to "cast away const." This looks questionable
> in code, and is difficult to document in the user guide with a straight face.
> Instead, we should change the union to the following:
> {noformat}
> union ble_gatt_access_ctxt {
> struct {
> const struct ble_gatt_chr_def *chr;
> const void *data;
> int len;
> } chr_read;
> struct {
> const struct ble_gatt_chr_def *chr;
> void *data;
> int len;
> } chr_write;
> struct {
> const struct ble_gatt_dsc_def *dsc;
> const void *data;
> int len;
> } dsc_read;
> struct {
> const struct ble_gatt_dsc_def *dsc;
> void *data;
> int len;
> } dsc_write;
> };
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)