-
Notifications
You must be signed in to change notification settings - Fork 75
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
WIP: UUID endian change #128
Conversation
…ttle endian to be consistent with the short UUID.
@rgrover as we discussed |
// error abort | ||
break; | ||
} else if (stringUUID[index] == '-') { | ||
// ignore hyphen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a check here to ensure that nibble is false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you want to guard against? I was thinking that as long as there are enough hexadecimal characters in the string, we should just ignore the hyphens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the hyphens could come at the wrong place. This constructor currently accepts -X-X-X-XXXXXXXXXXXXXXXX...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and I think we should allow that. Without a proper feedback mechanism the user could easily mistype a single hyphen and not know what went wrong.
+1 |
typedef enum { | ||
MSB, | ||
LSB | ||
} BitOrder_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a trivial note: this is byte-order, not bit-order. I'll fix this when I merge this PR.
published "ble-2.1.10" |
@marcuschangarm @pan- @rgrover : guys, I suppose that depending on the byte order used, the shortUUID should be set accordingly. The following is a proposal for the setupLong() method in UUID.h void setupLong(const LongUUIDBytes_t longUUID, ByteOrder_t order = UUID::MSB) {
type = UUID_TYPE_LONG;
if (order == UUID::MSB) {
// Switch endian. Input is big-endian, internal representation is little endian.
std::reverse_copy(longUUID, longUUID + LENGTH_OF_LONG_UUID, baseUUID);
shortUUID = (uint16_t)((baseUUID[3] << 8) | (baseUUID[2]));
} else {
std::copy(longUUID, longUUID + LENGTH_OF_LONG_UUID, baseUUID);
shortUUID = (uint16_t)((baseUUID[13] << 8) | (baseUUID[12]));
}
} |
@apalmieriGH Isn't that what we are doing already? https://github.com/ARMmbed/ble/blob/master/ble/UUID.h#L185 |
I think this is fine just for LSB. Shouldn't be shortUUID = (uint16_t)((baseUUID[3] << 8) | (baseUUID[2])); for MSB case? |
The line is outside the if-else statement, so baseUUID is already LSB. |
Maybe I'm missing something. But in the "if" (which is also the default) case the baseUUID is supposed in MSB, right? |
Yes, and then it gets reversed copied into baseUUID, so after the if-else baseUUID is LSB regardless of input. |
Ok, then in this case, the shortUUID shoud be always shortUUID = (uint16_t)((baseUUID[3] << 8) | (baseUUID[2])); Do you agree? |
No, that would give you BBBB when we want AAAA:
|
Reversed internal representation of long UUID in the UUID class to little endian to be consistent with the short UUID, advertisements, and the nordic softdevice.
Added string constructor to UUID for human readable UUID.
Made changes to the services.
see ARMmbed/ble-nrf51822#82