Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
30c92efa
Commit
30c92efa
authored
11 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
Initialize addresses from CPU ID
parent
31682af0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile.dep
+1
-0
1 addition, 0 deletions
Makefile.dep
sys/auto_init/auto_init.c
+43
-1
43 additions, 1 deletion
sys/auto_init/auto_init.c
with
44 additions
and
1 deletion
Makefile.dep
+
1
−
0
View file @
30c92efa
...
...
@@ -89,6 +89,7 @@ endif
ifneq
(,$(filter net_if,$(USEMODULE)))
USEMODULE
+=
transceiver
USEMODULE
+=
net_help
USEMODULE
+=
hashes
endif
ifneq
(,$(filter ccn_lite,$(USEMODULE)))
...
...
This diff is collapsed.
Click to expand it.
sys/auto_init/auto_init.c
+
43
−
1
View file @
30c92efa
...
...
@@ -64,11 +64,20 @@
#endif
#ifdef MODULE_NET_IF
#include
"cpu-conf.h"
#include
"cpu.h"
#include
"kernel.h"
#include
"net_if.h"
#include
"transceiver.h"
#include
"net_help.h"
#include
"hashes.h"
#include
"periph/cpuid.h"
#endif
#define ENABLE_DEBUG (0)
#if ENABLE_DEBUG
#define DEBUG_ENABLED
#endif
#include
"debug.h"
#ifndef CONF_RADIO_ADDR
...
...
@@ -141,16 +150,47 @@ void auto_init(void)
net_if_init
();
if
(
transceivers
!=
0
)
{
#if CPUID_ID_LEN && defined(MODULE_HASHES)
uint8_t
cpuid
[
CPUID_ID_LEN
];
cpuid_get
(
cpuid
);
#endif
transceiver_init
(
transceivers
);
transceiver_start
();
iface
=
net_if_init_interface
(
0
,
transceivers
);
#if CPUID_ID_LEN && defined(MODULE_HASHES)
net_if_eui64_t
eui64
;
if
(
CPUID_ID_LEN
<
sizeof
(
net_if_eui64_t
))
{
memset
(
&
eui64
,
0xff
,
sizeof
(
net_if_eui64_t
));
}
memcpy
(
&
eui64
,
djb2_hash
(
cpuid
,
CPUID_ID_LEN
),
sizeof
(
uint32_t
));
net_if_set_eui64
(
iface
,
&
eui64
);
#ifdef DEBUG_ENABLED
DEBUG
(
"Auto init radio long address on interface %d to "
,
iface
);
for
(
size_t
i
=
0
;
i
<
8
;
i
++
)
{
printf
(
"%02x "
,
eui64
.
uint8
[
i
]);
}
DEBUG
(
"
\n
"
);
#endif
#undef CONF_RADIO_ADDR
uint16_t
hwaddr
=
HTONS
(
*
((
uint16_t
*
)(
&
cpuid
)));
net_if_set_hardware_address
(
iface
,
hwaddr
);
DEBUG
(
"Auto init radio address on interface %d to 0x%04x
\n
"
,
iface
,
hwaddr
);
#else
if
(
net_if_set_src_address_mode
(
iface
,
NET_IF_TRANS_ADDR_M_SHORT
))
{
DEBUG
(
"Auto init source address mode to short on interface %d
\n
"
,
iface
);
}
else
{
net_if_set_
hardware
_address
(
iface
,
NET_IF_TRANS_ADDR_M_LONG
);
net_if_set_
src
_address
_mode
(
iface
,
NET_IF_TRANS_ADDR_M_LONG
);
DEBUG
(
"Auto init source address mode to long on interface %d
\n
"
,
iface
);
}
...
...
@@ -161,6 +201,8 @@ void auto_init(void)
net_if_set_hardware_address
(
iface
,
CONF_RADIO_ADDR
);
}
#endif
if
(
net_if_get_pan_id
(
iface
)
<=
0
)
{
DEBUG
(
"Auto init PAN ID on interface %d to 0x%04x
\n
"
,
iface
,
CONF_PAN_ID
);
DEBUG
(
"Change this value at compile time with macro CONF_PAN_ID
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment