1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #1878 from authmillenon/rpl_udp-16bit-addr

rpl_udp: Addresses must only be 8-bit with cc110x
This commit is contained in:
Martine Lenders 2014-11-02 18:03:53 +01:00
commit 1729524f38
5 changed files with 25 additions and 16 deletions

View File

@ -2,7 +2,6 @@
command order:
set <node-id>
init [r|n]
server
send <node-id> <message>
@ -24,11 +23,6 @@ Run the first node
make term
Type ``help`` to see the commands available.
Now you need set the node ID. This ID will be used by other nodes to address this node.
> set 1
set 1
Set node ID to 1
Init your rpl node as either a root or a node router.

View File

@ -43,7 +43,11 @@ void rpl_udp_set_id(int argc, char **argv)
{
if (argc != 2) {
printf("Usage: %s address\n", argv[0]);
#if defined(MODULE_CC110X_LEGACY_CSMA) || defined(MODULE_CC110X_LEGACY)
printf("\taddress must be an 8 bit integer\n");
#else
printf("\taddress must be an 16 bit integer\n");
#endif
printf("\n\t(Current address is %u)\n", id);
return;
}
@ -123,11 +127,20 @@ void rpl_udp_ignore(int argc, char **argv)
{
uint16_t a;
if (argc < 2) {
printf("Usage: %s <addr>\n", argv[0]);
return;
}
if (transceiver_pid == KERNEL_PID_UNDEF) {
puts("Transceiver not runnning.");
return;
}
/* cppcheck: a is actually read via tcmd.data */
/* cppcheck-suppress unreadVariable */
a = atoi(argv[1]);
msg_t mesg;
mesg.type = DBG_IGN;
mesg.content.ptr = (char *) &tcmd;
@ -135,14 +148,7 @@ void rpl_udp_ignore(int argc, char **argv)
tcmd.transceivers = TRANSCEIVER_CC1100;
tcmd.data = &a;
if (argc == 2) {
/* cppcheck: a is actually read via tcmd.data */
/* cppcheck-suppress unreadVariable */
a = atoi(argv[1]);
printf("sending to transceiver (%" PRIkernel_pid "): %u\n", transceiver_pid, (*(uint8_t *)tcmd.data));
msg_send(&mesg, transceiver_pid);
}
else {
printf("Usage: %s <addr>\n", argv[0]);
}
printf("sending to transceiver (%" PRIkernel_pid "): %u\n", transceiver_pid,
(*(uint8_t *)tcmd.data));
msg_send(&mesg, transceiver_pid);
}

View File

@ -46,6 +46,7 @@ int main(void)
/* start shell */
posix_open(uart0_handler_pid, 0);
net_if_set_src_address_mode(0, NET_IF_TRANS_ADDR_M_SHORT);
id = net_if_get_hardware_address(0);
shell_t shell;
shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);

View File

@ -60,10 +60,12 @@ void rpl_udp_init(int argc, char **argv)
((command == 'h') ? "non-" : ""),
(((command == 'n') || (command == 'h')) ? "node" : "root"), id);
#if defined(MODULE_CC110X_LEGACY_CSMA) || defined(MODULE_CC110X_LEGACY)
if (!id || (id > 255)) {
printf("ERROR: address not a valid 8 bit integer\n");
return;
}
#endif
DEBUGF("Setting HW address to %u\n", id);
net_if_set_hardware_address(0, id);

View File

@ -152,7 +152,13 @@ void auto_init_net_if(void)
#endif /* DEBUG_ENABLED */
#undef CONF_RADIO_ADDR
#if defined(MODULE_CC110X_LEGACY_CSMA) || defined(MODULE_CC110X_LEGACY)
uint8_t hwaddr = (uint8_t)((hash_l ^ hash_h) ^ ((hash_l ^ hash_h) >> 24));
/* do not combine more parts to keep the propability low that it just
* becomes 0xff */
#else
uint16_t hwaddr = HTONS((uint16_t)((hash_l ^ hash_h) ^ ((hash_l ^ hash_h) >> 16)));
#endif
net_if_set_hardware_address(iface, hwaddr);
DEBUG("Auto init radio address on interface %d to 0x%04x\n", iface, hwaddr);
#else /* CPUID_ID_LEN && defined(MODULE_HASHES) */