If no MAC is defined, create one from the node ID

This commit is contained in:
Adam Dunkels 2011-09-05 22:04:06 +02:00
parent 3fa14d3cd5
commit eeb25b9667

View file

@ -214,7 +214,6 @@ main(int argc, char **argv)
slip_arch_init(BAUD2UBR(115200)); slip_arch_init(BAUD2UBR(115200));
#endif /* WITH_UIP */ #endif /* WITH_UIP */
xmem_init(); xmem_init();
rtimer_init(); rtimer_init();
@ -225,30 +224,46 @@ main(int argc, char **argv)
/* Restore node id if such has been stored in external mem */ /* Restore node id if such has been stored in external mem */
node_id_restore(); node_id_restore();
/* If no MAC address was burned, we use the node ID. */
if(node_mac[0] | node_mac[1] | node_mac[2] | node_mac[3] |
node_mac[4] | node_mac[5] | node_mac[6] | node_mac[7]) {
node_mac[0] = 0xc1; /* Hardcoded for Z1 */
node_mac[1] = 0x0c; /* Hardcoded for Revision C */
node_mac[2] = 0x00; /* Hardcoded to arbitrary even number so that
the 802.15.4 MAC address is compatible with
an Ethernet MAC address - byte 0 (byte 2 in
the DS ID) */
node_mac[3] = 0x00; /* Hardcoded */
node_mac[4] = 0x00; /* Hardcoded */
node_mac[5] = 0x00; /* Hardcoded */
node_mac[6] = node_id >> 8;
node_mac[7] = node_id & 0xff;
}
/* Overwrite node MAC if desired at compile time */ /* Overwrite node MAC if desired at compile time */
#ifdef MACID #ifdef MACID
#warning "***** CHANGING DEFAULT MAC *****" #warning "***** CHANGING DEFAULT MAC *****"
node_mac[0] = 0xC1; // Hardcoded for Z1 node_mac[0] = 0xc1; /* Hardcoded for Z1 */
node_mac[1] = 0x0C; // Hardcoded for Revision C node_mac[1] = 0x0c; /* Hardcoded for Revision C */
node_mac[2] = 0x00; // Hardcoded to arbitrary even number so that the 802.15.4 MAC address node_mac[2] = 0x00; /* Hardcoded to arbitrary even number so that
// is compatible with an Ethernet MAC address - byte 0 (byte 2 in the DS ID) the 802.15.4 MAC address is compatible with
node_mac[3] = 0x00; // Hardcoded an Ethernet MAC address - byte 0 (byte 2 in
node_mac[4] = 0x00; // Hardcoded the DS ID) */
node_mac[5] = 0x00; // Hardcoded node_mac[3] = 0x00; /* Hardcoded */
node_mac[4] = 0x00; /* Hardcoded */
node_mac[5] = 0x00; /* Hardcoded */
node_mac[6] = MACID >> 8; node_mac[6] = MACID >> 8;
node_mac[7] = MACID & 0xff; node_mac[7] = MACID & 0xff;
#endif #endif
/* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
#ifdef IEEE_802154_MAC_ADDRESS #ifdef IEEE_802154_MAC_ADDRESS
/* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
{ {
uint8_t ieee[] = IEEE_802154_MAC_ADDRESS; uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
memcpy(node_mac, ieee, sizeof(uip_lladdr.addr)); memcpy(node_mac, ieee, sizeof(uip_lladdr.addr));
node_mac[7] = node_id & 0xff; node_mac[7] = node_id & 0xff;
} }
#endif #endif /* IEEE_802154_MAC_ADDRESS */
/* /*
* Initialize Contiki and our processes. * Initialize Contiki and our processes.