diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2012-10-03 15:18:16 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-03 22:40:28 +0300 |
commit | 1748b9e5490ccb237efb36a8bcc7e44584c87024 (patch) | |
tree | 204e531b03919ac622d10193286d8a437fac2b8f | |
parent | 7814825978fbe037d5872017e0d4c0dff534a476 (diff) |
eir: Store class in struct eir_data as uint32_t
This simplify code as class is stored on storage as uint32_t and
had to be converted to it in few places.
-rw-r--r-- | src/adapter.c | 11 | ||||
-rw-r--r-- | src/eir.c | 3 | ||||
-rw-r--r-- | src/eir.h | 2 | ||||
-rw-r--r-- | src/event.c | 11 | ||||
-rw-r--r-- | src/event.h | 2 | ||||
-rw-r--r-- | src/mgmt.c | 2 |
6 files changed, 12 insertions, 19 deletions
diff --git a/src/adapter.c b/src/adapter.c index a6a4a4ba..4ca0c53c 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -3063,7 +3063,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, struct eir_data eir_data; char *alias, *name; gboolean legacy, name_known; - uint32_t dev_class; int err; GSList *l; @@ -3074,10 +3073,8 @@ void adapter_update_found_devices(struct btd_adapter *adapter, return; } - dev_class = eir_data.dev_class[0] | (eir_data.dev_class[1] << 8) | - (eir_data.dev_class[2] << 16); - if (dev_class != 0) - write_remote_class(&adapter->bdaddr, bdaddr, dev_class); + if (eir_data.class != 0) + write_remote_class(&adapter->bdaddr, bdaddr, eir_data.class); if (eir_data.appearance != 0) write_remote_appearance(&adapter->bdaddr, bdaddr, bdaddr_type, @@ -3133,8 +3130,8 @@ void adapter_update_found_devices(struct btd_adapter *adapter, alias = read_stored_data(&adapter->bdaddr, bdaddr, bdaddr_type, "aliases"); - dev = found_device_new(bdaddr, bdaddr_type, name, alias, dev_class, - legacy, eir_data.flags); + dev = found_device_new(bdaddr, bdaddr_type, name, alias, + eir_data.class, legacy, eir_data.flags); free(name); free(alias); @@ -166,7 +166,8 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len) case EIR_CLASS_OF_DEV: if (data_len < 3) break; - memcpy(eir->dev_class, data, 3); + eir->class = data[0] | (data[1] << 8) | + (data[2] << 16); break; case EIR_GAP_APPEARANCE: @@ -47,7 +47,7 @@ struct eir_data { GSList *services; int flags; char *name; - uint8_t dev_class[3]; + uint32_t class; uint16_t appearance; gboolean name_complete; uint8_t *hash; diff --git a/src/event.c b/src/event.c index 1db73be2..96260538 100644 --- a/src/event.c +++ b/src/event.c @@ -452,7 +452,7 @@ int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type, } void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type, - char *name, uint8_t *dev_class) + char *name, uint32_t class) { struct btd_adapter *adapter; struct btd_device *device; @@ -462,13 +462,8 @@ void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_typ update_lastused(local, peer, bdaddr_type); - if (dev_class != NULL) { - uint32_t class = dev_class[0] | (dev_class[1] << 8) | - (dev_class[2] << 16); - - if (class != 0) - write_remote_class(local, peer, class); - } + if (class != 0) + write_remote_class(local, peer, class); device_set_addr_type(device, bdaddr_type); diff --git a/src/event.h b/src/event.h index 7031cc9d..6d001dd7 100644 --- a/src/event.h +++ b/src/event.h @@ -30,7 +30,7 @@ void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer, gboolean lega void btd_event_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class); void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name); void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type, - char *name, uint8_t *dev_class); + char *name, uint32_t class); void btd_event_conn_failed(bdaddr_t *local, bdaddr_t *peer, uint8_t status); void btd_event_disconn_complete(bdaddr_t *local, bdaddr_t *peer); void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t status); @@ -515,7 +515,7 @@ static void mgmt_device_connected(int sk, uint16_t index, void *buf, size_t len) btd_event_conn_complete(&info->bdaddr, &ev->addr.bdaddr, ev->addr.type, eir_data.name, - eir_data.dev_class); + eir_data.class); eir_data_free(&eir_data); } |