diff --git a/cpu/cc2538/ieee-addr.c b/cpu/cc2538/ieee-addr.c index cb8c901bc..0e615f87e 100644 --- a/cpu/cc2538/ieee-addr.c +++ b/cpu/cc2538/ieee-addr.c @@ -49,10 +49,22 @@ ieee_addr_cpy_to(uint8_t *dst, uint8_t len) memcpy(dst, &ieee_addr_hc[8 - len], len); } else { - /* Reading from Info Page, we need to invert byte order */ + /* Verify if we detect TI OUI in fourth position. TI store the MAC @ on + two parts (4 bytes LSB first and 4 bytes MSB) in this case, we need + to flip the 2 parts */ int i; - for(i = 0; i < len; i++) { - dst[i] = ((uint8_t *)IEEE_ADDR_LOCATION)[len - 1 - i]; + uint8_t oui_ti[3] = IEEE_ADDR_OUI_TI; + if(((uint8_t *)IEEE_ADDR_LOCATION)[3] == oui_ti[0] && ((uint8_t *)IEEE_ADDR_LOCATION)[2] == oui_ti[1] && ((uint8_t *)IEEE_ADDR_LOCATION)[1] == oui_ti[2]) { + for(i = 0; i < len / 2; i++) { + dst[i] = ((uint8_t *)IEEE_ADDR_LOCATION)[len / 2 - 1 - i]; + } + for(i = 0; i < len / 2; i++) { + dst[i + len / 2] = ((uint8_t *)IEEE_ADDR_LOCATION)[len - 1 - i]; + } + } else { + for(i = 0; i < len; i++) { + dst[i] = ((uint8_t *)IEEE_ADDR_LOCATION)[len - 1 - i]; + } } } diff --git a/cpu/cc2538/ieee-addr.h b/cpu/cc2538/ieee-addr.h index c7618c1e7..79e97d1fc 100644 --- a/cpu/cc2538/ieee-addr.h +++ b/cpu/cc2538/ieee-addr.h @@ -48,6 +48,13 @@ #include /*---------------------------------------------------------------------------*/ +/** + * \name TI OUI + * @{ + */ +#define IEEE_ADDR_OUI_TI { 0x00, 0x12, 0x4B } /**< TI OUI */ +/** @} */ +/*---------------------------------------------------------------------------*/ /** * \name IEEE address locations * @{