File tree Expand file tree Collapse file tree 5 files changed +50
-0
lines changed Expand file tree Collapse file tree 5 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ USEMODULE += bme280_i2c
12
12
USEMODULE += wsn
13
13
EXTERNAL_MODULE_DIRS += $(CURDIR ) /../../sys/wsn
14
14
15
+ CFLAGS += -DNODE_ID=\"$(NODE_ID ) \"
16
+
15
17
include $(RIOTBASE ) /Makefile.include
Original file line number Diff line number Diff line change 24
24
#define TICKS_PER_SEC US_PER_SEC
25
25
#endif
26
26
27
+ #ifndef NODE_ID
28
+ #define NODE_ID ""
29
+ #endif
30
+
27
31
#define SLEEP 5 // seconds
28
32
29
33
@@ -98,6 +102,18 @@ int main(void)
98
102
nanocbor_fmt_uint (& enc , 0 );
99
103
nanocbor_fmt_uint (& enc , now / TICKS_PER_SEC );
100
104
105
+ // Serial number
106
+ nanocbor_fmt_uint (& enc , 1 );
107
+ nanocbor_fmt_uint (& enc , cpuid );
108
+
109
+ // Name (Node Identifier)
110
+ nanocbor_fmt_uint (& enc , 2 );
111
+ nanocbor_put_tstr (& enc , NODE_ID );
112
+
113
+ // Frame sequence number
114
+ nanocbor_fmt_uint (& enc , 3 );
115
+ nanocbor_fmt_uint (& enc , loop );
116
+
101
117
saul_reg_t * dev = saul_reg ;
102
118
while (dev ) {
103
119
// TODO Support 2 BME280 sensors at addresses 0x76 and 0x77
Original file line number Diff line number Diff line change 13
13
#ifndef WSN_H
14
14
#define WSN_H
15
15
16
+ /**
17
+ * @brief Uniquely identifies the mote
18
+ */
19
+ extern uint64_t cpuid ;
20
+
16
21
/**
17
22
* @brief Code to run at boot
18
23
*
Original file line number Diff line number Diff line change
1
+ FEATURES_REQUIRED = periph_cpuid
2
+
1
3
# Storage
2
4
USEMODULE += fatfs_vfs
3
5
USEMODULE += mtd_sdcard
Original file line number Diff line number Diff line change 2
2
#include <log.h>
3
3
#include <net/netif.h>
4
4
#include <net/gnrc/netif.h>
5
+ #include <periph/cpuid.h>
5
6
6
7
// Project
7
8
#include "settings.h"
8
9
#include "wsn.h"
9
10
10
11
12
+ uint64_t cpuid = 0 ;
13
+
14
+
11
15
void wsn_boot (void )
12
16
{
17
+ /*
18
+ * ID
19
+ *
20
+ * XXX In the cc2539 the CPU id is based on the MAC address, which is
21
+ * defined by two 32bit little-endian words stored in memory: first the
22
+ * most-significat word (IEEE_ADDR_MSWORD), then the less-significat word
23
+ * (IEEE_ADDR_MSWORD). But the CPU id is read from memory as-is.
24
+ *
25
+ * For example if in memory we have 00:4b:12:00 2e:15:40:19 then:
26
+ * - MAC address is 00:12:4B:00:19:40:15:2E
27
+ * - But CPU id is 00:4b:12:00:2e:15:40:19
28
+ *
29
+ */
30
+ uint8_t buffer [CPUID_LEN ];
31
+ cpuid_get (buffer );
32
+
33
+ for (unsigned int i = 0 ; i < CPUID_LEN ; i ++ ) {
34
+ cpuid = cpuid << 8 ;
35
+ cpuid |= buffer [i ];
36
+ }
37
+
13
38
/*
14
39
* Storage
15
40
*/
You can’t perform that action at this time.
0 commit comments