-
Notifications
You must be signed in to change notification settings - Fork 2k
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
drivers/802154: improve setting of default short address #5461
drivers/802154: improve setting of default short address #5461
Conversation
It took my some minutes to find out you changed your nickname :-) |
@@ -438,6 +439,7 @@ int kw2xrf_init(kw2xrf_t *dev, spi_t spi, spi_speed_t spi_speed, | |||
#if CPUID_LEN > IEEE802154_LONG_ADDRESS_LEN | |||
for (int i = IEEE802154_LONG_ADDRESS_LEN; i < CPUID_LEN; i++) { | |||
cpuid[i & 0x07] ^= cpuid[i]; | |||
addr_short ^= (uint16_t)(cpuid[i] << ((i & 0x01) * 8)); |
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 for understanding of that line: you are taking every odd byte of the CPU ID and XOR it with the most-significant byte of the short address and every even byte with the least-significant byte. Is that correct? (maybe add a comment?)
;-) Other then the readability of the code I'm fine with this change. |
That is correct. I can give it a comment then. Generally, do you prefer the version in the first commit which takes the full Will adapt this PR once #5461 is clarified. |
I think I prefer version 1, too, though it should be |
740e010
to
20c809b
Compare
@miri64, I moved the short address generation some lines upwards so it will be set once Let's see this PR as a quick fix. I don't want to elaborate on this single driver any more because (i) after discussing in #5457 I think we need some "major " restructuring in terms of address generation and (ii) @jfischer-phytec-iot already proposed a (WIP) driver for netdev2. What do you say, can we merge as is (after squashing)? |
Yes, ACK. Please squash. |
20c809b
to
ed470e1
Compare
Did |
In #5457 we concluded to spend some more entropy for the default short address generation of 802.15.4 transceivers. As there is no standard for such generation, I propose two possibilities here, demonstrated at the current kw2xrf driver. The first commit takes all
CPUID_LEN
bytes of theCPUID
into account whereas the second commit only usesCPUID_LEN - IEEE802154_LONG_ADDRESS_LEN
bytes of theCPUID
.