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
1 changed files with 28 additions and 13 deletions

View File

@ -214,7 +214,6 @@ main(int argc, char **argv)
slip_arch_init(BAUD2UBR(115200));
#endif /* WITH_UIP */
xmem_init();
rtimer_init();
@ -225,31 +224,47 @@ main(int argc, char **argv)
/* Restore node id if such has been stored in external mem */
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 */
#ifdef MACID
#ifdef MACID
#warning "***** CHANGING DEFAULT MAC *****"
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[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] = MACID >> 8;
node_mac[7] = MACID & 0xff;
#endif
/* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
#ifdef IEEE_802154_MAC_ADDRESS
/* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
{
uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
memcpy(node_mac, ieee, sizeof(uip_lladdr.addr));
node_mac[7] = node_id & 0xff;
}
#endif
#endif /* IEEE_802154_MAC_ADDRESS */
/*
* Initialize Contiki and our processes.
*/