@@ -39,11 +39,11 @@ void loop() {
39
39
Serial.println (" OpenThread Network Information:" );
40
40
41
41
// Basic network information
42
- Serial.printf (" Role: %s\n " , threadLeaderNode.otGetStringDeviceRole ());
43
- Serial.printf (" RLOC16: 0x%04x\n " , threadLeaderNode.getRloc16 ());
44
- Serial.printf (" Network Name: %s\n " , threadLeaderNode.getNetworkName ().c_str ());
45
- Serial.printf (" Channel: %d\n " , threadLeaderNode.getChannel ());
46
- Serial.printf (" PAN ID: 0x%04x\n " , threadLeaderNode.getPanId ());
42
+ Serial.printf (" Role: %s\r\ n " , threadLeaderNode.otGetStringDeviceRole ());
43
+ Serial.printf (" RLOC16: 0x%04x\r\ n " , threadLeaderNode.getRloc16 ());
44
+ Serial.printf (" Network Name: %s\r\ n " , threadLeaderNode.getNetworkName ().c_str ());
45
+ Serial.printf (" Channel: %d\r\ n " , threadLeaderNode.getChannel ());
46
+ Serial.printf (" PAN ID: 0x%04x\r\ n " , threadLeaderNode.getPanId ());
47
47
48
48
// Extended PAN ID
49
49
const uint8_t *extPanId = threadLeaderNode.getExtendedPanId ();
@@ -67,51 +67,42 @@ void loop() {
67
67
68
68
// Mesh Local EID
69
69
IPAddress meshLocalEid = threadLeaderNode.getMeshLocalEid ();
70
- Serial.printf (" Mesh Local EID: %s\n " , meshLocalEid.toString ().c_str ());
70
+ Serial.printf (" Mesh Local EID: %s\r\ n " , meshLocalEid.toString ().c_str ());
71
71
72
72
// Leader RLOC
73
73
IPAddress leaderRloc = threadLeaderNode.getLeaderRloc ();
74
- Serial.printf (" Leader RLOC: %s\n " , leaderRloc.toString ().c_str ());
74
+ Serial.printf (" Leader RLOC: %s\r\ n " , leaderRloc.toString ().c_str ());
75
75
76
76
// Node RLOC
77
77
IPAddress nodeRloc = threadLeaderNode.getRloc ();
78
- Serial.printf (" Node RLOC: %s\n " , nodeRloc.toString ().c_str ());
78
+ Serial.printf (" Node RLOC: %s\r\ n " , nodeRloc.toString ().c_str ());
79
79
80
80
// Demonstrate address listing with two different methods:
81
81
// Method 1: Unicast addresses using counting API (individual access)
82
- Serial.println (" \n --- Unicast Addresses (Using Count + Index API) ---" );
82
+ Serial.println (" \r\ n --- Unicast Addresses (Using Count + Index API) ---" );
83
83
size_t unicastCount = threadLeaderNode.getUnicastAddressCount ();
84
84
for (size_t i = 0 ; i < unicastCount; i++) {
85
85
IPAddress addr = threadLeaderNode.getUnicastAddress (i);
86
- Serial.printf (" [%zu]: %s\n " , i, addr.toString ().c_str ());
86
+ Serial.printf (" [%zu]: %s\r\ n " , i, addr.toString ().c_str ());
87
87
}
88
88
89
89
// Method 2: Multicast addresses using std::vector (bulk access)
90
- Serial.println (" \n --- Multicast Addresses (Using std::vector API) ---" );
90
+ Serial.println (" \r\ n --- Multicast Addresses (Using std::vector API) ---" );
91
91
std::vector<IPAddress> allMulticast = threadLeaderNode.getAllMulticastAddresses ();
92
92
for (size_t i = 0 ; i < allMulticast.size (); i++) {
93
- Serial.printf (" [%zu]: %s\n " , i, allMulticast[i].toString ().c_str ());
93
+ Serial.printf (" [%zu]: %s\r\ n " , i, allMulticast[i].toString ().c_str ());
94
94
}
95
-
96
- // Cache management information
97
- Serial.println (" \n --- Address Access Methods ---" );
98
- Serial.println (" Two ways to access addresses:" );
99
- Serial.println (" 1. Count + Index: getUnicastAddressCount() + getUnicastAddress(index)" );
100
- Serial.println (" 2. Vector: getAllUnicastAddresses() or getAllMulticastAddresses()" );
101
- Serial.println (" Cache is automatically populated when empty" );
102
-
103
- Serial.println (" ==============================================\n " );
104
-
95
+
105
96
// Check for role change and clear cache if needed (only when active)
106
97
if (currentRole != lastKnownRole) {
107
- Serial.printf (" Role changed from %s to %s - clearing address cache\n " ,
98
+ Serial.printf (" Role changed from %s to %s - clearing address cache\r\ n " ,
108
99
(lastKnownRole < 5 ) ? otRoleString[lastKnownRole] : " Unknown" ,
109
100
threadLeaderNode.otGetStringDeviceRole ());
110
101
threadLeaderNode.clearAllAddressCache ();
111
102
lastKnownRole = currentRole;
112
103
}
113
104
} else {
114
- Serial.printf (" Thread Node Status: %s - Waiting for network connection ...\n " ,
105
+ Serial.printf (" Thread Node Status: %s - Waiting for thread network start ...\r \n" ,
115
106
threadLeaderNode.otGetStringDeviceRole ());
116
107
117
108
// Update role tracking even when detached/disabled, but don't clear cache
0 commit comments