Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Adress related types from Gap.h into BLEProtocol.h #142

Merged
merged 4 commits into from
Dec 15, 2015
Merged

Extract Adress related types from Gap.h into BLEProtocol.h #142

merged 4 commits into from
Dec 15, 2015

Conversation

rgrover
Copy link
Contributor

@rgrover rgrover commented Dec 14, 2015

While adding support for white-listing, I realized that a lot of core types, such as Address_t, are currently residing in Gap.h but are more abstract than Gap. They should be abstracted out of Gap otherwise they will result in circular dependencies.

I've also taken the opportunity to cleanup the types and add some documentation.

internal-ref: IOTSFW-1416
@pan- @marcuschangarm @andresag01 @LiyouZhou

@@ -239,7 +239,7 @@ class BLE
* ble.setAddress(...) should be replaced with
* ble.gap().setAddress(...).
*/
ble_error_t setAddress(Gap::AddressType_t type, const Gap::Address_t address) {
ble_error_t setAddress(BLEProtocol::AddressType::Type type, const Gap::Address_t address) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Gap::Address_t is still used instead of BLEProtocol::Address_t ?

@pan-
Copy link
Member

pan- commented Dec 15, 2015

What other data type should live want inside the BLEProtocol ?

* typedef AddressType_t AliasedType_t;
* would allow the use of AliasedType_t::PUBLIC in code.
*/
enum Type {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it can be useful to add a typedef to this type inside BLEProtocol namespace: typedef AddressType::Type AddressType_t. It would allow user code to use address type like this: BLEProtocol::AddressType_t instead of BLEProtocol::AddressType::Type.

@rgrover
Copy link
Contributor Author

rgrover commented Dec 15, 2015

@pan-: All generic types and data-structures could be migrated to BLEProtocol. I'll soon add datatypes involved in security and white-listing.

@rgrover
Copy link
Contributor Author

rgrover commented Dec 15, 2015

@pan- @LiyouZhou @andresag01: please review the latest.

@rgrover
Copy link
Contributor Author

rgrover commented Dec 15, 2015

Other opportunities of pulling out abstract protocol-specific types into BLEProtocol.h:

GapAdvertisingParams::AdvertisingType_t
GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL etc.
GapScanningParams::SCAN_INTERVAL_MIN etc.

and others to follow.

@LiyouZhou
Copy link

+1

1 similar comment
@andresag01
Copy link

+1


static const unsigned ADDR_LEN = BLEProtocol::ADDR_LEN; /**< Length (in octets) of the BLE MAC address. */
typedef BLEProtocol::Address_t Address_t; /**< 48-bit address, LSB format. @Note: Deprecated. Use BLEProtocol::Address_t instead. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Address_t is being deprecated, shouldn't all occurrences in this file be replaced?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being deprecated, not removed. If it was removed now, it will break user code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know what the word means, but shouldn't we be leading by example and at least make the changes inside the same file?

When I see this it looks weird:

const Address_t             peerAddr,
BLEProtocol::AddressType_t  ownAddrType,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something but it is already the case, no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pan- there were a couple of places in Gap.h where I had missed replacing Gap::Address_t with BLEProtocol::Address_t

@pan-
Copy link
Member

pan- commented Dec 15, 2015

+1

@rgrover
Copy link
Contributor Author

rgrover commented Dec 15, 2015

@marcuschangarm thanks for pointing out the use of deprecated Gap::Address_t. I've fixed this now. Please review.

@marcuschangarm
Copy link
Contributor

Looks good. What are your future plans for BLEProtocol?

@rgrover
Copy link
Contributor Author

rgrover commented Dec 15, 2015

@marcuschangarm I believe we will increasingly move protocol specific constants and algorithms into this file. For instance, I'll soon move types supporting whitelisting into BLEProtocol.h.

rgrover added a commit that referenced this pull request Dec 15, 2015
Extract Adress related types from Gap.h into BLEProtocol.h
@rgrover rgrover merged commit 95541a1 into ARMmbed:develop Dec 15, 2015
@rgrover
Copy link
Contributor Author

rgrover commented Dec 15, 2015

published latest version: 2.1.15 to the private registry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants